diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@alloca.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@alloca.h new file mode 100644 index 0000000..bd44688 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@alloca.h @@ -0,0 +1,40 @@ +/* Copyright (C) 1992-2020 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 definitions. */ +#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/@@home@ado@git@ssp/@usr@include@alloca.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@alloca.h.blob new file mode 100644 index 0000000..f00623f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@alloca.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@asm-generic@errno-base.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@asm-generic@errno-base.h new file mode 100644 index 0000000..9653140 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@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/@@home@ado@git@ssp/@usr@include@asm-generic@errno-base.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@asm-generic@errno-base.h.blob new file mode 100644 index 0000000..50aa3d5 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@asm-generic@errno-base.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@asm-generic@errno.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@asm-generic@errno.h new file mode 100644 index 0000000..cf9c51a --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@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/@@home@ado@git@ssp/@usr@include@asm-generic@errno.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@asm-generic@errno.h.blob new file mode 100644 index 0000000..0108258 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@asm-generic@errno.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@assert.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@assert.h new file mode 100644 index 0000000..ae9831b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@assert.h @@ -0,0 +1,144 @@ +/* Copyright (C) 1991-2020 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. */ + +#ifndef _ASSERT_H_DECLS +#define _ASSERT_H_DECLS +__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 +#endif /* Not _ASSERT_H_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/@@home@ado@git@ssp/@usr@include@assert.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@assert.h.blob new file mode 100644 index 0000000..40268e8 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@assert.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@algorithm b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@algorithm new file mode 100644 index 0000000..4b956b8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@algorithm @@ -0,0 +1,86 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 // UK-300. +#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/@@home@ado@git@ssp/@usr@include@c++@10@algorithm.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@algorithm.blob new file mode 100644 index 0000000..d0dff33 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@algorithm.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@array b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@array new file mode 100644 index 0000000..3bb6f48 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@array @@ -0,0 +1,451 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + 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 _GLIBCXX_STD_C::__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. + _GLIBCXX17_CONSTEXPR iterator + begin() noexcept + { return iterator(data()); } + + _GLIBCXX17_CONSTEXPR const_iterator + begin() const noexcept + { return const_iterator(data()); } + + _GLIBCXX17_CONSTEXPR iterator + end() noexcept + { return iterator(data() + _Nm); } + + _GLIBCXX17_CONSTEXPR const_iterator + end() const noexcept + { return const_iterator(data() + _Nm); } + + _GLIBCXX17_CONSTEXPR reverse_iterator + rbegin() noexcept + { return reverse_iterator(end()); } + + _GLIBCXX17_CONSTEXPR const_reverse_iterator + rbegin() const noexcept + { return const_reverse_iterator(end()); } + + _GLIBCXX17_CONSTEXPR reverse_iterator + rend() noexcept + { return reverse_iterator(begin()); } + + _GLIBCXX17_CONSTEXPR const_reverse_iterator + rend() const noexcept + { return const_reverse_iterator(begin()); } + + _GLIBCXX17_CONSTEXPR const_iterator + cbegin() const noexcept + { return const_iterator(data()); } + + _GLIBCXX17_CONSTEXPR const_iterator + cend() const noexcept + { return const_iterator(data() + _Nm); } + + _GLIBCXX17_CONSTEXPR const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + _GLIBCXX17_CONSTEXPR const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } + + // Capacity. + constexpr size_type + size() const noexcept { return _Nm; } + + constexpr size_type + max_size() const noexcept { return _Nm; } + + _GLIBCXX_NODISCARD constexpr bool + empty() const noexcept { return size() == 0; } + + // Element access. + _GLIBCXX17_CONSTEXPR reference + operator[](size_type __n) noexcept + { return _AT_Type::_S_ref(_M_elems, __n); } + + constexpr const_reference + operator[](size_type __n) const noexcept + { 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)); + } + + _GLIBCXX17_CONSTEXPR reference + front() noexcept + { return *begin(); } + + constexpr const_reference + front() const noexcept + { return _AT_Type::_S_ref(_M_elems, 0); } + + _GLIBCXX17_CONSTEXPR reference + back() noexcept + { return _Nm ? *(end() - 1) : *end(); } + + constexpr const_reference + back() const noexcept + { + return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1) + : _AT_Type::_S_ref(_M_elems, 0); + } + + _GLIBCXX17_CONSTEXPR pointer + data() noexcept + { return _AT_Type::_S_ptr(_M_elems); } + + _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 + _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 + constexpr __detail::__synth3way_t<_Tp> + operator<=>(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) + { +#ifdef __cpp_lib_is_constant_evaluated + 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; + } +#endif + + 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 + _GLIBCXX20_CONSTEXPR + inline bool + operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one == __two); } + + template + _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 + _GLIBCXX20_CONSTEXPR + inline bool + operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return __two < __one; } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one > __two); } + + template + _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< + _GLIBCXX_STD_C::__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< + !_GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value>::type + swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete; +#endif + + template + constexpr _Tp& + get(array<_Tp, _Nm>& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>:: + _S_ref(__arr._M_elems, _Int); + } + + template + constexpr _Tp&& + get(array<_Tp, _Nm>&& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return std::move(_GLIBCXX_STD_C::get<_Int>(__arr)); + } + + template + constexpr const _Tp& + get(const array<_Tp, _Nm>& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>:: + _S_ref(__arr._M_elems, _Int); + } + + template + constexpr const _Tp&& + get(const array<_Tp, _Nm>&& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return std::move(_GLIBCXX_STD_C::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 + 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 _GLIBCXX_STD_C::__to_array(__a, make_index_sequence<_Nm>{}); + __builtin_unreachable(); // FIXME: see PR c++/91388 + } + + template + 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 _GLIBCXX_STD_C::__to_array<1>(__a, make_index_sequence<_Nm>{}); + __builtin_unreachable(); // FIXME: see PR c++/91388 + } +#endif // C++20 + +_GLIBCXX_END_NAMESPACE_CONTAINER +} // namespace std + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Tuple interface to class template array. + + /// tuple_size + template + struct tuple_size; + + /// Partial specialization for std::array + template + struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>> + : public integral_constant { }; + + /// tuple_element + template + struct tuple_element; + + /// Partial specialization for std::array + template + struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>> + { + static_assert(_Int < _Nm, "index is out of bounds"); + typedef _Tp type; + }; + + template + struct __is_tuple_like_impl<_GLIBCXX_STD_C::array<_Tp, _Nm>> : true_type + { }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#endif // C++11 + +#endif // _GLIBCXX_ARRAY diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@array.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@array.blob new file mode 100644 index 0000000..e1eb5f4 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@array.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@backward@auto_ptr.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@backward@auto_ptr.h new file mode 100644 index 0000000..8511636 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@backward@auto_ptr.h @@ -0,0 +1,337 @@ +// auto_ptr implementation -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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) { } + } _GLIBCXX_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()); } + } _GLIBCXX_DEPRECATED; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 541. shared_ptr template assignment and void + template<> + class auto_ptr + { + public: + typedef void element_type; + } _GLIBCXX_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/@@home@ado@git@ssp/@usr@include@c++@10@backward@auto_ptr.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@backward@auto_ptr.h.blob new file mode 100644 index 0000000..868e378 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@backward@auto_ptr.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@backward@binders.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@backward@binders.h new file mode 100644 index 0000000..8c2c00d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@backward@binders.h @@ -0,0 +1,182 @@ +// Functor implementations -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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); } + } _GLIBCXX_DEPRECATED; + + /// One of the @link binders binder functors@endlink. + template + 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); } + } _GLIBCXX_DEPRECATED; + + /// One of the @link binders binder functors@endlink. + template + 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/@@home@ado@git@ssp/@usr@include@c++@10@backward@binders.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@backward@binders.h.blob new file mode 100644 index 0000000..7d2257d Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@backward@binders.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@algorithmfwd.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@algorithmfwd.h new file mode 100644 index 0000000..799d9d5 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@algorithmfwd.h @@ -0,0 +1,967 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@algorithmfwd.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@algorithmfwd.h.blob new file mode 100644 index 0000000..98fd7c5 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@algorithmfwd.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@alloc_traits.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@alloc_traits.h new file mode 100644 index 0000000..86d8ed2 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@alloc_traits.h @@ -0,0 +1,743 @@ +// Allocator traits -*- C++ -*- + +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 201411 + + 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; + + /** + * @brief Uniform interface to all allocator types. + * @ingroup allocators + */ + 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 @a _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; } + }; + +#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; +#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 + 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 + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@alloc_traits.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@alloc_traits.h.blob new file mode 100644 index 0000000..043b3b4 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@alloc_traits.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocated_ptr.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocated_ptr.h new file mode 100644 index 0000000..5058ab0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocated_ptr.h @@ -0,0 +1,104 @@ +// Guarded Allocation -*- C++ -*- + +// Copyright (C) 2014-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + + /// 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) }; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocated_ptr.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocated_ptr.h.blob new file mode 100644 index 0000000..402fd6d Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocated_ptr.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocator.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocator.h new file mode 100644 index 0000000..d224aa3 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocator.h @@ -0,0 +1,323 @@ +// Allocators -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 201505 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup allocators + * @{ + */ + + /// allocator specialization. + template<> + class allocator + { + public: + typedef void value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; +#if __cplusplus <= 201703L + typedef void* pointer; + typedef const void* const_pointer; + + template + struct rebind + { typedef allocator<_Tp1> other; }; +#else + allocator() = default; + + template + constexpr + allocator(const allocator<_Up>&) { } +#endif // ! C++20 + +#if __cplusplus >= 201103L && __cplusplus <= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2103. std::allocator propagate_on_container_move_assignment + typedef true_type propagate_on_container_move_assignment; + + typedef true_type is_always_equal; + + 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(); } +#endif // C++11 to C++17 + }; + + /** + * @brief The @a standard allocator, as per [20.4]. + * + * 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 + 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 + typedef true_type propagate_on_container_move_assignment; + + typedef true_type is_always_equal; +#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) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); +#endif + return __allocator_base<_Tp>::allocate(__n, 0); + } + + [[__gnu__::__always_inline__]] + constexpr void + deallocate(_Tp* __p, size_t __n) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + ::operator delete(__p); + return; + } +#endif + __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> + { + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocator.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocator.h.blob new file mode 100644 index 0000000..7ee75fa Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@allocator.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_base.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_base.h new file mode 100644 index 0000000..41d5928 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_base.h @@ -0,0 +1,1703 @@ +// -*- C++ -*- header. + +// Copyright (C) 2008-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +#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)); + } + + _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)); + } + + _GLIBCXX_ALWAYS_INLINE void + clear(memory_order __m = memory_order_seq_cst) noexcept + { + memory_order __b = __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 = __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 = __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 = __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 = __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 = __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 + { + memory_order __b2 = __m2 & __memory_order_mask; + memory_order __b1 = __m1 & __memory_order_mask; + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + 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 + { + memory_order __b2 = __m2 & __memory_order_mask; + memory_order __b1 = __m1 & __memory_order_mask; + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + 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 + { + memory_order __b2 = __m2 & __memory_order_mask; + memory_order __b1 = __m1 & __memory_order_mask; + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + 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 + { + memory_order __b2 = __m2 & __memory_order_mask; + memory_order __b1 = __m1 & __memory_order_mask; + + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + 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)); + } + + _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 = __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 = __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 = __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 = __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_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) noexcept + { + memory_order __b2 = __m2 & __memory_order_mask; + memory_order __b1 = __m1 & __memory_order_mask; + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + 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 + { + memory_order __b2 = __m2 & __memory_order_mask; + memory_order __b1 = __m1 & __memory_order_mask; + + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 0, + int(__m1), int(__m2)); + } + + _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 + { + 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 + { + return __atomic_compare_exchange(__ptr, std::__addressof(__expected), + std::__addressof(__desired), false, + int(__success), int(__failure)); + } + + 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)); + } + + 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)); + } + + 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)); + } + + 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)); + } + + 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)); + } + + _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/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_base.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_base.h.blob new file mode 100644 index 0000000..b60dcb4 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_base.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_lockfree_defines.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_lockfree_defines.h new file mode 100644 index 0000000..f0b57ae --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_lockfree_defines.h @@ -0,0 +1,66 @@ +// -*- C++ -*- header. + +// Copyright (C) 2008-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_lockfree_defines.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_lockfree_defines.h.blob new file mode 100644 index 0000000..e996e13 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@atomic_lockfree_defines.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.h new file mode 100644 index 0000000..2771756 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.h @@ -0,0 +1,518 @@ +// Iostreams base classes -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.h.blob new file mode 100644 index 0000000..32d6c7d Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.tcc new file mode 100644 index 0000000..c8c786f --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.tcc @@ -0,0 +1,188 @@ +// basic_ios member functions -*- C++ -*- + +// Copyright (C) 1999-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 != &__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/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.tcc.blob new file mode 100644 index 0000000..5f1d583 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_ios.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.h new file mode 100644 index 0000000..bbab7b9 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.h @@ -0,0 +1,6951 @@ +// Components for manipulating sequences of characters -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#include + +#if __cplusplus >= 201103L +#include +#endif + +#if __cplusplus >= 201703L +# include +#endif + + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if _GLIBCXX_USE_CXX11_ABI +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + /** + * @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; + typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; + + // 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. + 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 + { + 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. + */ + 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 + _Alloc_hider(pointer __dat, const _Alloc& __a) + : allocator_type(__a), _M_p(__dat) { } + + _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; + }; + + void + _M_data(pointer __p) + { _M_dataplus._M_p = __p; } + + void + _M_length(size_type __length) + { _M_string_length = __length; } + + pointer + _M_data() const + { return _M_dataplus._M_p; } + + pointer + _M_local_data() + { +#if __cplusplus >= 201103L + return std::pointer_traits::pointer_to(*_M_local_buf); +#else + return pointer(_M_local_buf); +#endif + } + + 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 + } + + void + _M_capacity(size_type __capacity) + { _M_allocated_capacity = __capacity; } + + void + _M_set_length(size_type __n) + { + _M_length(__n); + traits_type::assign(_M_data()[__n], _CharT()); + } + + bool + _M_is_local() const + { return _M_data() == _M_local_data(); } + + // Create & Destroy + pointer + _M_create(size_type&, size_type); + + void + _M_dispose() + { + if (!_M_is_local()) + _M_destroy(_M_allocated_capacity); + } + + void + _M_destroy(size_type __size) throw() + { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); } + + // _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); } + + template + void + _M_construct(_InIterator __beg, _InIterator __end) + { + typedef typename std::__is_integer<_InIterator>::__type _Integral; + _M_construct_aux(__beg, __end, _Integral()); + } + + // For Input Iterators, used in istreambuf_iterators, etc. + template + 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 + void + _M_construct(_FwdIterator __beg, _FwdIterator __end, + std::forward_iterator_tag); + + void + _M_construct(size_type __req, _CharT __c); + + allocator_type& + _M_get_allocator() + { return _M_dataplus; } + + const allocator_type& + _M_get_allocator() const + { return _M_dataplus; } + + 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 + + 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; + } + + 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. + 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. + 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); + } + + 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); + } + + 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 + 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. + } + + static void + _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT + { _S_copy_chars(__p, __k1.base(), __k2.base()); } + + static void + _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2) + _GLIBCXX_NOEXCEPT + { _S_copy_chars(__p, __k1.base(), __k2.base()); } + + static void + _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT + { _S_copy(__p, __k1, __k2 - __k1); } + + static void + _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2) + _GLIBCXX_NOEXCEPT + { _S_copy(__p, __k1, __k2 - __k1); } + + 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); + } + + void + _M_assign(const basic_string&); + + void + _M_mutate(size_type __pos, size_type __len1, const _CharT* __s, + size_type __len2); + + 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. + */ + basic_string() + _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value) + : _M_dataplus(_M_local_data()) + { _M_set_length(0); } + + /** + * @brief Construct an empty string using allocator @a a. + */ + explicit + basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT + : _M_dataplus(_M_local_data(), __a) + { _M_set_length(0); } + + /** + * @brief Construct string with copy of value of @a __str. + * @param __str Source string. + */ + 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()); } + + // _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. + */ + 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)); + } + + /** + * @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. + */ + 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)); + } + + /** + * @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. + */ + 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)); + } + + /** + * @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. + */ + basic_string(const _CharT* __s, size_type __n, + const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__s, __s + __n); } + + /** + * @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 + basic_string(const _CharT* __s, const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); } + + /** + * @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 + 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. + **/ + 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, + _S_local_capacity + 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). + */ + basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__l.begin(), __l.end()); } + + basic_string(const basic_string& __str, const _Alloc& __a) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__str.begin(), __str.end()); } + + 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, + _S_local_capacity + 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()); + } + +#endif // C++11 + + /** + * @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 + basic_string(_InputIterator __beg, _InputIterator __end, + const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__beg, __end); } + +#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> + 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> + 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. + */ + ~basic_string() + { _M_dispose(); } + + /** + * @brief Assign the value of @a str to this string. + * @param __str Source string. + */ + 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. + */ + 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. + */ + 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 + 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. + 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. + */ + 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 + _If_sv<_Tp, basic_string&> + operator=(const _Tp& __svt) + { return this->assign(__svt); } + + /** + * @brief Convert to a string_view. + * @return A string_view. + */ + 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. + */ + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(_M_data()); } + + /** + * Returns a read-only (constant) iterator that points to the first + * character in the %string. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_string_length; } + + /// Returns the number of characters in the string, not including any + /// null-termination. + size_type + length() const _GLIBCXX_NOEXCEPT + { return _M_string_length; } + + /// Returns the size() of the largest possible %string. + 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. + */ + 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. + */ + void + resize(size_type __n) + { this->resize(__n, _CharT()); } + +#if __cplusplus >= 201103L + /// A non-binding request to reduce capacity() to size(). + void + shrink_to_fit() noexcept + { +#if __cpp_exceptions + if (capacity() > size()) + { + try + { reserve(0); } + catch(...) + { } + } +#endif + } +#endif + + /** + * Returns the total number of characters that the %string can hold + * before needing to allocate more memory. + */ + 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. + */ + void + reserve(size_type __res_arg = 0); + + /** + * Erases the string, making it empty. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_set_length(0); } + + /** + * Returns true if the %string is empty. Equivalent to + * *this == "". + */ + _GLIBCXX_NODISCARD 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().) + */ + 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().) + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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 + _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. + */ + basic_string& + append(const basic_string& __str) + { return _M_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. + */ + basic_string& + append(const basic_string& __str, size_type __pos, size_type __n = npos) + { return _M_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. + */ + 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. + */ + 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. + */ + 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. + */ + 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> +#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 + _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 + _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. + */ + 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. + */ + 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_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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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> +#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. + */ + 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 + _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 + _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. + */ + 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> + 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(). + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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 + _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 + _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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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> + 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. + 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); + } + + 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); + } + + 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); + } + + 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. + */ + 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 + _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 + _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 + _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 + 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 + basic_string& + _M_replace_dispatch(const_iterator __i1, const_iterator __i2, + _InputIterator __k1, _InputIterator __k2, + __false_type); + + basic_string& + _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, + _CharT __c); + + basic_string& + _M_replace(size_type __pos, size_type __len1, const _CharT* __s, + const size_type __len2); + + 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. + */ + 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. + */ + 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. + */ + 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). + */ + 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. + */ + _CharT* + data() noexcept + { return _M_data(); } +#endif + + /** + * @brief Return copy of allocator used to construct this string. + */ + 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. + */ + 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. + */ + 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 + _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. + */ + 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. + */ + 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. + */ + 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 + _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. + */ + 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. + */ + 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. + */ + 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. + */ + 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 + _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. + */ + 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. + */ + 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). + */ + 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. + */ + 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 + _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. + */ + 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. + */ + 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). + */ + 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. + */ + 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> + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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 + _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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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 + _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 + _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 + _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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + int + compare(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) const; + +#if __cplusplus > 201703L + bool + starts_with(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + starts_with(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + starts_with(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + ends_with(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } + + bool + ends_with(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } + + bool + ends_with(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } +#endif // C++20 + + // Allow basic_stringbuf::__xfer_bufptrs to call _M_length: + template friend class basic_stringbuf; + }; +_GLIBCXX_END_NAMESPACE_CXX11 +#else // !_GLIBCXX_USE_CXX11_ABI + // Reference-counted COW string implentation + + /** + * @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. + * + * @doctodo + * + * + * Documentation? What's that? + * Nathan Myers . + * + * A string looks like this: + * + * @code + * [_Rep] + * _M_length + * [basic_string] _M_capacity + * _M_dataplus _M_refcount + * _M_p ----------------> unnamed array of char_type + * @endcode + * + * Where the _M_p points to the first character in the string, and + * you cast it to a pointer-to-_Rep and subtract 1 to get a + * pointer to the header. + * + * This approach has the enormous advantage that a string object + * requires only one allocation. All the ugliness is confined + * within a single %pair of inline functions, which each compile to + * a single @a add instruction: _Rep::_M_data(), and + * string::_M_rep(); and the allocation function which gets a + * block of raw bytes and with room enough and constructs a _Rep + * object at the front. + * + * The reason you want _M_data pointing to the character %array and + * not the _Rep is so that the debugger can see the string + * contents. (Probably we should add a non-inline member to get + * the _Rep for the debugger to use, so users can check the actual + * string length.) + * + * Note that the _Rep object is a POD so that you can have a + * static empty string _Rep object already @a constructed before + * static constructors have run. The reference-count encoding is + * chosen so that a 0 indicates one reference, so you never try to + * destroy the empty-string _Rep object. + * + * All but the last paragraph is considered pretty conventional + * for a C++ string implementation. + */ + // 21.3 Template class basic_string + template + class basic_string + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_CharT>::other _CharT_alloc_type; + typedef __gnu_cxx::__alloc_traits<_CharT_alloc_type> _CharT_alloc_traits; + + // Types: + public: + typedef _Traits traits_type; + typedef typename _Traits::char_type value_type; + typedef _Alloc allocator_type; + typedef typename _CharT_alloc_type::size_type size_type; + typedef typename _CharT_alloc_type::difference_type difference_type; +#if __cplusplus < 201103L + typedef typename _CharT_alloc_type::reference reference; + typedef typename _CharT_alloc_type::const_reference const_reference; +#else + typedef value_type& reference; + typedef const value_type& const_reference; +#endif + typedef typename _CharT_alloc_traits::pointer pointer; + typedef typename _CharT_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; + + protected: + // type used for positions in insert, erase etc. + typedef iterator __const_iterator; + + private: + // _Rep: string representation + // Invariants: + // 1. String really contains _M_length + 1 characters: due to 21.3.4 + // must be kept null-terminated. + // 2. _M_capacity >= _M_length + // Allocated memory is always (_M_capacity + 1) * sizeof(_CharT). + // 3. _M_refcount has three states: + // -1: leaked, one reference, no ref-copies allowed, non-const. + // 0: one reference, non-const. + // n>0: n + 1 references, operations require a lock, const. + // 4. All fields==0 is an empty string, given the extra storage + // beyond-the-end for a null terminator; thus, the shared + // empty string representation needs no constructor. + + struct _Rep_base + { + size_type _M_length; + size_type _M_capacity; + _Atomic_word _M_refcount; + }; + + struct _Rep : _Rep_base + { + // Types: + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind::other _Raw_bytes_alloc; + + // (Public) Data members: + + // The maximum number of individual char_type elements of an + // individual string is determined by _S_max_size. This is the + // value that will be returned by max_size(). (Whereas npos + // is the maximum number of bytes the allocator can allocate.) + // If one was to divvy up the theoretical largest size string, + // with a terminating character and m _CharT elements, it'd + // look like this: + // npos = sizeof(_Rep) + (m * sizeof(_CharT)) + sizeof(_CharT) + // Solving for m: + // m = ((npos - sizeof(_Rep))/sizeof(CharT)) - 1 + // In addition, this implementation quarters this amount. + static const size_type _S_max_size; + static const _CharT _S_terminal; + + // The following storage is init'd to 0 by the linker, resulting + // (carefully) in an empty string with one reference. + static size_type _S_empty_rep_storage[]; + + static _Rep& + _S_empty_rep() _GLIBCXX_NOEXCEPT + { + // NB: Mild hack to avoid strict-aliasing warnings. Note that + // _S_empty_rep_storage is never modified and the punning should + // be reasonably safe in this case. + void* __p = reinterpret_cast(&_S_empty_rep_storage); + return *reinterpret_cast<_Rep*>(__p); + } + + bool + _M_is_leaked() const _GLIBCXX_NOEXCEPT + { +#if defined(__GTHREADS) + // _M_refcount is mutated concurrently by _M_refcopy/_M_dispose, + // so we need to use an atomic load. However, _M_is_leaked + // predicate does not change concurrently (i.e. the string is either + // leaked or not), so a relaxed load is enough. + return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0; +#else + return this->_M_refcount < 0; +#endif + } + + bool + _M_is_shared() const _GLIBCXX_NOEXCEPT + { +#if defined(__GTHREADS) + // _M_refcount is mutated concurrently by _M_refcopy/_M_dispose, + // so we need to use an atomic load. Another thread can drop last + // but one reference concurrently with this check, so we need this + // load to be acquire to synchronize with release fetch_and_add in + // _M_dispose. + return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0; +#else + return this->_M_refcount > 0; +#endif + } + + void + _M_set_leaked() _GLIBCXX_NOEXCEPT + { this->_M_refcount = -1; } + + void + _M_set_sharable() _GLIBCXX_NOEXCEPT + { this->_M_refcount = 0; } + + void + _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__builtin_expect(this != &_S_empty_rep(), false)) +#endif + { + this->_M_set_sharable(); // One reference. + this->_M_length = __n; + traits_type::assign(this->_M_refdata()[__n], _S_terminal); + // grrr. (per 21.3.4) + // You cannot leave those LWG people alone for a second. + } + } + + _CharT* + _M_refdata() throw() + { return reinterpret_cast<_CharT*>(this + 1); } + + _CharT* + _M_grab(const _Alloc& __alloc1, const _Alloc& __alloc2) + { + return (!_M_is_leaked() && __alloc1 == __alloc2) + ? _M_refcopy() : _M_clone(__alloc1); + } + + // Create & Destroy + static _Rep* + _S_create(size_type, size_type, const _Alloc&); + + void + _M_dispose(const _Alloc& __a) _GLIBCXX_NOEXCEPT + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__builtin_expect(this != &_S_empty_rep(), false)) +#endif + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); + // Decrement of _M_refcount is acq_rel, because: + // - all but last decrements need to release to synchronize with + // the last decrement that will delete the object. + // - the last decrement needs to acquire to synchronize with + // all the previous decrements. + // - last but one decrement needs to release to synchronize with + // the acquire load in _M_is_shared that will conclude that + // the object is not shared anymore. + if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, + -1) <= 0) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); + _M_destroy(__a); + } + } + } // XXX MT + + void + _M_destroy(const _Alloc&) throw(); + + _CharT* + _M_refcopy() throw() + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__builtin_expect(this != &_S_empty_rep(), false)) +#endif + __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1); + return _M_refdata(); + } // XXX MT + + _CharT* + _M_clone(const _Alloc&, size_type __res = 0); + }; + + // Use empty-base optimization: http://www.cantrip.org/emptyopt.html + struct _Alloc_hider : _Alloc + { + _Alloc_hider(_CharT* __dat, const _Alloc& __a) _GLIBCXX_NOEXCEPT + : _Alloc(__a), _M_p(__dat) { } + + _CharT* _M_p; // The actual data. + }; + + public: + // Data Members (public): + // NB: This is an unsigned type, and thus represents the maximum + // size that the allocator can hold. + /// Value returned by various member functions when they fail. + static const size_type npos = static_cast(-1); + + private: + // Data Members (private): + mutable _Alloc_hider _M_dataplus; + + _CharT* + _M_data() const _GLIBCXX_NOEXCEPT + { return _M_dataplus._M_p; } + + _CharT* + _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT + { return (_M_dataplus._M_p = __p); } + + _Rep* + _M_rep() const _GLIBCXX_NOEXCEPT + { return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); } + + // For the internal use we have functions similar to `begin'/`end' + // but they do not call _M_leak. + iterator + _M_ibegin() const _GLIBCXX_NOEXCEPT + { return iterator(_M_data()); } + + iterator + _M_iend() const _GLIBCXX_NOEXCEPT + { return iterator(_M_data() + this->size()); } + + void + _M_leak() // for use in begin() & non-const op[] + { + if (!_M_rep()->_M_is_leaked()) + _M_leak_hard(); + } + + size_type + _M_check(size_type __pos, const char* __s) const + { + if (__pos > this->size()) + __throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > " + "this->size() (which is %zu)"), + __s, __pos, this->size()); + return __pos; + } + + void + _M_check_length(size_type __n1, size_type __n2, const char* __s) const + { + if (this->max_size() - (this->size() - __n1) < __n2) + __throw_length_error(__N(__s)); + } + + // NB: _M_limit doesn't check for a bad __pos value. + 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. + static void + _M_copy(_CharT* __d, const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT + { + if (__n == 1) + traits_type::assign(*__d, *__s); + else + traits_type::copy(__d, __s, __n); + } + + static void + _M_move(_CharT* __d, const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT + { + if (__n == 1) + traits_type::assign(*__d, *__s); + else + traits_type::move(__d, __s, __n); + } + + static void + _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT + { + 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 + 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. + } + + static void + _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT + { _S_copy_chars(__p, __k1.base(), __k2.base()); } + + static void + _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2) + _GLIBCXX_NOEXCEPT + { _S_copy_chars(__p, __k1.base(), __k2.base()); } + + static void + _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT + { _M_copy(__p, __k1, __k2 - __k1); } + + static void + _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2) + _GLIBCXX_NOEXCEPT + { _M_copy(__p, __k1, __k2 - __k1); } + + 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); + } + + void + _M_mutate(size_type __pos, size_type __len1, size_type __len2); + + void + _M_leak_hard(); + + static _Rep& + _S_empty_rep() _GLIBCXX_NOEXCEPT + { return _Rep::_S_empty_rep(); } + +#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. + 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 + { + 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. + */ + explicit + basic_string(__sv_wrapper __svw, const _Alloc& __a) + : basic_string(__svw._M_sv.data(), __svw._M_sv.size(), __a) { } +#endif + + 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. + */ + basic_string() +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + _GLIBCXX_NOEXCEPT + : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) +#else + : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) +#endif + { } + + /** + * @brief Construct an empty string using allocator @a a. + */ + explicit + basic_string(const _Alloc& __a); + + // NB: per LWG issue 42, semantics different from IS: + /** + * @brief Construct string with copy of value of @a str. + * @param __str Source string. + */ + basic_string(const basic_string& __str); + + // _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. + */ + basic_string(const basic_string& __str, size_type __pos, + const _Alloc& __a = _Alloc()); + + /** + * @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. + */ + basic_string(const basic_string& __str, size_type __pos, + size_type __n); + /** + * @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. + */ + basic_string(const basic_string& __str, size_type __pos, + size_type __n, const _Alloc& __a); + + /** + * @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. + */ + basic_string(const _CharT* __s, size_type __n, + const _Alloc& __a = _Alloc()); + + /** + * @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 + basic_string(const _CharT* __s, const _Alloc& __a = _Alloc()) + : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) : + __s + npos, __a), __a) + { } + + /** + * @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). + */ + basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc()); + +#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. + **/ + basic_string(basic_string&& __str) +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + noexcept // FIXME C++11: should always be noexcept. +#endif + : _M_dataplus(std::move(__str._M_dataplus)) + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + __str._M_data(_S_empty_rep()._M_refdata()); +#else + __str._M_data(_S_construct(size_type(), _CharT(), get_allocator())); +#endif + } + + /** + * @brief Construct string from an initializer %list. + * @param __l std::initializer_list of characters. + * @param __a Allocator to use (default is default allocator). + */ + basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()); + + basic_string(const basic_string& __str, const _Alloc& __a) + : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.get_allocator()), __a) + { } + + basic_string(basic_string&& __str, const _Alloc& __a) + : _M_dataplus(__str._M_data(), __a) + { + if (__a == __str.get_allocator()) + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + __str._M_data(_S_empty_rep()._M_refdata()); +#else + __str._M_data(_S_construct(size_type(), _CharT(), __a)); +#endif + } + else + _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a); + } +#endif // C++11 + + /** + * @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). + */ + template + basic_string(_InputIterator __beg, _InputIterator __end, + const _Alloc& __a = _Alloc()); + +#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> + 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> + 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. + */ + ~basic_string() _GLIBCXX_NOEXCEPT + { _M_rep()->_M_dispose(this->get_allocator()); } + + /** + * @brief Assign the value of @a str to this string. + * @param __str Source string. + */ + 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. + */ + 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. + */ + 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. + **/ + basic_string& + operator=(basic_string&& __str) + _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value) + { + // NB: DR 1204. + this->swap(__str); + return *this; + } + + /** + * @brief Set value to string constructed from initializer %list. + * @param __l std::initializer_list. + */ + 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 + _If_sv<_Tp, basic_string&> + operator=(const _Tp& __svt) + { return this->assign(__svt); } + + /** + * @brief Convert to a string_view. + * @return A string_view. + */ + 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. Unshares the string. + */ + iterator + begin() // FIXME C++11: should be noexcept. + { + _M_leak(); + return iterator(_M_data()); + } + + /** + * Returns a read-only (constant) iterator that points to the first + * character in the %string. + */ + 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. Unshares the string. + */ + iterator + end() // FIXME C++11: should be noexcept. + { + _M_leak(); + return iterator(_M_data() + this->size()); + } + + /** + * Returns a read-only (constant) iterator that points one past the + * last character in the %string. + */ + 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. Unshares the string. + */ + reverse_iterator + rbegin() // FIXME C++11: should be 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. + */ + 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. Unshares the string. + */ + reverse_iterator + rend() // FIXME C++11: should be 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_rep()->_M_length; } + + /// Returns the number of characters in the string, not including any + /// null-termination. + size_type + length() const _GLIBCXX_NOEXCEPT + { return _M_rep()->_M_length; } + + /// Returns the size() of the largest possible %string. + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _Rep::_S_max_size; } + + /** + * @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. + */ + 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. + */ + void + resize(size_type __n) + { this->resize(__n, _CharT()); } + +#if __cplusplus >= 201103L + /// A non-binding request to reduce capacity() to size(). + void + shrink_to_fit() _GLIBCXX_NOEXCEPT + { +#if __cpp_exceptions + if (capacity() > size()) + { + try + { reserve(0); } + catch(...) + { } + } +#endif + } +#endif + + /** + * Returns the total number of characters that the %string can hold + * before needing to allocate more memory. + */ + size_type + capacity() const _GLIBCXX_NOEXCEPT + { return _M_rep()->_M_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. + */ + void + reserve(size_type __res_arg = 0); + + /** + * Erases the string, making it empty. + */ +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + void + clear() _GLIBCXX_NOEXCEPT + { + if (_M_rep()->_M_is_shared()) + { + _M_rep()->_M_dispose(this->get_allocator()); + _M_data(_S_empty_rep()._M_refdata()); + } + else + _M_rep()->_M_set_length_and_sharable(0); + } +#else + // PR 56166: this should not throw. + void + clear() + { _M_mutate(0, this->size(), 0); } +#endif + + /** + * Returns true if the %string is empty. Equivalent to + * *this == "". + */ + _GLIBCXX_NODISCARD 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().) + */ + 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().) Unshares the string. + */ + 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()); + _M_leak(); + 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. + */ + 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. Success results in + * unsharing the string. + */ + 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()); + _M_leak(); + return _M_data()[__n]; + } + +#if __cplusplus >= 201103L + /** + * Returns a read/write reference to the data at the first + * element of the %string. + */ + reference + front() + { + __glibcxx_assert(!empty()); + return operator[](0); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %string. + */ + 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. + */ + reference + back() + { + __glibcxx_assert(!empty()); + return operator[](this->size() - 1); + } + + /** + * Returns a read-only (constant) reference to the data at the + * last element of the %string. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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 The object convertible to string_view to be appended. + * @return Reference to this string. + */ + template + _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. + */ + basic_string& + append(const basic_string& __str); + + /** + * @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. + */ + basic_string& + append(const basic_string& __str, size_type __pos, size_type __n = npos); + + /** + * @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. + */ + basic_string& + append(const _CharT* __s, size_type __n); + + /** + * @brief Append a C string. + * @param __s The C string to append. + * @return Reference to this string. + */ + basic_string& + append(const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->append(__s, traits_type::length(__s)); + } + + /** + * @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. + */ + basic_string& + append(size_type __n, _CharT __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. + */ + 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. + */ + template + basic_string& + append(_InputIterator __first, _InputIterator __last) + { return this->replace(_M_iend(), _M_iend(), __first, __last); } + +#if __cplusplus >= 201703L + /** + * @brief Append a string_view. + * @param __svt The object convertible to string_view to be appended. + * @return Reference to this string. + */ + template + _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 The 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 + _If_sv<_Tp, basic_string&> + append(const _Tp& __svt, size_type __pos, size_type __n = npos) + { + __sv_type __sv = __svt; + return 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. + */ + void + push_back(_CharT __c) + { + const size_type __len = 1 + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + traits_type::assign(_M_data()[this->size()], __c); + _M_rep()->_M_set_length_and_sharable(__len); + } + + /** + * @brief Set value to contents of another string. + * @param __str Source string to use. + * @return Reference to this string. + */ + basic_string& + assign(const basic_string& __str); + +#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. + */ + basic_string& + assign(basic_string&& __str) + noexcept(allocator_traits<_Alloc>::is_always_equal::value) + { + this->swap(__str); + return *this; + } +#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. + */ + basic_string& + assign(const basic_string& __str, size_type __pos, size_type __n = npos) + { return this->assign(__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. + */ + basic_string& + assign(const _CharT* __s, size_type __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. + */ + basic_string& + assign(const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->assign(__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. + */ + 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). + */ + template + basic_string& + assign(_InputIterator __first, _InputIterator __last) + { return this->replace(_M_ibegin(), _M_iend(), __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. + */ + 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 + _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 + _If_sv<_Tp, basic_string&> + assign(const _Tp& __svt, size_type __pos, size_type __n = npos) + { + __sv_type __sv = __svt; + return assign(__sv.data() + + std::__sv_check(__sv.size(), __pos, "basic_string::assign"), + std::__sv_limit(__sv.size(), __pos, __n)); + } +#endif // C++17 + + /** + * @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); } + + /** + * @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); } + +#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(). + */ + void + insert(iterator __p, initializer_list<_CharT> __l) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend()); + this->insert(__p - _M_ibegin(), __l.begin(), __l.size()); + } +#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. + */ + basic_string& + insert(size_type __pos1, const basic_string& __str) + { return this->insert(__pos1, __str, size_type(0), __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. + */ + basic_string& + insert(size_type __pos1, const basic_string& __str, + size_type __pos2, size_type __n = npos) + { return this->insert(__pos1, __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. + */ + basic_string& + insert(size_type __pos, const _CharT* __s, size_type __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. + */ + basic_string& + insert(size_type __pos, const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->insert(__pos, __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. + */ + 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. + */ + iterator + insert(iterator __p, _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend()); + const size_type __pos = __p - _M_ibegin(); + _M_replace_aux(__pos, size_type(0), size_type(1), __c); + _M_rep()->_M_set_leaked(); + return iterator(_M_data() + __pos); + } + +#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 + _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 __pos Position in string to insert at. + * @param __svt The object convertible to string_view to insert from. + * @param __pos Position in string_view to insert + * from. + * @param __n The number of characters to insert. + * @return Reference to this string. + */ + template + _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. + */ + basic_string& + erase(size_type __pos = 0, size_type __n = npos) + { + _M_mutate(_M_check(__pos, "basic_string::erase"), + _M_limit(__pos, __n), size_type(0)); + return *this; + } + + /** + * @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. + */ + iterator + erase(iterator __position) + { + _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin() + && __position < _M_iend()); + const size_type __pos = __position - _M_ibegin(); + _M_mutate(__pos, size_type(1), size_type(0)); + _M_rep()->_M_set_leaked(); + return iterator(_M_data() + __pos); + } + + /** + * @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. + */ + iterator + erase(iterator __first, iterator __last); + +#if __cplusplus >= 201103L + /** + * @brief Remove the last character. + * + * The string must be non-empty. + */ + void + pop_back() // FIXME C++11: should be noexcept. + { + __glibcxx_assert(!empty()); + 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. + */ + 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. + */ + 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. + */ + basic_string& + replace(size_type __pos, size_type __n1, const _CharT* __s, + size_type __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. + */ + 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. + */ + 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. + */ + basic_string& + replace(iterator __i1, 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. + */ + basic_string& + replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + return this->replace(__i1 - _M_ibegin(), __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. + */ + basic_string& + replace(iterator __i1, 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. + */ + basic_string& + replace(iterator __i1, iterator __i2, size_type __n, _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + return _M_replace_aux(__i1 - _M_ibegin(), __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. + */ + template + basic_string& + replace(iterator __i1, iterator __i2, + _InputIterator __k1, _InputIterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral()); + } + + // Specializations for the common case of pointer and iterator: + // useful to avoid the overhead of temporary buffering in _M_replace. + basic_string& + replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1, __k2 - __k1); + } + + basic_string& + replace(iterator __i1, iterator __i2, + const _CharT* __k1, const _CharT* __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1, __k2 - __k1); + } + + basic_string& + replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1.base(), __k2 - __k1); + } + + basic_string& + replace(iterator __i1, iterator __i2, + const_iterator __k1, const_iterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __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. + */ + basic_string& replace(iterator __i1, iterator __i2, + initializer_list<_CharT> __l) + { return this->replace(__i1, __i2, __l.begin(), __l.end()); } +#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 + _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 + _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 + _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 + basic_string& + _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n, + _Integer __val, __true_type) + { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); } + + template + basic_string& + _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1, + _InputIterator __k2, __false_type); + + basic_string& + _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, + _CharT __c); + + basic_string& + _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s, + size_type __n2); + + // _S_construct_aux is used to implement the 21.3.1 para 15 which + // requires special behaviour if _InIter is an integral type + template + static _CharT* + _S_construct_aux(_InIterator __beg, _InIterator __end, + const _Alloc& __a, __false_type) + { + typedef typename iterator_traits<_InIterator>::iterator_category _Tag; + return _S_construct(__beg, __end, __a, _Tag()); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + static _CharT* + _S_construct_aux(_Integer __beg, _Integer __end, + const _Alloc& __a, __true_type) + { return _S_construct_aux_2(static_cast(__beg), + __end, __a); } + + static _CharT* + _S_construct_aux_2(size_type __req, _CharT __c, const _Alloc& __a) + { return _S_construct(__req, __c, __a); } + + template + static _CharT* + _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a) + { + typedef typename std::__is_integer<_InIterator>::__type _Integral; + return _S_construct_aux(__beg, __end, __a, _Integral()); + } + + // For Input Iterators, used in istreambuf_iterators, etc. + template + static _CharT* + _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, + input_iterator_tag); + + // For forward_iterators up to random_access_iterators, used for + // string::iterator, _CharT*, etc. + template + static _CharT* + _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a, + forward_iterator_tag); + + static _CharT* + _S_construct(size_type __req, _CharT __c, const _Alloc& __a); + + public: + + /** + * @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. + */ + 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. + */ + void + swap(basic_string& __s) + _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value); + + // 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. + */ + 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). + */ + 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. + */ + _CharT* + data() noexcept + { + _M_leak(); + return _M_data(); + } +#endif + + /** + * @brief Return copy of allocator used to construct this string. + */ + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return _M_dataplus; } + + /** + * @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. + */ + 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. + */ + size_type + find(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return this->find(__str.data(), __pos, __str.size()); } + + /** + * @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. + */ + 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. + */ + size_type + find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT; + +#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 + _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 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. + */ + size_type + rfind(const basic_string& __str, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { return this->rfind(__str.data(), __pos, __str.size()); } + + /** + * @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. + */ + 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. + */ + size_type + rfind(const _CharT* __s, size_type __pos = npos) const _GLIBCXX_NOEXCEPT + { + __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. + */ + size_type + rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT; + +#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 + _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 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. + */ + 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()); } + + /** + * @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. + */ + 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. + */ + 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). + */ + size_type + find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT + { return this->find(__c, __pos); } + +#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 + _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 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. + */ + 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()); } + + /** + * @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. + */ + 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. + */ + 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). + */ + size_type + find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT + { return this->rfind(__c, __pos); } + +#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 + _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 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. + */ + 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()); } + + /** + * @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. + */ + 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. + */ + 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. + */ + size_type + find_first_not_of(_CharT __c, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT; + +#if __cplusplus >= 201703L + /** + * @brief Find 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 from (default 0). + * @return Index of first occurrence. + */ + template + _If_sv<_Tp, size_type> + 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 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. + */ + 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()); } + + /** + * @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. + */ + 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. + */ + 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. + */ + size_type + find_last_not_of(_CharT __c, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT; + +#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 + _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 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. + */ + 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. + */ + 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 + _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 + _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 + _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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + int + compare(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) const; + +#if __cplusplus > 201703L + bool + starts_with(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + starts_with(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + starts_with(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + ends_with(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } + + bool + ends_with(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } + + bool + ends_with(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } +#endif // C++20 + +# ifdef _GLIBCXX_TM_TS_INTERNAL + friend void + ::_txnal_cow_string_C1_for_exceptions(void* that, const char* s, + void* exc); + friend const char* + ::_txnal_cow_string_c_str(const void *that); + friend void + ::_txnal_cow_string_D1(void *that); + friend void + ::_txnal_cow_string_D1_commit(void *that); +# endif + }; +#endif // !_GLIBCXX_USE_CXX11_ABI + +#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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + inline basic_string<_CharT, _Traits, _Alloc> + operator+(const _CharT* __lhs, + basic_string<_CharT, _Traits, _Alloc>&& __rhs) + { return std::move(__rhs.insert(0, __lhs)); } + + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(_CharT __lhs, + basic_string<_CharT, _Traits, _Alloc>&& __rhs) + { return std::move(__rhs.insert(0, 1, __lhs)); } + + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, + const _CharT* __rhs) + { return std::move(__lhs.append(__rhs)); } + + template + 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 + 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 + 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 + 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 + inline 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 + inline 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 + 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) + { + 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) + { + 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) + { + 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) + { + 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 + { }; + +#ifdef _GLIBCXX_USE_WCHAR_T + /// 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 +#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 201304 + + inline namespace literals + { + inline namespace string_literals + { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" + _GLIBCXX_DEFAULT_ABI_TAG + inline basic_string + operator""s(const char* __str, size_t __len) + { return basic_string{__str, __len}; } + +#ifdef _GLIBCXX_USE_WCHAR_T + _GLIBCXX_DEFAULT_ABI_TAG + inline basic_string + operator""s(const wchar_t* __str, size_t __len) + { return basic_string{__str, __len}; } +#endif + +#ifdef _GLIBCXX_USE_CHAR8_T + _GLIBCXX_DEFAULT_ABI_TAG + inline basic_string + operator""s(const char8_t* __str, size_t __len) + { return basic_string{__str, __len}; } +#endif + + _GLIBCXX_DEFAULT_ABI_TAG + inline basic_string + operator""s(const char16_t* __str, size_t __len) + { return basic_string{__str, __len}; } + + _GLIBCXX_DEFAULT_ABI_TAG + inline basic_string + operator""s(const char32_t* __str, size_t __len) + { return basic_string{__str, __len}; } + +#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/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.h.blob new file mode 100644 index 0000000..a70ced0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.tcc new file mode 100644 index 0000000..204a140 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.tcc @@ -0,0 +1,1657 @@ +// Components for manipulating sequences of characters -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + void + basic_string<_CharT, _Traits, _Alloc>:: + swap(basic_string& __s) _GLIBCXX_NOEXCEPT + { + if (this == &__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_local_capacity + 1); + traits_type::copy(__s._M_local_buf, _M_local_buf, + _S_local_capacity + 1); + traits_type::copy(_M_local_buf, __tmp_data, + _S_local_capacity + 1); + } + else if (__s.length()) + { + traits_type::copy(_M_local_buf, __s._M_local_buf, + _S_local_capacity + 1); + _M_length(__s.length()); + __s._M_set_length(0); + return; + } + else if (length()) + { + traits_type::copy(__s._M_local_buf, _M_local_buf, + _S_local_capacity + 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, + _S_local_capacity + 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_local_capacity + 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 + 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 + 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); + + while (__beg != __end && __len < __capacity) + { + _M_data()[__len++] = *__beg; + ++__beg; + } + + __try + { + 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); + } + _M_data()[__len++] = *__beg; + ++__beg; + } + } + __catch(...) + { + _M_dispose(); + __throw_exception_again; + } + + _M_set_length(__len); + } + + template + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_construct(_InIterator __beg, _InIterator __end, + std::forward_iterator_tag) + { + // NB: Not required, but considered best practice. + if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end) + std::__throw_logic_error(__N("basic_string::" + "_M_construct null not valid")); + + 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); + } + + // Check for out_of_range and length_error exceptions. + __try + { this->_S_copy_chars(_M_data(), __beg, __end); } + __catch(...) + { + _M_dispose(); + __throw_exception_again; + } + + _M_set_length(__dnew); + } + + template + 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); + } + + if (__n) + this->_S_assign(_M_data(), __n, __c); + + _M_set_length(__n); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_assign(const basic_string& __str) + { + if (this != &__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 + void + basic_string<_CharT, _Traits, _Alloc>:: + reserve(size_type __res) + { + // Make sure we don't shrink below the current size. + if (__res < length()) + __res = length(); + + const size_type __capacity = capacity(); + if (__res != __capacity) + { + if (__res > __capacity + || __res > size_type(_S_local_capacity)) + { + pointer __tmp = _M_create(__res, __capacity); + this->_S_copy(__tmp, _M_data(), length() + 1); + _M_dispose(); + _M_data(__tmp); + _M_capacity(__res); + } + else if (!_M_is_local()) + { + this->_S_copy(_M_local_data(), _M_data(), length() + 1); + _M_destroy(__capacity); + _M_data(_M_local_data()); + } + } + } + + template + 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 + 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 + 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 + 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 + 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 + 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 + 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 (_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) + this->_S_copy(__p, __s + __len2 - __len1, __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 + 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; + } + +#else // !_GLIBCXX_USE_CXX11_ABI + + template + const typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + _Rep::_S_max_size = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4; + + template + const _CharT + basic_string<_CharT, _Traits, _Alloc>:: + _Rep::_S_terminal = _CharT(); + + template + const typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>::npos; + + // Linker sets _S_empty_rep_storage to all 0s (one reference, empty string) + // at static init time (before static ctors are run). + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_empty_rep_storage[ + (sizeof(_Rep_base) + sizeof(_CharT) + sizeof(size_type) - 1) / + sizeof(size_type)]; + + // 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 + _CharT* + basic_string<_CharT, _Traits, _Alloc>:: + _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, + input_iterator_tag) + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__beg == __end && __a == _Alloc()) + return _S_empty_rep()._M_refdata(); +#endif + // Avoid reallocation for common case. + _CharT __buf[128]; + size_type __len = 0; + while (__beg != __end && __len < sizeof(__buf) / sizeof(_CharT)) + { + __buf[__len++] = *__beg; + ++__beg; + } + _Rep* __r = _Rep::_S_create(__len, size_type(0), __a); + _M_copy(__r->_M_refdata(), __buf, __len); + __try + { + while (__beg != __end) + { + if (__len == __r->_M_capacity) + { + // Allocate more space. + _Rep* __another = _Rep::_S_create(__len + 1, __len, __a); + _M_copy(__another->_M_refdata(), __r->_M_refdata(), __len); + __r->_M_destroy(__a); + __r = __another; + } + __r->_M_refdata()[__len++] = *__beg; + ++__beg; + } + } + __catch(...) + { + __r->_M_destroy(__a); + __throw_exception_again; + } + __r->_M_set_length_and_sharable(__len); + return __r->_M_refdata(); + } + + template + template + _CharT* + basic_string<_CharT, _Traits, _Alloc>:: + _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, + forward_iterator_tag) + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__beg == __end && __a == _Alloc()) + return _S_empty_rep()._M_refdata(); +#endif + // NB: Not required, but considered best practice. + if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end) + __throw_logic_error(__N("basic_string::_S_construct null not valid")); + + const size_type __dnew = static_cast(std::distance(__beg, + __end)); + // Check for out_of_range and length_error exceptions. + _Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a); + __try + { _S_copy_chars(__r->_M_refdata(), __beg, __end); } + __catch(...) + { + __r->_M_destroy(__a); + __throw_exception_again; + } + __r->_M_set_length_and_sharable(__dnew); + return __r->_M_refdata(); + } + + template + _CharT* + basic_string<_CharT, _Traits, _Alloc>:: + _S_construct(size_type __n, _CharT __c, const _Alloc& __a) + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__n == 0 && __a == _Alloc()) + return _S_empty_rep()._M_refdata(); +#endif + // Check for out_of_range and length_error exceptions. + _Rep* __r = _Rep::_S_create(__n, size_type(0), __a); + if (__n) + _M_assign(__r->_M_refdata(), __n, __c); + + __r->_M_set_length_and_sharable(__n); + return __r->_M_refdata(); + } + + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(const basic_string& __str) + : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.get_allocator()), + __str.get_allocator()), + __str.get_allocator()) + { } + + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(const _Alloc& __a) + : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a) + { } + + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(const basic_string& __str, size_type __pos, const _Alloc& __a) + : _M_dataplus(_S_construct(__str._M_data() + + __str._M_check(__pos, + "basic_string::basic_string"), + __str._M_data() + __str._M_limit(__pos, npos) + + __pos, __a), __a) + { } + + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(const basic_string& __str, size_type __pos, size_type __n) + : _M_dataplus(_S_construct(__str._M_data() + + __str._M_check(__pos, + "basic_string::basic_string"), + __str._M_data() + __str._M_limit(__pos, __n) + + __pos, _Alloc()), _Alloc()) + { } + + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(const basic_string& __str, size_type __pos, + size_type __n, const _Alloc& __a) + : _M_dataplus(_S_construct(__str._M_data() + + __str._M_check(__pos, + "basic_string::basic_string"), + __str._M_data() + __str._M_limit(__pos, __n) + + __pos, __a), __a) + { } + + // TBD: DPG annotate + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(const _CharT* __s, size_type __n, const _Alloc& __a) + : _M_dataplus(_S_construct(__s, __s + __n, __a), __a) + { } + + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(size_type __n, _CharT __c, const _Alloc& __a) + : _M_dataplus(_S_construct(__n, __c, __a), __a) + { } + + // TBD: DPG annotate + template + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a) + : _M_dataplus(_S_construct(__beg, __end, __a), __a) + { } + +#if __cplusplus >= 201103L + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(initializer_list<_CharT> __l, const _Alloc& __a) + : _M_dataplus(_S_construct(__l.begin(), __l.end(), __a), __a) + { } +#endif + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + assign(const basic_string& __str) + { + if (_M_rep() != __str._M_rep()) + { + // XXX MT + const allocator_type __a = this->get_allocator(); + _CharT* __tmp = __str._M_rep()->_M_grab(__a, __str.get_allocator()); + _M_rep()->_M_dispose(__a); + _M_data(__tmp); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + assign(const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + _M_check_length(this->size(), __n, "basic_string::assign"); + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) + return _M_replace_safe(size_type(0), this->size(), __s, __n); + else + { + // Work in-place. + const size_type __pos = __s - _M_data(); + if (__pos >= __n) + _M_copy(_M_data(), __s, __n); + else if (__pos) + _M_move(_M_data(), __s, __n); + _M_rep()->_M_set_length_and_sharable(__n); + return *this; + } + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(size_type __n, _CharT __c) + { + if (__n) + { + _M_check_length(size_type(0), __n, "basic_string::append"); + const size_type __len = __n + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_assign(_M_data() + this->size(), __n, __c); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + if (__n) + { + _M_check_length(size_type(0), __n, "basic_string::append"); + const size_type __len = __n + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + { + if (_M_disjunct(__s)) + this->reserve(__len); + else + { + const size_type __off = __s - _M_data(); + this->reserve(__len); + __s = _M_data() + __off; + } + } + _M_copy(_M_data() + this->size(), __s, __n); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(const basic_string& __str) + { + const size_type __size = __str.size(); + if (__size) + { + const size_type __len = __size + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_copy(_M_data() + this->size(), __str._M_data(), __size); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(const basic_string& __str, size_type __pos, size_type __n) + { + __str._M_check(__pos, "basic_string::append"); + __n = __str._M_limit(__pos, __n); + if (__n) + { + const size_type __len = __n + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_copy(_M_data() + this->size(), __str._M_data() + __pos, __n); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + insert(size_type __pos, const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + _M_check(__pos, "basic_string::insert"); + _M_check_length(size_type(0), __n, "basic_string::insert"); + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) + return _M_replace_safe(__pos, size_type(0), __s, __n); + else + { + // Work in-place. + const size_type __off = __s - _M_data(); + _M_mutate(__pos, 0, __n); + __s = _M_data() + __off; + _CharT* __p = _M_data() + __pos; + if (__s + __n <= __p) + _M_copy(__p, __s, __n); + else if (__s >= __p) + _M_copy(__p, __s + __n, __n); + else + { + const size_type __nleft = __p - __s; + _M_copy(__p, __s, __nleft); + _M_copy(__p + __nleft, __p + __n, __n - __nleft); + } + return *this; + } + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::iterator + basic_string<_CharT, _Traits, _Alloc>:: + erase(iterator __first, iterator __last) + { + _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last + && __last <= _M_iend()); + + // NB: This isn't just an optimization (bail out early when + // there is nothing to do, really), it's also a correctness + // issue vs MT, see libstdc++/40518. + const size_type __size = __last - __first; + if (__size) + { + const size_type __pos = __first - _M_ibegin(); + _M_mutate(__pos, __size, size_type(0)); + _M_rep()->_M_set_leaked(); + return iterator(_M_data() + __pos); + } + else + return __first; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + replace(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) + { + __glibcxx_requires_string_len(__s, __n2); + _M_check(__pos, "basic_string::replace"); + __n1 = _M_limit(__pos, __n1); + _M_check_length(__n1, __n2, "basic_string::replace"); + bool __left; + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) + return _M_replace_safe(__pos, __n1, __s, __n2); + else if ((__left = __s + __n2 <= _M_data() + __pos) + || _M_data() + __pos + __n1 <= __s) + { + // Work in-place: non-overlapping case. + size_type __off = __s - _M_data(); + __left ? __off : (__off += __n2 - __n1); + _M_mutate(__pos, __n1, __n2); + _M_copy(_M_data() + __pos, _M_data() + __off, __n2); + return *this; + } + else + { + // Todo: overlapping case. + const basic_string __tmp(__s, __n2); + return _M_replace_safe(__pos, __n1, __tmp._M_data(), __n2); + } + } + + template + void + basic_string<_CharT, _Traits, _Alloc>::_Rep:: + _M_destroy(const _Alloc& __a) throw () + { + const size_type __size = sizeof(_Rep_base) + + (this->_M_capacity + 1) * sizeof(_CharT); + _Raw_bytes_alloc(__a).deallocate(reinterpret_cast(this), __size); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_leak_hard() + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (_M_rep() == &_S_empty_rep()) + return; +#endif + if (_M_rep()->_M_is_shared()) + _M_mutate(0, 0, 0); + _M_rep()->_M_set_leaked(); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_mutate(size_type __pos, size_type __len1, size_type __len2) + { + const size_type __old_size = this->size(); + const size_type __new_size = __old_size + __len2 - __len1; + const size_type __how_much = __old_size - __pos - __len1; + + if (__new_size > this->capacity() || _M_rep()->_M_is_shared()) + { + // Must reallocate. + const allocator_type __a = get_allocator(); + _Rep* __r = _Rep::_S_create(__new_size, this->capacity(), __a); + + if (__pos) + _M_copy(__r->_M_refdata(), _M_data(), __pos); + if (__how_much) + _M_copy(__r->_M_refdata() + __pos + __len2, + _M_data() + __pos + __len1, __how_much); + + _M_rep()->_M_dispose(__a); + _M_data(__r->_M_refdata()); + } + else if (__how_much && __len1 != __len2) + { + // Work in-place. + _M_move(_M_data() + __pos + __len2, + _M_data() + __pos + __len1, __how_much); + } + _M_rep()->_M_set_length_and_sharable(__new_size); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + reserve(size_type __res) + { + if (__res != this->capacity() || _M_rep()->_M_is_shared()) + { + // Make sure we don't shrink below the current size + if (__res < this->size()) + __res = this->size(); + const allocator_type __a = get_allocator(); + _CharT* __tmp = _M_rep()->_M_clone(__a, __res - this->size()); + _M_rep()->_M_dispose(__a); + _M_data(__tmp); + } + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + swap(basic_string& __s) + _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value) + { + if (_M_rep()->_M_is_leaked()) + _M_rep()->_M_set_sharable(); + if (__s._M_rep()->_M_is_leaked()) + __s._M_rep()->_M_set_sharable(); + if (this->get_allocator() == __s.get_allocator()) + { + _CharT* __tmp = _M_data(); + _M_data(__s._M_data()); + __s._M_data(__tmp); + } + // The code below can usually be optimized away. + else + { + const basic_string __tmp1(_M_ibegin(), _M_iend(), + __s.get_allocator()); + const basic_string __tmp2(__s._M_ibegin(), __s._M_iend(), + this->get_allocator()); + *this = __tmp2; + __s = __tmp1; + } + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::_Rep* + basic_string<_CharT, _Traits, _Alloc>::_Rep:: + _S_create(size_type __capacity, size_type __old_capacity, + const _Alloc& __alloc) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 83. String::npos vs. string::max_size() + if (__capacity > _S_max_size) + __throw_length_error(__N("basic_string::_S_create")); + + // The standard places no restriction on allocating more memory + // than is strictly needed within this layer at the moment or as + // requested by an explicit application call to reserve(). + + // Many malloc implementations perform quite poorly when an + // application attempts to allocate memory in a stepwise fashion + // growing each allocation size by only 1 char. Additionally, + // it makes little sense to allocate less linear memory than the + // natural blocking size of the malloc implementation. + // Unfortunately, we would need a somewhat low-level calculation + // with tuned parameters to get this perfect for any particular + // malloc implementation. Fortunately, generalizations about + // common features seen among implementations seems to suffice. + + // __pagesize need not match the actual VM page size for good + // results in practice, thus we pick a common value on the low + // side. __malloc_header_size is an estimate of the amount of + // overhead per memory allocation (in practice seen N * sizeof + // (void*) where N is 0, 2 or 4). According to folklore, + // picking this value on the high side is better than + // low-balling it (especially when this algorithm is used with + // malloc implementations that allocate memory blocks rounded up + // to a size which is a power of 2). + const size_type __pagesize = 4096; + const size_type __malloc_header_size = 4 * sizeof(void*); + + // 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. + // It's active for allocations requiring an amount of memory above + // system pagesize. This is consistent with the requirements of the + // standard: http://gcc.gnu.org/ml/libstdc++/2001-07/msg00130.html + if (__capacity > __old_capacity && __capacity < 2 * __old_capacity) + __capacity = 2 * __old_capacity; + + // NB: Need an array of char_type[__capacity], plus a terminating + // null char_type() element, plus enough for the _Rep data structure. + // Whew. Seemingly so needy, yet so elemental. + size_type __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep); + + const size_type __adj_size = __size + __malloc_header_size; + if (__adj_size > __pagesize && __capacity > __old_capacity) + { + const size_type __extra = __pagesize - __adj_size % __pagesize; + __capacity += __extra / sizeof(_CharT); + // Never allocate a string bigger than _S_max_size. + if (__capacity > _S_max_size) + __capacity = _S_max_size; + __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep); + } + + // NB: Might throw, but no worries about a leak, mate: _Rep() + // does not throw. + void* __place = _Raw_bytes_alloc(__alloc).allocate(__size); + _Rep *__p = new (__place) _Rep; + __p->_M_capacity = __capacity; + // ABI compatibility - 3.4.x set in _S_create both + // _M_refcount and _M_length. All callers of _S_create + // in basic_string.tcc then set just _M_length. + // In 4.0.x and later both _M_refcount and _M_length + // are initialized in the callers, unfortunately we can + // have 3.4.x compiled code with _S_create callers inlined + // calling 4.0.x+ _S_create. + __p->_M_set_sharable(); + return __p; + } + + template + _CharT* + basic_string<_CharT, _Traits, _Alloc>::_Rep:: + _M_clone(const _Alloc& __alloc, size_type __res) + { + // Requested capacity of the clone. + const size_type __requested_cap = this->_M_length + __res; + _Rep* __r = _Rep::_S_create(__requested_cap, this->_M_capacity, + __alloc); + if (this->_M_length) + _M_copy(__r->_M_refdata(), _M_refdata(), this->_M_length); + + __r->_M_set_length_and_sharable(this->_M_length); + return __r->_M_refdata(); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + resize(size_type __n, _CharT __c) + { + const size_type __size = this->size(); + _M_check_length(__size, __n, "basic_string::resize"); + if (__size < __n) + this->append(__n - __size, __c); + else if (__n < __size) + this->erase(__n); + // else nothing (in particular, avoid calling _M_mutate() unnecessarily.) + } + + template + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1, + _InputIterator __k2, __false_type) + { + const basic_string __s(__k1, __k2); + const size_type __n1 = __i2 - __i1; + _M_check_length(__n1, __s.size(), "basic_string::_M_replace_dispatch"); + return _M_replace_safe(__i1 - _M_ibegin(), __n1, __s._M_data(), + __s.size()); + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, + _CharT __c) + { + _M_check_length(__n1, __n2, "basic_string::_M_replace_aux"); + _M_mutate(__pos1, __n1, __n2); + if (__n2) + _M_assign(_M_data() + __pos1, __n2, __c); + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s, + size_type __n2) + { + _M_mutate(__pos1, __n1, __n2); + if (__n2) + _M_copy(_M_data() + __pos1, __s, __n2); + return *this; + } + + template + typename 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) + _M_copy(__s, _M_data() + __pos, __n); + // 21.3.5.7 par 3: do not append null. (good.) + return __n; + } +#endif // !_GLIBCXX_USE_CXX11_ABI + + template + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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; + } + + // 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 (_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/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.tcc.blob new file mode 100644 index 0000000..a6b908c Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@basic_string.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@char_traits.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@char_traits.h new file mode 100644 index 0000000..c2267fa --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@char_traits.h @@ -0,0 +1,950 @@ +// Character Traits for use by standard string and iostream -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 // std::copy, std::fill_n +#include // For streampos +#include // For WEOF, wmemmove, wmemset, etc. +#if __cplusplus > 201703L +# 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 + + /** + * @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) + { __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; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + if (__s1 > __s2 && __s1 < __s2 + __n) + std::copy_backward(__s2, __s2 + __n, __s1); + else + std::copy(__s2, __s2 + __n, __s1); + return __s1; + } +#endif + return static_cast<_CharT*>(__builtin_memmove(__s1, __s2, + __n * sizeof(char_type))); + } + + template + _GLIBCXX20_CONSTEXPR + typename char_traits<_CharT>::char_type* + char_traits<_CharT>:: + copy(char_type* __s1, const char_type* __s2, std::size_t __n) + { + // NB: Inline std::copy so no recursive dependencies. + std::copy(__s2, __s2 + __n, __s1); + 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) + { + // NB: Inline std::fill_n so no recursive dependencies. + std::fill_n(__s, __n, __a); + return __s; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201703L + +#if __cplusplus == 201703L +// Unofficial macro indicating P0426R1 support +# define __cpp_lib_constexpr_char_traits 201611L +#else +// Also support P1032R1 in C++20 +# define __cpp_lib_constexpr_char_traits 201811L +#endif + + /** + * @brief Determine whether the characters of a NULL-terminated + * string are known at compile time. + * @param __s The string. + * + * Assumes that _CharT is a built-in character type. + */ + template + static _GLIBCXX_ALWAYS_INLINE constexpr bool + __constant_string_p(const _CharT* __s) + { +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + (void) __s; + // In constexpr contexts all strings should be constant. + return __builtin_is_constant_evaluated(); +#else + while (__builtin_constant_p(*__s) && *__s) + __s++; + return __builtin_constant_p(*__s); +#endif + } + + /** + * @brief Determine whether the characters of a character array are + * known at compile time. + * @param __a The character array. + * @param __n Number of characters. + * + * Assumes that _CharT is a built-in character type. + */ + template + static _GLIBCXX_ALWAYS_INLINE constexpr bool + __constant_char_array_p(const _CharT* __a, size_t __n) + { +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + (void) __a; + (void) __n; + // In constexpr contexts all character arrays should be constant. + return __builtin_is_constant_evaluated(); +#else + size_t __i = 0; + while (__i < __n && __builtin_constant_p(__a[__i])) + __i++; + return __i == __n; +#endif + } +#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 + { __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 (__builtin_constant_p(__n) + && __constant_char_array_p(__s1, __n) + && __constant_char_array_p(__s2, __n)) + 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 (__constant_string_p(__s)) + 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 (__builtin_constant_p(__n) + && __builtin_constant_p(__a) + && __constant_char_array_p(__s, __n)) + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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 + { __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 (__builtin_constant_p(__n) + && __constant_char_array_p(__s1, __n) + && __constant_char_array_p(__s2, __n)) + 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 (__constant_string_p(__s)) + 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 (__builtin_constant_p(__n) + && __builtin_constant_p(__a) + && __constant_char_array_p(__s, __n)) + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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; } + }; +#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 + { __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 > 201402 + if (__builtin_constant_p(__n) + && __constant_char_array_p(__s1, __n) + && __constant_char_array_p(__s2, __n)) + 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 > 201402 + if (__constant_string_p(__s)) + 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 > 201402 + if (__builtin_constant_p(__n) + && __builtin_constant_p(__a) + && __constant_char_array_p(__s, __n)) + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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 + { __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; +#ifdef __cpp_lib_is_constant_evaluated + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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 + { __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; +#ifdef __cpp_lib_is_constant_evaluated + 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; +#ifdef __cpp_lib_is_constant_evaluated + 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 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _CHAR_TRAITS_H diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@char_traits.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@char_traits.h.blob new file mode 100644 index 0000000..738fa4c Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@char_traits.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@charconv.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@charconv.h new file mode 100644 index 0000000..a3149bd --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@charconv.h @@ -0,0 +1,106 @@ +// Numeric conversions (to_string, to_chars) -*- C++ -*- + +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@charconv.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@charconv.h.blob new file mode 100644 index 0000000..f7b39c5 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@charconv.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@codecvt.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@codecvt.h new file mode 100644 index 0000000..f6e20f0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@codecvt.h @@ -0,0 +1,840 @@ +// Locale support (codecvt) -*- C++ -*- + +// Copyright (C) 2000-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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* __s, 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* __s, 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@codecvt.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@codecvt.h.blob new file mode 100644 index 0000000..3c294f2 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@codecvt.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@concept_check.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@concept_check.h new file mode 100644 index 0000000..8923a71 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@concept_check.h @@ -0,0 +1,81 @@ +// Concept-checking control -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@concept_check.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@concept_check.h.blob new file mode 100644 index 0000000..c9eae3d Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@concept_check.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cpp_type_traits.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cpp_type_traits.h new file mode 100644 index 0000000..ca83f59 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cpp_type_traits.h @@ -0,0 +1,551 @@ +// The -*- C++ -*- type traits classes for internal use in libstdc++ + +// Copyright (C) 2000-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 _GLIBCXX_USE_WCHAR_T + 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) \ + template<> \ + struct __is_integer \ + { \ + enum { __value = 1 }; \ + typedef __true_type __type; \ + }; \ + 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 _GLIBCXX_USE_WCHAR_T + 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 narrow character types (and std::byte). + template::__value> + 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 + // 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@cpp_type_traits.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cpp_type_traits.h.blob new file mode 100644 index 0000000..1aae0ec Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cpp_type_traits.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_forced.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_forced.h new file mode 100644 index 0000000..9e61a38 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_forced.h @@ -0,0 +1,60 @@ +// cxxabi.h subset for cancellation -*- C++ -*- + +// Copyright (C) 2007-2020 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_forced.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_forced.h.blob new file mode 100644 index 0000000..2b78bfb Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_forced.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_init_exception.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_init_exception.h new file mode 100644 index 0000000..9ea0599 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_init_exception.h @@ -0,0 +1,80 @@ +// ABI Support -*- C++ -*- + +// Copyright (C) 2016-2020 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_init_exception.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_init_exception.h.blob new file mode 100644 index 0000000..4d88f2f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@cxxabi_init_exception.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception.h new file mode 100644 index 0000000..47c6eea --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception.h @@ -0,0 +1,84 @@ +// Exception Handling support header for -*- C++ -*- + +// Copyright (C) 2016-2020 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 + * + * Classes and functions for reporting errors via exception classes. + * @{ + */ + + /** + * @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/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception.h.blob new file mode 100644 index 0000000..b87f54e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_defines.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_defines.h new file mode 100644 index 0000000..70ce9c6 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_defines.h @@ -0,0 +1,45 @@ +// -fno-exceptions Support -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_defines.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_defines.h.blob new file mode 100644 index 0000000..d50fc9e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_defines.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_ptr.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_ptr.h new file mode 100644 index 0000000..fb38a3d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_ptr.h @@ -0,0 +1,224 @@ +// Exception Handling support header (exception_ptr class) for -*- C++ -*- + +// Copyright (C) 2008-2020 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 + +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(0) + { } + + exception_ptr(exception_ptr&& __o) noexcept + : _M_exception_object(__o._M_exception_object) + { __o._M_exception_object = 0; } +#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 + { return _M_exception_object; } +#endif + + friend bool + operator==(const exception_ptr&, const exception_ptr&) + _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); + + const class std::type_info* + __cxa_exception_type() const _GLIBCXX_USE_NOEXCEPT + __attribute__ ((__pure__)); + }; + + /// @relates exception_ptr @{ + + bool + operator==(const exception_ptr&, const exception_ptr&) + _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); + + bool + operator!=(const exception_ptr&, const exception_ptr&) + _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); + + inline void + swap(exception_ptr& __lhs, exception_ptr& __rhs) + { __lhs.swap(__rhs); } + + // @} + + /// @cond undocumented + template + 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. + template + exception_ptr + make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT + { +#if __cpp_exceptions && __cpp_rtti && !_GLIBCXX_HAVE_CDTOR_CALLABI + void* __e = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ex)); + (void) __cxxabiv1::__cxa_init_primary_exception( + __e, const_cast(&typeid(__ex)), + __exception_ptr::__dest_thunk<_Ex>); + try + { + ::new (__e) _Ex(__ex); + return exception_ptr(__e); + } + catch(...) + { + __cxxabiv1::__cxa_free_exception(__e); + return current_exception(); + } +#elif __cpp_exceptions + try + { + throw __ex; + } + catch(...) + { + return current_exception(); + } +#else // no RTTI and no exceptions + return exception_ptr(); +#endif + } + + // @} group exceptions +} // namespace std + +} // extern "C++" + +#pragma GCC visibility pop + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_ptr.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_ptr.h.blob new file mode 100644 index 0000000..3957a0e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@exception_ptr.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@fstream.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@fstream.tcc new file mode 100644 index 0000000..81d00c4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@fstream.tcc @@ -0,0 +1,1102 @@ +// File based streams -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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(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/@@home@ado@git@ssp/@usr@include@c++@10@bits@fstream.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@fstream.tcc.blob new file mode 100644 index 0000000..b944e8b Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@fstream.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@functexcept.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@functexcept.h new file mode 100644 index 0000000..52eef2b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@functexcept.h @@ -0,0 +1,115 @@ +// Function-Based Exception Support -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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__)); + + // 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@functexcept.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@functexcept.h.blob new file mode 100644 index 0000000..f1a201d Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@functexcept.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@functional_hash.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@functional_hash.h new file mode 100644 index 0000000..6ca7915 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@functional_hash.h @@ -0,0 +1,289 @@ +// functional_hash.h header -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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 + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0) + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0 unsigned) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_1 + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1) + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1 unsigned) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_2 + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2) + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2 unsigned) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_3 + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3) + _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/@@home@ado@git@ssp/@usr@include@c++@10@bits@functional_hash.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@functional_hash.h.blob new file mode 100644 index 0000000..5643fe0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@functional_hash.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@hash_bytes.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@hash_bytes.h new file mode 100644 index 0000000..8d9c9eb --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@hash_bytes.h @@ -0,0 +1,59 @@ +// Declarations for hash functions. -*- C++ -*- + +// Copyright (C) 2010-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@hash_bytes.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@hash_bytes.h.blob new file mode 100644 index 0000000..77765e6 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@hash_bytes.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@invoke.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@invoke.h new file mode 100644 index 0000000..18f5b94 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@invoke.h @@ -0,0 +1,163 @@ +// Implementation of INVOKE -*- C++ -*- + +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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/@@home@ado@git@ssp/@usr@include@c++@10@bits@invoke.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@invoke.h.blob new file mode 100644 index 0000000..b606dd3 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@invoke.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ios_base.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ios_base.h new file mode 100644 index 0000000..729ebd1 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ios_base.h @@ -0,0 +1,1109 @@ +// Iostreams base classes -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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_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; + + // 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@ios_base.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ios_base.h.blob new file mode 100644 index 0000000..2b76f75 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ios_base.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@istream.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@istream.tcc new file mode 100644 index 0000000..c82da56 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@istream.tcc @@ -0,0 +1,1100 @@ +// istream classes -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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); + + while (!traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __idelim) + && !traits_type::eq_int_type(__sb.sputc(__c2), __eof)) + { + ++_M_gcount; + __c = __this_sb->snextc(); + __c2 = traits_type::to_char_type(__c); + } + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_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 (__large_ignore) + _M_gcount = __gnu_cxx::__numeric_traits::__max; + + 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 (__large_ignore) + _M_gcount = __gnu_cxx::__numeric_traits::__max; + + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + else if (traits_type::eq_int_type(__c, __delim)) + { + if (_M_gcount + < __gnu_cxx::__numeric_traits::__max) + ++_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 + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef typename _Traits::int_type int_type; + typedef _CharT char_type; + typedef ctype<_CharT> __ctype_type; + + streamsize __extracted = 0; + ios_base::iostate __err = ios_base::goodbit; + typename __istream_type::sentry __cerb(__in, false); + if (__cerb) + { + __try + { + // Figure out how many characters to extract. + streamsize __num = __in.width(); + if (__num <= 0) + __num = __gnu_cxx::__numeric_traits::__max; + + const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); + + const int_type __eof = _Traits::eof(); + __streambuf_type* __sb = __in.rdbuf(); + int_type __c = __sb->sgetc(); + + while (__extracted < __num - 1 + && !_Traits::eq_int_type(__c, __eof) + && !__ct.is(ctype_base::space, + _Traits::to_char_type(__c))) + { + *__s++ = _Traits::to_char_type(__c); + ++__extracted; + __c = __sb->snextc(); + } + if (_Traits::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + + // _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); + return __in; + } + + // 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; + + const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); + const __int_type __eof = _Traits::eof(); + __streambuf_type* __sb = __in.rdbuf(); + __int_type __c = __sb->sgetc(); + + while (!_Traits::eq_int_type(__c, __eof) + && __ct.is(ctype_base::space, _Traits::to_char_type(__c))) + __c = __sb->snextc(); + + if (_Traits::eq_int_type(__c, __eof)) + __in.setstate(ios_base::eofbit); + return __in; + } + + // 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&, char*); + extern template istream& operator>>(istream&, unsigned char&); + extern template istream& operator>>(istream&, signed char&); + extern template istream& operator>>(istream&, unsigned char*); + extern template istream& operator>>(istream&, signed char*); + + extern template istream& istream::_M_extract(unsigned short&); + extern template istream& istream::_M_extract(unsigned int&); + extern template istream& istream::_M_extract(long&); + extern template istream& istream::_M_extract(unsigned long&); + extern template istream& istream::_M_extract(bool&); +#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 wistream& operator>>(wistream&, wchar_t*); + + extern template wistream& wistream::_M_extract(unsigned short&); + extern template wistream& wistream::_M_extract(unsigned int&); + extern template wistream& wistream::_M_extract(long&); + extern template wistream& wistream::_M_extract(unsigned long&); + extern template wistream& wistream::_M_extract(bool&); +#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/@@home@ado@git@ssp/@usr@include@c++@10@bits@istream.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@istream.tcc.blob new file mode 100644 index 0000000..35638f0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@istream.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@iterator_concepts.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@iterator_concepts.h new file mode 100644 index 0000000..e2ad371 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@iterator_concepts.h @@ -0,0 +1,934 @@ +// Concepts and traits for use with iterators -*- C++ -*- + +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/iterator_concepts.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _ITERATOR_CONCEPTS_H +#define _ITERATOR_CONCEPTS_H 1 + +#pragma GCC system_header + +#include +#include // to_address +#include // identity, ranges::less + +#if __cpp_lib_concepts +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + struct input_iterator_tag; + struct output_iterator_tag; + struct forward_iterator_tag; + struct bidirectional_iterator_tag; + struct random_access_iterator_tag; + struct contiguous_iterator_tag; + + template + struct iterator_traits; + + template requires is_object_v<_Tp> + struct iterator_traits<_Tp*>; + + template + struct __iterator_traits; + + namespace __detail + { + template + using __with_ref = _Tp&; + + template + concept __can_reference = requires { typename __with_ref<_Tp>; }; + + template + concept __dereferenceable = requires(_Tp& __t) + { + { *__t } -> __can_reference; + }; + } // namespace __detail + + template<__detail::__dereferenceable _Tp> + using iter_reference_t = decltype(*std::declval<_Tp&>()); + + namespace ranges + { + namespace __cust_imove + { + void iter_move(); + + template + concept __adl_imove + = (std::__detail::__class_or_enum>) + && requires(_Tp&& __t) { iter_move(static_cast<_Tp&&>(__t)); }; + + struct _IMove + { + private: + template + struct __result + { using type = iter_reference_t<_Tp>; }; + + template + requires __adl_imove<_Tp> + struct __result<_Tp> + { using type = decltype(iter_move(std::declval<_Tp>())); }; + + template + requires (!__adl_imove<_Tp>) + && is_lvalue_reference_v> + struct __result<_Tp> + { using type = remove_reference_t>&&; }; + + template + static constexpr bool + _S_noexcept() + { + if constexpr (__adl_imove<_Tp>) + return noexcept(iter_move(std::declval<_Tp>())); + else + return noexcept(*std::declval<_Tp>()); + } + + public: + // The result type of iter_move(std::declval<_Tp>()) + template + using __type = typename __result<_Tp>::type; + + template + constexpr __type<_Tp> + operator()(_Tp&& __e) const + noexcept(_S_noexcept<_Tp>()) + { + if constexpr (__adl_imove<_Tp>) + return iter_move(static_cast<_Tp&&>(__e)); + else if constexpr (is_lvalue_reference_v>) + return static_cast<__type<_Tp>>(*__e); + else + return *__e; + } + }; + } // namespace __cust_imove + + inline namespace __cust + { + inline constexpr __cust_imove::_IMove iter_move{}; + } // inline namespace __cust + } // namespace ranges + + template<__detail::__dereferenceable _Tp> + requires requires(_Tp& __t) + { { ranges::iter_move(__t) } -> __detail::__can_reference; } + using iter_rvalue_reference_t + = decltype(ranges::iter_move(std::declval<_Tp&>())); + + template struct incrementable_traits { }; + + template requires is_object_v<_Tp> + struct incrementable_traits<_Tp*> + { using difference_type = ptrdiff_t; }; + + template + struct incrementable_traits + : incrementable_traits<_Iter> { }; + + template requires requires { typename _Tp::difference_type; } + struct incrementable_traits<_Tp> + { using difference_type = typename _Tp::difference_type; }; + + template + requires (!requires { typename _Tp::difference_type; } + && requires(const _Tp& __a, const _Tp& __b) + { + requires (!is_void_v>); // PR c++/78173 + { __a - __b } -> integral; + }) + struct incrementable_traits<_Tp> + { + using difference_type + = make_signed_t() - std::declval<_Tp>())>; + }; + +#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__ + // __int128 is incrementable even if !integral<__int128> + template<> + struct incrementable_traits<__int128> + { using difference_type = __int128; }; + + template<> + struct incrementable_traits + { using difference_type = __int128; }; +#endif + + namespace __detail + { + // An iterator such that iterator_traits<_Iter> names a specialization + // generated from the primary template. + template + concept __primary_traits_iter + = __is_base_of(__iterator_traits<_Iter, void>, iterator_traits<_Iter>); + + template + struct __iter_traits_impl + { using type = iterator_traits<_Iter>; }; + + template + requires __primary_traits_iter<_Iter> + struct __iter_traits_impl<_Iter, _Tp> + { using type = _Tp; }; + + // ITER_TRAITS + template + using __iter_traits = typename __iter_traits_impl<_Iter, _Tp>::type; + + template + using __iter_diff_t = typename + __iter_traits<_Tp, incrementable_traits<_Tp>>::difference_type; + } // namespace __detail + + template + using iter_difference_t = __detail::__iter_diff_t>; + + namespace __detail + { + template struct __cond_value_type { }; + + template requires is_object_v<_Tp> + struct __cond_value_type<_Tp> + { using value_type = remove_cv_t<_Tp>; }; + } // namespace __detail + + template struct indirectly_readable_traits { }; + + template + struct indirectly_readable_traits<_Tp*> + : __detail::__cond_value_type<_Tp> + { }; + + template requires is_array_v<_Iter> + struct indirectly_readable_traits<_Iter> + { using value_type = remove_cv_t>; }; + + template + struct indirectly_readable_traits + : indirectly_readable_traits<_Iter> + { }; + + template requires requires { typename _Tp::value_type; } + struct indirectly_readable_traits<_Tp> + : __detail::__cond_value_type + { }; + + template requires requires { typename _Tp::element_type; } + struct indirectly_readable_traits<_Tp> + : __detail::__cond_value_type + { }; + + namespace __detail + { + template + using __iter_value_t = typename + __iter_traits<_Tp, indirectly_readable_traits<_Tp>>::value_type; + } // namespace __detail + + template + using iter_value_t = __detail::__iter_value_t>; + + namespace __detail + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3420. cpp17-iterator should check [type] looks like an iterator first + template + concept __cpp17_iterator = requires(_Iter __it) + { + { *__it } -> __can_reference; + { ++__it } -> same_as<_Iter&>; + { *__it++ } -> __can_reference; + } && copyable<_Iter>; + + template + concept __cpp17_input_iterator = __cpp17_iterator<_Iter> + && equality_comparable<_Iter> + && requires(_Iter __it) + { + typename incrementable_traits<_Iter>::difference_type; + typename indirectly_readable_traits<_Iter>::value_type; + typename common_reference_t&&, + typename indirectly_readable_traits<_Iter>::value_type&>; + typename common_reference_t::value_type&>; + requires signed_integral< + typename incrementable_traits<_Iter>::difference_type>; + }; + + template + concept __cpp17_fwd_iterator = __cpp17_input_iterator<_Iter> + && constructible_from<_Iter> + && is_lvalue_reference_v> + && same_as>, + typename indirectly_readable_traits<_Iter>::value_type> + && requires(_Iter __it) + { + { __it++ } -> convertible_to; + { *__it++ } -> same_as>; + }; + + template + concept __cpp17_bidi_iterator = __cpp17_fwd_iterator<_Iter> + && requires(_Iter __it) + { + { --__it } -> same_as<_Iter&>; + { __it-- } -> convertible_to; + { *__it-- } -> same_as>; + }; + + template + concept __cpp17_randacc_iterator = __cpp17_bidi_iterator<_Iter> + && totally_ordered<_Iter> + && requires(_Iter __it, + typename incrementable_traits<_Iter>::difference_type __n) + { + { __it += __n } -> same_as<_Iter&>; + { __it -= __n } -> same_as<_Iter&>; + { __it + __n } -> same_as<_Iter>; + { __n + __it } -> same_as<_Iter>; + { __it - __n } -> same_as<_Iter>; + { __it - __it } -> same_as; + { __it[__n] } -> convertible_to>; + }; + + template + concept __iter_with_nested_types = requires { + typename _Iter::iterator_category; + typename _Iter::value_type; + typename _Iter::difference_type; + typename _Iter::reference; + }; + + template + concept __iter_without_nested_types = !__iter_with_nested_types<_Iter>; + + template + concept __iter_without_category + = !requires { typename _Iter::iterator_category; }; + + } // namespace __detail + + template + requires __detail::__iter_with_nested_types<_Iterator> + struct __iterator_traits<_Iterator, void> + { + private: + template + struct __ptr + { using type = void; }; + + template requires requires { typename _Iter::pointer; } + struct __ptr<_Iter> + { using type = typename _Iter::pointer; }; + + public: + using iterator_category = typename _Iterator::iterator_category; + using value_type = typename _Iterator::value_type; + using difference_type = typename _Iterator::difference_type; + using pointer = typename __ptr<_Iterator>::type; + using reference = typename _Iterator::reference; + }; + + template + requires __detail::__iter_without_nested_types<_Iterator> + && __detail::__cpp17_input_iterator<_Iterator> + struct __iterator_traits<_Iterator, void> + { + private: + template + struct __cat + { using type = input_iterator_tag; }; + + template + requires requires { typename _Iter::iterator_category; } + struct __cat<_Iter> + { using type = typename _Iter::iterator_category; }; + + template + requires __detail::__iter_without_category<_Iter> + && __detail::__cpp17_randacc_iterator<_Iter> + struct __cat<_Iter> + { using type = random_access_iterator_tag; }; + + template + requires __detail::__iter_without_category<_Iter> + && __detail::__cpp17_bidi_iterator<_Iter> + struct __cat<_Iter> + { using type = bidirectional_iterator_tag; }; + + template + requires __detail::__iter_without_category<_Iter> + && __detail::__cpp17_fwd_iterator<_Iter> + struct __cat<_Iter> + { using type = forward_iterator_tag; }; + + template + struct __ptr + { using type = void; }; + + template requires requires { typename _Iter::pointer; } + struct __ptr<_Iter> + { using type = typename _Iter::pointer; }; + + template + requires (!requires { typename _Iter::pointer; } + && requires(_Iter& __it) { __it.operator->(); }) + struct __ptr<_Iter> + { using type = decltype(std::declval<_Iter&>().operator->()); }; + + template + struct __ref + { using type = iter_reference_t<_Iter>; }; + + template requires requires { typename _Iter::reference; } + struct __ref<_Iter> + { using type = typename _Iter::reference; }; + + public: + using iterator_category = typename __cat<_Iterator>::type; + using value_type + = typename indirectly_readable_traits<_Iterator>::value_type; + using difference_type + = typename incrementable_traits<_Iterator>::difference_type; + using pointer = typename __ptr<_Iterator>::type; + using reference = typename __ref<_Iterator>::type; + }; + + template + requires __detail::__iter_without_nested_types<_Iterator> + && __detail::__cpp17_iterator<_Iterator> + struct __iterator_traits<_Iterator, void> + { + private: + template + struct __diff + { using type = void; }; + + template + requires requires + { typename incrementable_traits<_Iter>::difference_type; } + struct __diff<_Iter> + { + using type = typename incrementable_traits<_Iter>::difference_type; + }; + + public: + using iterator_category = output_iterator_tag; + using value_type = void; + using difference_type = typename __diff<_Iterator>::type; + using pointer = void; + using reference = void; + }; + + namespace __detail + { + template + struct __iter_concept_impl; + + // ITER_CONCEPT(I) is ITER_TRAITS(I)::iterator_concept if that is valid. + template + requires requires { typename __iter_traits<_Iter>::iterator_concept; } + struct __iter_concept_impl<_Iter> + { using type = typename __iter_traits<_Iter>::iterator_concept; }; + + // Otherwise, ITER_TRAITS(I)::iterator_category if that is valid. + template + requires (!requires { typename __iter_traits<_Iter>::iterator_concept; } + && requires { typename __iter_traits<_Iter>::iterator_category; }) + struct __iter_concept_impl<_Iter> + { using type = typename __iter_traits<_Iter>::iterator_category; }; + + // Otherwise, random_access_tag if iterator_traits is not specialized. + template + requires (!requires { typename __iter_traits<_Iter>::iterator_concept; } + && !requires { typename __iter_traits<_Iter>::iterator_category; } + && __primary_traits_iter<_Iter>) + struct __iter_concept_impl<_Iter> + { using type = random_access_iterator_tag; }; + + // Otherwise, there is no ITER_CONCEPT(I) type. + template + struct __iter_concept_impl + { }; + + // ITER_CONCEPT + template + using __iter_concept = typename __iter_concept_impl<_Iter>::type; + + template + concept __indirectly_readable_impl = requires(const _In __in) + { + typename iter_value_t<_In>; + typename iter_reference_t<_In>; + typename iter_rvalue_reference_t<_In>; + { *__in } -> same_as>; + { ranges::iter_move(__in) } -> same_as>; + } + && common_reference_with&&, iter_value_t<_In>&> + && common_reference_with&&, + iter_rvalue_reference_t<_In>&&> + && common_reference_with&&, + const iter_value_t<_In>&>; + + } // namespace __detail + + /// Requirements for types that are readable by applying operator*. + template + concept indirectly_readable + = __detail::__indirectly_readable_impl>; + + template + using iter_common_reference_t + = common_reference_t, iter_value_t<_Tp>&>; + + /// Requirements for writing a value into an iterator's referenced object. + template + concept indirectly_writable = requires(_Out&& __o, _Tp&& __t) + { + *__o = std::forward<_Tp>(__t); + *std::forward<_Out>(__o) = std::forward<_Tp>(__t); + const_cast&&>(*__o) + = std::forward<_Tp>(__t); + const_cast&&>(*std::forward<_Out>(__o)) + = std::forward<_Tp>(__t); + }; + + namespace ranges::__detail + { +#if __SIZEOF_INT128__ + using __max_diff_type = __int128; + using __max_size_type = unsigned __int128; +#else + using __max_diff_type = long long; + using __max_size_type = unsigned long long; +#endif + + template + concept __is_integer_like = integral<_Tp> + || same_as<_Tp, __max_diff_type> || same_as<_Tp, __max_size_type>; + + template + concept __is_signed_integer_like = signed_integral<_Tp> + || same_as<_Tp, __max_diff_type>; + + } // namespace ranges::__detail + + namespace __detail { using ranges::__detail::__is_signed_integer_like; } + + /// Requirements on types that can be incremented with ++. + template + concept weakly_incrementable = default_initializable<_Iter> + && movable<_Iter> + && requires(_Iter __i) + { + typename iter_difference_t<_Iter>; + requires __detail::__is_signed_integer_like>; + { ++__i } -> same_as<_Iter&>; + __i++; + }; + + template + concept incrementable = regular<_Iter> && weakly_incrementable<_Iter> + && requires(_Iter __i) { { __i++ } -> same_as<_Iter>; }; + + template + concept input_or_output_iterator + = requires(_Iter __i) { { *__i } -> __detail::__can_reference; } + && weakly_incrementable<_Iter>; + + template + concept sentinel_for = semiregular<_Sent> + && input_or_output_iterator<_Iter> + && __detail::__weakly_eq_cmp_with<_Sent, _Iter>; + + template + inline constexpr bool disable_sized_sentinel_for = false; + + template + concept sized_sentinel_for = sentinel_for<_Sent, _Iter> + && !disable_sized_sentinel_for, remove_cv_t<_Iter>> + && requires(const _Iter& __i, const _Sent& __s) + { + { __s - __i } -> same_as>; + { __i - __s } -> same_as>; + }; + + template + concept input_iterator = input_or_output_iterator<_Iter> + && indirectly_readable<_Iter> + && requires { typename __detail::__iter_concept<_Iter>; } + && derived_from<__detail::__iter_concept<_Iter>, input_iterator_tag>; + + template + concept output_iterator = input_or_output_iterator<_Iter> + && indirectly_writable<_Iter, _Tp> + && requires(_Iter __i, _Tp&& __t) { *__i++ = std::forward<_Tp>(__t); }; + + template + concept forward_iterator = input_iterator<_Iter> + && derived_from<__detail::__iter_concept<_Iter>, forward_iterator_tag> + && incrementable<_Iter> && sentinel_for<_Iter, _Iter>; + + template + concept bidirectional_iterator = forward_iterator<_Iter> + && derived_from<__detail::__iter_concept<_Iter>, + bidirectional_iterator_tag> + && requires(_Iter __i) + { + { --__i } -> same_as<_Iter&>; + { __i-- } -> same_as<_Iter>; + }; + + template + concept random_access_iterator = bidirectional_iterator<_Iter> + && derived_from<__detail::__iter_concept<_Iter>, + random_access_iterator_tag> + && totally_ordered<_Iter> && sized_sentinel_for<_Iter, _Iter> + && requires(_Iter __i, const _Iter __j, + const iter_difference_t<_Iter> __n) + { + { __i += __n } -> same_as<_Iter&>; + { __j + __n } -> same_as<_Iter>; + { __n + __j } -> same_as<_Iter>; + { __i -= __n } -> same_as<_Iter&>; + { __j - __n } -> same_as<_Iter>; + { __j[__n] } -> same_as>; + }; + + template + concept contiguous_iterator = random_access_iterator<_Iter> + && derived_from<__detail::__iter_concept<_Iter>, contiguous_iterator_tag> + && is_lvalue_reference_v> + && same_as, remove_cvref_t>> + && requires(const _Iter& __i) + { + { std::to_address(__i) } + -> same_as>>; + }; + + // [indirectcallable], indirect callable requirements + + // [indirectcallable.indirectinvocable], indirect callables + + template + concept indirectly_unary_invocable = indirectly_readable<_Iter> + && copy_constructible<_Fn> && invocable<_Fn&, iter_value_t<_Iter>&> + && invocable<_Fn&, iter_reference_t<_Iter>> + && invocable<_Fn&, iter_common_reference_t<_Iter>> + && common_reference_with&>, + invoke_result_t<_Fn&, iter_reference_t<_Iter>>>; + + template + concept indirectly_regular_unary_invocable = indirectly_readable<_Iter> + && copy_constructible<_Fn> + && regular_invocable<_Fn&, iter_value_t<_Iter>&> + && regular_invocable<_Fn&, iter_reference_t<_Iter>> + && regular_invocable<_Fn&, iter_common_reference_t<_Iter>> + && common_reference_with&>, + invoke_result_t<_Fn&, iter_reference_t<_Iter>>>; + + template + concept indirect_unary_predicate = indirectly_readable<_Iter> + && copy_constructible<_Fn> && predicate<_Fn&, iter_value_t<_Iter>&> + && predicate<_Fn&, iter_reference_t<_Iter>> + && predicate<_Fn&, iter_common_reference_t<_Iter>>; + + template + concept indirect_binary_predicate + = indirectly_readable<_I1> && indirectly_readable<_I2> + && copy_constructible<_Fn> + && predicate<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&> + && predicate<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>> + && predicate<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&> + && predicate<_Fn&, iter_reference_t<_I1>, iter_reference_t<_I2>> + && predicate<_Fn&, iter_common_reference_t<_I1>, + iter_common_reference_t<_I2>>; + + template + concept indirect_equivalence_relation + = indirectly_readable<_I1> && indirectly_readable<_I2> + && copy_constructible<_Fn> + && equivalence_relation<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&> + && equivalence_relation<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>> + && equivalence_relation<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&> + && equivalence_relation<_Fn&, iter_reference_t<_I1>, + iter_reference_t<_I2>> + && equivalence_relation<_Fn&, iter_common_reference_t<_I1>, + iter_common_reference_t<_I2>>; + + template + concept indirect_strict_weak_order + = indirectly_readable<_I1> && indirectly_readable<_I2> + && copy_constructible<_Fn> + && strict_weak_order<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&> + && strict_weak_order<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>> + && strict_weak_order<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&> + && strict_weak_order<_Fn&, iter_reference_t<_I1>, iter_reference_t<_I2>> + && strict_weak_order<_Fn&, iter_common_reference_t<_I1>, + iter_common_reference_t<_I2>>; + + template + requires (indirectly_readable<_Is> && ...) + && invocable<_Fn, iter_reference_t<_Is>...> + using indirect_result_t = invoke_result_t<_Fn, iter_reference_t<_Is>...>; + + /// [projected], projected + template _Proj> + struct projected + { + using value_type = remove_cvref_t>; + + indirect_result_t<_Proj&, _Iter> operator*() const; // not defined + }; + + template + struct incrementable_traits> + { using difference_type = iter_difference_t<_Iter>; }; + + // [alg.req], common algorithm requirements + + /// [alg.req.ind.move], concept `indirectly_movable` + + template + concept indirectly_movable = indirectly_readable<_In> + && indirectly_writable<_Out, iter_rvalue_reference_t<_In>>; + + template + concept indirectly_movable_storable = indirectly_movable<_In, _Out> + && indirectly_writable<_Out, iter_value_t<_In>> + && movable> + && constructible_from, iter_rvalue_reference_t<_In>> + && assignable_from&, iter_rvalue_reference_t<_In>>; + + /// [alg.req.ind.copy], concept `indirectly_copyable` + template + concept indirectly_copyable = indirectly_readable<_In> + && indirectly_writable<_Out, iter_reference_t<_In>>; + + template + concept indirectly_copyable_storable = indirectly_copyable<_In, _Out> + && indirectly_writable<_Out, iter_value_t<_In>&> + && indirectly_writable<_Out, const iter_value_t<_In>&> + && indirectly_writable<_Out, iter_value_t<_In>&&> + && indirectly_writable<_Out, const iter_value_t<_In>&&> + && copyable> + && constructible_from, iter_reference_t<_In>> + && assignable_from&, iter_reference_t<_In>>; + +namespace ranges +{ + namespace __cust_iswap + { + template + void iter_swap(_It1, _It2) = delete; + + template + concept __adl_iswap + = (std::__detail::__class_or_enum> + || std::__detail::__class_or_enum>) + && requires(_Tp&& __t, _Up&& __u) { + iter_swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); + }; + + template + constexpr iter_value_t<_Xp> + __iter_exchange_move(_Xp&& __x, _Yp&& __y) + noexcept(noexcept(iter_value_t<_Xp>(iter_move(__x))) + && noexcept(*__x = iter_move(__y))) + { + iter_value_t<_Xp> __old_value(iter_move(__x)); + *__x = iter_move(__y); + return __old_value; + } + + struct _IterSwap + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__adl_iswap<_Tp, _Up>) + return noexcept(iter_swap(std::declval<_Tp>(), + std::declval<_Up>())); + else if constexpr (indirectly_readable<_Tp> + && indirectly_readable<_Up> + && swappable_with, iter_reference_t<_Up>>) + return noexcept(ranges::swap(*std::declval<_Tp>(), + *std::declval<_Up>())); + else + return noexcept(*std::declval<_Tp>() + = __iter_exchange_move(std::declval<_Up>(), + std::declval<_Tp>())); + } + + public: + template + requires __adl_iswap<_Tp, _Up> + || (indirectly_readable> + && indirectly_readable> + && swappable_with, iter_reference_t<_Up>>) + || (indirectly_movable_storable<_Tp, _Up> + && indirectly_movable_storable<_Up, _Tp>) + constexpr void + operator()(_Tp&& __e1, _Up&& __e2) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__adl_iswap<_Tp, _Up>) + iter_swap(static_cast<_Tp&&>(__e1), static_cast<_Up&&>(__e2)); + else if constexpr (indirectly_readable<_Tp> + && indirectly_readable<_Up> + && swappable_with, iter_reference_t<_Up>>) + ranges::swap(*__e1, *__e2); + else + *__e1 = __iter_exchange_move(__e2, __e1); + } + }; + } // namespace __cust_iswap + + inline namespace __cust + { + inline constexpr __cust_iswap::_IterSwap iter_swap{}; + } // inline namespace __cust + +} // namespace ranges + + /// [alg.req.ind.swap], concept `indirectly_swappable` + template + concept indirectly_swappable + = indirectly_readable<_I1> && indirectly_readable<_I2> + && requires(const _I1 __i1, const _I2 __i2) + { + ranges::iter_swap(__i1, __i1); + ranges::iter_swap(__i2, __i2); + ranges::iter_swap(__i1, __i2); + ranges::iter_swap(__i2, __i1); + }; + + /// [alg.req.ind.cmp], concept `indirectly_comparable` + template + concept indirectly_comparable + = indirect_binary_predicate<_Rel, projected<_I1, _P1>, + projected<_I2, _P2>>; + + /// [alg.req.permutable], concept `permutable` + template + concept permutable = forward_iterator<_Iter> + && indirectly_movable_storable<_Iter, _Iter> + && indirectly_swappable<_Iter, _Iter>; + + /// [alg.req.mergeable], concept `mergeable` + template + concept mergeable = input_iterator<_I1> && input_iterator<_I2> + && weakly_incrementable<_Out> && indirectly_copyable<_I1, _Out> + && indirectly_copyable<_I2, _Out> + && indirect_strict_weak_order<_Rel, projected<_I1, _P1>, + projected<_I2, _P2>>; + + /// [alg.req.sortable], concept `sortable` + template + concept sortable = permutable<_Iter> + && indirect_strict_weak_order<_Rel, projected<_Iter, _Proj>>; + + struct unreachable_sentinel_t + { + template + friend constexpr bool + operator==(unreachable_sentinel_t, const _It&) noexcept + { return false; } + }; + + inline constexpr unreachable_sentinel_t unreachable_sentinel{}; + + struct default_sentinel_t { }; + inline constexpr default_sentinel_t default_sentinel{}; + + namespace __detail + { + template + constexpr decay_t<_Tp> + __decay_copy(_Tp&& __t) + noexcept(is_nothrow_convertible_v<_Tp, decay_t<_Tp>>) + { return std::forward<_Tp>(__t); } + + template + concept __member_begin = requires(_Tp& __t) + { + { __detail::__decay_copy(__t.begin()) } -> input_or_output_iterator; + }; + + void begin(auto&) = delete; + void begin(const auto&) = delete; + + template + concept __adl_begin = __class_or_enum> + && requires(_Tp& __t) + { + { __detail::__decay_copy(begin(__t)) } -> input_or_output_iterator; + }; + + // Simplified version of std::ranges::begin that only supports lvalues, + // for use by __range_iter_t below. + template + requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&> + auto + __ranges_begin(_Tp& __t) + { + if constexpr (is_array_v<_Tp>) + { + static_assert(sizeof(remove_all_extents_t<_Tp>) != 0, + "not array of incomplete type"); + return __t + 0; + } + else if constexpr (__member_begin<_Tp&>) + return __t.begin(); + else + return begin(__t); + } + + // Implementation of std::ranges::iterator_t, without using ranges::begin. + template + using __range_iter_t + = decltype(__detail::__ranges_begin(std::declval<_Tp&>())); + + } // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 library concepts +#endif // _ITERATOR_CONCEPTS_H diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@iterator_concepts.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@iterator_concepts.h.blob new file mode 100644 index 0000000..33b3f45 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@iterator_concepts.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.h new file mode 100644 index 0000000..ab90682 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.h @@ -0,0 +1,855 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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*); + }; + + + /** + * @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/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.h.blob new file mode 100644 index 0000000..2b6bf3a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.tcc new file mode 100644 index 0000000..49df726 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.tcc @@ -0,0 +1,298 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.tcc.blob new file mode 100644 index 0000000..9eb58c6 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_classes.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_conv.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_conv.h new file mode 100644 index 0000000..4a11e23 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_conv.h @@ -0,0 +1,618 @@ +// wstring_convert implementation -*- C++ -*- + +// Copyright (C) 2015-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#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 + && (__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 == (__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 == (__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 + +#ifdef _GLIBCXX_USE_WCHAR_T + +_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) + { + if (!_M_cvt) + __throw_logic_error("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), _M_state(__state), _M_with_cvtstate(true) + { + if (!_M_cvt) + __throw_logic_error("wstring_convert"); + } + + /** 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) + { + if (!_M_cvt) + __throw_logic_error("wstring_convert"); + } + + ~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: + unique_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), _M_state(__state) + { + if (!_M_cvt) + __throw_logic_error("wbuffer_convert"); + + _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; + unique_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; + }; + +#endif // _GLIBCXX_USE_WCHAR_T + + /// @} group locales + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // __cplusplus + +#endif /* _LOCALE_CONV_H */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_conv.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_conv.h.blob new file mode 100644 index 0000000..34fe6c0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_conv.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.h new file mode 100644 index 0000000..3e0ae87 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.h @@ -0,0 +1,2657 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + + // NB: Don't instantiate required wchar_t facets if no wchar_t support. +#ifdef _GLIBCXX_USE_WCHAR_T +# define _GLIBCXX_NUM_FACETS 28 +# define _GLIBCXX_NUM_CXX11_FACETS 16 +#else +# define _GLIBCXX_NUM_FACETS 14 +# define _GLIBCXX_NUM_CXX11_FACETS 8 +#endif +#ifdef _GLIBCXX_USE_CHAR8_T +# define _GLIBCXX_NUM_UNICODE_FACETS 4 +#else +# define _GLIBCXX_NUM_UNICODE_FACETS 2 +#endif + + // 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; + + /** + * @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__ + 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_COMPAT && defined __LONG_DOUBLE_128__ + 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_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/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.h.blob new file mode 100644 index 0000000..ea87867 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.tcc new file mode 100644 index 0000000..ebc9933 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.tcc @@ -0,0 +1,1377 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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; + } + + // 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; + } + +_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/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.tcc.blob new file mode 100644 index 0000000..26038ac Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.h new file mode 100644 index 0000000..b76eac4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.h @@ -0,0 +1,2017 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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(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 + +_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; + }; + + 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 + 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_COMPAT && defined __LONG_DOUBLE_128__ \ + && _GLIBCXX_USE_CXX11_ABI == 0 + 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 + 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_COMPAT && defined __LONG_DOUBLE_128__ \ + && _GLIBCXX_USE_CXX11_ABI == 0 + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.h.blob new file mode 100644 index 0000000..3782c28 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.tcc new file mode 100644 index 0000000..17b12c9 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.tcc @@ -0,0 +1,1504 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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); + + _M_decimal_point = __mp.decimal_point(); + _M_thousands_sep = __mp.thousands_sep(); + _M_frac_digits = __mp.frac_digits(); + + char* __grouping = 0; + _CharT* __curr_symbol = 0; + _CharT* __positive_sign = 0; + _CharT* __negative_sign = 0; + __try + { + const string& __g = __mp.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>& __cs = __mp.curr_symbol(); + _M_curr_symbol_size = __cs.size(); + __curr_symbol = new _CharT[_M_curr_symbol_size]; + __cs.copy(__curr_symbol, _M_curr_symbol_size); + + const basic_string<_CharT>& __ps = __mp.positive_sign(); + _M_positive_sign_size = __ps.size(); + __positive_sign = new _CharT[_M_positive_sign_size]; + __ps.copy(__positive_sign, _M_positive_sign_size); + + const basic_string<_CharT>& __ns = __mp.negative_sign(); + _M_negative_sign_size = __ns.size(); + __negative_sign = new _CharT[_M_negative_sign_size]; + __ns.copy(__negative_sign, _M_negative_sign_size); + + _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_grouping = __grouping; + _M_curr_symbol = __curr_symbol; + _M_positive_sign = __positive_sign; + _M_negative_sign = __negative_sign; + _M_allocated = true; + } + __catch(...) + { + delete [] __grouping; + delete [] __curr_symbol; + delete [] __positive_sign; + delete [] __negative_sign; + __throw_exception_again; + } + } + +_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 + 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; + } + + 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 + 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); } + +_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 strftime 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) 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': + // Abbreviated weekday name [tm_wday] + const char_type* __days1[7]; + __tp._M_days_abbreviated(__days1); + __beg = _M_extract_name(__beg, __end, __mem, __days1, + 7, __io, __tmperr); + if (!__tmperr) + __tm->tm_wday = __mem; + break; + case 'A': + // Weekday name [tm_wday]. + const char_type* __days2[7]; + __tp._M_days(__days2); + __beg = _M_extract_name(__beg, __end, __mem, __days2, + 7, __io, __tmperr); + if (!__tmperr) + __tm->tm_wday = __mem; + break; + case 'h': + case 'b': + // Abbreviated month name [tm_mon] + const char_type* __months1[12]; + __tp._M_months_abbreviated(__months1); + __beg = _M_extract_name(__beg, __end, __mem, + __months1, 12, __io, __tmperr); + if (!__tmperr) + __tm->tm_mon = __mem; + break; + case 'B': + // Month name [tm_mon]. + const char_type* __months2[12]; + __tp._M_months(__months2); + __beg = _M_extract_name(__beg, __end, __mem, + __months2, 12, __io, __tmperr); + if (!__tmperr) + __tm->tm_mon = __mem; + 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]); + break; + case 'd': + // Day [01, 31]. [tm_mday] + __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2, + __io, __tmperr); + if (!__tmperr) + __tm->tm_mday = __mem; + break; + case 'e': + // Day [1, 31], with single digits preceded by + // space. [tm_mday] + if (__ctype.is(ctype_base::space, *__beg)) + __beg = _M_extract_num(++__beg, __end, __mem, 1, 9, + 1, __io, __tmperr); + else + __beg = _M_extract_num(__beg, __end, __mem, 10, 31, + 2, __io, __tmperr); + if (!__tmperr) + __tm->tm_mday = __mem; + 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); + 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; + 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; + 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; + 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': + if (__ctype.narrow(*__beg, 0) == '\n') + ++__beg; + else + __tmperr |= ios_base::failbit; + 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); + 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': + if (__ctype.narrow(*__beg, 0) == '\t') + ++__beg; + else + __tmperr |= ios_base::failbit; + 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); + 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]); + 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]); + break; + case 'y': + case 'C': // C99 + // Two digit year. + case 'Y': + // Year [1900). + // NB: We parse either two digits, implicitly years since + // 1900, or 4 digits, full year. In both cases we can + // reconstruct [tm_year]. See also libstdc++/26701. + __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4, + __io, __tmperr); + if (!__tmperr) + __tm->tm_year = __mem < 0 ? __mem + 100 : __mem - 1900; + 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; + default: + // Not recognized. + __tmperr |= ios_base::failbit; + } + } + else + { + // Verify format and input match, extract and discard. + if (__format[__i] == *__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_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); + + // As-is works for __len = 1, 2, 4, the values actually used. + int __mult = __len == 2 ? 10 : (__len == 4 ? 1000 : 1); + + ++__min; + 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'); + const int __valuec = __value * __mult; + if (__valuec > __max || __valuec + __mult < __min) + break; + __mult /= 10; + } + else + break; + } + if (__i == __len) + __member = __value; + // Special encoding for do_get_year, 'y', and 'Y' above. + else if (__len == 4 && __i == 2) + __member = __value - 100; + else + __err |= ios_base::failbit; + + return __beg; + } + + // Assumptions: + // All elements in __names are unique. + 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); + + int* __matches = static_cast(__builtin_alloca(sizeof(int) + * __indexlen)); + size_t __nmatches = 0; + size_t __pos = 0; + bool __testvalid = true; + const char_type* __name; + + // Look for initial matches. + // NB: Some of the locale data is in the form of all lowercase + // names, and some is in the form of initially-capitalized + // names. Look for both. + if (__beg != __end) + { + const char_type __c = *__beg; + for (size_t __i1 = 0; __i1 < __indexlen; ++__i1) + if (__c == __names[__i1][0] + || __c == __ctype.toupper(__names[__i1][0])) + __matches[__nmatches++] = __i1; + } + + while (__nmatches > 1) + { + // Find smallest matching string. + size_t __minlen = __traits_type::length(__names[__matches[0]]); + for (size_t __i2 = 1; __i2 < __nmatches; ++__i2) + __minlen = std::min(__minlen, + __traits_type::length(__names[__matches[__i2]])); + ++__beg; + ++__pos; + if (__pos < __minlen && __beg != __end) + for (size_t __i3 = 0; __i3 < __nmatches;) + { + __name = __names[__matches[__i3]]; + if (!(__name[__pos] == *__beg)) + __matches[__i3] = __matches[--__nmatches]; + else + ++__i3; + } + else + break; + } + + if (__nmatches == 1) + { + // Make sure found name is completely extracted. + ++__beg; + ++__pos; + __name = __names[__matches[0]]; + const size_t __len = __traits_type::length(__name); + while (__pos < __len && __beg != __end && __name[__pos] == *__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] >= __indexlen + ? __matches[0] - __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); + __beg = _M_extract_via_format(__beg, __end, __io, __err, + __tm, __times[0]); + 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); + __beg = _M_extract_via_format(__beg, __end, __io, __err, + __tm, __dates[0]); + 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; + + __beg = _M_extract_num(__beg, __end, __tmpyear, 0, 9999, 4, + __io, __tmperr); + if (!__tmperr) + __tm->tm_year = __tmpyear < 0 ? __tmpyear + 100 : __tmpyear - 1900; + 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; + while (__fmt != __fmtend && + __err == ios_base::goodbit) + { + if (__s == __end) + { + __err = ios_base::eofbit | ios_base::failbit; + break; + } + else if (__ctype.narrow(*__fmt, 0) == '%') + { + 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; + } + __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; + } + } + 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(); + } + + __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt); + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.tcc.blob new file mode 100644 index 0000000..ff8fa94 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@locale_facets_nonio.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@localefwd.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@localefwd.h new file mode 100644 index 0000000..8fecc0b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@localefwd.h @@ -0,0 +1,214 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + class 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 + class 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@localefwd.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@localefwd.h.blob new file mode 100644 index 0000000..3b38a20 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@localefwd.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@memoryfwd.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@memoryfwd.h new file mode 100644 index 0000000..af1a1c6 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@memoryfwd.h @@ -0,0 +1,82 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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; + +#if __cplusplus <= 201703L + template<> + class allocator; +#endif + +#if __cplusplus >= 201103L + /// Declare uses_allocator so it can be specialized in \ etc. + template + struct uses_allocator; +#endif + + /// @} group memory + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@memoryfwd.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@memoryfwd.h.blob new file mode 100644 index 0000000..fe6253b Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@memoryfwd.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@move.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@move.h new file mode 100644 index 0000000..5a4dbdc --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@move.h @@ -0,0 +1,224 @@ +// Move, forward and identity for C++11 + swap -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + 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 + constexpr _Tp&& + forward(typename std::remove_reference<_Tp>::type&& __t) noexcept + { + static_assert(!std::is_lvalue_reference<_Tp>::value, "template argument" + " substituting _Tp is an lvalue reference type"); + 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 + 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 + constexpr typename + conditional<__move_if_noexcept_cond<_Tp>::value, const _Tp&, _Tp&&>::type + 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 201603 +#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 + 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_MOVE(__val) std::move(__val) +#define _GLIBCXX_FORWARD(_Tp, __val) std::forward<_Tp>(__val) +#else +#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/@@home@ado@git@ssp/@usr@include@c++@10@bits@move.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@move.h.blob new file mode 100644 index 0000000..0099867 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@move.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@nested_exception.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@nested_exception.h new file mode 100644 index 0000000..1a9c603 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@nested_exception.h @@ -0,0 +1,171 @@ +// Nested Exception support header (nested_exception class) for -*- C++ -*- + +// Copyright (C) 2009-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@nested_exception.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@nested_exception.h.blob new file mode 100644 index 0000000..0997727 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@nested_exception.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream.tcc new file mode 100644 index 0000000..67348c4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream.tcc @@ -0,0 +1,407 @@ +// ostream classes -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + __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) + { + __try + { _M_write(__s, __n); } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_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. + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (this->rdbuf() && this->rdbuf()->pubsync() == -1) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_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() + { + pos_type __ret = pos_type(-1); + __try + { + if (!this->fail()) + __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + return __ret; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + seekp(pos_type __pos) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + 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))) + __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_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + seekp(off_type __off, ios_base::seekdir __dir) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (!this->fail()) + { + // _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))) + __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_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/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream.tcc.blob new file mode 100644 index 0000000..2d1cf26 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream_insert.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream_insert.h new file mode 100644 index 0000000..89011ea --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream_insert.h @@ -0,0 +1,129 @@ +// Helpers for ostream inserters -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream_insert.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream_insert.h.blob new file mode 100644 index 0000000..b81130a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ostream_insert.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@postypes.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@postypes.h new file mode 100644 index 0000000..718ff44 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@postypes.h @@ -0,0 +1,253 @@ +// Position types -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +// XXX If is really needed, make sure to define the macros +// before including it, in order not to break (and +// in C++11). Reconsider all this as soon as possible... +#if (defined(_GLIBCXX_HAVE_INT64_T) && !defined(_GLIBCXX_HAVE_INT64_T_LONG) \ + && !defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)) + +#ifndef __STDC_LIMIT_MACROS +# define _UNDEF__STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS +#endif +#ifndef __STDC_CONSTANT_MACROS +# define _UNDEF__STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS +#endif +#include // For int64_t +#ifdef _UNDEF__STDC_LIMIT_MACROS +# undef __STDC_LIMIT_MACROS +# undef _UNDEF__STDC_LIMIT_MACROS +#endif +#ifdef _UNDEF__STDC_CONSTANT_MACROS +# undef __STDC_CONSTANT_MACROS +# undef _UNDEF__STDC_CONSTANT_MACROS +#endif + +#endif + +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 _GLIBCXX_HAVE_INT64_T_LONG + typedef long streamoff; +#elif defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG) + typedef long long streamoff; +#elif defined(_GLIBCXX_HAVE_INT64_T) + typedef int64_t 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@postypes.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@postypes.h.blob new file mode 100644 index 0000000..acea1eb Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@postypes.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@predefined_ops.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@predefined_ops.h new file mode 100644 index 0000000..7ac9a46 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@predefined_ops.h @@ -0,0 +1,405 @@ +// Default predicates for internal use -*- C++ -*- + +// Copyright (C) 2013-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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/@@home@ado@git@ssp/@usr@include@c++@10@bits@predefined_ops.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@predefined_ops.h.blob new file mode 100644 index 0000000..56df8e9 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@predefined_ops.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ptr_traits.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ptr_traits.h new file mode 100644 index 0000000..541abab --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ptr_traits.h @@ -0,0 +1,215 @@ +// Pointer Traits -*- C++ -*- + +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#define __cpp_lib_constexpr_memory 201811L +namespace __gnu_debug { struct _Safe_iterator_base; } +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + class __undefined; + + // Given Template return T, otherwise invalid. + template + struct __get_first_arg + { using type = __undefined; }; + + template class _Template, typename _Tp, + typename... _Types> + struct __get_first_arg<_Template<_Tp, _Types...>> + { using type = _Tp; }; + + template + using __get_first_arg_t = typename __get_first_arg<_Tp>::type; + + // Given Template and U return Template, otherwise invalid. + template + struct __replace_first_arg + { }; + + template class _Template, typename _Up, + typename _Tp, typename... _Types> + struct __replace_first_arg<_Template<_Tp, _Types...>, _Up> + { using type = _Template<_Up, _Types...>; }; + + template + using __replace_first_arg_t = typename __replace_first_arg<_Tp, _Up>::type; + + template + using __make_not_void + = typename conditional::value, __undefined, _Tp>::type; + + /** + * @brief Uniform interface to all pointer-like types + * @ingroup pointer_abstractions + */ + template + struct pointer_traits + { + private: + template + using __element_type = typename _Tp::element_type; + + template + using __difference_type = typename _Tp::difference_type; + + template + struct __rebind : __replace_first_arg<_Tp, _Up> { }; + + template + struct __rebind<_Tp, _Up, __void_t>> + { using type = typename _Tp::template rebind<_Up>; }; + + public: + /// The pointer type. + using pointer = _Ptr; + + /// The type pointed to. + using element_type + = __detected_or_t<__get_first_arg_t<_Ptr>, __element_type, _Ptr>; + + /// The type used to represent the difference between two pointers. + using difference_type + = __detected_or_t; + + /// A pointer to a different type. + template + using rebind = typename __rebind<_Ptr, _Up>::type; + + static _Ptr + pointer_to(__make_not_void& __e) + { return _Ptr::pointer_to(__e); } + + static_assert(!is_same::value, + "pointer type defines element_type or is like SomePointer"); + }; + + /** + * @brief Partial specialization for built-in pointers. + * @ingroup pointer_abstractions + */ + template + struct pointer_traits<_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; + + template + using rebind = _Up*; + + /** + * @brief Obtain a pointer to an object + * @param __r A reference to an object of type @c element_type + * @return @c addressof(__r) + */ + static _GLIBCXX20_CONSTEXPR pointer + pointer_to(__make_not_void& __r) noexcept + { return std::addressof(__r); } + }; + + /// 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@ptr_traits.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ptr_traits.h.blob new file mode 100644 index 0000000..97c7243 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ptr_traits.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@quoted_string.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@quoted_string.h new file mode 100644 index 0000000..c5bddcf --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@quoted_string.h @@ -0,0 +1,182 @@ +// Helpers for quoted stream manipulators -*- C++ -*- + +// Copyright (C) 2013-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@quoted_string.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@quoted_string.h.blob new file mode 100644 index 0000000..a6c66f7 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@quoted_string.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_access.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_access.h new file mode 100644 index 0000000..3853bbf --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_access.h @@ -0,0 +1,1158 @@ +// -*- C++ -*- + +// Copyright (C) 2010-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#include + +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 + 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 + 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 + 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 + 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 + inline _GLIBCXX14_CONSTEXPR _Tp* + begin(_Tp (&__arr)[_Nm]) + { return __arr; } + + /** + * @brief Return an iterator pointing to one past the last element + * of the array. + * @param __arr Array. + */ + template + inline _GLIBCXX14_CONSTEXPR _Tp* + end(_Tp (&__arr)[_Nm]) + { 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>&); + template const _Tp* begin(const valarray<_Tp>&); + template _Tp* end(valarray<_Tp>&); + template const _Tp* end(const valarray<_Tp>&); + + /** + * @brief Return an iterator pointing to the first element of + * the const container. + * @param __cont Container. + */ + template + inline 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 + inline 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 + 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 + 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 + 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 + 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 + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*> + rbegin(_Tp (&__arr)[_Nm]) + { return reverse_iterator<_Tp*>(__arr + _Nm); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the array. + * @param __arr Array. + */ + template + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*> + rend(_Tp (&__arr)[_Nm]) + { return reverse_iterator<_Tp*>(__arr); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the initializer_list. + * @param __il initializer_list. + */ + template + inline _GLIBCXX17_CONSTEXPR reverse_iterator + rbegin(initializer_list<_Tp> __il) + { 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 + inline _GLIBCXX17_CONSTEXPR reverse_iterator + rend(initializer_list<_Tp> __il) + { return reverse_iterator(__il.begin()); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the const container. + * @param __cont Container. + */ + template + 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 + 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 201411 + + /** + * @brief Return the size of a container. + * @param __cont Container. + */ + template + constexpr auto + size(const _Container& __cont) noexcept(noexcept(__cont.size())) + -> decltype(__cont.size()) + { return __cont.size(); } + + /** + * @brief Return the size of an array. + */ + template + 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 + 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 + 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 + constexpr _Tp* + data(_Tp (&__array)[_Nm]) noexcept + { return __array; } + + /** + * @brief Return the data pointer of an initializer list. + * @param __il Initializer list. + */ + template + constexpr const _Tp* + data(initializer_list<_Tp> __il) noexcept + { return __il.begin(); } + +#endif // C++17 + +#if __cplusplus > 201703L +#define __cpp_lib_ssize 201902L + template + constexpr auto + ssize(const _Container& __cont) + noexcept(noexcept(__cont.size())) + -> common_type_t> + { + using type = make_signed_t; + return static_cast>(__cont.size()); + } + + template + constexpr ptrdiff_t + ssize(const _Tp (&)[_Num]) noexcept + { return _Num; } + +#ifdef __cpp_lib_concepts +namespace ranges +{ + template + inline constexpr bool disable_sized_range = false; + + template + inline constexpr bool enable_borrowed_range = false; + + template + extern const bool enable_view; + + namespace __detail + { + template + constexpr auto + __to_unsigned_like(_Tp __t) noexcept + { return static_cast>(__t); } + +#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__ + constexpr unsigned __int128 + __to_unsigned_like(__int128 __t) noexcept + { return __t; } + + constexpr unsigned __int128 + __to_unsigned_like(unsigned __int128 __t) noexcept + { return __t; } +#endif + + template + using __make_unsigned_like_t + = decltype(__detail::__to_unsigned_like(std::declval<_Tp>())); + + // Part of the constraints of ranges::borrowed_range + template + concept __maybe_borrowed_range + = is_lvalue_reference_v<_Tp> + || enable_borrowed_range>; + + } // namespace __detail + + namespace __cust_access + { + using std::ranges::__detail::__maybe_borrowed_range; + using std::__detail::__class_or_enum; + using std::__detail::__decay_copy; + using std::__detail::__member_begin; + using std::__detail::__adl_begin; + + struct _Begin + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (is_array_v>) + return true; + else if constexpr (__member_begin<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp&>().begin())); + else + return noexcept(__decay_copy(begin(std::declval<_Tp&>()))); + } + + public: + template<__maybe_borrowed_range _Tp> + requires is_array_v> || __member_begin<_Tp> + || __adl_begin<_Tp> + constexpr auto + operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp>()) + { + if constexpr (is_array_v>) + { + static_assert(is_lvalue_reference_v<_Tp>); + using _Up = remove_all_extents_t>; + static_assert(sizeof(_Up) != 0, "not array of incomplete type"); + return __t + 0; + } + else if constexpr (__member_begin<_Tp>) + return __t.begin(); + else + return begin(__t); + } + }; + + template + concept __member_end = requires(_Tp& __t) + { + { __decay_copy(__t.end()) } + -> sentinel_for(__t)))>; + }; + + void end(auto&) = delete; + void end(const auto&) = delete; + + template + concept __adl_end = __class_or_enum> + && requires(_Tp& __t) + { + { __decay_copy(end(__t)) } + -> sentinel_for(__t)))>; + }; + + struct _End + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (is_bounded_array_v>) + return true; + else if constexpr (__member_end<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp&>().end())); + else + return noexcept(__decay_copy(end(std::declval<_Tp&>()))); + } + + public: + template<__maybe_borrowed_range _Tp> + requires is_bounded_array_v> || __member_end<_Tp> + || __adl_end<_Tp> + constexpr auto + operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp>()) + { + if constexpr (is_bounded_array_v>) + { + static_assert(is_lvalue_reference_v<_Tp>); + return __t + extent_v>; + } + else if constexpr (__member_end<_Tp>) + return __t.end(); + else + return end(__t); + } + }; + + template + constexpr decltype(auto) + __as_const(_Tp&& __t) noexcept + { + if constexpr (is_lvalue_reference_v<_Tp>) + return static_cast&>(__t); + else + return static_cast(__t); + } + + struct _CBegin + { + template + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_Begin{}(__cust_access::__as_const((_Tp&&)__e)))) + requires requires { _Begin{}(__cust_access::__as_const((_Tp&&)__e)); } + { + return _Begin{}(__cust_access::__as_const(std::forward<_Tp>(__e))); + } + }; + + struct _CEnd + { + template + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_End{}(__cust_access::__as_const((_Tp&&)__e)))) + requires requires { _End{}(__cust_access::__as_const((_Tp&&)__e)); } + { + return _End{}(__cust_access::__as_const(std::forward<_Tp>(__e))); + } + }; + + template + concept __member_rbegin = requires(_Tp& __t) + { + { __decay_copy(__t.rbegin()) } -> input_or_output_iterator; + }; + + void rbegin(auto&) = delete; + void rbegin(const auto&) = delete; + + template + concept __adl_rbegin = __class_or_enum> + && requires(_Tp& __t) + { + { __decay_copy(rbegin(__t)) } -> input_or_output_iterator; + }; + + template + concept __reversable = requires(_Tp& __t) + { + { _Begin{}(__t) } -> bidirectional_iterator; + { _End{}(__t) } -> same_as; + }; + + struct _RBegin + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__member_rbegin<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp&>().rbegin())); + else if constexpr (__adl_rbegin<_Tp>) + return noexcept(__decay_copy(rbegin(std::declval<_Tp&>()))); + else + { + if constexpr (noexcept(_End{}(std::declval<_Tp&>()))) + { + using _It = decltype(_End{}(std::declval<_Tp&>())); + // std::reverse_iterator copy-initializes its member. + return is_nothrow_copy_constructible_v<_It>; + } + else + return false; + } + } + + public: + template<__maybe_borrowed_range _Tp> + requires __member_rbegin<_Tp> || __adl_rbegin<_Tp> || __reversable<_Tp> + constexpr auto + operator()(_Tp&& __t) const + noexcept(_S_noexcept<_Tp>()) + { + if constexpr (__member_rbegin<_Tp>) + return __t.rbegin(); + else if constexpr (__adl_rbegin<_Tp>) + return rbegin(__t); + else + return std::make_reverse_iterator(_End{}(__t)); + } + }; + + template + concept __member_rend = requires(_Tp& __t) + { + { __decay_copy(__t.rend()) } + -> sentinel_for; + }; + + void rend(auto&) = delete; + void rend(const auto&) = delete; + + template + concept __adl_rend = __class_or_enum> + && requires(_Tp& __t) + { + { __decay_copy(rend(__t)) } + -> sentinel_for(__t)))>; + }; + + struct _REnd + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__member_rend<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp&>().rend())); + else if constexpr (__adl_rend<_Tp>) + return noexcept(__decay_copy(rend(std::declval<_Tp&>()))); + else + { + if constexpr (noexcept(_Begin{}(std::declval<_Tp&>()))) + { + using _It = decltype(_Begin{}(std::declval<_Tp&>())); + // std::reverse_iterator copy-initializes its member. + return is_nothrow_copy_constructible_v<_It>; + } + else + return false; + } + } + + public: + template<__maybe_borrowed_range _Tp> + requires __member_rend<_Tp> || __adl_rend<_Tp> || __reversable<_Tp> + constexpr auto + operator()(_Tp&& __t) const + noexcept(_S_noexcept<_Tp>()) + { + if constexpr (__member_rend<_Tp>) + return __t.rend(); + else if constexpr (__adl_rend<_Tp>) + return rend(__t); + else + return std::make_reverse_iterator(_Begin{}(__t)); + } + }; + + struct _CRBegin + { + template + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_RBegin{}(__cust_access::__as_const((_Tp&&)__e)))) + requires requires { _RBegin{}(__cust_access::__as_const((_Tp&&)__e)); } + { + return _RBegin{}(__cust_access::__as_const(std::forward<_Tp>(__e))); + } + }; + + struct _CREnd + { + template + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_REnd{}(__cust_access::__as_const((_Tp&&)__e)))) + requires requires { _REnd{}(__cust_access::__as_const((_Tp&&)__e)); } + { + return _REnd{}(__cust_access::__as_const(std::forward<_Tp>(__e))); + } + }; + + template + concept __member_size = !disable_sized_range> + && requires(_Tp&& __t) + { + { __decay_copy(std::forward<_Tp>(__t).size()) } + -> __detail::__is_integer_like; + }; + + void size(auto&) = delete; + void size(const auto&) = delete; + + template + concept __adl_size = __class_or_enum> + && !disable_sized_range> + && requires(_Tp&& __t) + { + { __decay_copy(size(std::forward<_Tp>(__t))) } + -> __detail::__is_integer_like; + }; + + template + concept __sentinel_size = requires(_Tp&& __t) + { + { _Begin{}(std::forward<_Tp>(__t)) } -> forward_iterator; + + { _End{}(std::forward<_Tp>(__t)) } + -> sized_sentinel_for(__t)))>; + }; + + struct _Size + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (is_bounded_array_v>) + return true; + else if constexpr (__member_size<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp>().size())); + else if constexpr (__adl_size<_Tp>) + return noexcept(__decay_copy(size(std::declval<_Tp>()))); + else if constexpr (__sentinel_size<_Tp>) + return noexcept(_End{}(std::declval<_Tp>()) + - _Begin{}(std::declval<_Tp>())); + } + + public: + template + requires is_bounded_array_v> + || __member_size<_Tp> || __adl_size<_Tp> || __sentinel_size<_Tp> + constexpr auto + operator()(_Tp&& __e) const noexcept(_S_noexcept<_Tp>()) + { + if constexpr (is_bounded_array_v>) + { + return extent_v>; + } + else if constexpr (__member_size<_Tp>) + return std::forward<_Tp>(__e).size(); + else if constexpr (__adl_size<_Tp>) + return size(std::forward<_Tp>(__e)); + else if constexpr (__sentinel_size<_Tp>) + return __detail::__to_unsigned_like( + _End{}(std::forward<_Tp>(__e)) + - _Begin{}(std::forward<_Tp>(__e))); + } + }; + + struct _SSize + { + template + requires requires (_Tp&& __e) + { + _Begin{}(std::forward<_Tp>(__e)); + _Size{}(std::forward<_Tp>(__e)); + } + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_Size{}(std::forward<_Tp>(__e)))) + { + using __iter_type = decltype(_Begin{}(std::forward<_Tp>(__e))); + using __diff_type = iter_difference_t<__iter_type>; + using __gnu_cxx::__int_traits; + auto __size = _Size{}(std::forward<_Tp>(__e)); + if constexpr (integral<__diff_type>) + { + if constexpr (__int_traits<__diff_type>::__digits + < __int_traits::__digits) + return static_cast(__size); + } + return static_cast<__diff_type>(__size); + } + }; + + template + concept __member_empty = requires(_Tp&& __t) + { bool(std::forward<_Tp>(__t).empty()); }; + + template + concept __size0_empty = requires(_Tp&& __t) + { _Size{}(std::forward<_Tp>(__t)) == 0; }; + + template + concept __eq_iter_empty = requires(_Tp&& __t) + { + { _Begin{}(std::forward<_Tp>(__t)) } -> forward_iterator; + bool(_Begin{}(std::forward<_Tp>(__t)) + == _End{}(std::forward<_Tp>(__t))); + }; + + struct _Empty + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__member_empty<_Tp>) + return noexcept(std::declval<_Tp>().empty()); + else if constexpr (__size0_empty<_Tp>) + return noexcept(_Size{}(std::declval<_Tp>()) == 0); + else + return noexcept(bool(_Begin{}(std::declval<_Tp>()) + == _End{}(std::declval<_Tp>()))); + } + + public: + template + requires __member_empty<_Tp> || __size0_empty<_Tp> + || __eq_iter_empty<_Tp> + constexpr bool + operator()(_Tp&& __e) const noexcept(_S_noexcept<_Tp>()) + { + if constexpr (__member_empty<_Tp>) + return bool(std::forward<_Tp>(__e).empty()); + else if constexpr (__size0_empty<_Tp>) + return _Size{}(std::forward<_Tp>(__e)) == 0; + else + return bool(_Begin{}(std::forward<_Tp>(__e)) + == _End{}(std::forward<_Tp>(__e))); + } + }; + + template + concept __pointer_to_object = is_pointer_v<_Tp> + && is_object_v>; + + template + concept __member_data = is_lvalue_reference_v<_Tp> + && requires(_Tp __t) { { __t.data() } -> __pointer_to_object; }; + + template + concept __begin_data = requires(_Tp&& __t) + { { _Begin{}(std::forward<_Tp>(__t)) } -> contiguous_iterator; }; + + struct _Data + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__member_data<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp>().data())); + else + return noexcept(_Begin{}(std::declval<_Tp>())); + } + + public: + template<__maybe_borrowed_range _Tp> + requires __member_data<_Tp> || __begin_data<_Tp> + constexpr auto + operator()(_Tp&& __e) const noexcept(_S_noexcept<_Tp>()) + { + if constexpr (__member_data<_Tp>) + return __e.data(); + else + return std::to_address(_Begin{}(std::forward<_Tp>(__e))); + } + }; + + struct _CData + { + template + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_Data{}(__cust_access::__as_const((_Tp&&)__e)))) + requires requires { _Data{}(__cust_access::__as_const((_Tp&&)__e)); } + { + return _Data{}(__cust_access::__as_const(std::forward<_Tp>(__e))); + } + }; + + } // namespace __cust_access + + inline namespace __cust + { + inline constexpr __cust_access::_Begin begin{}; + inline constexpr __cust_access::_End end{}; + inline constexpr __cust_access::_CBegin cbegin{}; + inline constexpr __cust_access::_CEnd cend{}; + inline constexpr __cust_access::_RBegin rbegin{}; + inline constexpr __cust_access::_REnd rend{}; + inline constexpr __cust_access::_CRBegin crbegin{}; + inline constexpr __cust_access::_CREnd crend{}; + inline constexpr __cust_access::_Size size{}; + inline constexpr __cust_access::_SSize ssize{}; + inline constexpr __cust_access::_Empty empty{}; + inline constexpr __cust_access::_Data data{}; + inline constexpr __cust_access::_CData cdata{}; + } + + /// [range.range] The range concept. + template + concept range = requires(_Tp& __t) + { + ranges::begin(__t); + ranges::end(__t); + }; + + /// [range.range] The borrowed_range concept. + template + concept borrowed_range + = range<_Tp> && __detail::__maybe_borrowed_range<_Tp>; + + template + using iterator_t = std::__detail::__range_iter_t<_Tp>; + + template + using sentinel_t = decltype(ranges::end(std::declval<_Range&>())); + + template + using range_difference_t = iter_difference_t>; + + template + using range_value_t = iter_value_t>; + + template + using range_reference_t = iter_reference_t>; + + template + using range_rvalue_reference_t + = iter_rvalue_reference_t>; + + /// [range.sized] The sized_range concept. + template + concept sized_range = range<_Tp> + && requires(_Tp& __t) { ranges::size(__t); }; + + template + using range_size_t = decltype(ranges::size(std::declval<_Range&>())); + + // [range.refinements] + + /// A range for which ranges::begin returns an output iterator. + template + concept output_range + = range<_Range> && output_iterator, _Tp>; + + /// A range for which ranges::begin returns an input iterator. + template + concept input_range = range<_Tp> && input_iterator>; + + /// A range for which ranges::begin returns a forward iterator. + template + concept forward_range + = input_range<_Tp> && forward_iterator>; + + /// A range for which ranges::begin returns a bidirectional iterator. + template + concept bidirectional_range + = forward_range<_Tp> && bidirectional_iterator>; + + /// A range for which ranges::begin returns a random access iterator. + template + concept random_access_range + = bidirectional_range<_Tp> && random_access_iterator>; + + /// A range for which ranges::begin returns a contiguous iterator. + template + concept contiguous_range + = random_access_range<_Tp> && contiguous_iterator> + && requires(_Tp& __t) + { + { ranges::data(__t) } -> same_as>>; + }; + + /// A range for which ranges::begin and ranges::end return the same type. + template + concept common_range + = range<_Tp> && same_as, sentinel_t<_Tp>>; + + // [range.iter.ops] range iterator operations + + template + constexpr void + advance(_It& __it, iter_difference_t<_It> __n) + { + if constexpr (random_access_iterator<_It>) + __it += __n; + else if constexpr (bidirectional_iterator<_It>) + { + if (__n > 0) + { + do + { + ++__it; + } + while (--__n); + } + else if (__n < 0) + { + do + { + --__it; + } + while (++__n); + } + } + else + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated() && __n < 0) + throw "attempt to decrement a non-bidirectional iterator"; +#endif + __glibcxx_assert(__n >= 0); + while (__n-- > 0) + ++__it; + } + } + + template _Sent> + constexpr void + advance(_It& __it, _Sent __bound) + { + if constexpr (assignable_from<_It&, _Sent>) + __it = std::move(__bound); + else if constexpr (sized_sentinel_for<_Sent, _It>) + ranges::advance(__it, __bound - __it); + else + { + while (__it != __bound) + ++__it; + } + } + + template _Sent> + constexpr iter_difference_t<_It> + advance(_It& __it, iter_difference_t<_It> __n, _Sent __bound) + { + if constexpr (sized_sentinel_for<_Sent, _It>) + { + const auto __diff = __bound - __it; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated() + && !(__n == 0 || __diff == 0 || (__n < 0 == __diff < 0))) + throw "inconsistent directions for distance and bound"; +#endif + // n and bound must not lead in opposite directions: + __glibcxx_assert(__n == 0 || __diff == 0 || (__n < 0 == __diff < 0)); + const auto __absdiff = __diff < 0 ? -__diff : __diff; + const auto __absn = __n < 0 ? -__n : __n;; + if (__absn >= __absdiff) + { + ranges::advance(__it, __bound); + return __n - __diff; + } + else + { + ranges::advance(__it, __n); + return 0; + } + } + else if (__it == __bound || __n == 0) + return iter_difference_t<_It>(0); + else if (__n > 0) + { + iter_difference_t<_It> __m = 0; + do + { + ++__it; + ++__m; + } + while (__m != __n && __it != __bound); + return __n - __m; + } + else if constexpr (bidirectional_iterator<_It> && same_as<_It, _Sent>) + { + iter_difference_t<_It> __m = 0; + do + { + --__it; + --__m; + } + while (__m != __n && __it != __bound); + return __n - __m; + } + else + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated() && __n < 0) + throw "attempt to decrement a non-bidirectional iterator"; +#endif + __glibcxx_assert(__n >= 0); + return __n; + } + } + + template _Sent> + constexpr iter_difference_t<_It> + distance(_It __first, _Sent __last) + { + if constexpr (sized_sentinel_for<_Sent, _It>) + return __last - __first; + else + { + iter_difference_t<_It> __n = 0; + while (__first != __last) + { + ++__first; + ++__n; + } + return __n; + } + } + + template + constexpr range_difference_t<_Range> + distance(_Range&& __r) + { + if constexpr (sized_range<_Range>) + return static_cast>(ranges::size(__r)); + else + return ranges::distance(ranges::begin(__r), ranges::end(__r)); + } + + template + constexpr _It + next(_It __x) + { + ++__x; + return __x; + } + + template + constexpr _It + next(_It __x, iter_difference_t<_It> __n) + { + ranges::advance(__x, __n); + return __x; + } + + template _Sent> + constexpr _It + next(_It __x, _Sent __bound) + { + ranges::advance(__x, __bound); + return __x; + } + + template _Sent> + constexpr _It + next(_It __x, iter_difference_t<_It> __n, _Sent __bound) + { + ranges::advance(__x, __n, __bound); + return __x; + } + + template + constexpr _It + prev(_It __x) + { + --__x; + return __x; + } + + template + constexpr _It + prev(_It __x, iter_difference_t<_It> __n) + { + ranges::advance(__x, -__n); + return __x; + } + + template + constexpr _It + prev(_It __x, iter_difference_t<_It> __n, _It __bound) + { + ranges::advance(__x, -__n, __bound); + return __x; + } + +} // namespace ranges +#endif // library concepts +#endif // C++20 +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _GLIBCXX_RANGE_ACCESS_H diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_access.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_access.h.blob new file mode 100644 index 0000000..a74caeb Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_access.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_cmp.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_cmp.h new file mode 100644 index 0000000..0587c59 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_cmp.h @@ -0,0 +1,195 @@ +// Concept-constrained comparison implementations -*- C++ -*- + +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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_cmp.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _RANGE_CMP_H +#define _RANGE_CMP_H 1 + +#if __cplusplus > 201703L +# include +# include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + struct __is_transparent; // not defined + + // Define std::identity here so that and + // don't need to include to get it. + + /// [func.identity] The identity function. + struct identity + { + template + constexpr _Tp&& + operator()(_Tp&& __t) const noexcept + { return std::forward<_Tp>(__t); } + + using is_transparent = __is_transparent; + }; + +#ifdef __cpp_lib_concepts +// Define this here, included by all the headers that need to define it. +#define __cpp_lib_ranges 201911L + +namespace ranges +{ + namespace __detail + { + // BUILTIN-PTR-CMP(T, ==, U) + template + concept __eq_builtin_ptr_cmp + = requires (_Tp&& __t, _Up&& __u) { { __t == __u } -> same_as; } + && convertible_to<_Tp, const volatile void*> + && convertible_to<_Up, const volatile void*> + && (! requires(_Tp&& __t, _Up&& __u) + { operator==(std::forward<_Tp>(__t), std::forward<_Up>(__u)); } + && + ! requires(_Tp&& __t, _Up&& __u) + { std::forward<_Tp>(__t).operator==(std::forward<_Up>(__u)); }); + + // BUILTIN-PTR-CMP(T, <, U) + template + concept __less_builtin_ptr_cmp + = requires (_Tp&& __t, _Up&& __u) { { __t < __u } -> same_as; } + && convertible_to<_Tp, const volatile void*> + && convertible_to<_Up, const volatile void*> + && (! requires(_Tp&& __t, _Up&& __u) + { operator<(std::forward<_Tp>(__t), std::forward<_Up>(__u)); } + && ! requires(_Tp&& __t, _Up&& __u) + { std::forward<_Tp>(__t).operator<(std::forward<_Up>(__u)); }); + } // namespace __detail + + // [range.cmp] Concept-constrained comparisons + + /// ranges::equal_to function object type. + struct equal_to + { + template + requires equality_comparable_with<_Tp, _Up> + || __detail::__eq_builtin_ptr_cmp<_Tp, _Up> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Tp>() == std::declval<_Up>())) + { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); } + + using is_transparent = __is_transparent; + }; + + /// ranges::not_equal_to function object type. + struct not_equal_to + { + template + requires equality_comparable_with<_Tp, _Up> + || __detail::__eq_builtin_ptr_cmp<_Tp, _Up> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Up>() == std::declval<_Tp>())) + { return !equal_to{}(std::forward<_Tp>(__t), std::forward<_Up>(__u)); } + + using is_transparent = __is_transparent; + }; + + /// ranges::less function object type. + struct less + { + template + requires totally_ordered_with<_Tp, _Up> + || __detail::__less_builtin_ptr_cmp<_Tp, _Up> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>())) + { + if constexpr (__detail::__less_builtin_ptr_cmp<_Tp, _Up>) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __t < __u; +#endif + auto __x = reinterpret_cast<__UINTPTR_TYPE__>( + static_cast(std::forward<_Tp>(__t))); + auto __y = reinterpret_cast<__UINTPTR_TYPE__>( + static_cast(std::forward<_Up>(__u))); + return __x < __y; + } + else + return std::forward<_Tp>(__t) < std::forward<_Up>(__u); + } + + using is_transparent = __is_transparent; + }; + + /// ranges::greater function object type. + struct greater + { + template + requires totally_ordered_with<_Tp, _Up> + || __detail::__less_builtin_ptr_cmp<_Up, _Tp> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Up>() < std::declval<_Tp>())) + { return less{}(std::forward<_Up>(__u), std::forward<_Tp>(__t)); } + + using is_transparent = __is_transparent; + }; + + /// ranges::greater_equal function object type. + struct greater_equal + { + template + requires totally_ordered_with<_Tp, _Up> + || __detail::__less_builtin_ptr_cmp<_Tp, _Up> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>())) + { return !less{}(std::forward<_Tp>(__t), std::forward<_Up>(__u)); } + + using is_transparent = __is_transparent; + }; + + /// ranges::less_equal function object type. + struct less_equal + { + template + requires totally_ordered_with<_Tp, _Up> + || __detail::__less_builtin_ptr_cmp<_Up, _Tp> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Up>() < std::declval<_Tp>())) + { return !less{}(std::forward<_Up>(__u), std::forward<_Tp>(__t)); } + + using is_transparent = __is_transparent; + }; + +} // namespace ranges +#endif // library concepts +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 +#endif // _RANGE_CMP_H diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_cmp.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_cmp.h.blob new file mode 100644 index 0000000..5958ca5 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@range_cmp.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ranges_uninitialized.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ranges_uninitialized.h new file mode 100644 index 0000000..25e664d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ranges_uninitialized.h @@ -0,0 +1,574 @@ +// Raw memory manipulators -*- C++ -*- + +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/ranges_uninitialized.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _RANGES_UNINITIALIZED_H +#define _RANGES_UNINITIALIZED_H 1 + +#if __cplusplus > 201703L +#if __cpp_lib_concepts + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +namespace ranges +{ + namespace __detail + { + template + constexpr void* + __voidify(_Tp& __obj) noexcept + { + return const_cast + (static_cast(std::__addressof(__obj))); + } + + template + concept __nothrow_input_iterator + = (input_iterator<_Iter> + && is_lvalue_reference_v> + && same_as>, + iter_value_t<_Iter>>); + + template + concept __nothrow_sentinel = sentinel_for<_Sent, _Iter>; + + template + concept __nothrow_input_range + = (range<_Range> + && __nothrow_input_iterator> + && __nothrow_sentinel, iterator_t<_Range>>); + + template + concept __nothrow_forward_iterator + = (__nothrow_input_iterator<_Iter> + && forward_iterator<_Iter> + && __nothrow_sentinel<_Iter, _Iter>); + + template + concept __nothrow_forward_range + = (__nothrow_input_range<_Range> + && __nothrow_forward_iterator>); + } // namespace __detail + + struct __destroy_fn + { + template<__detail::__nothrow_input_iterator _Iter, + __detail::__nothrow_sentinel<_Iter> _Sent> + requires destructible> + constexpr _Iter + operator()(_Iter __first, _Sent __last) const noexcept; + + template<__detail::__nothrow_input_range _Range> + requires destructible> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r) const noexcept; + }; + + inline constexpr __destroy_fn destroy{}; + + namespace __detail + { + template + requires destructible> + struct _DestroyGuard + { + private: + _Iter _M_first; + const _Iter* _M_cur; + + public: + explicit + _DestroyGuard(const _Iter* __iter) + : _M_first(*__iter), _M_cur(__iter) + { } + + void + release() noexcept + { _M_cur = nullptr; } + + ~_DestroyGuard() + { + if (_M_cur != nullptr) + ranges::destroy(std::move(_M_first), *_M_cur); + } + }; + + template + requires destructible> + && is_trivially_destructible_v> + struct _DestroyGuard<_Iter> + { + explicit + _DestroyGuard(const _Iter*) + { } + + void + release() noexcept + { } + }; + } // namespace __detail + + struct __uninitialized_default_construct_fn + { + template<__detail::__nothrow_forward_iterator _Iter, + __detail::__nothrow_sentinel<_Iter> _Sent> + requires default_initializable> + _Iter + operator()(_Iter __first, _Sent __last) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivially_default_constructible_v<_ValueType>) + return ranges::next(__first, __last); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __first != __last; ++__first) + ::new (__detail::__voidify(*__first)) _ValueType; + __guard.release(); + return __first; + } + } + + template<__detail::__nothrow_forward_range _Range> + requires default_initializable> + borrowed_iterator_t<_Range> + operator()(_Range&& __r) const + { + return (*this)(ranges::begin(__r), ranges::end(__r)); + } + }; + + inline constexpr __uninitialized_default_construct_fn + uninitialized_default_construct{}; + + struct __uninitialized_default_construct_n_fn + { + template<__detail::__nothrow_forward_iterator _Iter> + requires default_initializable> + _Iter + operator()(_Iter __first, iter_difference_t<_Iter> __n) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivially_default_constructible_v<_ValueType>) + return ranges::next(__first, __n); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __n > 0; ++__first, (void) --__n) + ::new (__detail::__voidify(*__first)) _ValueType; + __guard.release(); + return __first; + } + } + }; + + inline constexpr __uninitialized_default_construct_n_fn + uninitialized_default_construct_n; + + struct __uninitialized_value_construct_fn + { + template<__detail::__nothrow_forward_iterator _Iter, + __detail::__nothrow_sentinel<_Iter> _Sent> + requires default_initializable> + _Iter + operator()(_Iter __first, _Sent __last) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivial_v<_ValueType> + && is_copy_assignable_v<_ValueType>) + return ranges::fill(__first, __last, _ValueType()); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __first != __last; ++__first) + ::new (__detail::__voidify(*__first)) _ValueType(); + __guard.release(); + return __first; + } + } + + template<__detail::__nothrow_forward_range _Range> + requires default_initializable> + borrowed_iterator_t<_Range> + operator()(_Range&& __r) const + { + return (*this)(ranges::begin(__r), ranges::end(__r)); + } + }; + + inline constexpr __uninitialized_value_construct_fn + uninitialized_value_construct{}; + + struct __uninitialized_value_construct_n_fn + { + template<__detail::__nothrow_forward_iterator _Iter> + requires default_initializable> + _Iter + operator()(_Iter __first, iter_difference_t<_Iter> __n) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivial_v<_ValueType> + && is_copy_assignable_v<_ValueType>) + return ranges::fill_n(__first, __n, _ValueType()); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __n > 0; ++__first, (void) --__n) + ::new (__detail::__voidify(*__first)) _ValueType(); + __guard.release(); + return __first; + } + } + }; + + inline constexpr __uninitialized_value_construct_n_fn + uninitialized_value_construct_n; + + template + using uninitialized_copy_result = in_out_result<_Iter, _Out>; + + struct __uninitialized_copy_fn + { + template _ISent, + __detail::__nothrow_forward_iterator _Out, + __detail::__nothrow_sentinel<_Out> _OSent> + requires constructible_from, iter_reference_t<_Iter>> + uninitialized_copy_result<_Iter, _Out> + operator()(_Iter __ifirst, _ISent __ilast, + _Out __ofirst, _OSent __olast) const + { + using _OutType = remove_reference_t>; + if constexpr (sized_sentinel_for<_ISent, _Iter> + && sized_sentinel_for<_OSent, _Out> + && is_trivial_v<_OutType> + && is_nothrow_assignable_v<_OutType&, + iter_reference_t<_Iter>>) + { + auto __d1 = __ilast - __ifirst; + auto __d2 = __olast - __ofirst; + return ranges::copy_n(std::move(__ifirst), std::min(__d1, __d2), + __ofirst); + } + else + { + auto __guard = __detail::_DestroyGuard(&__ofirst); + for (; __ifirst != __ilast && __ofirst != __olast; + ++__ofirst, (void)++__ifirst) + ::new (__detail::__voidify(*__ofirst)) _OutType(*__ifirst); + __guard.release(); + return {std::move(__ifirst), __ofirst}; + } + } + + template + requires constructible_from, + range_reference_t<_IRange>> + uninitialized_copy_result, + borrowed_iterator_t<_ORange>> + operator()(_IRange&& __inr, _ORange&& __outr) const + { + return (*this)(ranges::begin(__inr), ranges::end(__inr), + ranges::begin(__outr), ranges::end(__outr)); + } + }; + + inline constexpr __uninitialized_copy_fn uninitialized_copy{}; + + template + using uninitialized_copy_n_result = in_out_result<_Iter, _Out>; + + struct __uninitialized_copy_n_fn + { + template _Sent> + requires constructible_from, iter_reference_t<_Iter>> + uninitialized_copy_n_result<_Iter, _Out> + operator()(_Iter __ifirst, iter_difference_t<_Iter> __n, + _Out __ofirst, _Sent __olast) const + { + using _OutType = remove_reference_t>; + if constexpr (sized_sentinel_for<_Sent, _Out> + && is_trivial_v<_OutType> + && is_nothrow_assignable_v<_OutType&, + iter_reference_t<_Iter>>) + { + auto __d = __olast - __ofirst; + return ranges::copy_n(std::move(__ifirst), std::min(__n, __d), + __ofirst); + } + else + { + auto __guard = __detail::_DestroyGuard(&__ofirst); + for (; __n > 0 && __ofirst != __olast; + ++__ofirst, (void)++__ifirst, (void)--__n) + ::new (__detail::__voidify(*__ofirst)) _OutType(*__ifirst); + __guard.release(); + return {std::move(__ifirst), __ofirst}; + } + } + }; + + inline constexpr __uninitialized_copy_n_fn uninitialized_copy_n{}; + + template + using uninitialized_move_result = in_out_result<_Iter, _Out>; + + struct __uninitialized_move_fn + { + template _ISent, + __detail::__nothrow_forward_iterator _Out, + __detail::__nothrow_sentinel<_Out> _OSent> + requires constructible_from, + iter_rvalue_reference_t<_Iter>> + uninitialized_move_result<_Iter, _Out> + operator()(_Iter __ifirst, _ISent __ilast, + _Out __ofirst, _OSent __olast) const + { + using _OutType = remove_reference_t>; + if constexpr (sized_sentinel_for<_ISent, _Iter> + && sized_sentinel_for<_OSent, _Out> + && is_trivial_v<_OutType> + && is_nothrow_assignable_v<_OutType&, + iter_rvalue_reference_t<_Iter>>) + { + auto __d1 = __ilast - __ifirst; + auto __d2 = __olast - __ofirst; + auto [__in, __out] + = ranges::copy_n(std::make_move_iterator(std::move(__ifirst)), + std::min(__d1, __d2), __ofirst); + return {std::move(__in).base(), __out}; + } + else + { + auto __guard = __detail::_DestroyGuard(&__ofirst); + for (; __ifirst != __ilast && __ofirst != __olast; + ++__ofirst, (void)++__ifirst) + ::new (__detail::__voidify(*__ofirst)) + _OutType(ranges::iter_move(__ifirst)); + __guard.release(); + return {std::move(__ifirst), __ofirst}; + } + } + + template + requires constructible_from, + range_rvalue_reference_t<_IRange>> + uninitialized_move_result, + borrowed_iterator_t<_ORange>> + operator()(_IRange&& __inr, _ORange&& __outr) const + { + return (*this)(ranges::begin(__inr), ranges::end(__inr), + ranges::begin(__outr), ranges::end(__outr)); + } + }; + + inline constexpr __uninitialized_move_fn uninitialized_move{}; + + template + using uninitialized_move_n_result = in_out_result<_Iter, _Out>; + + struct __uninitialized_move_n_fn + { + template _Sent> + requires constructible_from, + iter_rvalue_reference_t<_Iter>> + uninitialized_move_n_result<_Iter, _Out> + operator()(_Iter __ifirst, iter_difference_t<_Iter> __n, + _Out __ofirst, _Sent __olast) const + { + using _OutType = remove_reference_t>; + if constexpr (sized_sentinel_for<_Sent, _Out> + && is_trivial_v<_OutType> + && is_nothrow_assignable_v<_OutType&, + iter_rvalue_reference_t<_Iter>>) + { + auto __d = __olast - __ofirst; + auto [__in, __out] + = ranges::copy_n(std::make_move_iterator(std::move(__ifirst)), + std::min(__n, __d), __ofirst); + return {std::move(__in).base(), __out}; + } + else + { + auto __guard = __detail::_DestroyGuard(&__ofirst); + for (; __n > 0 && __ofirst != __olast; + ++__ofirst, (void)++__ifirst, (void)--__n) + ::new (__detail::__voidify(*__ofirst)) + _OutType(ranges::iter_move(__ifirst)); + __guard.release(); + return {std::move(__ifirst), __ofirst}; + } + } + }; + + inline constexpr __uninitialized_move_n_fn uninitialized_move_n{}; + + struct __uninitialized_fill_fn + { + template<__detail::__nothrow_forward_iterator _Iter, + __detail::__nothrow_sentinel<_Iter> _Sent, typename _Tp> + requires constructible_from, const _Tp&> + _Iter + operator()(_Iter __first, _Sent __last, const _Tp& __x) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivial_v<_ValueType> + && is_nothrow_assignable_v<_ValueType&, const _Tp&>) + return ranges::fill(__first, __last, __x); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __first != __last; ++__first) + ::new (__detail::__voidify(*__first)) _ValueType(__x); + __guard.release(); + return __first; + } + } + + template<__detail::__nothrow_forward_range _Range, typename _Tp> + requires constructible_from, const _Tp&> + borrowed_iterator_t<_Range> + operator()(_Range&& __r, const _Tp& __x) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), __x); + } + }; + + inline constexpr __uninitialized_fill_fn uninitialized_fill{}; + + struct __uninitialized_fill_n_fn + { + template<__detail::__nothrow_forward_iterator _Iter, typename _Tp> + requires constructible_from, const _Tp&> + _Iter + operator()(_Iter __first, iter_difference_t<_Iter> __n, + const _Tp& __x) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivial_v<_ValueType> + && is_nothrow_assignable_v<_ValueType&, const _Tp&>) + return ranges::fill_n(__first, __n, __x); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __n > 0; ++__first, (void)--__n) + ::new (__detail::__voidify(*__first)) _ValueType(__x); + __guard.release(); + return __first; + } + } + }; + + inline constexpr __uninitialized_fill_n_fn uninitialized_fill_n{}; + + struct __construct_at_fn + { + template + requires requires { + ::new (std::declval()) _Tp(std::declval<_Args>()...); + } + constexpr _Tp* + operator()(_Tp* __location, _Args&&... __args) const + noexcept(noexcept(std::construct_at(__location, + std::forward<_Args>(__args)...))) + { + return std::construct_at(__location, + std::forward<_Args>(__args)...); + } + }; + + inline constexpr __construct_at_fn construct_at{}; + + struct __destroy_at_fn + { + template + constexpr void + operator()(_Tp* __location) const noexcept + { + if constexpr (is_array_v<_Tp>) + ranges::destroy(ranges::begin(*__location), ranges::end(*__location)); + else + __location->~_Tp(); + } + }; + + inline constexpr __destroy_at_fn destroy_at{}; + + template<__detail::__nothrow_input_iterator _Iter, + __detail::__nothrow_sentinel<_Iter> _Sent> + requires destructible> + constexpr _Iter + __destroy_fn::operator()(_Iter __first, _Sent __last) const noexcept + { + if constexpr (is_trivially_destructible_v>) + return ranges::next(std::move(__first), __last); + else + { + for (; __first != __last; ++__first) + ranges::destroy_at(std::__addressof(*__first)); + return __first; + } + } + + template<__detail::__nothrow_input_range _Range> + requires destructible> + constexpr borrowed_iterator_t<_Range> + __destroy_fn::operator()(_Range&& __r) const noexcept + { + return (*this)(ranges::begin(__r), ranges::end(__r)); + } + + struct __destroy_n_fn + { + template<__detail::__nothrow_input_iterator _Iter> + requires destructible> + constexpr _Iter + operator()(_Iter __first, iter_difference_t<_Iter> __n) const noexcept + { + if constexpr (is_trivially_destructible_v>) + return ranges::next(std::move(__first), __n); + else + { + for (; __n > 0; ++__first, (void)--__n) + ranges::destroy_at(std::__addressof(*__first)); + return __first; + } + } + }; + + inline constexpr __destroy_n_fn destroy_n{}; +} +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // concepts +#endif // C++20 +#endif // _RANGES_UNINITIALIZED_H diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ranges_uninitialized.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ranges_uninitialized.h.blob new file mode 100644 index 0000000..726ab1f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@ranges_uninitialized.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@refwrap.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@refwrap.h new file mode 100644 index 0000000..717aa01 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@refwrap.h @@ -0,0 +1,401 @@ +// Implementation of std::reference_wrapper -*- C++ -*- + +// Copyright (C) 2004-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#else + +#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 { }; + + /// 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> { }; + + 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> + { }; + + // - 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; + }; +#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/@@home@ado@git@ssp/@usr@include@c++@10@bits@refwrap.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@refwrap.h.blob new file mode 100644 index 0000000..1fc2fbc Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@refwrap.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr.h new file mode 100644 index 0000000..0c393e2 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr.h @@ -0,0 +1,918 @@ +// shared_ptr and weak_ptr implementation -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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 + } + + /** + * @brief A smart pointer with reference-counted copy semantics. + * + * 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 201606 + /// The corresponding weak_ptr type for this shared_ptr + 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()` + * + * 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<_Yp> + allocate_shared(const _Alloc& __a, _Args&&... __args); + + // This constructor is non-standard, it is used by weak_ptr::lock(). + shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t) + : __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` + 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` + 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` + 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` + 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` + 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 + * + * 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 member function shared_from_this. + */ + 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 201603 + 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<_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<_Tp> + make_shared(_Args&&... __args) + { + typedef typename std::remove_cv<_Tp>::type _Tp_nc; + return std::allocate_shared<_Tp>(std::allocator<_Tp_nc>(), + std::forward<_Args>(__args)...); + } + + /// 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr.h.blob new file mode 100644 index 0000000..9422c29 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_atomic.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_atomic.h new file mode 100644 index 0000000..13eb7f4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_atomic.h @@ -0,0 +1,336 @@ +// shared_ptr atomic access -*- C++ -*- + +// Copyright (C) 2014-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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); + } + // @} + + // @} relates shared_ptr + // @} group pointer_abstractions + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _SHARED_PTR_ATOMIC_H diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_atomic.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_atomic.h.blob new file mode 100644 index 0000000..43e1f73 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_atomic.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_base.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_base.h new file mode 100644 index 0000000..ff578e6 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_base.h @@ -0,0 +1,1898 @@ +// shared_ptr and weak_ptr implementation details -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#if __cplusplus > 201703L +# 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; + + void + _M_add_ref_copy() + { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); } + + void + _M_add_ref_lock(); + + bool + _M_add_ref_lock_nothrow(); + + void + _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) + { + _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(); + } + } + } + + void + _M_weak_add_ref() noexcept + { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); } + + 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 void + _Sp_counted_base<_S_single>:: + _M_add_ref_lock() + { + if (_M_use_count == 0) + __throw_bad_weak_ptr(); + ++_M_use_count; + } + + template<> + inline void + _Sp_counted_base<_S_mutex>:: + _M_add_ref_lock() + { + __gnu_cxx::__scoped_lock sentry(*this); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) + { + _M_use_count = 0; + __throw_bad_weak_ptr(); + } + } + + template<> + inline void + _Sp_counted_base<_S_atomic>:: + _M_add_ref_lock() + { + // Perform lock-free add-if-not-zero operation. + _Atomic_word __count = _M_get_use_count(); + do + { + if (__count == 0) + __throw_bad_weak_ptr(); + // Replace the current counter value with the old value + 1, as + // long as it's not changed meanwhile. + } + while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1, + true, __ATOMIC_ACQ_REL, + __ATOMIC_RELAXED)); + } + + template<> + inline bool + _Sp_counted_base<_S_single>:: + _M_add_ref_lock_nothrow() + { + 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() + { + __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() + { + // 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_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; + + + // 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 { } + + 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 + : _M_ptr(__p), _Del_base(std::move(__d)), _Alloc_base(__a) + { } + + _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 std::type_info& __ti) 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; + }; + + // 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 + { + template + struct __not_alloc_shared_tag { using type = void; }; + + template + struct __not_alloc_shared_tag<_Sp_alloc_shared_tag<_Tp>> { }; + + 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 _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 = typename conditional::value, + reference_wrapper::type>, + _Del>::type; + 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); + _Alloc_traits::construct(__a, __mem, __r.release(), + __r.get_deleter()); // non-throwing + _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); + + ~__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 != 0) + _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 != 0) + __tmp->_M_add_ref_copy(); + if (_M_pi != 0) + _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 != 0 ? _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>; + + _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>; + + _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(); + else + __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) + : _M_pi(__r._M_pi) + { + if (_M_pi != nullptr) + if (!_M_pi->_M_add_ref_lock_nothrow()) + _M_pi = nullptr; + } + +#define __cpp_lib_shared_ptr_arrays 201611L + + // 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 + { + __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 = typename enable_if<__and_< + __sp_compatible_with<_Yp*, _Tp*>, is_convertible<_Ptr, element_type*> + >::value, _Res>::type; + + // 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 = 0; + } + + __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 = 0; + } + + 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 = 0; + } + + 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 == 0 || __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 // never throws + { return _M_ptr == 0 ? false : true; } + + /// 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); + + // 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) + : _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; + + 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>; + + 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); } + + 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); } + }; + + 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) + { + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_base.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_base.h.blob new file mode 100644 index 0000000..34f3ef3 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@shared_ptr_base.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@sstream.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@sstream.tcc new file mode 100644 index 0000000..9e70c36 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@sstream.tcc @@ -0,0 +1,307 @@ +// String based streams -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 ((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/@@home@ado@git@ssp/@usr@include@c++@10@bits@sstream.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@sstream.tcc.blob new file mode 100644 index 0000000..ac5d32a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@sstream.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_abs.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_abs.h new file mode 100644 index 0000000..7047f82 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_abs.h @@ -0,0 +1,111 @@ +// -*- C++ -*- C library enhancements header. + +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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) + 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) + 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) + 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) + 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) && !defined(__CUDACC__) + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_abs.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_abs.h.blob new file mode 100644 index 0000000..1caee91 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_abs.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_function.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_function.h new file mode 100644 index 0000000..e2bf9b9 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_function.h @@ -0,0 +1,741 @@ +// Implementation of std::function -*- C++ -*- + +// Copyright (C) 2004-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +#if __cpp_rtti +# include +#endif +#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() { return &_M_pod_data[0]; } + const void* _M_access() const { return &_M_pod_data[0]; } + + template + _Tp& + _M_access() + { return *static_cast<_Tp*>(_M_access()); } + + template + const _Tp& + _M_access() const + { 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)); + + typedef integral_constant _Local_storage; + + // Retrieve a pointer to the function object + static _Functor* + _M_get_pointer(const _Any_data& __source) + { + 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*>(); + } + + // Clone a location-invariant function object that fits within + // an _Any_data structure. + static void + _M_clone(_Any_data& __dest, const _Any_data& __source, true_type) + { + ::new (__dest._M_access()) _Functor(__source._M_access<_Functor>()); + } + + // Clone a function object that is not location-invariant or + // that cannot fit into an _Any_data structure. + static void + _M_clone(_Any_data& __dest, const _Any_data& __source, false_type) + { + __dest._M_access<_Functor*>() = + new _Functor(*__source._M_access()); + } + + // Destroying a location-invariant object may still require + // destruction. + static void + _M_destroy(_Any_data& __victim, true_type) + { + __victim._M_access<_Functor>().~_Functor(); + } + + // Destroying 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) + { +#if __cpp_rtti + case __get_type_info: + __dest._M_access() = &typeid(_Functor); + break; +#endif + case __get_functor_ptr: + __dest._M_access<_Functor*>() = _M_get_pointer(__source); + break; + + case __clone_functor: + _M_clone(__dest, __source, _Local_storage()); + break; + + case __destroy_functor: + _M_destroy(__dest, _Local_storage()); + break; + } + return false; + } + + static void + _M_init_functor(_Any_data& __functor, _Functor&& __f) + { _M_init_functor(__functor, std::move(__f), _Local_storage()); } + + template + static bool + _M_not_empty_function(const function<_Signature>& __f) + { return static_cast(__f); } + + template + static bool + _M_not_empty_function(_Tp* __fp) + { return __fp != nullptr; } + + template + static bool + _M_not_empty_function(_Tp _Class::* __mp) + { return __mp != nullptr; } + + template + static bool + _M_not_empty_function(const _Tp&) + { return true; } + + private: + static void + _M_init_functor(_Any_data& __functor, _Functor&& __f, true_type) + { ::new (__functor._M_access()) _Functor(std::move(__f)); } + + static void + _M_init_functor(_Any_data& __functor, _Functor&& __f, false_type) + { __functor._M_access<_Functor*>() = new _Functor(std::move(__f)); } + }; + + _Function_base() : _M_manager(nullptr) { } + + ~_Function_base() + { + if (_M_manager) + _M_manager(_M_functor, _M_functor, __destroy_functor); + } + + bool _M_empty() const { return !_M_manager; } + + typedef bool (*_Manager_type)(_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> + { + typedef _Function_base::_Base_manager<_Functor> _Base; + + 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)...); + } + }; + + /** + * @brief Primary class template for std::function. + * @ingroup functors + * + * Polymorphic function wrapper. + */ + template + class function<_Res(_ArgTypes...)> + : public _Maybe_unary_or_binary_function<_Res, _ArgTypes...>, + private _Function_base + { + template> + struct _Callable + : __is_invocable_impl<_Res2, _Res>::type + { }; + + // Used so the return type convertibility checks aren't done when + // performing overload resolution for copy construction/assignment. + template + struct _Callable : false_type { }; + + template + using _Requires = typename enable_if<_Cond::value, _Tp>::type; + + public: + typedef _Res result_type; + + // [3.7.2.1] construct/copy/destroy + + /** + * @brief Default construct creates an empty function call wrapper. + * @post @c !(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 @c bool(*this) == bool(__x) + * + * The newly-created %function contains a copy of the target of @a + * __x (if it has one). + */ + function(const function& __x); + + /** + * @brief %Function move constructor. + * @param __x A %function object rvalue with identical call signature. + * + * The newly-created %function contains the target of @a __x + * (if it has one). + */ + function(function&& __x) noexcept : _Function_base() + { + __x.swap(*this); + } + + /** + * @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 @c T1, @c T2, ..., @c TN and returns a value convertible + * to @c Res. + * + * The newly-created %function object will target a copy of + * @a __f. If @a __f is @c reference_wrapper, then this function + * object will contain a reference to the function object @c + * __f.get(). If @a __f is a NULL function pointer or NULL + * pointer-to-member, the newly-created object will be empty. + * + * If @a __f is a non-NULL function pointer or an object of type @c + * reference_wrapper, this function will not throw. + */ + template>, void>, + typename = _Requires<_Callable<_Functor>, void>> + function(_Functor); + + /** + * @brief %Function assignment operator. + * @param __x A %function with identical call signature. + * @post @c (bool)*this == (bool)x + * @returns @c *this + * + * The target of @a __x is copied to @c *this. If @a __x has no + * target, then @c *this will be empty. + * + * If @a __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 @c *this + * + * The target of @a __x is moved to @c *this. If @a __x has no + * target, then @c *this will be empty. + * + * If @a __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 zero. + * @post @c !(bool)*this + * @returns @c *this + * + * The target of @c *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 @c T1, @c T2, ..., @c TN and returns a value convertible + * to @c Res. + * @return @c *this + * + * This %function object wrapper will target a copy of @a + * __f. If @a __f is @c reference_wrapper, then this function + * object will contain a reference to the function object @c + * __f.get(). If @a __f is a NULL function pointer or NULL + * pointer-to-member, @c this object will be empty. + * + * If @a __f is a non-NULL function pointer or an object of type @c + * reference_wrapper, this function will not throw. + */ + template + _Requires<_Callable::type>, function&> + operator=(_Functor&& __f) + { + 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 @c this function object and @a __f. This + * function will not throw an %exception. + */ + 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 @c true when this %function object contains a target, + * or @c false when it is empty. + * + * This function will not throw an %exception. + */ + explicit operator bool() const noexcept + { return !_M_empty(); } + + // [3.7.2.4] function invocation + + /** + * @brief Invokes the function targeted by @c *this. + * @returns the result of the target. + * @throws bad_function_call when @c !(bool)*this + * + * The function call operator invokes the target function object + * stored by @c this. + */ + _Res operator()(_ArgTypes... __args) const; + +#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 + * @c typeid(void) if @c !(bool)*this. + * + * This function will not throw an %exception. + */ + const type_info& target_type() const noexcept; + + /** + * @brief Access the stored target function object. + * + * @return Returns a pointer to the stored target function object, + * if @c typeid(_Functor).equals(target_type()); otherwise, a NULL + * pointer. + * + * This function does not throw exceptions. + * + * @{ + */ + template _Functor* target() noexcept; + + template const _Functor* target() const noexcept; + // @} +#endif + + private: + using _Invoker_type = _Res (*)(const _Any_data&, _ArgTypes&&...); + _Invoker_type _M_invoker; + }; + +#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 + + // Out-of-line member definitions. + template + function<_Res(_ArgTypes...)>:: + 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; + } + } + + template + template + function<_Res(_ArgTypes...)>:: + function(_Functor __f) + : _Function_base() + { + typedef _Function_handler<_Res(_ArgTypes...), _Functor> _My_handler; + + if (_My_handler::_M_not_empty_function(__f)) + { + _My_handler::_M_init_functor(_M_functor, std::move(__f)); + _M_invoker = &_My_handler::_M_invoke; + _M_manager = &_My_handler::_M_manager; + } + } + + template + _Res + function<_Res(_ArgTypes...)>:: + operator()(_ArgTypes... __args) const + { + if (_M_empty()) + __throw_bad_function_call(); + return _M_invoker(_M_functor, std::forward<_ArgTypes>(__args)...); + } + +#if __cpp_rtti + template + const type_info& + function<_Res(_ArgTypes...)>:: + target_type() const noexcept + { + if (_M_manager) + { + _Any_data __typeinfo_result; + _M_manager(__typeinfo_result, _M_functor, __get_type_info); + return *__typeinfo_result._M_access(); + } + else + return typeid(void); + } + + template + template + _Functor* + function<_Res(_ArgTypes...)>:: + target() noexcept + { + const function* __const_this = this; + const _Functor* __func = __const_this->template target<_Functor>(); + return const_cast<_Functor*>(__func); + } + + template + template + const _Functor* + function<_Res(_ArgTypes...)>:: + target() const noexcept + { + if (typeid(_Functor) == target_type() && _M_manager) + { + _Any_data __ptr; + _M_manager(__ptr, _M_functor, __get_functor_ptr); + return __ptr._M_access(); + } + else + return nullptr; + } +#endif + + // [20.7.15.2.6] null pointer comparisons + + /** + * @brief Compares a polymorphic function object wrapper against 0 + * (the NULL pointer). + * @returns @c true if the wrapper has no target, @c false otherwise + * + * This function will not throw an %exception. + */ + 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 Compares a polymorphic function object wrapper against 0 + * (the NULL pointer). + * @returns @c false if the wrapper has no target, @c true otherwise + * + * This function will not throw an %exception. + */ + 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 an %exception. + */ + // _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/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_function.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_function.h.blob new file mode 100644 index 0000000..da28969 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@std_function.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algo.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algo.h new file mode 100644 index 0000000..bbb4313 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algo.h @@ -0,0 +1,5889 @@ +// Algorithm implementation -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 // for rand +#include +#include +#include // for _Temporary_buffer +#include + +#if __cplusplus >= 201103L +#include +#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_a(_InputIterator __first, _Size __n, _OutputIterator __result) + { + if (__n > 0) + { + while (true) + { + *__result = *__first; + ++__result; + if (--__n > 0) + ++__first; + else + break; + } + } + return __result; + } + + template + __enable_if_t<__is_char<_CharT>::__value, _CharT*> + __copy_n_a(istreambuf_iterator<_CharT, char_traits<_CharT>>, + _Size, _CharT*); + + 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))); + } + + 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>) + __glibcxx_requires_can_increment(__first, __n); + __glibcxx_requires_can_increment(__result, __n); + + return std::__copy_n(__first, __n, __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 + + 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; + } + + /** + * @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; + + if (__first == __middle || __middle == __last) + return; + + const _DistanceType __len1 = std::distance(__first, __middle); + const _DistanceType __len2 = std::distance(__middle, __last); + + typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf; + _TmpBuf __buf(__first, __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; + else if (__comp(__first1, __first2)) + ++__first1; + else + { + ++__first1; + ++__first2; + } + + 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)); + } + + // N2722 + DR 915. + template + _GLIBCXX14_CONSTEXPR + inline _Tp + min(initializer_list<_Tp> __l) + { return *std::min_element(__l.begin(), __l.end()); } + + template + _GLIBCXX14_CONSTEXPR + inline _Tp + min(initializer_list<_Tp> __l, _Compare __comp) + { return *std::min_element(__l.begin(), __l.end(), __comp); } + + template + _GLIBCXX14_CONSTEXPR + inline _Tp + max(initializer_list<_Tp> __l) + { return *std::max_element(__l.begin(), __l.end()); } + + template + _GLIBCXX14_CONSTEXPR + inline _Tp + max(initializer_list<_Tp> __l, _Compare __comp) + { return *std::max_element(__l.begin(), __l.end(), __comp); } + + template + _GLIBCXX14_CONSTEXPR + inline pair<_Tp, _Tp> + minmax(initializer_list<_Tp> __l) + { + pair __p = + std::minmax_element(__l.begin(), __l.end()); + return std::make_pair(*__p.first, *__p.second); + } + + template + _GLIBCXX14_CONSTEXPR + inline pair<_Tp, _Tp> + minmax(initializer_list<_Tp> __l, _Compare __comp) + { + pair __p = + std::minmax_element(__l.begin(), __l.end(), __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 > 201402L + +#define __cpp_lib_clamp 201603 + + /** + * @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. + * @return max(__val, __lo) if __val < __hi or min(__val, __hi) otherwise. + */ + template + constexpr const _Tp& + clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi) + { + __glibcxx_assert(!(__hi < __lo)); + return (__val < __lo) ? __lo : (__hi < __val) ? __hi : __val; + } + + /** + * @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. + * @return max(__val, __lo, __comp) if __comp(__val, __hi) + * or min(__val, __hi, __comp) otherwise. + */ + template + constexpr const _Tp& + clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi, _Compare __comp) + { + __glibcxx_assert(!__comp(__hi, __lo)); + return __comp(__val, __lo) ? __lo : __comp(__hi, __val) ? __hi : __val; + } +#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 + +#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 > 201402L + /** @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 _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. + */ + template + 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). + */ + template + 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); + } + } + + + /** + * @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; + _TmpBuf __buf(__first, std::distance(__first, __last)); + + if (__buf.begin() == 0) + std::__inplace_stable_sort(__first, __last, __comp); + else + std::__stable_sort_adaptive(__first, __last, __buf.begin(), + _DistanceType(__buf.size()), __comp); + } + + /** + * @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 >= 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 201603 + /// 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algo.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algo.h.blob new file mode 100644 index 0000000..e213943 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algo.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algobase.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algobase.h new file mode 100644 index 0000000..7750335 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algobase.h @@ -0,0 +1,2070 @@ +// Core algorithmic facilities -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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; } + + // 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<_IsMove, + is_move_assignable<_Tp>, + is_copy_assignable<_Tp>>; + // trivial types can have deleted assignment + static_assert( __assignable::type::value, "type is not assignable" ); +#endif + const ptrdiff_t _Num = __last - __first; + if (_Num) + __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); + return __result + _Num; + } + }; + + // 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 + _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); + } + +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + struct _Deque_iterator; + +_GLIBCXX_END_NAMESPACE_CONTAINER + + 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>&); + + /** + * @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>::value_type>) + __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<_IsMove, + is_move_assignable<_Tp>, + is_copy_assignable<_Tp>>; + // trivial types can have deleted assignment + static_assert( __assignable::type::value, "type is not 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(_ConvertibleConcept< + typename iterator_traits<_BI1>::value_type, + typename iterator_traits<_BI2>::value_type>) + __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(_ConvertibleConcept< + typename iterator_traits<_BI1>::value_type, + typename iterator_traits<_BI2>::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&); + + 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) + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0 + __size_to_integer(__GLIBCXX_TYPE_INT_N_0 __n) { return __n; } + 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) + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1 + __size_to_integer(__GLIBCXX_TYPE_INT_N_1 __n) { return __n; } + 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) + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2 + __size_to_integer(__GLIBCXX_TYPE_INT_N_2 __n) { return __n; } + 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) + inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_3 + __size_to_integer(__GLIBCXX_TYPE_INT_N_3 __n) { return __n; } + 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 __n; } + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(double __n) { return __n; } + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(long double __n) { return __n; } +#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__) + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(__float128 __n) { return __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, _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<> + struct __lexicographical_compare + { + template + _GLIBCXX20_CONSTEXPR + static bool + __lc(const _Tp* __first1, const _Tp* __last1, + const _Up* __first2, const _Up* __last2) + { + const size_t __len1 = __last1 - __first1; + const size_t __len2 = __last2 - __first2; + if (const size_t __len = std::min(__len1, __len2)) + if (int __result = std::__memcmp(__first1, __first2, __len)) + return __result < 0; + return __len1 < __len2; + } + }; + + template + _GLIBCXX20_CONSTEXPR + inline bool + __lexicographical_compare_aux(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2) + { + typedef typename iterator_traits<_II1>::value_type _ValueType1; + typedef typename iterator_traits<_II2>::value_type _ValueType2; + const bool __simple = + (__is_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 + _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 201304 + + /** + * @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(std::__niter_base(__first1), + std::__niter_base(__last1), + std::__niter_base(__first2), + std::__niter_base(__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); + +#if __cpp_lib_is_constant_evaluated + 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] + = std::__min_cmp(__last1 - __first1, __last2 - __first2); + if (__len) + { + const auto __c + = __builtin_memcmp(&*__first1, &*__first2, __len) <=> 0; + if (__c != 0) + return __c; + } + return __lencmp; + } +#endif // is_constant_evaluated + 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 std::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; + } + +#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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algobase.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algobase.h.blob new file mode 100644 index 0000000..0632e87 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_algobase.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_bvector.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_bvector.h new file mode 100644 index 0000000..f245e52 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_bvector.h @@ -0,0 +1,1363 @@ +// vector specialization -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + typedef unsigned long _Bit_type; + enum { _S_word_bit = int(__CHAR_BIT__ * sizeof(_Bit_type)) }; + + struct _Bit_reference + { + _Bit_type * _M_p; + _Bit_type _M_mask; + + _Bit_reference(_Bit_type * __x, _Bit_type __y) + : _M_p(__x), _M_mask(__y) { } + + _Bit_reference() _GLIBCXX_NOEXCEPT : _M_p(0), _M_mask(0) { } + +#if __cplusplus >= 201103L + _Bit_reference(const _Bit_reference&) = default; +#endif + + operator bool() const _GLIBCXX_NOEXCEPT + { return !!(*_M_p & _M_mask); } + + _Bit_reference& + operator=(bool __x) _GLIBCXX_NOEXCEPT + { + if (__x) + *_M_p |= _M_mask; + else + *_M_p &= ~_M_mask; + return *this; + } + + _Bit_reference& + operator=(const _Bit_reference& __x) _GLIBCXX_NOEXCEPT + { return *this = bool(__x); } + + bool + operator==(const _Bit_reference& __x) const + { return bool(*this) == bool(__x); } + + bool + operator<(const _Bit_reference& __x) const + { return !bool(*this) && bool(__x); } + + void + flip() _GLIBCXX_NOEXCEPT + { *_M_p ^= _M_mask; } + }; + +#if __cplusplus >= 201103L + inline void + swap(_Bit_reference __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + inline void + swap(_Bit_reference __x, bool& __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + inline void + swap(bool& __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } +#endif + + struct _Bit_iterator_base + : public std::iterator + { + _Bit_type * _M_p; + unsigned int _M_offset; + + _Bit_iterator_base(_Bit_type * __x, unsigned int __y) + : _M_p(__x), _M_offset(__y) { } + + void + _M_bump_up() + { + if (_M_offset++ == int(_S_word_bit) - 1) + { + _M_offset = 0; + ++_M_p; + } + } + + void + _M_bump_down() + { + if (_M_offset-- == 0) + { + _M_offset = int(_S_word_bit) - 1; + --_M_p; + } + } + + void + _M_incr(ptrdiff_t __i) + { + difference_type __n = __i + _M_offset; + _M_p += __n / int(_S_word_bit); + __n = __n % int(_S_word_bit); + if (__n < 0) + { + __n += int(_S_word_bit); + --_M_p; + } + _M_offset = static_cast(__n); + } + + 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 + 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 + 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); + } + + friend bool + operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return !(__x == __y); } + + friend bool + operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return __y < __x; } + + friend bool + operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return !(__y < __x); } + + friend bool + operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return !(__x < __y); } +#endif // three-way comparison + + friend ptrdiff_t + operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { + return (int(_S_word_bit) * (__x._M_p - __y._M_p) + + __x._M_offset - __y._M_offset); + } + }; + + struct _Bit_iterator : public _Bit_iterator_base + { + typedef _Bit_reference reference; +#if __cplusplus > 201703L + typedef void pointer; +#else + typedef _Bit_reference* pointer; +#endif + typedef _Bit_iterator iterator; + + _Bit_iterator() : _Bit_iterator_base(0, 0) { } + + _Bit_iterator(_Bit_type * __x, unsigned int __y) + : _Bit_iterator_base(__x, __y) { } + + iterator + _M_const_cast() const + { return *this; } + + reference + operator*() const + { return reference(_M_p, 1UL << _M_offset); } + + iterator& + operator++() + { + _M_bump_up(); + return *this; + } + + iterator + operator++(int) + { + iterator __tmp = *this; + _M_bump_up(); + return __tmp; + } + + iterator& + operator--() + { + _M_bump_down(); + return *this; + } + + iterator + operator--(int) + { + iterator __tmp = *this; + _M_bump_down(); + return __tmp; + } + + iterator& + operator+=(difference_type __i) + { + _M_incr(__i); + return *this; + } + + iterator& + operator-=(difference_type __i) + { + *this += -__i; + return *this; + } + + reference + operator[](difference_type __i) const + { return *(*this + __i); } + + friend iterator + operator+(const iterator& __x, difference_type __n) + { + iterator __tmp = __x; + __tmp += __n; + return __tmp; + } + + friend iterator + operator+(difference_type __n, const iterator& __x) + { return __x + __n; } + + friend 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; + + _Bit_const_iterator() : _Bit_iterator_base(0, 0) { } + + _Bit_const_iterator(_Bit_type * __x, unsigned int __y) + : _Bit_iterator_base(__x, __y) { } + + _Bit_const_iterator(const _Bit_iterator& __x) + : _Bit_iterator_base(__x._M_p, __x._M_offset) { } + + _Bit_iterator + _M_const_cast() const + { return _Bit_iterator(_M_p, _M_offset); } + + const_reference + operator*() const + { return _Bit_reference(_M_p, 1UL << _M_offset); } + + const_iterator& + operator++() + { + _M_bump_up(); + return *this; + } + + const_iterator + operator++(int) + { + const_iterator __tmp = *this; + _M_bump_up(); + return __tmp; + } + + const_iterator& + operator--() + { + _M_bump_down(); + return *this; + } + + const_iterator + operator--(int) + { + const_iterator __tmp = *this; + _M_bump_down(); + return __tmp; + } + + const_iterator& + operator+=(difference_type __i) + { + _M_incr(__i); + return *this; + } + + const_iterator& + operator-=(difference_type __i) + { + *this += -__i; + return *this; + } + + const_reference + operator[](difference_type __i) const + { return *(*this + __i); } + + friend const_iterator + operator+(const const_iterator& __x, difference_type __n) + { + const_iterator __tmp = __x; + __tmp += __n; + return __tmp; + } + + friend const_iterator + operator-(const const_iterator& __x, difference_type __n) + { + const_iterator __tmp = __x; + __tmp -= __n; + return __tmp; + } + + friend const_iterator + operator+(difference_type __n, const const_iterator& __x) + { return __x + __n; } + }; + + inline void + __fill_bvector(_Bit_type * __v, + unsigned int __first, unsigned int __last, bool __x) + { + 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; + } + + inline void + fill(_Bit_iterator __first, _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); + + __builtin_memset(__first_p, __x ? ~0 : 0, + (__last._M_p - __first_p) * sizeof(_Bit_type)); + + 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); + } + + 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 + { + _Bit_iterator _M_start; + _Bit_iterator _M_finish; + _Bit_pointer _M_end_of_storage; + + _Bvector_impl_data() _GLIBCXX_NOEXCEPT + : _M_start(), _M_finish(), _M_end_of_storage() + { } + +#if __cplusplus >= 201103L + _Bvector_impl_data(_Bvector_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_reset(); } + + void + _M_move_data(_Bvector_impl_data&& __x) noexcept + { + this->_M_start = __x._M_start; + this->_M_finish = __x._M_finish; + this->_M_end_of_storage = __x._M_end_of_storage; + __x._M_reset(); + } +#endif + + void + _M_reset() _GLIBCXX_NOEXCEPT + { + _M_start = _M_finish = _Bit_iterator(); + _M_end_of_storage = _Bit_pointer(); + } + }; + + struct _Bvector_impl + : public _Bit_alloc_type, public _Bvector_impl_data + { + public: + _Bvector_impl() _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Bit_alloc_type>::value) + : _Bit_alloc_type() + { } + + _Bvector_impl(const _Bit_alloc_type& __a) _GLIBCXX_NOEXCEPT + : _Bit_alloc_type(__a) + { } + +#if __cplusplus >= 201103L + _Bvector_impl(_Bvector_impl&&) = default; +#endif + + _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; + + _Bit_alloc_type& + _M_get_Bit_allocator() _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + const _Bit_alloc_type& + _M_get_Bit_allocator() const _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_get_Bit_allocator()); } + +#if __cplusplus >= 201103L + _Bvector_base() = default; +#else + _Bvector_base() { } +#endif + + _Bvector_base(const allocator_type& __a) + : _M_impl(__a) { } + +#if __cplusplus >= 201103L + _Bvector_base(_Bvector_base&&) = default; +#endif + + ~_Bvector_base() + { this->_M_deallocate(); } + + protected: + _Bvector_impl _M_impl; + + _Bit_pointer + _M_allocate(size_t __n) + { return _Bit_alloc_traits::allocate(_M_impl, _S_nword(__n)); } + + 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 + void + _M_move_data(_Bvector_base&& __x) noexcept + { _M_impl._M_move_data(std::move(__x._M_impl)); } +#endif + + static size_t + _S_nword(size_t __n) + { return (__n + int(_S_word_bit) - 1) / int(_S_word_bit); } + }; + +_GLIBCXX_END_NAMESPACE_CONTAINER +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +// Declare a partial specialization of vector. +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /** + * @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; + + 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 + + explicit + vector(const allocator_type& __a) + : _Base(__a) { } + +#if __cplusplus >= 201103L + explicit + vector(size_type __n, const allocator_type& __a = allocator_type()) + : vector(__n, false, __a) + { } + + 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); + } + + 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(), this->_M_impl._M_start); + } + +#if __cplusplus >= 201103L + vector(vector&&) = default; + + vector(vector&& __x, const allocator_type& __a) + noexcept(_Bit_alloc_traits::_S_always_equal()) + : _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(); + } + } + + vector(const vector& __x, const allocator_type& __a) + : _Base(__a) + { + _M_initialize(__x.size()); + _M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start); + } + + 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> + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { _M_initialize_dispatch(__first, __last, __false_type()); } +#else + template + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#endif + + ~vector() _GLIBCXX_NOEXCEPT { } + + 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 + 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; + } + + 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. + void + assign(size_type __n, const bool& __x) + { _M_fill_assign(__n, __x); } + +#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 + void + assign(initializer_list __l) + { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } +#endif + + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_start._M_p, 0); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_start._M_p, 0); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish; } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish; } + + 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()); } + +#if __cplusplus >= 201103L + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_impl._M_start._M_p, 0); } + + const_iterator + cend() const noexcept + { return this->_M_impl._M_finish; } + + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + size_type + size() const _GLIBCXX_NOEXCEPT + { return size_type(end() - begin()); } + + 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); + } + + size_type + capacity() const _GLIBCXX_NOEXCEPT + { return size_type(const_iterator(this->_M_impl._M_end_addr(), 0) + - begin()); } + + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return begin() == end(); } + + reference + operator[](size_type __n) + { + return *iterator(this->_M_impl._M_start._M_p + + __n / int(_S_word_bit), __n % int(_S_word_bit)); + } + + const_reference + operator[](size_type __n) const + { + return *const_iterator(this->_M_impl._M_start._M_p + + __n / int(_S_word_bit), __n % int(_S_word_bit)); + } + + protected: + void + _M_range_check(size_type __n) const + { + if (__n >= this->size()) + __throw_out_of_range_fmt(__N("vector::_M_range_check: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + } + + public: + reference + at(size_type __n) + { _M_range_check(__n); return (*this)[__n]; } + + const_reference + at(size_type __n) const + { _M_range_check(__n); return (*this)[__n]; } + + void + reserve(size_type __n) + { + if (__n > max_size()) + __throw_length_error(__N("vector::reserve")); + if (capacity() < __n) + _M_reallocate(__n); + } + + reference + front() + { return *begin(); } + + const_reference + front() const + { return *begin(); } + + reference + back() + { return *(end() - 1); } + + const_reference + back() const + { return *(end() - 1); } + + // _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 way we are implementing DR 464 in the debug-mode + // vector class. + void + data() _GLIBCXX_NOEXCEPT { } + + 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); + } + + void + swap(vector& __x) _GLIBCXX_NOEXCEPT + { + std::swap(this->_M_impl._M_start, __x._M_impl._M_start); + std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); + std::swap(this->_M_impl._M_end_of_storage, + __x._M_impl._M_end_of_storage); + _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 + static void + swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const bool& __x = bool()) +#else + insert(iterator __position, const bool& __x = bool()) +#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 __cplusplus >= 201103L + template> + iterator + insert(const_iterator __position, + _InputIterator __first, _InputIterator __last) + { + difference_type __offset = __position - cbegin(); + _M_insert_dispatch(__position._M_const_cast(), + __first, __last, __false_type()); + return begin() + __offset; + } +#else + template + void + insert(iterator __position, + _InputIterator __first, _InputIterator __last) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_insert_dispatch(__position, __first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + 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 + iterator + insert(const_iterator __p, initializer_list __l) + { return this->insert(__p, __l.begin(), __l.end()); } +#endif + + void + pop_back() + { --this->_M_impl._M_finish; } + + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) +#else + erase(iterator __position) +#endif + { return _M_erase(__position._M_const_cast()); } + + 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()); } + + 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 + void + shrink_to_fit() + { _M_shrink_to_fit(); } +#endif + + 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; + } + + void + clear() _GLIBCXX_NOEXCEPT + { _M_erase_at_end(begin()); } + +#if __cplusplus >= 201103L + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_back(_Args&&... __args) + { + push_back(bool(__args...)); +#if __cplusplus > 201402L + return back(); +#endif + } + + template + iterator + emplace(const_iterator __pos, _Args&&... __args) + { return insert(__pos, bool(__args...)); } +#endif + + protected: + // Precondition: __first._M_offset == 0 && __result._M_offset == 0. + iterator + _M_copy_aligned(const_iterator __first, const_iterator __last, + iterator __result) + { + _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p); + return std::copy(const_iterator(__last._M_p, 0), __last, + iterator(__q, 0)); + } + + void + _M_initialize(size_type __n) + { + if (__n) + { + _Bit_pointer __q = this->_M_allocate(__n); + this->_M_impl._M_end_of_storage = __q + _S_nword(__n); + this->_M_impl._M_start = iterator(std::__addressof(*__q), 0); + } + else + { + this->_M_impl._M_end_of_storage = _Bit_pointer(); + this->_M_impl._M_start = iterator(0, 0); + } + this->_M_impl._M_finish = this->_M_impl._M_start + difference_type(__n); + + } + + void + _M_initialize_value(bool __x) + { + if (_Bit_type* __p = this->_M_impl._M_start._M_p) + __builtin_memset(__p, __x ? ~0 : 0, + (this->_M_impl._M_end_addr() - __p) + * sizeof(_Bit_type)); + } + + void + _M_reallocate(size_type __n); + +#if __cplusplus >= 201103L + bool + _M_shrink_to_fit(); +#endif + + // Check whether it's an integral type. If so, it's not an iterator. + + // _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)); } + + template + void + _M_initialize_range(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + for (; __first != __last; ++__first) + push_back(*__first); + } + + template + void + _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __n = std::distance(__first, __last); + _M_initialize(__n); + std::copy(__first, __last, this->_M_impl._M_start); + } + +#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 + + 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 + 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 + 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); + } + } + + // Check whether it's an integral type. If so, it's not an iterator. + + // _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)); } + + void + _M_fill_insert(iterator __position, size_type __n, bool __x); + + template + void + _M_insert_range(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag) + { + for (; __first != __last; ++__first) + { + __pos = insert(__pos, *__first); + ++__pos; + } + } + + template + void + _M_insert_range(iterator __position, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag); + + void + _M_insert_aux(iterator __position, bool __x); + + size_type + _M_check_len(size_type __n, const char* __s) const + { + if (max_size() - size() < __n) + __throw_length_error(__N(__s)); + + const size_type __len = size() + std::max(size(), __n); + return (__len < size() || __len > max_size()) ? max_size() : __len; + } + + void + _M_erase_at_end(iterator __pos) + { this->_M_impl._M_finish = __pos; } + + iterator + _M_erase(iterator __pos); + + iterator + _M_erase(iterator __first, iterator __last); + }; + +_GLIBCXX_END_NAMESPACE_CONTAINER +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#if __cplusplus >= 201103L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // 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; + }; + +_GLIBCXX_END_NAMESPACE_VERSION +}// namespace std + +#endif // C++11 + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_bvector.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_bvector.h.blob new file mode 100644 index 0000000..c151ab4 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_bvector.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_construct.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_construct.h new file mode 100644 index 0000000..72a7cb4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_construct.h @@ -0,0 +1,256 @@ +// nonstandard construct and destroy functions -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 > 201703L + 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 + inline void + _Construct(_Tp* __p, _Args&&... __args) + { ::new(static_cast(__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(static_cast(__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 > 201703L && defined __cpp_lib_is_constant_evaluated + 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 > 201703L && defined __cpp_lib_is_constant_evaluated + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_construct.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_construct.h.blob new file mode 100644 index 0000000..6afdca6 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_construct.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_function.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_function.h new file mode 100644 index 0000000..77f8ccb --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_function.h @@ -0,0 +1,1395 @@ +// Functor implementations -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 @e functors, are objects with an @c 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 @a 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 @c a and @c b containing @c double, + * and put the result in @c a, use + * \code + * transform (a.begin(), a.end(), b.begin(), a.begin(), plus()); + * \endcode + * To negate every element in @c a, use + * \code + * transform(a.begin(), a.end(), a.begin(), negate()); + * \endcode + * The addition and negation functions will be inlined directly. + * + * The standard functors are derived from structs named @c unary_function + * and @c binary_function. These two classes contain nothing but typedefs, + * to aid in generic (template) programming. If you write your own + * functors, you might consider doing the same. + * + * @{ + */ + /** + * This is one of the @link functors functor base classes@endlink. + */ + 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; + }; + + /** + * This is one of the @link functors functor base classes@endlink. + */ + 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; + }; + /** @} */ + + // 20.3.2 arithmetic + /** @defgroup arithmetic_functors Arithmetic Classes + * @ingroup functors + * + * Because basic math often needs to be done during an algorithm, + * the library provides functors for those operations. See the + * documentation for @link functors the base classes@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 + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct plus : 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 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; } + }; + +#if __cplusplus > 201103L + +#define __cpp_lib_transparent_operators 201510 + + 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 + + /// 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 +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + if (__builtin_is_constant_evaluated()) +#else + if (__builtin_constant_p(__x > __y)) +#endif + 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 +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + if (__builtin_is_constant_evaluated()) +#else + if (__builtin_constant_p(__x < __y)) +#endif + 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 +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + if (__builtin_is_constant_evaluated()) +#else + if (__builtin_constant_p(__x >= __y)) +#endif + 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 +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + if (__builtin_is_constant_evaluated()) +#else + if (__builtin_constant_p(__x <= __y)) +#endif + return __x <= __y; +#endif + return (__UINTPTR_TYPE__)__x <= (__UINTPTR_TYPE__)__y; + } + }; + +#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 + * + * Here are wrapper functors for Boolean operations: @c &&, @c ||, + * and @c !. + * + * @{ + */ +#if __cplusplus > 201103L + template + struct logical_and; + + template + struct logical_or; + + template + struct logical_not; +#endif + + /// 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; } + }; + +#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 + + // _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; } + }; + +#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 + + // 20.3.5 negators + /** @defgroup negators Negators + * @ingroup functors + * + * The functions @c not1 and @c not2 each take a predicate functor + * and return an instance of @c unary_negate or + * @c binary_negate, respectively. These classes are functors whose + * @c operator() performs the stored 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) { return x > 3; } + * }; + * + * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree())); + * \endcode + * The call to @c find_if will locate the first index (i) of @c 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 which + * take two arguments. + * + * @{ + */ + /// One of the @link negators negation functors@endlink. + template + class 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 + _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 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 + _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., @c result_type + * from the base classes @c unary_function and @c 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 @c pointer_to_unary_function is constructed with a + * function pointer @c f, and its @c operator() called with argument @c x + * returns @c f(x). The functor @c pointer_to_binary_function does the same + * thing, but with a double-argument @c f and @c operator(). + * + * The function @c ptr_fun takes a pointer-to-function @c f and constructs + * an instance of the appropriate functor. + * + * @{ + */ + /// 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); } + }; + + /// One of the @link pointer_adaptors adaptors for function pointers@endlink. + template + 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); } + }; + + /// One of the @link pointer_adaptors adaptors for function pointers@endlink. + template + 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 memory_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. + * + * @{ + */ + /// One of the @link memory_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)(); + }; + + /// One of the @link memory_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; + }; + + /// One of the @link memory_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)(); + }; + + /// One of the @link memory_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; + }; + + /// One of the @link memory_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); + }; + + /// One of the @link memory_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; + }; + + /// One of the @link memory_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); + }; + + /// One of the @link memory_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; + }; + + // Mem_fun adaptor helper functions. There are only two: + // mem_fun and mem_fun_ref. + template + inline mem_fun_t<_Ret, _Tp> + mem_fun(_Ret (_Tp::*__f)()) + { return mem_fun_t<_Ret, _Tp>(__f); } + + template + inline const_mem_fun_t<_Ret, _Tp> + mem_fun(_Ret (_Tp::*__f)() const) + { return const_mem_fun_t<_Ret, _Tp>(__f); } + + template + inline mem_fun_ref_t<_Ret, _Tp> + mem_fun_ref(_Ret (_Tp::*__f)()) + { return mem_fun_ref_t<_Ret, _Tp>(__f); } + + template + 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 + inline mem_fun1_t<_Ret, _Tp, _Arg> + mem_fun(_Ret (_Tp::*__f)(_Arg)) + { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); } + + template + 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 + 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 + 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); } + + /** @} */ + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED +# include +#endif + +#endif /* _STL_FUNCTION_H */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_function.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_function.h.blob new file mode 100644 index 0000000..2818a4f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_function.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_heap.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_heap.h new file mode 100644 index 0000000..52e3a3b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_heap.h @@ -0,0 +1,583 @@ +// Heap implementation -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_heap.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_heap.h.blob new file mode 100644 index 0000000..b75e79e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_heap.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator.h new file mode 100644 index 0000000..3ff38b9 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator.h @@ -0,0 +1,2237 @@ +// Iterators -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +#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 > 201703L +# include +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup iterators + * @{ + */ + +#if __cplusplus > 201703L && __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 + + // 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> + { + protected: + _Iterator current; + + typedef iterator_traits<_Iterator> __traits_type; + + public: + typedef _Iterator iterator_type; + typedef typename __traits_type::difference_type difference_type; + typedef typename __traits_type::pointer pointer; + typedef typename __traits_type::reference reference; + +#if __cplusplus > 201703L && __cpp_lib_concepts + using iterator_concept + = conditional_t, + random_access_iterator_tag, + bidirectional_iterator_tag>; + using iterator_category + = __detail::__clamp_iter_cat; +#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() : current() { } + + /** + * This %iterator will move in the opposite direction that @p x does. + */ + explicit _GLIBCXX17_CONSTEXPR + reverse_iterator(iterator_type __x) : current(__x) { } + + /** + * The copy constructor is normal. + */ + _GLIBCXX17_CONSTEXPR + reverse_iterator(const reverse_iterator& __x) + : 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 + _GLIBCXX17_CONSTEXPR + reverse_iterator(const reverse_iterator<_Iter>& __x) + : current(__x.base()) { } + + /** + * @return @c current, the %iterator used for underlying work. + */ + _GLIBCXX17_CONSTEXPR iterator_type + base() const + { 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 + */ + _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. + */ + _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. + */ + _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. + */ + _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. + */ + _GLIBCXX17_CONSTEXPR reference + operator[](difference_type __n) const + { return *(*this + __n); } + +#if __cplusplus > 201703L && __cpp_lib_concepts + 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 + inline _GLIBCXX17_CONSTEXPR bool + operator==(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __x.base() == __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __y.base() < __x.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return !(__x == __y); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __y < __x; } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return !(__y < __x); } + + template + 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 + 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 __y.base() < __x.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return !(__x == __y); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __y < __x; } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return !(__y < __x); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return !(__x < __y); } +#else // C++20 + template + 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 + 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 + 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 + 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 + 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 + 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> + constexpr compare_three_way_result_t<_IteratorL, _IteratorR> + operator<=>(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __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 + 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 + 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 201402 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 2285. make_reverse_iterator + /// Generator function for reverse_iterator. + template + 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; + + constexpr back_insert_iterator() noexcept : container(nullptr) { } +#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. + _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 + _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; + + constexpr front_insert_iterator() noexcept : container(nullptr) { } +#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. + _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 + _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>; + + protected: + _Container* container = nullptr; + _Iter iter = _Iter(); +#else + typedef typename _Container::iterator _Iter; + + protected: + _Container* container; + _Iter iter; +#endif + + 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; + + insert_iterator() = default; +#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. + _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; } + }; + + /** + * @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 + constexpr insert_iterator<_Container> + inserter(_Container& __x, std::__detail::__range_iter_t<_Container> __i) + { return insert_iterator<_Container>(__x, __i); } +#else + template + inline insert_iterator<_Container> + inserter(_Container& __x, _Iterator __i) + { + return insert_iterator<_Container>(__x, + typename _Container::iterator(__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; + + 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 + template + _GLIBCXX20_CONSTEXPR + __normal_iterator(const __normal_iterator<_Iter, + typename __enable_if< + (std::__are_same<_Iter, typename _Container::pointer>::__value), + _Container>::__type>& __i) _GLIBCXX_NOEXCEPT + : _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 + requires requires (_IteratorL __lhs, _IteratorR __rhs) + { { __lhs == __rhs } -> std::convertible_to; } + constexpr bool + operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + noexcept(noexcept(__lhs.base() == __rhs.base())) + { return __lhs.base() == __rhs.base(); } + + template + 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()); } +#else + // Forward iterator requirements + template + _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 + _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 + _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 + _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 + inline bool + operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() < __rhs.base(); } + + template + _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 + inline bool + operator>(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() > __rhs.base(); } + + template + _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 + inline bool + operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() <= __rhs.base(); } + + template + _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 + inline bool + operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() >= __rhs.base(); } + + template + _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. + _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 + _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 + _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 + /** + * @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; + } + + constexpr _Sent + base() const + noexcept(is_nothrow_copy_constructible_v<_Sent>) + { return _M_last; } + + private: + _Sent _M_last; + }; +#endif // C++20 + + // 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 + { + _Iterator _M_current; + + using __traits_type = iterator_traits<_Iterator>; +#if __cplusplus > 201703L && __cpp_lib_concepts + using __base_cat = typename __traits_type::iterator_category; +#else + using __base_ref = typename __traits_type::reference; +#endif + + public: + using iterator_type = _Iterator; + +#if __cplusplus > 201703L && __cpp_lib_concepts + using iterator_concept = input_iterator_tag; + using iterator_category + = __detail::__clamp_iter_cat<__base_cat, random_access_iterator_tag>; + 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 + typedef typename conditional::value, + typename remove_reference<__base_ref>::type&&, + __base_ref>::type reference; +#endif + + _GLIBCXX17_CONSTEXPR + move_iterator() + : _M_current() { } + + explicit _GLIBCXX17_CONSTEXPR + move_iterator(iterator_type __i) + : _M_current(std::move(__i)) { } + + template + _GLIBCXX17_CONSTEXPR + move_iterator(const move_iterator<_Iter>& __i) + : _M_current(__i.base()) { } + +#if __cplusplus <= 201703L + _GLIBCXX17_CONSTEXPR iterator_type + base() const + { return _M_current; } +#else + constexpr iterator_type + base() const & +#if __cpp_lib_concepts + requires copy_constructible +#endif + { return _M_current; } + + constexpr iterator_type + base() && + { return std::move(_M_current); } +#endif + + _GLIBCXX17_CONSTEXPR reference + operator*() const +#if __cplusplus > 201703L && __cpp_lib_concepts + { return ranges::iter_move(_M_current); } +#else + { return static_cast(*_M_current); } +#endif + + _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; + } + + _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; + } + + _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; + } + + _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> + friend constexpr bool + operator==(const move_iterator& __x, const move_sentinel<_Sent>& __y) + { return __x.base() == __y.base(); } + + template _Sent> + friend constexpr iter_difference_t<_Iterator> + operator-(const move_sentinel<_Sent>& __x, const move_iterator& __y) + { return __x.base() - __y.base(); } + + template _Sent> + friend constexpr iter_difference_t<_Iterator> + operator-(const move_iterator& __x, const move_sentinel<_Sent>& __y) + { return __x.base() - __y.base(); } + + 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 + 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> + 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 + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return !(__x == __y); } +#endif + + template + 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 + 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 + 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 + 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); } + +#if ! (__cplusplus > 201703L && __cpp_lib_concepts) + // Note: See __normal_iterator operators note from Gaby to understand + // why we have these extra overloads for some move_iterator operators. + + // These extra overloads are not needed in C++20, because the ones above + // are constrained with a requires-clause and so overload resolution will + // prefer them to greedy unconstrained function templates. + + template + inline _GLIBCXX17_CONSTEXPR bool + operator==(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __x.base() == __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__x == __y); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __x.base() < __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__y < __x); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __y < __x; } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__x < __y); } +#endif // ! C++20 + + // DR 685. + template + 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 + inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator> + operator+(typename move_iterator<_Iterator>::difference_type __n, + const move_iterator<_Iterator>& __x) + { return __x + __n; } + + template + 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>>::type> + 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*>>::type> + 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>>); + + } // 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 _Proxy + { + iter_value_t<_It> _M_keep; + + _Proxy(iter_reference_t<_It>&& __x) + : _M_keep(std::move(__x)) { } + + friend class common_iterator; + + public: + const iter_value_t<_It>* + operator->() const + { return std::__addressof(_M_keep); } + }; + + public: + constexpr + common_iterator() + noexcept(is_nothrow_default_constructible_v<_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) + { + if (_M_index == 0) + { + if constexpr (is_trivially_default_constructible_v<_It>) + _M_it = std::move(__x._M_it); + else + ::new((void*)std::__addressof(_M_it)) _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 + ::new((void*)std::__addressof(_M_sent)) _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 = std::move(__x._M_it); + else + ::new((void*)std::__addressof(_M_it)) _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 + ::new((void*)std::__addressof(_M_sent)) _Sent(__x._M_sent); + } + } + + 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>) + { + return this->operator=<_It, _Sent>(__x); + } + + template + requires convertible_to + && convertible_to + && assignable_from<_It&, const _It2&> + && assignable_from<_Sent&, const _Sent2&> + 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&>) + { + switch(_M_index << 2 | __x._M_index) + { + case 0b0000: + _M_it = __x._M_it; + break; + case 0b0101: + _M_sent = __x._M_sent; + break; + case 0b0001: + _M_it.~_It(); + _M_index = -1; + [[fallthrough]]; + case 0b1001: + ::new((void*)std::__addressof(_M_sent)) _Sent(__x._M_sent); + _M_index = 1; + break; + case 0b0100: + _M_sent.~_Sent(); + _M_index = -1; + [[fallthrough]]; + case 0b1000: + ::new((void*)std::__addressof(_M_it)) _It(__x._M_it); + _M_index = 0; + break; + default: + __glibcxx_assert(__x._M_has_value()); + __builtin_unreachable(); + } + return *this; + } + + ~common_iterator() + { + switch (_M_index) + { + case 0: + _M_it.~_It(); + break; + case 1: + _M_sent.~_Sent(); + break; + } + } + + decltype(auto) + operator*() + { + __glibcxx_assert(_M_index == 0); + return *_M_it; + } + + decltype(auto) + operator*() const requires __detail::__dereferenceable + { + __glibcxx_assert(_M_index == 0); + return *_M_it; + } + + decltype(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 _Proxy{*_M_it}; + } + + common_iterator& + operator++() + { + __glibcxx_assert(_M_index == 0); + ++_M_it; + return *this; + } + + decltype(auto) + operator++(int) + { + __glibcxx_assert(_M_index == 0); + if constexpr (forward_iterator<_It>) + { + common_iterator __tmp = *this; + ++*this; + return __tmp; + } + else + return _M_it++; + } + + template _Sent2> + requires sentinel_for<_Sent, _It2> + friend bool + operator==(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 bool + operator==(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 iter_difference_t<_It2> + operator-(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(); + } + } + + friend 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 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> + friend class common_iterator; + + bool _M_has_value() const noexcept { return _M_index < 2; } + + union + { + _It _M_it; + _Sent _M_sent; + unsigned char _M_valueless; + }; + unsigned char _M_index; // 0==_M_it, 1==_M_sent, 2==valueless + }; + + 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->()); + }; + + public: + using iterator_concept = conditional_t, + forward_iterator_tag, input_iterator_tag>; + using iterator_category = __detail::__clamp_iter_cat< + typename iterator_traits<_It>::iterator_category, + forward_iterator_tag, input_iterator_tag>; + 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 + + /// An iterator adaptor that keeps track of the distance to the end. + template + class counted_iterator + { + public: + using iterator_type = _It; + + constexpr counted_iterator() = 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; + } + + constexpr _It + base() const & + noexcept(is_nothrow_copy_constructible_v<_It>) + requires copy_constructible<_It> + { return _M_current; } + + constexpr _It + base() && + noexcept(is_nothrow_move_constructible_v<_It>) + { return std::move(_M_current); } + + constexpr iter_difference_t<_It> + count() const noexcept { return _M_length; } + + constexpr decltype(auto) + operator*() + noexcept(noexcept(*_M_current)) + { return *_M_current; } + + constexpr decltype(auto) + operator*() const + noexcept(noexcept(*_M_current)) + requires __detail::__dereferenceable + { return *_M_current; } + + constexpr counted_iterator& + operator++() + { + __glibcxx_assert(_M_length > 0); + ++_M_current; + --_M_length; + return *this; + } + + 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; + } + + constexpr counted_iterator + operator+(iter_difference_t<_It> __n) const + requires random_access_iterator<_It> + { return counted_iterator(_M_current + __n, _M_length - __n); } + + 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; + } + + 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> + friend constexpr iter_difference_t<_It2> + operator-(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + { return __y._M_length - __x._M_length; } + + friend constexpr iter_difference_t<_It> + operator-(const counted_iterator& __x, default_sentinel_t) + { return -__x._M_length; } + + 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; + } + + 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> + friend constexpr bool + operator==(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + { return __x._M_length == __y._M_length; } + + friend constexpr bool + operator==(const counted_iterator& __x, default_sentinel_t) + { return __x._M_length == 0; } + + template _It2> + friend constexpr strong_ordering + operator<=>(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + { return __y._M_length <=> __x._M_length; } + + 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> + { 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))) + { 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 + struct incrementable_traits> + { + using difference_type = iter_difference_t<_It>; + }; + + template + struct iterator_traits> : iterator_traits<_It> + { + using pointer = void; + }; +#endif // C++20 + + // @} group iterators + + template + 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 + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator.h.blob new file mode 100644 index 0000000..6a7150a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_funcs.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_funcs.h new file mode 100644 index 0000000..076b778 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_funcs.h @@ -0,0 +1,239 @@ +// Functions used by iterators -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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 + + /** + * @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 + 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; + } + + /** + * @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 + 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 + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_funcs.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_funcs.h.blob new file mode 100644 index 0000000..6c3aaf0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_funcs.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_types.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_types.h new file mode 100644 index 0000000..aa02af5 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_types.h @@ -0,0 +1,271 @@ +// Types used in iterator implementation -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_types.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_types.h.blob new file mode 100644 index 0000000..8532e0c Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_iterator_base_types.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_pair.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_pair.h new file mode 100644 index 0000000..491c599 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_pair.h @@ -0,0 +1,586 @@ +// Pair implementation -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +#include // for std::move / std::forward, and std::swap + +#if __cplusplus >= 201103L +# include // for std::__decay_and_strip, std::is_reference_v +#endif +#if __cplusplus > 201703L +# 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; + + // 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 + static constexpr bool _CopyMovePair() + { + using __do_converts = __and_, + is_convertible<_U2&&, _T2>>; + using __converts = typename conditional<__implicit, + __do_converts, + __not_<__do_converts>>::type; + return __and_, + is_constructible<_T2, _U2&&>, + __converts + >::value; + } + + template + static constexpr bool _MoveCopyPair() + { + using __do_converts = __and_, + is_convertible>; + using __converts = typename conditional<__implicit, + __do_converts, + __not_<__do_converts>>::type; + return __and_, + is_constructible<_T2, const _U2&&>, + __converts + >::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 // C++11 + + template class __pair_base + { +#if __cplusplus >= 201103L + 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 + : private __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 + + // _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. */ +#if __cplusplus >= 201103L + template , + __is_implicitly_default_constructible<_U2>> + ::value, bool>::type = true> +#endif + _GLIBCXX_CONSTEXPR pair() + : first(), second() { } + +#if __cplusplus >= 201103L + 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() { } +#endif + +#if __cplusplus < 201103L + /// Two objects may be passed to a @c pair constructor to be copied. + pair(const _T1& __a, const _T2& __b) + : first(__a), second(__b) { } +#else + // 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) { } +#endif + +#if __cplusplus < 201103L + /// There is also a templated constructor to convert from other pairs. + template + pair(const pair<_U1, _U2>& __p) + : first(__p.first), second(__p.second) { } +#else + // 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) { } +#endif + +#if __cplusplus >= 201103L + constexpr pair(const pair&) = default; ///< Copy constructor + constexpr pair(pair&&) = default; ///< Move constructor + + // DR 811. + template(), + bool>::type=true> + constexpr pair(_U1&& __x, const _T2& __y) + : first(std::forward<_U1>(__x)), second(__y) { } + + template(), + bool>::type=false> + explicit constexpr pair(_U1&& __x, const _T2& __y) + : first(std::forward<_U1>(__x)), second(__y) { } + + template(), + bool>::type=true> + constexpr pair(const _T1& __x, _U2&& __y) + : first(__x), second(std::forward<_U2>(__y)) { } + + template(), + bool>::type=false> + explicit pair(const _T1& __x, _U2&& __y) + : first(__x), second(std::forward<_U2>(__y)) { } + + 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)) { } + + template + _GLIBCXX20_CONSTEXPR + pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>); + + _GLIBCXX20_CONSTEXPR pair& + operator=(typename conditional< + __and_, + is_copy_assignable<_T2>>::value, + const pair&, const __nonesuch&>::type __p) + { + first = __p.first; + second = __p.second; + return *this; + } + + _GLIBCXX20_CONSTEXPR pair& + operator=(typename conditional< + __and_, + is_move_assignable<_T2>>::value, + pair&&, __nonesuch&&>::type __p) + noexcept(__and_, + is_nothrow_move_assignable<_T2>>::value) + { + first = std::forward(__p.first); + second = std::forward(__p.second); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + 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 + _GLIBCXX20_CONSTEXPR + 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; + } + + /// 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...>); +#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 + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_PAIR_H */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_pair.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_pair.h.blob new file mode 100644 index 0000000..c2b8114 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_pair.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_raw_storage_iter.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_raw_storage_iter.h new file mode 100644 index 0000000..df7a5f9 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_raw_storage_iter.h @@ -0,0 +1,123 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + + /** + * This iterator class lets algorithms store their results into + * uninitialized memory. + */ + template + class 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; } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_raw_storage_iter.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_raw_storage_iter.h.blob new file mode 100644 index 0000000..a77fa47 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_raw_storage_iter.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_relops.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_relops.h new file mode 100644 index 0000000..3b0afea --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_relops.h @@ -0,0 +1,133 @@ +// std::rel_ops implementation -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 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} + * + * Inclusion of this file has been removed from + * all of the other STL headers for safety reasons, except std_utility.h. + * For more information, see the thread of about twenty messages starting + * with http://gcc.gnu.org/ml/libstdc++/2001-01/msg00223.html, or + * http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.ambiguous_overloads + * + * Short summary: the rel_ops operators should be avoided for the present. + */ + +#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. + */ + + /** + * @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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_relops.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_relops.h.blob new file mode 100644 index 0000000..52d10c0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_relops.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_tempbuf.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_tempbuf.h new file mode 100644 index 0000000..f6f1796 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_tempbuf.h @@ -0,0 +1,284 @@ +// Temporary buffer implementation -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + 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 /= 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_tempbuf.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_tempbuf.h.blob new file mode 100644 index 0000000..f49b0a7 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_tempbuf.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_uninitialized.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_uninitialized.h new file mode 100644 index 0000000..3109a89 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_uninitialized.h @@ -0,0 +1,1041 @@ +// Raw memory manipulators -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 > 201402L +#include +#endif + +#if __cplusplus >= 201103L +#include +#endif + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @addtogroup memory + * @{ + */ + + /// @cond undocumented + + template + struct __uninitialized_copy + { + template + static _ForwardIterator + __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::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; +#if __cplusplus < 201103L + const bool __assignable = true; +#else + // Trivial types can have deleted copy constructor, but the std::copy + // optimization that uses memmove would happily "copy" them anyway. + static_assert(is_constructible<_ValueType2, decltype(*__first)>::value, + "result type must be constructible from value type of input range"); + + typedef typename iterator_traits<_InputIterator>::reference _RefType1; + typedef typename iterator_traits<_ForwardIterator>::reference _RefType2; + // Trivial types can have deleted assignment, so using std::copy + // would be ill-formed. Require assignability before using std::copy: + const bool __assignable = is_assignable<_RefType2, _RefType1>::value; +#endif + + return std::__uninitialized_copy<__is_trivial(_ValueType1) + && __is_trivial(_ValueType2) + && __assignable>:: + __uninit_copy(__first, __last, __result); + } + + /// @cond undocumented + + template + struct __uninitialized_fill + { + template + static void + __uninit_fill(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x) + { + _ForwardIterator __cur = __first; + __try + { + for (; __cur != __last; ++__cur) + std::_Construct(std::__addressof(*__cur), __x); + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + 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; +#if __cplusplus < 201103L + const bool __assignable = true; +#else + // Trivial types can have deleted copy constructor, but the std::fill + // optimization that uses memmove would happily "copy" them anyway. + static_assert(is_constructible<_ValueType, const _Tp&>::value, + "result type must be constructible from input type"); + + // Trivial types can have deleted assignment, so using std::fill + // would be ill-formed. Require assignability before using std::fill: + const bool __assignable = is_copy_assignable<_ValueType>::value; +#endif + + std::__uninitialized_fill<__is_trivial(_ValueType) && __assignable>:: + __uninit_fill(__first, __last, __x); + } + + /// @cond undocumented + + template + struct __uninitialized_fill_n + { + template + static _ForwardIterator + __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::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; +#if __cplusplus < 201103L + const bool __assignable = true; +#else + // Trivial types can have deleted copy constructor, but the std::fill + // optimization that uses memmove would happily "copy" them anyway. + static_assert(is_constructible<_ValueType, const _Tp&>::value, + "result type must be constructible from input type"); + + // Trivial types can have deleted assignment, so using std::fill + // would be ill-formed. Require assignability before using std::fill: + const bool __assignable = is_copy_assignable<_ValueType>::value; +#endif + return __uninitialized_fill_n<__is_trivial(_ValueType) && __assignable>:: + __uninit_fill_n(__first, __n, __x); + } + + /// @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 + _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 + inline _ForwardIterator + __uninitialized_copy_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, allocator<_Tp>&) + { return std::uninitialized_copy(__first, __last, __result); } + + template + 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 + 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 + 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 + inline void + __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x, allocator<_Tp2>&) + { std::uninitialized_fill(__first, __last, __x); } + + template + _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 + inline _ForwardIterator + __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, + const _Tp& __x, allocator<_Tp2>&) + { 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) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + + std::fill(__first, __last, _ValueType()); + } + }; + + template + struct __uninitialized_default_n_1 + { + template + 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 + static _ForwardIterator + __uninit_default_n(_ForwardIterator __first, _Size __n) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + + return std::fill_n(__first, __n, _ValueType()); + } + }; + + // __uninitialized_default + // Fills [first, last) with std::distance(first, last) default + // constructed value_types(s). + 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 n default constructed value_type(s). + template + inline _ForwardIterator + __uninitialized_default_n(_ForwardIterator __first, _Size __n) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + // trivial types can have deleted assignment + const bool __assignable = is_copy_assignable<_ValueType>::value; + + return __uninitialized_default_n_1<__is_trivial(_ValueType) + && __assignable>:: + __uninit_default_n(__first, __n); + } + + + // __uninitialized_default_a + // Fills [first, last) with std::distance(first, last) default + // constructed value_types(s), constructed with the allocator alloc. + 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 n default constructed value_types(s), + // constructed with the allocator alloc. + template + _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; + } + } + + template + 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 std::distance(first, last) default-initialized + // value_types(s). + 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_n + // Fills [first, first + n) with n default-initialized value_type(s). + 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 + * + * 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. + */ + 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 + */ + 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. + */ + 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 + */ + 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) + */ + 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 + */ + 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 + 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 + inline __enable_if_t::value, _Tp*> + __relocate_a_1(_Tp* __first, _Tp* __last, + _Tp* __result, allocator<_Up>&) noexcept + { + ptrdiff_t __count = __last - __first; + if (__count > 0) + __builtin_memmove(__result, __first, __count * sizeof(_Tp)); + return __result + __count; + } + + template + 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 + 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 __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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_uninitialized.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_uninitialized.h.blob new file mode 100644 index 0000000..76cc611 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_uninitialized.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_vector.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_vector.h new file mode 100644 index 0000000..d3f1b1f --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_vector.h @@ -0,0 +1,1985 @@ +// Vector implementation -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 > 201703L +# include +#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; + + _Vector_impl_data() _GLIBCXX_NOEXCEPT + : _M_start(), _M_finish(), _M_end_of_storage() + { } + +#if __cplusplus >= 201103L + _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 + + 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; + } + + 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 + { + _Vector_impl() _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Tp_alloc_type>::value) + : _Tp_alloc_type() + { } + + _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>. + _Vector_impl(_Vector_impl&& __x) noexcept + : _Tp_alloc_type(std::move(__x)), _Vector_impl_data(std::move(__x)) + { } + + _Vector_impl(_Tp_alloc_type&& __a) noexcept + : _Tp_alloc_type(std::move(__a)) + { } + + _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 void _S_shrink(_Vector_impl&, size_type) { } + static void _S_on_dealloc(_Vector_impl&) { } + + typedef _Vector_impl& _Reinit; + + struct _Grow + { + _Grow(_Vector_impl&, size_type) { } + 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 void + _S_adjust(_Vector_impl& __impl, pointer __prev, pointer __curr) + { + __sanitizer_annotate_contiguous_container(__impl._M_start, + __impl._M_end_of_storage, __prev, __curr); + } + + static void + _S_grow(_Vector_impl& __impl, size_type __n) + { _S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); } + + static void + _S_shrink(_Vector_impl& __impl, size_type __n) + { _S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); } + + static 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 _Reinit(_Vector_impl& __impl) : _M_impl(__impl) + { + // Mark unused capacity as valid again before deallocating it. + _S_on_dealloc(_M_impl); + } + + ~_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 + { + _Grow(_Vector_impl& __impl, size_type __n) + : _M_impl(__impl), _M_n(__n) + { _S_grow(_M_impl, __n); } + + ~_Grow() { if (_M_n) _S_shrink(_M_impl, _M_n); } + + 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; + + _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; } + + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_get_Tp_allocator()); } + +#if __cplusplus >= 201103L + _Vector_base() = default; +#else + _Vector_base() { } +#endif + + _Vector_base(const allocator_type& __a) _GLIBCXX_NOEXCEPT + : _M_impl(__a) { } + + // Kept for ABI compatibility. +#if !_GLIBCXX_INLINE_VERSION + _Vector_base(size_t __n) + : _M_impl() + { _M_create_storage(__n); } +#endif + + _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 + _Vector_base(_Tp_alloc_type&& __a) noexcept + : _M_impl(std::move(__a)) { } + + _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 + + _Vector_base(const allocator_type& __a, _Vector_base&& __x) + : _M_impl(_Tp_alloc_type(__a), std::move(__x._M_impl)) + { } +#endif + + ~_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; + + pointer + _M_allocate(size_t __n) + { + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr; + return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer(); + } + + 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: + 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 pointer + _S_relocate(pointer __first, pointer __last, pointer __result, + _Tp_alloc_type& __alloc) noexcept + { + using __do_it = __bool_constant<_S_use_relocate()>; + return _S_do_relocate(__first, __last, __result, __alloc, __do_it{}); + } +#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 + 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 + 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. + */ + 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). + */ + 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 + vector(const vector& __x, const allocator_type& __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: + vector(vector&& __rv, const allocator_type& __m, true_type) noexcept + : _Base(__m, std::move(__rv)) + { } + + 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 + vector(vector&& __rv, const allocator_type& __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. + */ + 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> + 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. + */ + ~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. + */ + 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. + */ + 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. + */ + 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. + */ + 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> + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. */ + 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. */ + 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. + */ + 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. + */ + 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. + */ + 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(). */ + 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. + */ + 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 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. + */ + 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().) + */ + 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().) + */ + 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(). + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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(). + */ + _Tp* + data() _GLIBCXX_NOEXCEPT + { return _M_data_ptr(this->_M_impl._M_start); } + + 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. + */ + 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 + 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 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. + */ + 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 + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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> + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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 + 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 + 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 + 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. + 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. + 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 + 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)); } + + // 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); + + // 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); + + // 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 + 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 + 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 + void + _M_range_insert(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag); + + // Called by the second insert_dispatch above + template + 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. + void + _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); + +#if __cplusplus >= 201103L + // Called by resize(n). + void + _M_default_append(size_type __n); + + 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 + explicit + _Temporary_value(vector* __vec, _Args&&... __args) : _M_this(__vec) + { + _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(), + std::forward<_Args>(__args)...); + } + + ~_Temporary_value() + { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); } + + value_type& + _M_val() { return *_M_ptr(); } + + private: + _Tp* + _M_ptr() { return reinterpret_cast<_Tp*>(&__buf); } + + vector* _M_this; + typename aligned_storage::type __buf; + }; + + // Called by insert(p,x) and other functions when insertion needs to + // reallocate or move existing elements. _Arg is either _Tp& or _Tp. + template + void + _M_insert_aux(iterator __position, _Arg&& __arg); + + template + void + _M_realloc_insert(iterator __position, _Args&&... __args); + + // Either move-construct at the end, or forward to _M_insert_aux. + iterator + _M_insert_rval(const_iterator __position, value_type&& __v); + + // Try to emplace at the end, otherwise forward to _M_insert_aux. + template + iterator + _M_emplace_aux(const_iterator __position, _Args&&... __args); + + // Emplacing an rvalue of the correct type can use _M_insert_rval. + 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. + 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 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 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. + 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); + } + } + + iterator + _M_erase(iterator __position); + + 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. + 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. + 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 + _Up* + _M_data_ptr(_Up* __ptr) const _GLIBCXX_NOEXCEPT + { return __ptr; } + +#if __cplusplus >= 201103L + template + 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 + 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 + 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 + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_vector.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_vector.h.blob new file mode 100644 index 0000000..df76968 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stl_vector.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf.tcc new file mode 100644 index 0000000..9d79946 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf.tcc @@ -0,0 +1,175 @@ +// Stream buffer classes -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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*); + extern template + streamsize + __copy_streambufs_eof(basic_streambuf*, + basic_streambuf*, bool&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_streambuf; + extern template + streamsize + __copy_streambufs(basic_streambuf*, + basic_streambuf*); + extern template + streamsize + __copy_streambufs_eof(basic_streambuf*, + basic_streambuf*, bool&); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf.tcc.blob new file mode 100644 index 0000000..81d2f0e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf_iterator.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf_iterator.h new file mode 100644 index 0000000..d3f1610 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf_iterator.h @@ -0,0 +1,507 @@ +// Streambuf iterators + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + * @{ + */ + + // 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*); + +#if __cplusplus >= 201103L + template + friend __enable_if_t<__is_char<_CharT2>::__value, _CharT2*> + __copy_n_a(istreambuf_iterator<_CharT2>, _Size, _CharT2*); +#endif + + 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. + 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. + 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 + friend bool + operator==(const istreambuf_iterator& __i, default_sentinel_t __s) + { return __i._M_at_eof(); } +#endif + }; + + template + inline bool + operator==(const istreambuf_iterator<_CharT, _Traits>& __a, + const istreambuf_iterator<_CharT, _Traits>& __b) + { return __a.equal(__b); } + + template + inline bool + operator!=(const istreambuf_iterator<_CharT, _Traits>& __a, + const istreambuf_iterator<_CharT, _Traits>& __b) + { return !__a.equal(__b); } + + /// 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. + 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. + 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; + } + }; + + // 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; + } + +#if __cplusplus >= 201103L + template + __enable_if_t<__is_char<_CharT>::__value, _CharT*> + __copy_n_a(istreambuf_iterator<_CharT> __it, _Size __n, _CharT* __result) + { + 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(__result - __beg == __n, + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(__it)); + return __result; + } +#endif // C++11 + + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf_iterator.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf_iterator.h.blob new file mode 100644 index 0000000..2a8df70 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@streambuf_iterator.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stringfwd.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stringfwd.h new file mode 100644 index 0000000..e4220ec --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stringfwd.h @@ -0,0 +1,104 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> struct char_traits; +#endif + +#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; + +#ifdef _GLIBCXX_USE_WCHAR_T + /// A string of @c wchar_t + typedef basic_string wstring; +#endif + +#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/@@home@ado@git@ssp/@usr@include@c++@10@bits@stringfwd.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stringfwd.h.blob new file mode 100644 index 0000000..8d58921 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@stringfwd.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uniform_int_dist.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uniform_int_dist.h new file mode 100644 index 0000000..e3d7934 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uniform_int_dist.h @@ -0,0 +1,395 @@ +// Class template uniform_int_distribution -*- C++ -*- + +// Copyright (C) 2009-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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 2. */ + template + inline 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 = numeric_limits<_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 = numeric_limits<_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()(_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 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, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + template + template + typename uniform_int_distribution<_IntType>::result_type + uniform_int_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + typedef typename _UniformRandomNumberGenerator::result_type + _Gresult_type; + typedef typename std::make_unsigned::type __utype; + typedef typename std::common_type<_Gresult_type, __utype>::type + __uctype; + + const __uctype __urngmin = __urng.min(); + const __uctype __urngmax = __urng.max(); + const __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 + 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, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + typedef typename _UniformRandomNumberGenerator::result_type + _Gresult_type; + typedef typename std::make_unsigned::type __utype; + typedef typename std::common_type<_Gresult_type, __utype>::type + __uctype; + + const __uctype __urngmin = __urng.min(); + const __uctype __urngmax = __urng.max(); + const __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 + { + const __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/@@home@ado@git@ssp/@usr@include@c++@10@bits@uniform_int_dist.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uniform_int_dist.h.blob new file mode 100644 index 0000000..a5408f6 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uniform_int_dist.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@unique_ptr.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@unique_ptr.h new file mode 100644 index 0000000..d0e4cef --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@unique_ptr.h @@ -0,0 +1,1011 @@ +// unique_ptr implementation -*- C++ -*- + +// Copyright (C) 2008-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#include +#if __cplusplus > 201703L +# include +# include +#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 + 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>> + default_delete(const default_delete<_Up>&) noexcept { } + + /// Calls `delete __ptr` + 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>> + default_delete(const default_delete<_Up[]>&) noexcept { } + + /// Calls `delete[] __ptr` + template + 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; + __uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; } + + template + __uniq_ptr_impl(pointer __p, _Del&& __d) + : _M_t(__p, std::forward<_Del>(__d)) { } + + __uniq_ptr_impl(__uniq_ptr_impl&& __u) noexcept + : _M_t(std::move(__u._M_t)) + { __u._M_ptr() = nullptr; } + + __uniq_ptr_impl& operator=(__uniq_ptr_impl&& __u) noexcept + { + reset(__u.release()); + _M_deleter() = std::forward<_Dp>(__u._M_deleter()); + return *this; + } + + pointer& _M_ptr() { return std::get<0>(_M_t); } + pointer _M_ptr() const { return std::get<0>(_M_t); } + _Dp& _M_deleter() { return std::get<1>(_M_t); } + const _Dp& _M_deleter() const { return std::get<1>(_M_t); } + + void reset(pointer __p) noexcept + { + const pointer __old_p = _M_ptr(); + _M_ptr() = __p; + if (__old_p) + _M_deleter()(__old_p); + } + + pointer release() noexcept + { + pointer __p = _M_ptr(); + _M_ptr() = nullptr; + return __p; + } + + 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. + 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> + 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>> + 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>> + unique_ptr(pointer __p, + __enable_if_t::value, + _Del&&> __d) noexcept + : _M_t(__p, std::move(__d)) + { } + + template::type> + 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, + typename conditional::value, + is_same<_Ep, _Dp>, + is_convertible<_Ep, _Dp>>::type>> + 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. + ~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 + 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. + unique_ptr& + operator=(nullptr_t) noexcept + { + reset(); + return *this; + } + + // Observers. + + /// Dereference the stored pointer. + typename add_lvalue_reference::type + operator*() const + { + __glibcxx_assert(get() != pointer()); + return *get(); + } + + /// Return the stored pointer. + pointer + operator->() const noexcept + { + _GLIBCXX_DEBUG_PEDASSERT(get() != pointer()); + return get(); + } + + /// Return the stored pointer. + pointer + get() const noexcept + { return _M_t._M_ptr(); } + + /// Return a reference to the stored deleter. + deleter_type& + get_deleter() noexcept + { return _M_t._M_deleter(); } + + /// Return a reference to the stored deleter. + const deleter_type& + get_deleter() const noexcept + { return _M_t._M_deleter(); } + + /// Return @c true if the stored pointer is not null. + explicit operator bool() const noexcept + { return get() == pointer() ? false : true; } + + // Modifiers. + + /// Release ownership of any stored pointer. + 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. + */ + 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. + 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 + 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> + 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>>> + 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>>> + 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, + typename conditional::value, + is_same<_Ep, _Dp>, + is_convertible<_Ep, _Dp>>::type>> + 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. + ~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 + 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. + unique_ptr& + operator=(nullptr_t) noexcept + { + reset(); + return *this; + } + + // Observers. + + /// Access an element of owned array. + typename std::add_lvalue_reference::type + operator[](size_t __i) const + { + __glibcxx_assert(get() != pointer()); + return get()[__i]; + } + + /// Return the stored pointer. + pointer + get() const noexcept + { return _M_t._M_ptr(); } + + /// Return a reference to the stored deleter. + deleter_type& + get_deleter() noexcept + { return _M_t._M_deleter(); } + + /// Return a reference to the stored deleter. + const deleter_type& + get_deleter() const noexcept + { return _M_t._M_deleter(); } + + /// Return @c true if the stored pointer is not null. + explicit operator bool() const noexcept + { return get() == pointer() ? false : true; } + + // Modifiers. + + /// Release ownership of any stored pointer. + 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(*)[] + > + > + > + >> + void + reset(_Up __p) noexcept + { _M_t.reset(std::move(__p)); } + + void reset(nullptr_t = nullptr) noexcept + { reset(pointer()); } + + /// Exchange the pointer and deleter with another object. + 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 + 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 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 !__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 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 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 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 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 inline bool + operator<=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { return !(nullptr < __x); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD 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 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 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 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 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 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> + 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> + 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 + /// @relates unique_ptr @{ +#define __cpp_lib_make_unique 201304 + + /// @cond undocumented + + 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 { }; }; + + /// @endcond + + /// std::make_unique for single objects + template + inline typename _MakeUniq<_Tp>::__single_object + make_unique(_Args&&... __args) + { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); } + + /// std::make_unique for arrays of unknown bound + template + inline typename _MakeUniq<_Tp>::__array + make_unique(size_t __num) + { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); } + + /// Disable std::make_unique for arrays of known bound + template + inline typename _MakeUniq<_Tp>::__invalid_type + make_unique(_Args&&...) = delete; + // @} relates unique_ptr +#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 + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@unique_ptr.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@unique_ptr.h.blob new file mode 100644 index 0000000..2b9dfce Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@unique_ptr.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uses_allocator.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uses_allocator.h new file mode 100644 index 0000000..1832d40 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uses_allocator.h @@ -0,0 +1,195 @@ +// Uses-allocator Construction -*- C++ -*- + +// Copyright (C) 2010-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + + // 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< + is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>::value, + __uses_alloc1<_Alloc>, + __uses_alloc2<_Alloc>>::type + { + // _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::value, + __or_<_Predicate<_Tp, allocator_arg_t, _Alloc, _Args...>, + _Predicate<_Tp, _Args..., _Alloc>>, + _Predicate<_Tp, _Args...>>::type { }; + + 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)...); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uses_allocator.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uses_allocator.h.blob new file mode 100644 index 0000000..e2b8e5b Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@uses_allocator.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@vector.tcc b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@vector.tcc new file mode 100644 index 0000000..27e6338 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@vector.tcc @@ -0,0 +1,1008 @@ +// Vector implementation (out of line) -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + 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 + 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 + 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 + 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 + 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 + vector<_Tp, _Alloc>& + vector<_Tp, _Alloc>:: + operator=(const vector<_Tp, _Alloc>& __x) + { + if (&__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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + bool + vector:: + _M_shrink_to_fit() + { + if (capacity() - size() < int(_S_word_bit)) + return false; + __try + { + _M_reallocate(size()); + 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; + using _GLIBCXX_STD_C::_S_word_bit; + using _GLIBCXX_STD_C::_Bit_type; + + 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/@@home@ado@git@ssp/@usr@include@c++@10@bits@vector.tcc.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@vector.tcc.blob new file mode 100644 index 0000000..64b78b3 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@bits@vector.tcc.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cassert b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cassert new file mode 100644 index 0000000..e1c0724 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cassert @@ -0,0 +1,44 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cassert.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cassert.blob new file mode 100644 index 0000000..ba1d4ba Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cassert.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cctype b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cctype new file mode 100644 index 0000000..0881d47 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cctype @@ -0,0 +1,94 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cctype.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cctype.blob new file mode 100644 index 0000000..3493cf6 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cctype.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cerrno b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cerrno new file mode 100644 index 0000000..83cbf24 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cerrno @@ -0,0 +1,52 @@ +// The -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cerrno.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cerrno.blob new file mode 100644 index 0000000..550233b Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cerrno.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cfloat b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cfloat new file mode 100644 index 0000000..3c20ea8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cfloat @@ -0,0 +1,56 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cfloat.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cfloat.blob new file mode 100644 index 0000000..64ee055 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cfloat.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cinttypes b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cinttypes new file mode 100644 index 0000000..fa9407b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cinttypes @@ -0,0 +1,81 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cinttypes.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cinttypes.blob new file mode 100644 index 0000000..80ee47b Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cinttypes.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@clocale b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@clocale new file mode 100644 index 0000000..076bdbc --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@clocale @@ -0,0 +1,58 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@clocale.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@clocale.blob new file mode 100644 index 0000000..86a1a7e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@clocale.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cmath b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cmath new file mode 100644 index 0000000..b99aaf8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cmath @@ -0,0 +1,1932 @@ +// -*- C++ -*- C forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 > 201402L + + // [c.math.hypot3], three-dimensional hypotenuse +#define __cpp_lib_hypot 201603 + + 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 + typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type + hypot(_Tp __x, _Up __y, _Vp __z) + { + using __type = typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type; + return std::__hypot3<__type>(__x, __y, __z); + } +#endif // C++17 + +#if __cplusplus > 201703L + // 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); } +#endif // C++20 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if _GLIBCXX_USE_STD_SPEC_FUNCS +# include +#endif + +} // extern "C++" + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cmath.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cmath.blob new file mode 100644 index 0000000..d2268a0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cmath.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@concepts b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@concepts new file mode 100644 index 0000000..e710a5e --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@concepts @@ -0,0 +1,367 @@ +// -*- C++ -*- + +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/concepts + * This is a Standard C++ Library header. + * @ingroup concepts + */ + +#ifndef _GLIBCXX_CONCEPTS +#define _GLIBCXX_CONCEPTS 1 + +#if __cplusplus > 201703L && __cpp_concepts >= 201907L + +#pragma GCC system_header + +/** + * @defgroup concepts Concepts + * @ingroup utilities + * + * Concepts for checking type requirements. + */ + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_concepts 202002L + + // [concepts.lang], language-related concepts + + namespace __detail + { + template + concept __same_as = std::is_same_v<_Tp, _Up>; + } // namespace __detail + + /// [concept.same], concept same_as + template + concept same_as + = __detail::__same_as<_Tp, _Up> && __detail::__same_as<_Up, _Tp>; + + /// [concept.derived], concept derived_from + template + concept derived_from = __is_base_of(_Base, _Derived) + && is_convertible_v; + + /// [concept.convertible], concept convertible_to + template + concept convertible_to = is_convertible_v<_From, _To> + && requires(add_rvalue_reference_t<_From> (&__f)()) { + static_cast<_To>(__f()); + }; + + /// [concept.commonref], concept common_reference_with + template + concept common_reference_with + = same_as, common_reference_t<_Up, _Tp>> + && convertible_to<_Tp, common_reference_t<_Tp, _Up>> + && convertible_to<_Up, common_reference_t<_Tp, _Up>>; + + /// [concept.common], concept common_with + template + concept common_with + = same_as, common_type_t<_Up, _Tp>> + && requires { + static_cast>(std::declval<_Tp>()); + static_cast>(std::declval<_Up>()); + } + && common_reference_with, + add_lvalue_reference_t> + && common_reference_with>, + common_reference_t< + add_lvalue_reference_t, + add_lvalue_reference_t>>; + + // [concepts.arithmetic], arithmetic concepts + + template + concept integral = is_integral_v<_Tp>; + + template + concept signed_integral = integral<_Tp> && is_signed_v<_Tp>; + + template + concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; + + template + concept floating_point = is_floating_point_v<_Tp>; + + namespace __detail + { + template + using __cref = const remove_reference_t<_Tp>&; + + template + concept __class_or_enum + = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>; + } // namespace __detail + + /// [concept.assignable], concept assignable_from + template + concept assignable_from + = is_lvalue_reference_v<_Lhs> + && common_reference_with<__detail::__cref<_Lhs>, __detail::__cref<_Rhs>> + && requires(_Lhs __lhs, _Rhs&& __rhs) { + { __lhs = static_cast<_Rhs&&>(__rhs) } -> same_as<_Lhs>; + }; + + /// [concept.destructible], concept destructible + template + concept destructible = is_nothrow_destructible_v<_Tp>; + + /// [concept.constructible], concept constructible_from + template + concept constructible_from + = destructible<_Tp> && is_constructible_v<_Tp, _Args...>; + + /// [concept.defaultinitializable], concept default_initializable + template + concept default_initializable = constructible_from<_Tp> + && requires + { + _Tp{}; + (void) ::new _Tp; + }; + + /// [concept.moveconstructible], concept move_constructible + template + concept move_constructible + = constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>; + + /// [concept.copyconstructible], concept copy_constructible + template + concept copy_constructible + = move_constructible<_Tp> + && constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> + && constructible_from<_Tp, const _Tp&> && convertible_to + && constructible_from<_Tp, const _Tp> && convertible_to; + + // [concept.swappable], concept swappable + + namespace ranges + { + namespace __cust_swap + { + template void swap(_Tp&, _Tp&) = delete; + + template + concept __adl_swap + = (__detail::__class_or_enum> + || __detail::__class_or_enum>) + && requires(_Tp&& __t, _Up&& __u) { + swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); + }; + + struct _Swap + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__adl_swap<_Tp, _Up>) + return noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())); + else + return is_nothrow_move_constructible_v> + && is_nothrow_move_assignable_v>; + } + + public: + template + requires __adl_swap<_Tp, _Up> + || (same_as<_Tp, _Up> && is_lvalue_reference_v<_Tp> + && move_constructible> + && assignable_from<_Tp, remove_reference_t<_Tp>>) + constexpr void + operator()(_Tp&& __t, _Up&& __u) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__adl_swap<_Tp, _Up>) + swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); + else + { + auto __tmp = static_cast&&>(__t); + __t = static_cast&&>(__u); + __u = static_cast&&>(__tmp); + } + } + + template + requires requires(const _Swap& __swap, _Tp& __e1, _Up& __e2) { + __swap(__e1, __e2); + } + constexpr void + operator()(_Tp (&__e1)[_Num], _Up (&__e2)[_Num]) const + noexcept(noexcept(std::declval()(*__e1, *__e2))) + { + for (size_t __n = 0; __n < _Num; ++__n) + (*this)(__e1[__n], __e2[__n]); + } + }; + } // namespace __cust_swap + + inline namespace __cust + { + inline constexpr __cust_swap::_Swap swap{}; + } // inline namespace __cust + } // namespace ranges + + template + concept swappable + = requires(_Tp& __a, _Tp& __b) { ranges::swap(__a, __b); }; + + template + concept swappable_with = common_reference_with<_Tp, _Up> + && requires(_Tp&& __t, _Up&& __u) { + ranges::swap(static_cast<_Tp&&>(__t), static_cast<_Tp&&>(__t)); + ranges::swap(static_cast<_Up&&>(__u), static_cast<_Up&&>(__u)); + ranges::swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); + ranges::swap(static_cast<_Up&&>(__u), static_cast<_Tp&&>(__t)); + }; + + // [concepts.object], Object concepts + + template + concept movable = is_object_v<_Tp> && move_constructible<_Tp> + && assignable_from<_Tp&, _Tp> && swappable<_Tp>; + + template + concept copyable = copy_constructible<_Tp> && movable<_Tp> + && assignable_from<_Tp&, _Tp&> && assignable_from<_Tp&, const _Tp&> + && assignable_from<_Tp&, const _Tp>; + + template + concept semiregular = copyable<_Tp> && default_initializable<_Tp>; + + // [concepts.compare], comparison concepts + + // [concept.booleantestable], Boolean testability + namespace __detail + { + template + concept __boolean_testable_impl = convertible_to<_Tp, bool>; + + template + concept __boolean_testable + = __boolean_testable_impl<_Tp> + && requires(_Tp&& __t) + { { !static_cast<_Tp&&>(__t) } -> __boolean_testable_impl; }; + } // namespace __detail + + // [concept.equalitycomparable], concept equality_comparable + + namespace __detail + { + template + concept __weakly_eq_cmp_with + = requires(__detail::__cref<_Tp> __t, __detail::__cref<_Up> __u) { + { __t == __u } -> __boolean_testable; + { __t != __u } -> __boolean_testable; + { __u == __t } -> __boolean_testable; + { __u != __t } -> __boolean_testable; + }; + } // namespace __detail + + template + concept equality_comparable = __detail::__weakly_eq_cmp_with<_Tp, _Tp>; + + template + concept equality_comparable_with + = equality_comparable<_Tp> && equality_comparable<_Up> + && common_reference_with<__detail::__cref<_Tp>, __detail::__cref<_Up>> + && equality_comparable, + __detail::__cref<_Up>>> + && __detail::__weakly_eq_cmp_with<_Tp, _Up>; + + namespace __detail + { + template + concept __partially_ordered_with + = requires(const remove_reference_t<_Tp>& __t, + const remove_reference_t<_Up>& __u) { + { __t < __u } -> __boolean_testable; + { __t > __u } -> __boolean_testable; + { __t <= __u } -> __boolean_testable; + { __t >= __u } -> __boolean_testable; + { __u < __t } -> __boolean_testable; + { __u > __t } -> __boolean_testable; + { __u <= __t } -> __boolean_testable; + { __u >= __t } -> __boolean_testable; + }; + } // namespace __detail + + // [concept.totallyordered], concept totally_ordered + template + concept totally_ordered + = equality_comparable<_Tp> + && __detail::__partially_ordered_with<_Tp, _Tp>; + + template + concept totally_ordered_with + = totally_ordered<_Tp> && totally_ordered<_Up> + && equality_comparable_with<_Tp, _Up> + && totally_ordered, + __detail::__cref<_Up>>> + && __detail::__partially_ordered_with<_Tp, _Up>; + + template + concept regular = semiregular<_Tp> && equality_comparable<_Tp>; + + // [concepts.callable], callable concepts + + /// [concept.invocable], concept invocable + template + concept invocable = is_invocable_v<_Fn, _Args...>; + + /// [concept.regularinvocable], concept regular_invocable + template + concept regular_invocable = invocable<_Fn, _Args...>; + + /// [concept.predicate], concept predicate + template + concept predicate = regular_invocable<_Fn, _Args...> + && __detail::__boolean_testable>; + + /// [concept.relation], concept relation + template + concept relation + = predicate<_Rel, _Tp, _Tp> && predicate<_Rel, _Up, _Up> + && predicate<_Rel, _Tp, _Up> && predicate<_Rel, _Up, _Tp>; + + /// [concept.equiv], concept equivalence_relation + template + concept equivalence_relation = relation<_Rel, _Tp, _Up>; + + /// [concept.strictweakorder], concept strict_weak_order + template + concept strict_weak_order = relation<_Rel, _Tp, _Up>; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++2a + +#endif /* _GLIBCXX_CONCEPTS */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@concepts.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@concepts.blob new file mode 100644 index 0000000..4699ba7 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@concepts.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdint b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdint new file mode 100644 index 0000000..8e742fa --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdint @@ -0,0 +1,91 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cstdint.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdint.blob new file mode 100644 index 0000000..4af44e5 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdint.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdio b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdio new file mode 100644 index 0000000..05a9ad9 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdio @@ -0,0 +1,194 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cstdio.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdio.blob new file mode 100644 index 0000000..65ad074 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdio.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdlib b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdlib new file mode 100644 index 0000000..f42db41 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdlib @@ -0,0 +1,261 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cstdlib.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdlib.blob new file mode 100644 index 0000000..e78dff1 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstdlib.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstring b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstring new file mode 100644 index 0000000..02199a8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstring @@ -0,0 +1,126 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cstring.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstring.blob new file mode 100644 index 0000000..b81b707 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cstring.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ctime b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ctime new file mode 100644 index 0000000..abac940 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ctime @@ -0,0 +1,84 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@ctime.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ctime.blob new file mode 100644 index 0000000..2efc299 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ctime.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cwchar b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cwchar new file mode 100644 index 0000000..21857fa --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cwchar @@ -0,0 +1,306 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cwchar.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cwchar.blob new file mode 100644 index 0000000..31717ed Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cwchar.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cwctype b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cwctype new file mode 100644 index 0000000..5190ce8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cwctype @@ -0,0 +1,110 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@cwctype.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cwctype.blob new file mode 100644 index 0000000..982b6fa Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@cwctype.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@debug@assertions.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@debug@assertions.h new file mode 100644 index 0000000..fb52e44 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@debug@assertions.h @@ -0,0 +1,68 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +#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(__builtin_expect(_First != _Last, true)) +# define __glibcxx_requires_subscript(_N) \ + __glibcxx_assert(__builtin_expect(_N < this->size(), true)) +// Verify that the container is nonempty +# define __glibcxx_requires_nonempty() \ + __glibcxx_assert(__builtin_expect(!this->empty(), true)) +#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/@@home@ado@git@ssp/@usr@include@c++@10@debug@assertions.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@debug@assertions.h.blob new file mode 100644 index 0000000..aec660f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@debug@assertions.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@debug@debug.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@debug@debug.h new file mode 100644 index 0000000..5c858e1 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@debug@debug.h @@ -0,0 +1,137 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@debug@debug.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@debug@debug.h.blob new file mode 100644 index 0000000..398ffdc Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@debug@debug.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@exception b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@exception new file mode 100644 index 0000000..863eb91 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@exception @@ -0,0 +1,151 @@ +// Exception Handling support header for -*- C++ -*- + +// Copyright (C) 1995-2020 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. */ + 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) (); + + /// If you write a replacement %unexpected handler, it must be of this type. + typedef void (*unexpected_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__)); + + /// Takes a new handler function as an argument, returns the old function. + unexpected_handler set_unexpected(unexpected_handler) _GLIBCXX_USE_NOEXCEPT; + +#if __cplusplus >= 201103L + /// Return the current unexpected handler. + unexpected_handler get_unexpected() noexcept; +#endif + + /** The runtime will call this function if an %exception is thrown which + * violates the function's %exception specification. */ + void unexpected() __attribute__ ((__noreturn__)); + + /** [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 @c unexpected() + * due to the throw; or after entering @c terminate() for any reason + * other than an explicit call to @c terminate(). [Note: This includes + * stack unwinding [15.2]. end note]' + * + * 2: 'When @c uncaught_exception() is true, throwing an + * %exception can result in a call of @c terminate() + * (15.5.1).' + */ + _GLIBCXX17_DEPRECATED + 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. + 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/@@home@ado@git@ssp/@usr@include@c++@10@exception.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@exception.blob new file mode 100644 index 0000000..a52cb9a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@exception.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@aligned_buffer.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@aligned_buffer.h new file mode 100644 index 0000000..667a9c0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@aligned_buffer.h @@ -0,0 +1,125 @@ +// Aligned memory buffer -*- C++ -*- + +// Copyright (C) 2013-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@ext@aligned_buffer.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@aligned_buffer.h.blob new file mode 100644 index 0000000..52b3e5a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@aligned_buffer.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@alloc_traits.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@alloc_traits.h new file mode 100644 index 0000000..3bbef9e --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@alloc_traits.h @@ -0,0 +1,171 @@ +// Allocator traits -*- C++ -*- + +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@ext@alloc_traits.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@alloc_traits.h.blob new file mode 100644 index 0000000..6c3323b Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@alloc_traits.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@atomicity.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@atomicity.h new file mode 100644 index 0000000..813ceb0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@atomicity.h @@ -0,0 +1,116 @@ +// Support for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // 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) + { +#ifdef __GTHREADS + if (__gthread_active_p()) + return __exchange_and_add(__mem, __val); +#endif + return __exchange_and_add_single(__mem, __val); + } + + inline void + __attribute__ ((__always_inline__)) + __atomic_add_dispatch(_Atomic_word* __mem, int __val) + { +#ifdef __GTHREADS + if (__gthread_active_p()) + { + __atomic_add(__mem, __val); + return; + } +#endif + __atomic_add_single(__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/@@home@ado@git@ssp/@usr@include@c++@10@ext@atomicity.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@atomicity.h.blob new file mode 100644 index 0000000..8a379a1 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@atomicity.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@concurrence.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@concurrence.h new file mode 100644 index 0000000..db3d9e7 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@concurrence.h @@ -0,0 +1,315 @@ +// Support for concurrent programing -*- C++ -*- + +// Copyright (C) 2003-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@ext@concurrence.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@concurrence.h.blob new file mode 100644 index 0000000..6ff32f5 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@concurrence.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@new_allocator.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@new_allocator.h new file mode 100644 index 0000000..131718b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@new_allocator.h @@ -0,0 +1,198 @@ +// Allocator that wraps operator new -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/new_allocator.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _NEW_ALLOCATOR_H +#define _NEW_ALLOCATOR_H 1 + +#include +#include +#include +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief An allocator that uses global new, as per [20.4]. + * @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 + + // 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 (__n > this->_M_max_size()) + 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*>(::operator new(__n * sizeof(_Tp), __al)); + } +#endif + return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); + } + + // __p is not permitted to be a null pointer. + void + deallocate(_Tp* __p, size_type __t) + { +#if __cpp_aligned_new + if (alignof(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__) + { + ::operator delete(__p, +# if __cpp_sized_deallocation + __t * sizeof(_Tp), +# endif + std::align_val_t(alignof(_Tp))); + return; + } +#endif + ::operator delete(__p +#if __cpp_sized_deallocation + , __t * sizeof(_Tp) +#endif + ); + } + +#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/@@home@ado@git@ssp/@usr@include@c++@10@ext@new_allocator.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@new_allocator.h.blob new file mode 100644 index 0000000..f5515cf Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@new_allocator.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@numeric_traits.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@numeric_traits.h new file mode 100644 index 0000000..c29f9f2 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@numeric_traits.h @@ -0,0 +1,194 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License as published by the Free Software +// Foundation; either version 3, or (at your option) any later +// version. + +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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) \ + template<> struct __is_integer_nonstrict \ + { \ + enum { __value = 1 }; \ + typedef std::__true_type __type; \ + enum { __width = WIDTH }; \ + }; \ + 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; + + template + struct __numeric_traits + : public __conditional_type<__is_integer_nonstrict<_Value>::__value, + __numeric_traits_integer<_Value>, + __numeric_traits_floating<_Value> >::__type + { }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#undef __glibcxx_floating +#undef __glibcxx_max_digits10 +#undef __glibcxx_digits10 +#undef __glibcxx_max_exponent10 + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@numeric_traits.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@numeric_traits.h.blob new file mode 100644 index 0000000..9aa51ce Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@numeric_traits.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@string_conversions.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@string_conversions.h new file mode 100644 index 0000000..0ded5fd --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@string_conversions.h @@ -0,0 +1,123 @@ +// String Conversions -*- C++ -*- + +// Copyright (C) 2008-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@ext@string_conversions.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@string_conversions.h.blob new file mode 100644 index 0000000..43e6841 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@string_conversions.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@type_traits.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@type_traits.h new file mode 100644 index 0000000..cf773cf --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@type_traits.h @@ -0,0 +1,221 @@ +// -*- C++ -*- + +// Copyright (C) 2005-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License as published by the Free Software +// Foundation; either version 3, or (at your option) any later +// version. + +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + inline bool + __is_null_pointer(_Type* __ptr) + { return __ptr == 0; } + + template + inline bool + __is_null_pointer(_Type) + { return false; } + +#if __cplusplus >= 201103L + inline bool + __is_null_pointer(std::nullptr_t) + { return true; } +#endif + + // For complex and cmath + 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; }; + + 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; + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +} // extern "C++" + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@type_traits.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@type_traits.h.blob new file mode 100644 index 0000000..aec9900 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ext@type_traits.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@filesystem b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@filesystem new file mode 100644 index 0000000..6a80abf --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@filesystem @@ -0,0 +1,53 @@ +// -*- C++ -*- + +// Copyright (C) 2014-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/filesystem + * This is a Standard C++ Library header. + * @ingroup filesystem + */ + +#ifndef _GLIBCXX_FILESYSTEM +#define _GLIBCXX_FILESYSTEM 1 + +#pragma GCC system_header + +#if __cplusplus >= 201703L + +/** + * @defgroup filesystem File System + * + * Utilities for performing operations on file systems and their components, + * such as paths, regular files, and directories. + */ + +#include +#include +#include +#include + +#define __cpp_lib_filesystem 201703 + +#endif // C++17 + +#endif // _GLIBCXX_FILESYSTEM diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@filesystem.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@filesystem.blob new file mode 100644 index 0000000..75488d0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@filesystem.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@fstream b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@fstream new file mode 100644 index 0000000..efc99d1 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@fstream @@ -0,0 +1,1295 @@ +// File based streams -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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/@@home@ado@git@ssp/@usr@include@c++@10@fstream.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@fstream.blob new file mode 100644 index 0000000..389fd17 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@fstream.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@functional b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@functional new file mode 100644 index 0000000..dc21c10 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@functional @@ -0,0 +1,1280 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +# include +#endif +#if __cplusplus > 201703L +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201703L +# define __cpp_lib_invoke 201411L +# if __cplusplus > 201703L +# define __cpp_lib_constexpr_functional 201907L +# endif + + /// Invoke a callable object. + 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)...); + } +#endif // C++17 + + 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; + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2048. Unnecessary mem_fn overloads + /** + * @brief Returns a function object that forwards to the member + * pointer @a pm. + * @ingroup functors + */ + template + _GLIBCXX20_CONSTEXPR + inline _Mem_fn<_Tp _Class::*> + mem_fn(_Tp _Class::* __pm) noexcept + { + return _Mem_fn<_Tp _Class::*>(__pm); + } + + /** + * @brief 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 bind(). + * + * C++11 [func.bind.isbind]. + * @ingroup binders + */ + 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 + */ + 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 + + /** @brief The type of placeholder objects defined by libstdc++. + * @ingroup binders + */ + template struct _Placeholder { }; + + /** @namespace std::placeholders + * @brief ISO C++ 2011 namespace for std::bind placeholders. + * @ingroup binders + */ + 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 + */ + template + struct is_placeholder<_Placeholder<_Num> > + : public integral_constant + { }; + + template + struct is_placeholder > + : public integral_constant + { }; + + + // 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)); } + + /// Type of the function object returned from bind(). + template + struct _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 + struct _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 + */ + 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 + */ + 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>...>; + + 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 + +#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 { }; + +#define __cpp_lib_not_fn 201603 + /// [func.not_fn] Function template not_fn + 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 201603 + + 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{ _GLIBCXX_STD_C::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<_GLIBCXX_STD_C::array<_Tp, _Len>, _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 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_FUNCTIONAL diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@functional.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@functional.blob new file mode 100644 index 0000000..c77aae3 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@functional.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@initializer_list b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@initializer_list new file mode 100644 index 0000000..9f48595 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@initializer_list @@ -0,0 +1,109 @@ +// std::initializer_list support -*- C++ -*- + +// Copyright (C) 2008-2020 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/@@home@ado@git@ssp/@usr@include@c++@10@initializer_list.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@initializer_list.blob new file mode 100644 index 0000000..1810a64 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@initializer_list.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iomanip b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iomanip new file mode 100644 index 0000000..a204972 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iomanip @@ -0,0 +1,540 @@ +// Standard stream manipulators -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 201304 + + /** + * @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/@@home@ado@git@ssp/@usr@include@c++@10@iomanip.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iomanip.blob new file mode 100644 index 0000000..2ff750c Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iomanip.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ios b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ios new file mode 100644 index 0000000..d9d33e5 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ios @@ -0,0 +1,46 @@ +// Iostreams base classes -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@ios.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ios.blob new file mode 100644 index 0000000..ea12c1f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ios.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iosfwd b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iosfwd new file mode 100644 index 0000000..0504075 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iosfwd @@ -0,0 +1,215 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + /** @} */ + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GLIBCXX_IOSFWD */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iosfwd.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iosfwd.blob new file mode 100644 index 0000000..8fd9331 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iosfwd.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iostream b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iostream new file mode 100644 index 0000000..f988342 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iostream @@ -0,0 +1,79 @@ +// Standard iostream objects -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@iostream.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iostream.blob new file mode 100644 index 0000000..454b1b2 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@iostream.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@istream b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@istream new file mode 100644 index 0000000..407c1cc --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@istream @@ -0,0 +1,993 @@ +// Input streams -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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)); } + //@} + + //@{ + /** + * @brief Character string extractors + * @param __in An input stream. + * @param __s A pointer to a character array. + * @return __in + * + * Behaves like one of the formatted arithmetic extractors described in + * std::basic_istream. After constructing a sentry object with good + * status, this function extracts up to @c n characters and stores them + * into the array starting at @a __s. @c n is defined as: + * + * - if @c width() is greater than zero, @c n is width() otherwise + * - @c n is the number of elements of the largest array of * + * - @c char_type that can store a terminating @c eos. + * - [27.6.1.2.3]/6 + * + * Characters are extracted and stored until one of the following happens: + * - @c n-1 characters are stored + * - EOF is reached + * - the next character is whitespace according to the current locale + * - the next character is a null byte (i.e., @c charT() ) + * + * @c width(0) is then called for the input stream. + * + * If no characters are extracted, sets failbit. + */ + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s); + + // Explicit specialization declaration, defined in src/istream.cc. + template<> + basic_istream& + operator>>(basic_istream& __in, char* __s); + + template + inline basic_istream& + operator>>(basic_istream& __in, unsigned char* __s) + { return (__in >> reinterpret_cast(__s)); } + + template + inline basic_istream& + operator>>(basic_istream& __in, signed char* __s) + { return (__in >> reinterpret_cast(__s)); } + //@} + + /** + * @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 + template + basic_istream<_Ch, _Up>& + __is_convertible_to_basic_istream_test(basic_istream<_Ch, _Up>*); + + template + struct __is_convertible_to_basic_istream_impl + { + using __istream_type = void; + }; + + template + using __do_is_convertible_to_basic_istream_impl = + decltype(__is_convertible_to_basic_istream_test + (declval::type*>())); + + template + struct __is_convertible_to_basic_istream_impl + <_Tp, + __void_t<__do_is_convertible_to_basic_istream_impl<_Tp>>> + { + using __istream_type = + __do_is_convertible_to_basic_istream_impl<_Tp>; + }; + + template + struct __is_convertible_to_basic_istream + : __is_convertible_to_basic_istream_impl<_Tp> + { + public: + using type = __not_::__istream_type>>; + constexpr static bool value = type::value; + }; + + template + struct __is_extractable : false_type {}; + + template + struct __is_extractable<_Istream, _Tp, + __void_t() + >> declval<_Tp>())>> + : true_type {}; + + template + using __rvalue_istream_type = + typename __is_convertible_to_basic_istream< + _Istream>::__istream_type; + + // [27.7.1.6] Rvalue stream extraction + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2328. Rvalue stream extraction should use perfect forwarding + /** + * @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 + typename enable_if<__and_<__not_>, + __is_convertible_to_basic_istream<_Istream>, + __is_extractable< + __rvalue_istream_type<_Istream>, + _Tp&&>>::value, + __rvalue_istream_type<_Istream>>::type + operator>>(_Istream&& __is, _Tp&& __x) + { + __rvalue_istream_type<_Istream> __ret_is = __is; + __ret_is >> std::forward<_Tp>(__x); + return __ret_is; + } +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include + +#endif /* _GLIBCXX_ISTREAM */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@istream.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@istream.blob new file mode 100644 index 0000000..0d6b0d6 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@istream.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@limits b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@limits new file mode 100644 index 0000000..ffb85c9 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@limits @@ -0,0 +1,1897 @@ +// The template and inlines for the numeric_limits classes. -*- C++ -*- + +// Copyright (C) 1999-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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) \ + 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; \ + }; \ + \ + 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/@@home@ado@git@ssp/@usr@include@c++@10@limits.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@limits.blob new file mode 100644 index 0000000..039a563 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@limits.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@locale b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@locale new file mode 100644 index 0000000..77e7a73 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@locale @@ -0,0 +1,46 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@locale.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@locale.blob new file mode 100644 index 0000000..5e0c100 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@locale.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@memory b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@memory new file mode 100644 index 0000000..3b3fec0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@memory @@ -0,0 +1,429 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#include + +#if __cplusplus >= 201103L +# include // std::exception +# include // std::type_info in get_deleter +# include // std::basic_ostream +# include +# include +# include +# include // std::less +# include +# include +# include +# include +# include +# include +# include +# if _GLIBCXX_USE_DEPRECATED +# include +# endif +#else +# include +#endif + +#if __cplusplus >= 201103L +#include +#if __cplusplus > 201703L +# include // for has_single_bit +# include // for placement operator new +# include // for tuple, make_tuple, make_from_tuple +#endif +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +/** + * @brief Fit aligned storage in buffer. + * @ingroup memory + * + * 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. + * + */ +inline void* +align(size_t __align, size_t __size, void*& __ptr, size_t& __space) noexcept +{ +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + const auto __intptr = reinterpret_cast(__ptr); +#else + // Cannot use std::uintptr_t so assume that std::size_t can be used instead. + static_assert(sizeof(size_t) >= sizeof(void*), + "std::size_t must be a suitable substitute for std::uintptr_t"); + const auto __intptr = reinterpret_cast(__ptr); +#endif + const auto __aligned = (__intptr - 1u + __align) & -__align; + const auto __diff = __aligned - __intptr; + if ((__size + __diff) > __space) + return nullptr; + else + { + __space -= __diff; + return __ptr = reinterpret_cast(__aligned); + } +} + +/** @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; } +// @} + +#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((std::uintptr_t)__ptr % _Align == 0); + return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Align)); + } + } +#endif // C++2a + +#if __cplusplus > 201703L + template + struct __is_pair : false_type { }; + template + struct __is_pair> : true_type { }; + template + struct __is_pair> : true_type { }; + +/** @addtogroup allocators + * @{ + */ + template>>, + typename _Alloc, typename... _Args> + constexpr auto + __uses_alloc_args(const _Alloc& __a, _Args&&... __args) noexcept + { + if constexpr (uses_allocator_v, _Alloc>) + { + if constexpr (is_constructible_v<_Tp, allocator_arg_t, + const _Alloc&, _Args...>) + { + return tuple( + allocator_arg, __a, std::forward<_Args>(__args)...); + } + else + { + static_assert(is_constructible_v<_Tp, _Args..., const _Alloc&>, + "construction with an allocator must be possible" + " if uses_allocator is true"); + + return tuple<_Args&&..., const _Alloc&>( + std::forward<_Args>(__args)..., __a); + } + } + else + { + static_assert(is_constructible_v<_Tp, _Args...>); + + return tuple<_Args&&...>(std::forward<_Args>(__args)...); + } + } + +#if __cpp_concepts + template + concept _Std_pair = __is_pair<_Tp>::value; +#endif + +// This is a temporary workaround until -fconcepts is implied by -std=gnu++2a +#if __cpp_concepts +# define _GLIBCXX_STD_PAIR_CONSTRAINT(T) _Std_pair T +# define _GLIBCXX_STD_PAIR_CONSTRAINT_(T) _Std_pair T +#else +# define _GLIBCXX_STD_PAIR_CONSTRAINT(T) \ + typename T, typename __ = _Require<__is_pair> +# define _GLIBCXX_STD_PAIR_CONSTRAINT_(T) typename T, typename +#endif + + template>>, +#endif + typename _Alloc, typename... _Args> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, + _Args&&... __args) noexcept +#if __cpp_concepts + requires (! _Std_pair<_Tp>) +#endif + { + return std::__uses_alloc_args<_Tp>(__a, std::forward<_Args>(__args)...); + } + + template<_GLIBCXX_STD_PAIR_CONSTRAINT(_Tp), typename _Alloc, + typename _Tuple1, typename _Tuple2> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t, + _Tuple1&& __x, _Tuple2&& __y) noexcept; + + template<_GLIBCXX_STD_PAIR_CONSTRAINT(_Tp), typename _Alloc> + constexpr auto + uses_allocator_construction_args(const _Alloc&) noexcept; + + template<_GLIBCXX_STD_PAIR_CONSTRAINT(_Tp), typename _Alloc, + typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc&, _Up&&, _Vp&&) noexcept; + + template<_GLIBCXX_STD_PAIR_CONSTRAINT(_Tp), typename _Alloc, + typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc&, + const pair<_Up, _Vp>&) noexcept; + + template<_GLIBCXX_STD_PAIR_CONSTRAINT(_Tp), typename _Alloc, + typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc&, pair<_Up, _Vp>&&) noexcept; + + template<_GLIBCXX_STD_PAIR_CONSTRAINT_(_Tp), typename _Alloc, + typename _Tuple1, typename _Tuple2> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t, + _Tuple1&& __x, _Tuple2&& __y) noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::apply([&__a](auto&&... __args1) { + return std::uses_allocator_construction_args<_Tp1>( + __a, std::forward(__args1)...); + }, std::forward<_Tuple1>(__x)), + std::apply([&__a](auto&&... __args2) { + return std::uses_allocator_construction_args<_Tp2>( + __a, std::forward(__args2)...); + }, std::forward<_Tuple2>(__y))); + } + + template<_GLIBCXX_STD_PAIR_CONSTRAINT_(_Tp), typename _Alloc> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a) noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::uses_allocator_construction_args<_Tp1>(__a), + std::uses_allocator_construction_args<_Tp2>(__a)); + } + + template<_GLIBCXX_STD_PAIR_CONSTRAINT_(_Tp), typename _Alloc, + typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, _Up&& __u, _Vp&& __v) + noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::uses_allocator_construction_args<_Tp1>(__a, + std::forward<_Up>(__u)), + std::uses_allocator_construction_args<_Tp2>(__a, + std::forward<_Vp>(__v))); + } + + template<_GLIBCXX_STD_PAIR_CONSTRAINT_(_Tp), typename _Alloc, + typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, + const pair<_Up, _Vp>& __pr) noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::uses_allocator_construction_args<_Tp1>(__a, __pr.first), + std::uses_allocator_construction_args<_Tp2>(__a, __pr.second)); + } + + template<_GLIBCXX_STD_PAIR_CONSTRAINT_(_Tp), typename _Alloc, + typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, + pair<_Up, _Vp>&& __pr) noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::uses_allocator_construction_args<_Tp1>(__a, + std::move(__pr).first), + std::uses_allocator_construction_args<_Tp2>(__a, + std::move(__pr).second)); + } + + template + inline _Tp + make_obj_using_allocator(const _Alloc& __a, _Args&&... __args) + { + return std::make_from_tuple<_Tp>( + std::uses_allocator_construction_args<_Tp>(__a, + std::forward<_Args>(__args)...)); + } + + template + inline _Tp* + uninitialized_construct_using_allocator(_Tp* __p, const _Alloc& __a, + _Args&&... __args) + { + return std::apply([&](auto&&... __xs) { + return std::construct_at(__p, std::forward(__xs)...); + }, std::uses_allocator_construction_args<_Tp>(__a, + std::forward<_Args>(__args)...)); + } +// @} + +#endif // C++2a + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++11 + +#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 +# endif + +// Feature test macro for parallel algorithms +# define __cpp_lib_parallel_algorithm 201603L +#endif // C++17 + +#endif /* _GLIBCXX_MEMORY */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@memory.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@memory.blob new file mode 100644 index 0000000..12392ee Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@memory.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@new b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@new new file mode 100644 index 0000000..ebd1c49 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@new @@ -0,0 +1,232 @@ +// The -*- C++ -*- dynamic memory management header. + +// Copyright (C) 1994-2020 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__, __malloc__)); +_GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT + __attribute__((__externally_visible__, __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__)); +_GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __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__)); +_GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __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 +#ifdef _GLIBCXX_HAVE_BUILTIN_LAUNDER +namespace std +{ +#define __cpp_lib_launder 201606 + /// 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 +#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/@@home@ado@git@ssp/@usr@include@c++@10@new.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@new.blob new file mode 100644 index 0000000..c998d7a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@new.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@optional b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@optional new file mode 100644 index 0000000..1c7863d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@optional @@ -0,0 +1,1293 @@ +// -*- C++ -*- + +// Copyright (C) 2013-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/optional + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_OPTIONAL +#define _GLIBCXX_OPTIONAL 1 + +#pragma GCC system_header + +#if __cplusplus >= 201703L + +#include +#include +#include +#include +#include +#include +#include +#include +#if __cplusplus > 201703L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup utilities + * @{ + */ + +#define __cpp_lib_optional 201606L + + template + class optional; + + /// Tag type to disengage optional objects. + struct nullopt_t + { + // Do not user-declare default constructor at all for + // optional_value = {} syntax to work. + // nullopt_t() = delete; + + // Used for constructing nullopt. + enum class _Construct { _Token }; + + // Must be constexpr for nullopt_t to be literal. + explicit constexpr nullopt_t(_Construct) { } + }; + + /// Tag to disengage optional objects. + inline constexpr nullopt_t nullopt { nullopt_t::_Construct::_Token }; + + /** + * @brief Exception class thrown when a disengaged optional object is + * dereferenced. + * @ingroup exceptions + */ + class bad_optional_access : public exception + { + public: + bad_optional_access() { } + + virtual const char* what() const noexcept override + { return "bad optional access"; } + + virtual ~bad_optional_access() noexcept = default; + }; + + void + __throw_bad_optional_access() + __attribute__((__noreturn__)); + + // XXX Does not belong here. + inline void + __throw_bad_optional_access() + { _GLIBCXX_THROW_OR_ABORT(bad_optional_access()); } + + // This class template manages construction/destruction of + // the contained value for a std::optional. + template + struct _Optional_payload_base + { + using _Stored_type = remove_const_t<_Tp>; + + _Optional_payload_base() = default; + ~_Optional_payload_base() = default; + + template + constexpr + _Optional_payload_base(in_place_t __tag, _Args&&... __args) + : _M_payload(__tag, std::forward<_Args>(__args)...), + _M_engaged(true) + { } + + template + constexpr + _Optional_payload_base(std::initializer_list<_Up> __il, + _Args&&... __args) + : _M_payload(__il, std::forward<_Args>(__args)...), + _M_engaged(true) + { } + + // Constructor used by _Optional_base copy constructor when the + // contained value is not trivially copy constructible. + constexpr + _Optional_payload_base(bool __engaged, + const _Optional_payload_base& __other) + { + if (__other._M_engaged) + this->_M_construct(__other._M_get()); + } + + // Constructor used by _Optional_base move constructor when the + // contained value is not trivially move constructible. + constexpr + _Optional_payload_base(bool __engaged, + _Optional_payload_base&& __other) + { + if (__other._M_engaged) + this->_M_construct(std::move(__other._M_get())); + } + + // Copy constructor is only used to when the contained value is + // trivially copy constructible. + _Optional_payload_base(const _Optional_payload_base&) = default; + + // Move constructor is only used to when the contained value is + // trivially copy constructible. + _Optional_payload_base(_Optional_payload_base&&) = default; + + _Optional_payload_base& + operator=(const _Optional_payload_base&) = default; + + _Optional_payload_base& + operator=(_Optional_payload_base&&) = default; + + // used to perform non-trivial copy assignment. + constexpr void + _M_copy_assign(const _Optional_payload_base& __other) + { + if (this->_M_engaged && __other._M_engaged) + this->_M_get() = __other._M_get(); + else + { + if (__other._M_engaged) + this->_M_construct(__other._M_get()); + else + this->_M_reset(); + } + } + + // used to perform non-trivial move assignment. + constexpr void + _M_move_assign(_Optional_payload_base&& __other) + noexcept(__and_v, + is_nothrow_move_assignable<_Tp>>) + { + if (this->_M_engaged && __other._M_engaged) + this->_M_get() = std::move(__other._M_get()); + else + { + if (__other._M_engaged) + this->_M_construct(std::move(__other._M_get())); + else + this->_M_reset(); + } + } + + struct _Empty_byte { }; + + template> + union _Storage + { + constexpr _Storage() noexcept : _M_empty() { } + + template + constexpr + _Storage(in_place_t, _Args&&... __args) + : _M_value(std::forward<_Args>(__args)...) + { } + + template + constexpr + _Storage(std::initializer_list<_Vp> __il, _Args&&... __args) + : _M_value(__il, std::forward<_Args>(__args)...) + { } + + _Empty_byte _M_empty; + _Up _M_value; + }; + + template + union _Storage<_Up, false> + { + constexpr _Storage() noexcept : _M_empty() { } + + template + constexpr + _Storage(in_place_t, _Args&&... __args) + : _M_value(std::forward<_Args>(__args)...) + { } + + template + constexpr + _Storage(std::initializer_list<_Vp> __il, _Args&&... __args) + : _M_value(__il, std::forward<_Args>(__args)...) + { } + + // User-provided destructor is needed when _Up has non-trivial dtor. + ~_Storage() { } + + _Empty_byte _M_empty; + _Up _M_value; + }; + + _Storage<_Stored_type> _M_payload; + + bool _M_engaged = false; + + template + void + _M_construct(_Args&&... __args) + noexcept(is_nothrow_constructible_v<_Stored_type, _Args...>) + { + ::new ((void *) std::__addressof(this->_M_payload)) + _Stored_type(std::forward<_Args>(__args)...); + this->_M_engaged = true; + } + + constexpr void + _M_destroy() noexcept + { + _M_engaged = false; + _M_payload._M_value.~_Stored_type(); + } + + // The _M_get() operations have _M_engaged as a precondition. + // They exist to access the contained value with the appropriate + // const-qualification, because _M_payload has had the const removed. + + constexpr _Tp& + _M_get() noexcept + { return this->_M_payload._M_value; } + + constexpr const _Tp& + _M_get() const noexcept + { return this->_M_payload._M_value; } + + // _M_reset is a 'safe' operation with no precondition. + constexpr void + _M_reset() noexcept + { + if (this->_M_engaged) + _M_destroy(); + } + }; + + // Class template that manages the payload for optionals. + template , + bool /*_HasTrivialCopy */ = + is_trivially_copy_assignable_v<_Tp> + && is_trivially_copy_constructible_v<_Tp>, + bool /*_HasTrivialMove */ = + is_trivially_move_assignable_v<_Tp> + && is_trivially_move_constructible_v<_Tp>> + struct _Optional_payload; + + // Payload for potentially-constexpr optionals (trivial copy/move/destroy). + template + struct _Optional_payload<_Tp, true, true, true> + : _Optional_payload_base<_Tp> + { + using _Optional_payload_base<_Tp>::_Optional_payload_base; + + _Optional_payload() = default; + }; + + // Payload for optionals with non-trivial copy construction/assignment. + template + struct _Optional_payload<_Tp, true, false, true> + : _Optional_payload_base<_Tp> + { + using _Optional_payload_base<_Tp>::_Optional_payload_base; + + _Optional_payload() = default; + ~_Optional_payload() = default; + _Optional_payload(const _Optional_payload&) = default; + _Optional_payload(_Optional_payload&&) = default; + _Optional_payload& operator=(_Optional_payload&&) = default; + + // Non-trivial copy assignment. + constexpr + _Optional_payload& + operator=(const _Optional_payload& __other) + { + this->_M_copy_assign(__other); + return *this; + } + }; + + // Payload for optionals with non-trivial move construction/assignment. + template + struct _Optional_payload<_Tp, true, true, false> + : _Optional_payload_base<_Tp> + { + using _Optional_payload_base<_Tp>::_Optional_payload_base; + + _Optional_payload() = default; + ~_Optional_payload() = default; + _Optional_payload(const _Optional_payload&) = default; + _Optional_payload(_Optional_payload&&) = default; + _Optional_payload& operator=(const _Optional_payload&) = default; + + // Non-trivial move assignment. + constexpr + _Optional_payload& + operator=(_Optional_payload&& __other) + noexcept(__and_v, + is_nothrow_move_assignable<_Tp>>) + { + this->_M_move_assign(std::move(__other)); + return *this; + } + }; + + // Payload for optionals with non-trivial copy and move assignment. + template + struct _Optional_payload<_Tp, true, false, false> + : _Optional_payload_base<_Tp> + { + using _Optional_payload_base<_Tp>::_Optional_payload_base; + + _Optional_payload() = default; + ~_Optional_payload() = default; + _Optional_payload(const _Optional_payload&) = default; + _Optional_payload(_Optional_payload&&) = default; + + // Non-trivial copy assignment. + constexpr + _Optional_payload& + operator=(const _Optional_payload& __other) + { + this->_M_copy_assign(__other); + return *this; + } + + // Non-trivial move assignment. + constexpr + _Optional_payload& + operator=(_Optional_payload&& __other) + noexcept(__and_v, + is_nothrow_move_assignable<_Tp>>) + { + this->_M_move_assign(std::move(__other)); + return *this; + } + }; + + // Payload for optionals with non-trivial destructors. + template + struct _Optional_payload<_Tp, false, _Copy, _Move> + : _Optional_payload<_Tp, true, false, false> + { + // Base class implements all the constructors and assignment operators: + using _Optional_payload<_Tp, true, false, false>::_Optional_payload; + _Optional_payload() = default; + _Optional_payload(const _Optional_payload&) = default; + _Optional_payload(_Optional_payload&&) = default; + _Optional_payload& operator=(const _Optional_payload&) = default; + _Optional_payload& operator=(_Optional_payload&&) = default; + + // Destructor needs to destroy the contained value: + ~_Optional_payload() { this->_M_reset(); } + }; + + // Common base class for _Optional_base to avoid repeating these + // member functions in each specialization. + template + class _Optional_base_impl + { + protected: + using _Stored_type = remove_const_t<_Tp>; + + // The _M_construct operation has !_M_engaged as a precondition + // while _M_destruct has _M_engaged as a precondition. + template + void + _M_construct(_Args&&... __args) + noexcept(is_nothrow_constructible_v<_Stored_type, _Args...>) + { + ::new + (std::__addressof(static_cast<_Dp*>(this)->_M_payload._M_payload)) + _Stored_type(std::forward<_Args>(__args)...); + static_cast<_Dp*>(this)->_M_payload._M_engaged = true; + } + + void + _M_destruct() noexcept + { static_cast<_Dp*>(this)->_M_payload._M_destroy(); } + + // _M_reset is a 'safe' operation with no precondition. + constexpr void + _M_reset() noexcept + { static_cast<_Dp*>(this)->_M_payload._M_reset(); } + + constexpr bool _M_is_engaged() const noexcept + { return static_cast(this)->_M_payload._M_engaged; } + + // The _M_get operations have _M_engaged as a precondition. + constexpr _Tp& + _M_get() noexcept + { + __glibcxx_assert(this->_M_is_engaged()); + return static_cast<_Dp*>(this)->_M_payload._M_get(); + } + + constexpr const _Tp& + _M_get() const noexcept + { + __glibcxx_assert(this->_M_is_engaged()); + return static_cast(this)->_M_payload._M_get(); + } + }; + + /** + * @brief Class template that provides copy/move constructors of optional. + * + * Such a separate base class template is necessary in order to + * conditionally make copy/move constructors trivial. + * + * When the contained value is trivially copy/move constructible, + * the copy/move constructors of _Optional_base will invoke the + * trivial copy/move constructor of _Optional_payload. Otherwise, + * they will invoke _Optional_payload(bool, const _Optional_payload&) + * or _Optional_payload(bool, _Optional_payload&&) to initialize + * the contained value, if copying/moving an engaged optional. + * + * Whether the other special members are trivial is determined by the + * _Optional_payload<_Tp> specialization used for the _M_payload member. + * + * @see optional, _Enable_special_members + */ + template, + bool = is_trivially_move_constructible_v<_Tp>> + struct _Optional_base + : _Optional_base_impl<_Tp, _Optional_base<_Tp>> + { + // Constructors for disengaged optionals. + constexpr _Optional_base() = default; + + // Constructors for engaged optionals. + template, bool> = false> + constexpr explicit _Optional_base(in_place_t, _Args&&... __args) + : _M_payload(in_place, + std::forward<_Args>(__args)...) { } + + template&, + _Args&&...>, bool> = false> + constexpr explicit _Optional_base(in_place_t, + initializer_list<_Up> __il, + _Args&&... __args) + : _M_payload(in_place, + __il, std::forward<_Args>(__args)...) + { } + + // Copy and move constructors. + constexpr _Optional_base(const _Optional_base& __other) + : _M_payload(__other._M_payload._M_engaged, + __other._M_payload) + { } + + constexpr _Optional_base(_Optional_base&& __other) + noexcept(is_nothrow_move_constructible_v<_Tp>) + : _M_payload(__other._M_payload._M_engaged, + std::move(__other._M_payload)) + { } + + // Assignment operators. + _Optional_base& operator=(const _Optional_base&) = default; + _Optional_base& operator=(_Optional_base&&) = default; + + _Optional_payload<_Tp> _M_payload; + }; + + template + struct _Optional_base<_Tp, false, true> + : _Optional_base_impl<_Tp, _Optional_base<_Tp>> + { + // Constructors for disengaged optionals. + constexpr _Optional_base() = default; + + // Constructors for engaged optionals. + template, bool> = false> + constexpr explicit _Optional_base(in_place_t, _Args&&... __args) + : _M_payload(in_place, + std::forward<_Args>(__args)...) { } + + template&, + _Args&&...>, bool> = false> + constexpr explicit _Optional_base(in_place_t, + initializer_list<_Up> __il, + _Args&&... __args) + : _M_payload(in_place, + __il, std::forward<_Args>(__args)...) + { } + + // Copy and move constructors. + constexpr _Optional_base(const _Optional_base& __other) + : _M_payload(__other._M_payload._M_engaged, + __other._M_payload) + { } + + constexpr _Optional_base(_Optional_base&& __other) = default; + + // Assignment operators. + _Optional_base& operator=(const _Optional_base&) = default; + _Optional_base& operator=(_Optional_base&&) = default; + + _Optional_payload<_Tp> _M_payload; + }; + + template + struct _Optional_base<_Tp, true, false> + : _Optional_base_impl<_Tp, _Optional_base<_Tp>> + { + // Constructors for disengaged optionals. + constexpr _Optional_base() = default; + + // Constructors for engaged optionals. + template, bool> = false> + constexpr explicit _Optional_base(in_place_t, _Args&&... __args) + : _M_payload(in_place, + std::forward<_Args>(__args)...) { } + + template&, + _Args&&...>, bool> = false> + constexpr explicit _Optional_base(in_place_t, + initializer_list<_Up> __il, + _Args&&... __args) + : _M_payload(in_place, + __il, std::forward<_Args>(__args)...) + { } + + // Copy and move constructors. + constexpr _Optional_base(const _Optional_base& __other) = default; + + constexpr _Optional_base(_Optional_base&& __other) + noexcept(is_nothrow_move_constructible_v<_Tp>) + : _M_payload(__other._M_payload._M_engaged, + std::move(__other._M_payload)) + { } + + // Assignment operators. + _Optional_base& operator=(const _Optional_base&) = default; + _Optional_base& operator=(_Optional_base&&) = default; + + _Optional_payload<_Tp> _M_payload; + }; + + template + struct _Optional_base<_Tp, true, true> + : _Optional_base_impl<_Tp, _Optional_base<_Tp>> + { + // Constructors for disengaged optionals. + constexpr _Optional_base() = default; + + // Constructors for engaged optionals. + template, bool> = false> + constexpr explicit _Optional_base(in_place_t, _Args&&... __args) + : _M_payload(in_place, + std::forward<_Args>(__args)...) { } + + template&, + _Args&&...>, bool> = false> + constexpr explicit _Optional_base(in_place_t, + initializer_list<_Up> __il, + _Args&&... __args) + : _M_payload(in_place, + __il, std::forward<_Args>(__args)...) + { } + + // Copy and move constructors. + constexpr _Optional_base(const _Optional_base& __other) = default; + constexpr _Optional_base(_Optional_base&& __other) = default; + + // Assignment operators. + _Optional_base& operator=(const _Optional_base&) = default; + _Optional_base& operator=(_Optional_base&&) = default; + + _Optional_payload<_Tp> _M_payload; + }; + + template + class optional; + + template + using __converts_from_optional = + __or_&>, + is_constructible<_Tp, optional<_Up>&>, + is_constructible<_Tp, const optional<_Up>&&>, + is_constructible<_Tp, optional<_Up>&&>, + is_convertible&, _Tp>, + is_convertible&, _Tp>, + is_convertible&&, _Tp>, + is_convertible&&, _Tp>>; + + template + using __assigns_from_optional = + __or_&>, + is_assignable<_Tp&, optional<_Up>&>, + is_assignable<_Tp&, const optional<_Up>&&>, + is_assignable<_Tp&, optional<_Up>&&>>; + + /** + * @brief Class template for optional values. + */ + template + class optional + : private _Optional_base<_Tp>, + private _Enable_copy_move< + // Copy constructor. + is_copy_constructible_v<_Tp>, + // Copy assignment. + __and_v, is_copy_assignable<_Tp>>, + // Move constructor. + is_move_constructible_v<_Tp>, + // Move assignment. + __and_v, is_move_assignable<_Tp>>, + // Unique tag type. + optional<_Tp>> + { + static_assert(!is_same_v, nullopt_t>); + static_assert(!is_same_v, in_place_t>); + static_assert(!is_reference_v<_Tp>); + + private: + using _Base = _Optional_base<_Tp>; + + // SFINAE helpers + template + using __not_self = __not_>>; + template + using __not_tag = __not_>>; + template + using _Requires = enable_if_t<__and_v<_Cond...>, bool>; + + public: + using value_type = _Tp; + + constexpr optional() = default; + + constexpr optional(nullopt_t) noexcept { } + + // Converting constructors for engaged optionals. + template, __not_tag<_Up>, + is_constructible<_Tp, _Up&&>, + is_convertible<_Up&&, _Tp>> = true> + constexpr + optional(_Up&& __t) + : _Base(std::in_place, std::forward<_Up>(__t)) { } + + template, __not_tag<_Up>, + is_constructible<_Tp, _Up&&>, + __not_>> = false> + explicit constexpr + optional(_Up&& __t) + : _Base(std::in_place, std::forward<_Up>(__t)) { } + + template>, + is_constructible<_Tp, const _Up&>, + is_convertible, + __not_<__converts_from_optional<_Tp, _Up>>> = true> + constexpr + optional(const optional<_Up>& __t) + { + if (__t) + emplace(*__t); + } + + template>, + is_constructible<_Tp, const _Up&>, + __not_>, + __not_<__converts_from_optional<_Tp, _Up>>> = false> + explicit constexpr + optional(const optional<_Up>& __t) + { + if (__t) + emplace(*__t); + } + + template >, + is_constructible<_Tp, _Up&&>, + is_convertible<_Up&&, _Tp>, + __not_<__converts_from_optional<_Tp, _Up>>> = true> + constexpr + optional(optional<_Up>&& __t) + { + if (__t) + emplace(std::move(*__t)); + } + + template >, + is_constructible<_Tp, _Up&&>, + __not_>, + __not_<__converts_from_optional<_Tp, _Up>>> = false> + explicit constexpr + optional(optional<_Up>&& __t) + { + if (__t) + emplace(std::move(*__t)); + } + + template> = false> + explicit constexpr + optional(in_place_t, _Args&&... __args) + : _Base(std::in_place, std::forward<_Args>(__args)...) { } + + template&, + _Args&&...>> = false> + explicit constexpr + optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) + : _Base(std::in_place, __il, std::forward<_Args>(__args)...) { } + + // Assignment operators. + optional& + operator=(nullopt_t) noexcept + { + this->_M_reset(); + return *this; + } + + template + enable_if_t<__and_v<__not_self<_Up>, + __not_<__and_, + is_same<_Tp, decay_t<_Up>>>>, + is_constructible<_Tp, _Up>, + is_assignable<_Tp&, _Up>>, + optional&> + operator=(_Up&& __u) + { + if (this->_M_is_engaged()) + this->_M_get() = std::forward<_Up>(__u); + else + this->_M_construct(std::forward<_Up>(__u)); + + return *this; + } + + template + enable_if_t<__and_v<__not_>, + is_constructible<_Tp, const _Up&>, + is_assignable<_Tp&, _Up>, + __not_<__converts_from_optional<_Tp, _Up>>, + __not_<__assigns_from_optional<_Tp, _Up>>>, + optional&> + operator=(const optional<_Up>& __u) + { + if (__u) + { + if (this->_M_is_engaged()) + this->_M_get() = *__u; + else + this->_M_construct(*__u); + } + else + { + this->_M_reset(); + } + return *this; + } + + template + enable_if_t<__and_v<__not_>, + is_constructible<_Tp, _Up>, + is_assignable<_Tp&, _Up>, + __not_<__converts_from_optional<_Tp, _Up>>, + __not_<__assigns_from_optional<_Tp, _Up>>>, + optional&> + operator=(optional<_Up>&& __u) + { + if (__u) + { + if (this->_M_is_engaged()) + this->_M_get() = std::move(*__u); + else + this->_M_construct(std::move(*__u)); + } + else + { + this->_M_reset(); + } + + return *this; + } + + template + enable_if_t, _Tp&> + emplace(_Args&&... __args) + { + this->_M_reset(); + this->_M_construct(std::forward<_Args>(__args)...); + return this->_M_get(); + } + + template + enable_if_t&, + _Args&&...>, _Tp&> + emplace(initializer_list<_Up> __il, _Args&&... __args) + { + this->_M_reset(); + this->_M_construct(__il, std::forward<_Args>(__args)...); + return this->_M_get(); + } + + // Destructor is implicit, implemented in _Optional_base. + + // Swap. + void + swap(optional& __other) + noexcept(is_nothrow_move_constructible_v<_Tp> + && is_nothrow_swappable_v<_Tp>) + { + using std::swap; + + if (this->_M_is_engaged() && __other._M_is_engaged()) + swap(this->_M_get(), __other._M_get()); + else if (this->_M_is_engaged()) + { + __other._M_construct(std::move(this->_M_get())); + this->_M_destruct(); + } + else if (__other._M_is_engaged()) + { + this->_M_construct(std::move(__other._M_get())); + __other._M_destruct(); + } + } + + // Observers. + constexpr const _Tp* + operator->() const + { return std::__addressof(this->_M_get()); } + + constexpr _Tp* + operator->() + { return std::__addressof(this->_M_get()); } + + constexpr const _Tp& + operator*() const& + { return this->_M_get(); } + + constexpr _Tp& + operator*()& + { return this->_M_get(); } + + constexpr _Tp&& + operator*()&& + { return std::move(this->_M_get()); } + + constexpr const _Tp&& + operator*() const&& + { return std::move(this->_M_get()); } + + constexpr explicit operator bool() const noexcept + { return this->_M_is_engaged(); } + + constexpr bool has_value() const noexcept + { return this->_M_is_engaged(); } + + constexpr const _Tp& + value() const& + { + return this->_M_is_engaged() + ? this->_M_get() + : (__throw_bad_optional_access(), this->_M_get()); + } + + constexpr _Tp& + value()& + { + return this->_M_is_engaged() + ? this->_M_get() + : (__throw_bad_optional_access(), this->_M_get()); + } + + constexpr _Tp&& + value()&& + { + return this->_M_is_engaged() + ? std::move(this->_M_get()) + : (__throw_bad_optional_access(), std::move(this->_M_get())); + } + + constexpr const _Tp&& + value() const&& + { + return this->_M_is_engaged() + ? std::move(this->_M_get()) + : (__throw_bad_optional_access(), std::move(this->_M_get())); + } + + template + constexpr _Tp + value_or(_Up&& __u) const& + { + static_assert(is_copy_constructible_v<_Tp>); + static_assert(is_convertible_v<_Up&&, _Tp>); + + return this->_M_is_engaged() + ? this->_M_get() : static_cast<_Tp>(std::forward<_Up>(__u)); + } + + template + constexpr _Tp + value_or(_Up&& __u) && + { + static_assert(is_move_constructible_v<_Tp>); + static_assert(is_convertible_v<_Up&&, _Tp>); + + return this->_M_is_engaged() + ? std::move(this->_M_get()) + : static_cast<_Tp>(std::forward<_Up>(__u)); + } + + void reset() noexcept { this->_M_reset(); } + }; + + template + using __optional_relop_t = + enable_if_t::value, bool>; + + template + using __optional_eq_t = __optional_relop_t< + decltype(std::declval() == std::declval()) + >; + + template + using __optional_ne_t = __optional_relop_t< + decltype(std::declval() != std::declval()) + >; + + template + using __optional_lt_t = __optional_relop_t< + decltype(std::declval() < std::declval()) + >; + + template + using __optional_gt_t = __optional_relop_t< + decltype(std::declval() > std::declval()) + >; + + template + using __optional_le_t = __optional_relop_t< + decltype(std::declval() <= std::declval()) + >; + + template + using __optional_ge_t = __optional_relop_t< + decltype(std::declval() >= std::declval()) + >; + + // Comparisons between optional values. + template + constexpr auto + operator==(const optional<_Tp>& __lhs, const optional<_Up>& __rhs) + -> __optional_eq_t<_Tp, _Up> + { + return static_cast(__lhs) == static_cast(__rhs) + && (!__lhs || *__lhs == *__rhs); + } + + template + constexpr auto + operator!=(const optional<_Tp>& __lhs, const optional<_Up>& __rhs) + -> __optional_ne_t<_Tp, _Up> + { + return static_cast(__lhs) != static_cast(__rhs) + || (static_cast(__lhs) && *__lhs != *__rhs); + } + + template + constexpr auto + operator<(const optional<_Tp>& __lhs, const optional<_Up>& __rhs) + -> __optional_lt_t<_Tp, _Up> + { + return static_cast(__rhs) && (!__lhs || *__lhs < *__rhs); + } + + template + constexpr auto + operator>(const optional<_Tp>& __lhs, const optional<_Up>& __rhs) + -> __optional_gt_t<_Tp, _Up> + { + return static_cast(__lhs) && (!__rhs || *__lhs > *__rhs); + } + + template + constexpr auto + operator<=(const optional<_Tp>& __lhs, const optional<_Up>& __rhs) + -> __optional_le_t<_Tp, _Up> + { + return !__lhs || (static_cast(__rhs) && *__lhs <= *__rhs); + } + + template + constexpr auto + operator>=(const optional<_Tp>& __lhs, const optional<_Up>& __rhs) + -> __optional_ge_t<_Tp, _Up> + { + return !__rhs || (static_cast(__lhs) && *__lhs >= *__rhs); + } + +#ifdef __cpp_lib_three_way_comparison + template _Up> + constexpr compare_three_way_result_t<_Tp, _Up> + operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) + { + return __x && __y ? *__x <=> *__y : bool(__x) <=> bool(__y); + } +#endif + + // Comparisons with nullopt. + template + constexpr bool + operator==(const optional<_Tp>& __lhs, nullopt_t) noexcept + { return !__lhs; } + +#ifdef __cpp_lib_three_way_comparison + template + constexpr strong_ordering + operator<=>(const optional<_Tp>& __x, nullopt_t) noexcept + { return bool(__x) <=> false; } +#else + template + constexpr bool + operator==(nullopt_t, const optional<_Tp>& __rhs) noexcept + { return !__rhs; } + + template + constexpr bool + operator!=(const optional<_Tp>& __lhs, nullopt_t) noexcept + { return static_cast(__lhs); } + + template + constexpr bool + operator!=(nullopt_t, const optional<_Tp>& __rhs) noexcept + { return static_cast(__rhs); } + + template + constexpr bool + operator<(const optional<_Tp>& /* __lhs */, nullopt_t) noexcept + { return false; } + + template + constexpr bool + operator<(nullopt_t, const optional<_Tp>& __rhs) noexcept + { return static_cast(__rhs); } + + template + constexpr bool + operator>(const optional<_Tp>& __lhs, nullopt_t) noexcept + { return static_cast(__lhs); } + + template + constexpr bool + operator>(nullopt_t, const optional<_Tp>& /* __rhs */) noexcept + { return false; } + + template + constexpr bool + operator<=(const optional<_Tp>& __lhs, nullopt_t) noexcept + { return !__lhs; } + + template + constexpr bool + operator<=(nullopt_t, const optional<_Tp>& /* __rhs */) noexcept + { return true; } + + template + constexpr bool + operator>=(const optional<_Tp>& /* __lhs */, nullopt_t) noexcept + { return true; } + + template + constexpr bool + operator>=(nullopt_t, const optional<_Tp>& __rhs) noexcept + { return !__rhs; } +#endif // three-way-comparison + + // Comparisons with value type. + template + constexpr auto + operator==(const optional<_Tp>& __lhs, const _Up& __rhs) + -> __optional_eq_t<_Tp, _Up> + { return __lhs && *__lhs == __rhs; } + + template + constexpr auto + operator==(const _Up& __lhs, const optional<_Tp>& __rhs) + -> __optional_eq_t<_Up, _Tp> + { return __rhs && __lhs == *__rhs; } + + template + constexpr auto + operator!=(const optional<_Tp>& __lhs, const _Up& __rhs) + -> __optional_ne_t<_Tp, _Up> + { return !__lhs || *__lhs != __rhs; } + + template + constexpr auto + operator!=(const _Up& __lhs, const optional<_Tp>& __rhs) + -> __optional_ne_t<_Up, _Tp> + { return !__rhs || __lhs != *__rhs; } + + template + constexpr auto + operator<(const optional<_Tp>& __lhs, const _Up& __rhs) + -> __optional_lt_t<_Tp, _Up> + { return !__lhs || *__lhs < __rhs; } + + template + constexpr auto + operator<(const _Up& __lhs, const optional<_Tp>& __rhs) + -> __optional_lt_t<_Up, _Tp> + { return __rhs && __lhs < *__rhs; } + + template + constexpr auto + operator>(const optional<_Tp>& __lhs, const _Up& __rhs) + -> __optional_gt_t<_Tp, _Up> + { return __lhs && *__lhs > __rhs; } + + template + constexpr auto + operator>(const _Up& __lhs, const optional<_Tp>& __rhs) + -> __optional_gt_t<_Up, _Tp> + { return !__rhs || __lhs > *__rhs; } + + template + constexpr auto + operator<=(const optional<_Tp>& __lhs, const _Up& __rhs) + -> __optional_le_t<_Tp, _Up> + { return !__lhs || *__lhs <= __rhs; } + + template + constexpr auto + operator<=(const _Up& __lhs, const optional<_Tp>& __rhs) + -> __optional_le_t<_Up, _Tp> + { return __rhs && __lhs <= *__rhs; } + + template + constexpr auto + operator>=(const optional<_Tp>& __lhs, const _Up& __rhs) + -> __optional_ge_t<_Tp, _Up> + { return __lhs && *__lhs >= __rhs; } + + template + constexpr auto + operator>=(const _Up& __lhs, const optional<_Tp>& __rhs) + -> __optional_ge_t<_Up, _Tp> + { return !__rhs || __lhs >= *__rhs; } + +#ifdef __cpp_lib_three_way_comparison + template + constexpr compare_three_way_result_t<_Tp, _Up> + operator<=>(const optional<_Tp>& __x, const _Up& __v) + { return bool(__x) ? *__x <=> __v : strong_ordering::less; } +#endif + + // Swap and creation functions. + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2748. swappable traits for optionals + template + inline enable_if_t && is_swappable_v<_Tp>> + swap(optional<_Tp>& __lhs, optional<_Tp>& __rhs) + noexcept(noexcept(__lhs.swap(__rhs))) + { __lhs.swap(__rhs); } + + template + enable_if_t && is_swappable_v<_Tp>)> + swap(optional<_Tp>&, optional<_Tp>&) = delete; + + template + constexpr optional> + make_optional(_Tp&& __t) + { return optional> { std::forward<_Tp>(__t) }; } + + template + constexpr optional<_Tp> + make_optional(_Args&&... __args) + { return optional<_Tp> { in_place, std::forward<_Args>(__args)... }; } + + template + constexpr optional<_Tp> + make_optional(initializer_list<_Up> __il, _Args&&... __args) + { return optional<_Tp> { in_place, __il, std::forward<_Args>(__args)... }; } + + // Hash. + + template, + bool = __poison_hash<_Up>::__enable_hash_call> + struct __optional_hash_call_base + { + size_t + operator()(const optional<_Tp>& __t) const + noexcept(noexcept(hash<_Up>{}(*__t))) + { + // We pick an arbitrary hash for disengaged optionals which hopefully + // usual values of _Tp won't typically hash to. + constexpr size_t __magic_disengaged_hash = static_cast(-3333); + return __t ? hash<_Up>{}(*__t) : __magic_disengaged_hash; + } + }; + + template + struct __optional_hash_call_base<_Tp, _Up, false> {}; + + template + struct hash> + : private __poison_hash>, + public __optional_hash_call_base<_Tp> + { + using result_type [[__deprecated__]] = size_t; + using argument_type [[__deprecated__]] = optional<_Tp>; + }; + + template + struct __is_fast_hash>> : __is_fast_hash> + { }; + + /// @} + +#if __cpp_deduction_guides >= 201606 + template optional(_Tp) -> optional<_Tp>; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++17 + +#endif // _GLIBCXX_OPTIONAL diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@optional.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@optional.blob new file mode 100644 index 0000000..91adcfd Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@optional.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ostream b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ostream new file mode 100644 index 0000000..9a80adf --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ostream @@ -0,0 +1,786 @@ +// Output streams -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + + /** + * @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 Core write functionality, without sentry. + * @param __s The array to insert. + * @param __n Maximum number of characters to insert. + */ + void + _M_write(const char_type* __s, streamsize __n) + { + const streamsize __put = this->rdbuf()->sputn(__s, __n); + if (__put != __n) + this->setstate(ios_base::badbit); + } + + /** + * @brief Character string insertion. + * @param __s The array to insert. + * @param __n Maximum number of characters to insert. + * @return *this + * + * Characters are copied from @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); + }; + + /** + * @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) + { return __ostream_insert(__out, &__c, 1); } + + 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) + { return __ostream_insert(__out, &__c, 1); } + + // 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. + +#ifdef _GLIBCXX_USE_WCHAR_T + template + basic_ostream& + operator<<(basic_ostream&, wchar_t) = delete; +#endif // _GLIBCXX_USE_WCHAR_T + +#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. + +#ifdef _GLIBCXX_USE_WCHAR_T + template + basic_ostream& + operator<<(basic_ostream&, const wchar_t*) = delete; +#endif // _GLIBCXX_USE_WCHAR_T + +#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 + template + basic_ostream<_Ch, _Up>& + __is_convertible_to_basic_ostream_test(basic_ostream<_Ch, _Up>*); + + template + struct __is_convertible_to_basic_ostream_impl + { + using __ostream_type = void; + }; + + template + using __do_is_convertible_to_basic_ostream_impl = + decltype(__is_convertible_to_basic_ostream_test + (declval::type*>())); + + template + struct __is_convertible_to_basic_ostream_impl + <_Tp, + __void_t<__do_is_convertible_to_basic_ostream_impl<_Tp>>> + { + using __ostream_type = + __do_is_convertible_to_basic_ostream_impl<_Tp>; + }; + + template + struct __is_convertible_to_basic_ostream + : __is_convertible_to_basic_ostream_impl<_Tp> + { + public: + using type = __not_::__ostream_type>>; + constexpr static bool value = type::value; + }; + + template + struct __is_insertable : false_type {}; + + template + struct __is_insertable<_Ostream, _Tp, + __void_t() + << declval())>> + : true_type {}; + + template + using __rvalue_ostream_type = + typename __is_convertible_to_basic_ostream< + _Ostream>::__ostream_type; + + /** + * @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 + typename enable_if<__and_<__not_>, + __is_convertible_to_basic_ostream<_Ostream>, + __is_insertable< + __rvalue_ostream_type<_Ostream>, + const _Tp&>>::value, + __rvalue_ostream_type<_Ostream>>::type + operator<<(_Ostream&& __os, const _Tp& __x) + { + __rvalue_ostream_type<_Ostream> __ret_os = __os; + __ret_os << __x; + return __ret_os; + } +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include + +#endif /* _GLIBCXX_OSTREAM */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ostream.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ostream.blob new file mode 100644 index 0000000..24dd570 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@ostream.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@sstream b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@sstream new file mode 100644 index 0000000..9cca54d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@sstream @@ -0,0 +1,881 @@ +// String based streams -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + +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; + 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); } + + // 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) + { + __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); + } +#endif + + // Get and set: + /** + * @brief Copying out the string buffer. + * @return A copy of one of the underlying sequences. + * + * If the buffer is only created in input mode, the underlying + * character sequence is equal to the input sequence; otherwise, it + * is equal to the output sequence. [27.7.1.2]/1 + */ + __string_type + str() const + { + __string_type __ret(_M_string.get_allocator()); + if (this->pptr()) + { + // The current egptr() may not be the actual string end. + if (this->pptr() > this->egptr()) + __ret.assign(this->pbase(), this->pptr()); + else + __ret.assign(this->pbase(), this->egptr()); + } + else + __ret = _M_string; + return __ret; + } + + /** + * @brief Setting a new buffer. + * @param __s The string to use as a new sequence. + * + * Deallocates any previous stored sequence, then copies @a s to + * use as a new one. + */ + void + str(const __string_type& __s) + { + // Cannot use _M_string = __s, since v3 strings are COW + // (not always true now but assign() always works). + _M_string.assign(__s.data(), __s.size()); + _M_stringbuf_init(_M_mode); + } + + protected: + // Common initialization code goes here. + void + _M_stringbuf_init(ios_base::openmode __mode) + { + _M_mode = __mode; + __size_type __len = 0; + if (_M_mode & (ios_base::ate | ios_base::app)) + __len = _M_string.size(); + _M_sync(const_cast(_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() + { + const bool __testin = _M_mode & ios_base::in; + if (this->pptr() && this->pptr() > this->egptr()) + { + if (__testin) + this->setg(this->eback(), this->gptr(), this->pptr()); + else + this->setg(this->pptr(), this->pptr(), this->pptr()); + } + } + + // 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: +#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 (__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)) + { } +#endif + }; + + + // [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); } + + // 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 + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __stringbuf_type* + rdbuf() const + { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ + __string_type + str() const + { return _M_stringbuf.str(); } + + /** + * @brief Setting a new buffer. + * @param __s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ + void + str(const __string_type& __s) + { _M_stringbuf.str(__s); } + }; + + + // [27.7.3] Template class basic_ostringstream + /** + * @brief Controlling output for std::string. + * @ingroup io + * + * @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); } + + // 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 + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __stringbuf_type* + rdbuf() const + { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ + __string_type + str() const + { return _M_stringbuf.str(); } + + /** + * @brief Setting a new buffer. + * @param __s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ + void + str(const __string_type& __s) + { _M_stringbuf.str(__s); } + }; + + + // [27.7.4] Template class basic_stringstream + /** + * @brief Controlling input and output for std::string. + * @ingroup io + * + * @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); } + + // 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 + + // Members: + /** + * @brief Accessing the underlying buffer. + * @return The current basic_stringbuf buffer. + * + * This hides both signatures of std::basic_ios::rdbuf(). + */ + __stringbuf_type* + rdbuf() const + { return const_cast<__stringbuf_type*>(&_M_stringbuf); } + + /** + * @brief Copying out the string buffer. + * @return @c rdbuf()->str() + */ + __string_type + str() const + { return _M_stringbuf.str(); } + + /** + * @brief Setting a new buffer. + * @param __s The string to use as a new sequence. + * + * Calls @c rdbuf()->str(s). + */ + void + str(const __string_type& __s) + { _M_stringbuf.str(__s); } + }; + +#if __cplusplus >= 201103L + /// Swap specialization for stringbufs. + template + inline void + swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, + basic_stringbuf<_CharT, _Traits, _Allocator>& __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 + +_GLIBCXX_END_NAMESPACE_CXX11 +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include + +#endif /* _GLIBCXX_SSTREAM */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@sstream.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@sstream.blob new file mode 100644 index 0000000..4086168 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@sstream.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@stdexcept b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@stdexcept new file mode 100644 index 0000000..49161d5 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@stdexcept @@ -0,0 +1,307 @@ +// Standard exception classes -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@c++@10@stdexcept.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@stdexcept.blob new file mode 100644 index 0000000..31d2f2f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@stdexcept.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@streambuf b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@streambuf new file mode 100644 index 0000000..7cb4fab --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@streambuf @@ -0,0 +1,862 @@ +// Stream buffer classes -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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); + + template + friend basic_istream<_CharT2, _Traits2>& + operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*); + + 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/@@home@ado@git@ssp/@usr@include@c++@10@streambuf.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@streambuf.blob new file mode 100644 index 0000000..1259d39 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@streambuf.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@string b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@string new file mode 100644 index 0000000..a95ef4d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@string @@ -0,0 +1,147 @@ +// Components for manipulating sequences of characters -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#if __cplusplus > 201703L +# include // For remove and remove_if +#endif // C++20 +#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; +#ifdef _GLIBCXX_USE_WCHAR_T + using wstring = basic_string; +#endif + } // 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 + { }; +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + struct hash + : public __hash_string_base + { }; +#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 + inline typename basic_string<_CharT, _Traits, _Alloc>::size_type + erase_if(basic_string<_CharT, _Traits, _Alloc>& __cont, _Predicate __pred) + { + const auto __osz = __cont.size(); + __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), + __cont.end()); + return __osz - __cont.size(); + } + + template + inline typename basic_string<_CharT, _Traits, _Alloc>::size_type + erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value) + { + const auto __osz = __cont.size(); + __cont.erase(std::remove(__cont.begin(), __cont.end(), __value), + __cont.end()); + return __osz - __cont.size(); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif /* _GLIBCXX_STRING */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@string.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@string.blob new file mode 100644 index 0000000..55208d5 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@string.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@system_error b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@system_error new file mode 100644 index 0000000..f92b434 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@system_error @@ -0,0 +1,513 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 { + + /** 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. + */ + 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 + + 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. + */ + struct error_code + { + 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. + */ + struct error_condition + { + 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 + /// @relates error_condition + 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_code + /// @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 + /// @relates error_condition + inline bool + operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept + { return !(__lhs == __rhs); } + + /// @relates error_code + /// @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. + * + * @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/@@home@ado@git@ssp/@usr@include@c++@10@system_error.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@system_error.blob new file mode 100644 index 0000000..8ffcfb0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@system_error.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@tuple b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@tuple new file mode 100644 index 0000000..94b9e03 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@tuple @@ -0,0 +1,1764 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#include +#include +#include +#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 + = typename conditional<__is_final(_Tp), false_type, + __is_empty_non_tuple<_Tp>>::type; + + template::value> + struct _Head_base; + + 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)) { } + + _Head_base(allocator_arg_t, __uses_alloc0) + : _Head() { } + + template + _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a) + : _Head(allocator_arg, *__a._M_a) { } + + template + _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a) + : _Head(*__a._M_a) { } + + template + _Head_base(__uses_alloc0, _UHead&& __uhead) + : _Head(std::forward<_UHead>(__uhead)) { } + + template + _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead) + : _Head(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) { } + + template + _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; } + }; + + 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 + _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a) + : _M_head_impl(allocator_arg, *__a._M_a) { } + + template + _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 + _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead) + : _M_head_impl(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) + { } + + template + _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 class _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::type> + 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; + + constexpr + _Tuple_impl(_Tuple_impl&& __in) + noexcept(__and_, + is_nothrow_move_constructible<_Inherited>>::value) + : _Inherited(std::move(_M_tail(__in))), + _Base(std::forward<_Head>(_M_head(__in))) { } + + 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 + _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::type> + _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 class _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; + + constexpr + _Tuple_impl(_Tuple_impl&& __in) + noexcept(is_nothrow_move_constructible<_Head>::value) + : _Base(std::forward<_Head>(_M_head(__in))) { } + + 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 + _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a, + const _Head& __head) + : _Base(__use_alloc<_Head, _Alloc, _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, _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=(typename conditional<__assignable(), + const tuple&, + const __nonesuch&>::type __in) + noexcept(__nothrow_assignable()) + { + this->_M_assign(__in); + return *this; + } + + _GLIBCXX20_CONSTEXPR + tuple& + operator=(typename conditional<__assignable<_Elements...>(), + tuple&&, + __nonesuch&&>::type __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: + 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=(typename conditional<__assignable(), + const tuple&, + const __nonesuch&>::type __in) + noexcept(__nothrow_assignable()) + { + this->_M_assign(__in); + return *this; + } + + _GLIBCXX20_CONSTEXPR + tuple& + operator=(typename conditional<__assignable<_T1, _T2>(), + tuple&&, + __nonesuch&&>::type __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 > 201402L + template + inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; +#endif + + /** + * Recursive case for tuple_element: strip off the first element in + * the tuple and retrieve the (i-1)th element of the remaining tuple. + */ + template + struct tuple_element<__i, tuple<_Head, _Tail...> > + : tuple_element<__i - 1, tuple<_Tail...> > { }; + + /** + * Basis case for tuple_element: The first element is the one we're seeking. + */ + template + struct tuple_element<0, tuple<_Head, _Tail...> > + { + typedef _Head type; + }; + + /** + * Error case for tuple_element: invalid index. + */ + template + struct tuple_element<__i, tuple<>> + { + static_assert(__i < tuple_size>::value, + "tuple index is in range"); + }; + + 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); } + + /// 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<__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<__i>(__t)); + } + +#if __cplusplus >= 201402L + +#define __cpp_lib_tuples_by_type 201304 + + template + constexpr _Head& + __get_helper2(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept + { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); } + + template + constexpr const _Head& + __get_helper2(const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept + { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); } + + /// Return a reference to the unique element of type _Tp of a tuple. + template + constexpr _Tp& + get(tuple<_Types...>& __t) noexcept + { return std::__get_helper2<_Tp>(__t); } + + /// Return a reference to the unique element of type _Tp of a tuple rvalue. + template + constexpr _Tp&& + get(tuple<_Types...>&& __t) noexcept + { return std::forward<_Tp&&>(std::__get_helper2<_Tp>(__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 + { return std::__get_helper2<_Tp>(__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 + { return std::forward(std::__get_helper2<_Tp>(__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)...); } + + 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, std::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 std::_Index_tuple<> __type; + }; + + template + struct __make_1st_indices<_Tp, _Tpls...> + { + typedef typename std::_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, std::_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, std::_Index_tuple<>> + { + template + static constexpr _Ret + _S_do(_Us&&... __us) + { + return _Ret(std::forward<_Us>(__us)...); + } + }; + + /// 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 201603 + + 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 201606 + + 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/@@home@ado@git@ssp/@usr@include@c++@10@tuple.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@tuple.blob new file mode 100644 index 0000000..378eece Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@tuple.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@type_traits b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@type_traits new file mode 100644 index 0000000..cf2106d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@type_traits @@ -0,0 +1,3460 @@ +// C++11 -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + + /** + * @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. + * + * @{ + */ + + /// 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 201304 + + constexpr value_type operator()() const noexcept { return value; } +#endif + }; + + template + constexpr _Tp integral_constant<_Tp, __v>::value; + + /// The type used as a compile-time boolean with true value. + typedef integral_constant true_type; + + /// The type used as a compile-time boolean with false value. + typedef integral_constant false_type; + + template + using __bool_constant = integral_constant; + +#if __cplusplus > 201402L +# define __cpp_lib_bool_constant 201505 + template + using bool_constant = integral_constant; +#endif + + // Meta programming helper types. + + template + struct conditional; + + 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<_B1::value, _B1, _B2>::type + { }; + + template + struct __or_<_B1, _B2, _B3, _Bn...> + : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type + { }; + + template + struct __and_; + + template<> + struct __and_<> + : public true_type + { }; + + template + struct __and_<_B1> + : public _B1 + { }; + + template + struct __and_<_B1, _B2> + : public conditional<_B1::value, _B2, _B1>::type + { }; + + template + struct __and_<_B1, _B2, _B3, _Bn...> + : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type + { }; + + template + struct __not_ + : public __bool_constant + { }; + +#if __cplusplus >= 201703L + + template + inline constexpr bool __or_v = __or_<_Bn...>::value; + template + inline constexpr bool __and_v = __and_<_Bn...>::value; + +#define __cpp_lib_logical_traits 201510 + + template + struct conjunction + : __and_<_Bn...> + { }; + + template + struct disjunction + : __or_<_Bn...> + { }; + + template + struct negation + : __not_<_Pp> + { }; + + 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 __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 + { }; + + template + struct remove_cv; + + // __remove_cv_t (std::remove_cv_t for C++11). + template + using __remove_cv_t = typename remove_cv<_Tp>::type; + + template + struct is_const; + + // Primary type categories. + + template + struct __is_void_helper + : public false_type { }; + + template<> + struct __is_void_helper + : public true_type { }; + + /// is_void + template + struct is_void + : public __is_void_helper<__remove_cv_t<_Tp>>::type + { }; + + 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 { }; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + struct __is_integral_helper + : public true_type { }; +#endif + +#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) + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; +#endif + + /// is_integral + template + struct is_integral + : public __is_integral_helper<__remove_cv_t<_Tp>>::type + { }; + + 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) && !defined(__CUDACC__) + template<> + struct __is_floating_point_helper<__float128> + : public true_type { }; +#endif + + /// 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 201309 + + 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). + 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 { }; + + template + struct __is_member_pointer_helper + : public false_type { }; + + template + struct __is_member_pointer_helper<_Tp _Cp::*> + : public true_type { }; + + /// is_member_pointer + template + struct is_member_pointer + : public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type + { }; + + template + struct is_same; + + template + using __is_one_of = __or_...>; + + // Check if a type is one of the signed integer types. + 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. + 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 + { }; + + // 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 in C++20) + // 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 + template + struct 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 + template + struct is_final + : public integral_constant + { }; +#endif + + /// is_abstract + template + struct is_abstract + : public integral_constant + { }; + + template::value> + struct __is_signed_helper + : public false_type { }; + + template + struct __is_signed_helper<_Tp, true> + : public integral_constant + { }; + + /// is_signed + template + struct is_signed + : public __is_signed_helper<_Tp>::type + { }; + + /// is_unsigned + template + struct is_unsigned + : public __and_, __not_>> + { }; + + + // Destructible and constructible type properties. + + /** + * @brief Utility to simplify expressions used in unevaluated operands + * @ingroup utilities + */ + + template + _Up + __declval(int); + + template + _Tp + __declval(long); + + template + auto declval() noexcept -> decltype(__declval<_Tp>(0)); + + template + struct extent; + + template + struct remove_all_extents; + + template + struct __is_array_known_bounds + : public integral_constant::value > 0)> + { }; + + template + struct __is_array_unknown_bounds + : public __and_, __not_>> + { }; + + // 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 { }; + + /// 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"); + }; + + // 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 { }; + + /// 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"); + }; + + template + struct __is_constructible_impl + : public __bool_constant<__is_constructible(_Tp, _Args...)> + { }; + + /// 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"); + }; + + 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&> + { }; + + /// 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"); + }; + + 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&&> + { }; + + /// 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"); + }; + + template + struct __is_nt_constructible_impl + : public false_type + { }; + + template + struct __is_nt_constructible_impl + : public __bool_constant()...))> + { }; + + template + struct __is_nt_constructible_impl + : public __bool_constant(std::declval<_Arg>()))> + { }; + + template + struct __is_nt_constructible_impl + : public __bool_constant + { }; + + template + struct __is_nt_constructible_impl + : public __bool_constant::type())> + { }; + +#if __cpp_aggregate_paren_init + template + struct __is_nt_constructible_impl + : public __is_nt_constructible_impl + { }; + + template + struct __is_nt_constructible_impl + : public __and_<__is_nt_constructible_impl...> + { }; +#endif + + template + using __is_nothrow_constructible_impl + = __is_nt_constructible_impl<__is_constructible(_Tp, _Args...), + _Tp, _Args...>; + + /// 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 __is_nothrow_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"); + }; + + + 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&> + { }; + + /// 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"); + }; + + 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&&> + { }; + + /// 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 + struct __is_nt_assignable_impl + : public integral_constant() = declval<_Up>())> + { }; + + template + struct __is_nothrow_assignable_impl + : public __and_<__bool_constant<__is_assignable(_Tp, _Up)>, + __is_nt_assignable_impl<_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_BUILTIN_IS_SAME_AS + : public integral_constant +#else + : public false_type +#endif + { }; + +#ifndef _GLIBCXX_BUILTIN_IS_SAME_AS + 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 201304 + + /// 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. + + // 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) + 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) + 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) + 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) + 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. +#if defined(_GLIBCXX_USE_WCHAR_T) + template<> + struct __make_unsigned + { + using __type + = typename __make_unsigned_selector::__type; + }; +#endif + +#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; + }; + + // 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; + + + // 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) + template<> + struct __make_signed + { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + template<> + struct __make_signed + { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + template<> + struct __make_signed + { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + 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. +#if defined(_GLIBCXX_USE_WCHAR_T) + template<> + struct __make_signed + { + using __type + = typename __make_signed_selector::__type; + }; +#endif + +#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; + }; + + // 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>> + { }; + + /// add_pointer + 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; }; + + 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; + + // 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; }; + + /// decay + template + class decay + { + typedef typename remove_reference<_Tp>::type __remove_type; + + public: + typedef typename __decay_selector<__remove_type>::__type type; + }; + + // __decay_t (std::decay_t for C++11). + template + using __decay_t = typename decay<_Tp>::type; + + template + class reference_wrapper; + + // 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; + }; + + template + using __decay_and_strip = __strip_reference_wrapper<__decay_t<_Tp>>; + + + // Primary template. + /// Define a member typedef @c type only if a boolean constant is true. + template + struct enable_if + { }; + + // Partial specialization for true. + template + struct enable_if + { typedef _Tp type; }; + + // __enable_if_t (std::enable_if_t for C++11) + template + using __enable_if_t = typename enable_if<_Cond, _Tp>::type; + + template + using _Require = __enable_if_t<__and_<_Cond...>::value>; + + // 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; }; + + // __remove_cvref_t (std::remove_cvref_t for C++11). + template + using __remove_cvref_t + = typename remove_cv::type>::type; + + /// common_type + template + struct common_type; + + // Sfinae-friendly common_type implementation: + + 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> + { }; + + /// The underlying type of an enum. + template + struct underlying_type + : public __underlying_type_impl<_Tp> + { }; + + template + struct __declval_protector + { + static const bool __stop = false; + }; + + 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 + class result_of; + + // Sfinae-friendly result_of implementation: + +#define __cpp_lib_result_of_sfinae 201210 + + 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<__or_, + is_base_of<_Class, _Argval>>::value, + __result_of_memobj_ref<_MemPtr, _Arg>, + __result_of_memobj_deref<_MemPtr, _Arg> + >::type::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::value, + __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, + __result_of_memfun_deref<_MemPtr, _Arg, _Args...> + >::type::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 + { }; + + template + struct result_of<_Functor(_ArgTypes...)> + : public __invoke_result<_Functor, _ArgTypes...> + { }; + +#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 201411 + /// A metafunction that always yields void, used for detecting valid types. + template using void_t = void; +#endif + + /// 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; + + /// @} group metaprogramming + + /** + * 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 + class tuple; + + template + struct __is_tuple_like_impl : false_type + { }; + + template + struct __is_tuple_like_impl> : true_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 + { }; + + 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); + + 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 + { }; + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 +#define __cpp_lib_is_swappable 201603 + /// 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 + + 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; + }; + + /// is_swappable_with + template + struct is_swappable_with + : public __is_swappable_with_impl<_Tp, _Up>::type + { }; + + /// is_nothrow_swappable_with + template + struct is_nothrow_swappable_with + : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type + { }; + +#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 + + // __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 + +#if __cplusplus >= 201703L +# define __cpp_lib_is_invocable 201703 + + /// std::invoke_result + template + struct invoke_result + : public __invoke_result<_Functor, _ArgTypes...> + { }; + + /// 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"); + }; + + /// 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"); + }; + + /// 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"); + }; + + template + struct __is_nt_invocable_impl : false_type { }; + + template + struct __is_nt_invocable_impl<_Result, _Ret, + __void_t> + : __or_, + __is_nothrow_convertible> + { }; + + /// 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 + { }; + + /// std::is_invocable_v + template + inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; + + /// std::is_nothrow_invocable_v + template + inline constexpr bool is_nothrow_invocable_v + = is_nothrow_invocable<_Fn, _Args...>::value; + + /// std::is_invocable_r_v + template + inline constexpr bool is_invocable_r_v + = is_invocable_r<_Ret, _Fn, _Args...>::value; + + /// std::is_nothrow_invocable_r_v + template + inline constexpr bool is_nothrow_invocable_r_v + = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; +#endif // C++17 + +#if __cplusplus >= 201703L +# define __cpp_lib_type_trait_variable_templates 201510L +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; +#pragma GCC diagnostic pop +template + inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; +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_BUILTIN_IS_SAME_AS +template + inline constexpr bool is_same_v = _GLIBCXX_BUILTIN_IS_SAME_AS(_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; + +#ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP +# define __cpp_lib_has_unique_object_representations 201606 + /// has_unique_object_representations + 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"); + }; + + 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 201703 + /// is_aggregate + template + struct is_aggregate + : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> + { }; + + /// is_aggregate_v + template + inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; +#endif +#endif // C++17 + +#if __cplusplus > 201703L +#define __cpp_lib_remove_cvref 201711L + + /// Remove references and cv-qualifiers. + template + struct remove_cvref + { + using type = __remove_cvref_t<_Tp>; + }; + + template + using remove_cvref_t = __remove_cvref_t<_Tp>; + +#define __cpp_lib_type_identity 201806L + /// Identity metafunction. + 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 + 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 + 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. + template + struct is_bounded_array + : public __is_array_known_bounds<_Tp> + { }; + + /// True for a type that is an array of unknown bound. + template + struct is_unbounded_array + : public __is_array_unknown_bounds<_Tp> + { }; + + template + inline constexpr bool is_bounded_array_v + = is_bounded_array<_Tp>::value; + + template + inline constexpr bool is_unbounded_array_v + = is_unbounded_array<_Tp>::value; + +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + +#define __cpp_lib_is_constant_evaluated 201811L + + constexpr inline bool + is_constant_evaluated() noexcept + { return __builtin_is_constant_evaluated(); } +#endif + + 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; + + // If A and B are both lvalue reference types, ... + template + struct __common_ref_impl<_Xp&, _Yp&, + __void_t<__cond_res<__copy_cv<_Xp, _Yp>&, __copy_cv<_Yp, _Xp>&>>> + { using type = __cond_res<__copy_cv<_Xp, _Yp>&, __copy_cv<_Yp, _Xp>&>; }; + + // 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&> + { }; + + template class _TQual, template class _UQual> + struct basic_common_reference + { }; + + 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; + + 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; }; + + 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...> + { }; + +#endif // C++2a + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_TYPE_TRAITS diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@type_traits.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@type_traits.blob new file mode 100644 index 0000000..958fd65 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@type_traits.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@typeinfo b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@typeinfo new file mode 100644 index 0000000..5a64e9f --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@typeinfo @@ -0,0 +1,225 @@ +// RTTI support for -*- C++ -*- +// Copyright (C) 1994-2020 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) + +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; } + +#if !__GXX_TYPEINFO_EQUALITY_INLINE + // 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. + bool before(const type_info& __arg) const _GLIBCXX_NOEXCEPT; + bool operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT; +#else + #if !__GXX_MERGED_TYPEINFO_NAMES + /** Returns true if @c *this precedes @c __arg in the implementation's + * collation order. */ + // 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. + bool before(const type_info& __arg) const _GLIBCXX_NOEXCEPT + { return (__name[0] == '*' && __arg.__name[0] == '*') + ? __name < __arg.__name + : __builtin_strcmp (__name, __arg.__name) < 0; } + + bool operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT + { + return ((__name == __arg.__name) + || (__name[0] != '*' && + __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. + bool before(const type_info& __arg) const _GLIBCXX_NOEXCEPT + { return __name < __arg.__name; } + + bool operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT + { return __name == __arg.__name; } + #endif +#endif + +#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: + /// Assigning type_info is not supported. + type_info& operator=(const type_info&); + type_info(const type_info&); + }; + + /** + * @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/@@home@ado@git@ssp/@usr@include@c++@10@typeinfo.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@typeinfo.blob new file mode 100644 index 0000000..e52375f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@typeinfo.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@utility b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@utility new file mode 100644 index 0000000..32747f8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@utility @@ -0,0 +1,478 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + * + * Components deemed generally useful. Includes pair, tuple, + * forward/move helpers, ratio, function object, metaprogramming and + * type traits, time, date, and memory functions. + */ + +#include +#include +#include + +#if __cplusplus >= 201103L + +#include +#include +#include + +#if __cplusplus > 201703L +#include +#endif + +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> { }; + + /// 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 +// The standard says this macro and alias template should be in +// but we define them here, to be available when the partial specializations +// of tuple_element> and tuple_element> are defined. +#define __cpp_lib_tuple_element_t 201402L + + template + using tuple_element_t = typename tuple_element<__i, _Tp>::type; +#endif + + // Various functions which give std::pair a tuple-like interface. + + /// Partial specialization for std::pair + 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, std::pair<_Tp1, _Tp2>> + { typedef _Tp1 type; }; + + /// Partial specialization for std::pair + template + struct tuple_element<1, std::pair<_Tp1, _Tp2>> + { typedef _Tp2 type; }; + + template + struct __pair_get; + + template<> + struct __pair_get<0> + { + template + static constexpr _Tp1& + __get(std::pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.first; } + + template + static constexpr _Tp1&& + __move_get(std::pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward<_Tp1>(__pair.first); } + + template + static constexpr const _Tp1& + __const_get(const std::pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.first; } + + template + static constexpr const _Tp1&& + __const_move_get(const std::pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward(__pair.first); } + }; + + template<> + struct __pair_get<1> + { + template + static constexpr _Tp2& + __get(std::pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.second; } + + template + static constexpr _Tp2&& + __move_get(std::pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward<_Tp2>(__pair.second); } + + template + static constexpr const _Tp2& + __const_get(const std::pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.second; } + + template + static constexpr const _Tp2&& + __const_move_get(const std::pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward(__pair.second); } + }; + + template + constexpr typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type& + get(std::pair<_Tp1, _Tp2>& __in) noexcept + { return __pair_get<_Int>::__get(__in); } + + template + constexpr typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type&& + get(std::pair<_Tp1, _Tp2>&& __in) noexcept + { return __pair_get<_Int>::__move_get(std::move(__in)); } + + template + constexpr const typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type& + get(const std::pair<_Tp1, _Tp2>& __in) noexcept + { return __pair_get<_Int>::__const_get(__in); } + + template + constexpr const typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type&& + get(const std::pair<_Tp1, _Tp2>&& __in) noexcept + { return __pair_get<_Int>::__const_move_get(std::move(__in)); } + +#if __cplusplus >= 201402L + +#define __cpp_lib_tuples_by_type 201304 + + 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); } + +#define __cpp_lib_exchange_function 201304 + + /// Assign @p __new_val to @p __obj and return its previous value. + template + _GLIBCXX20_CONSTEXPR + inline _Tp + exchange(_Tp& __obj, _Up&& __new_val) + { return std::__exchange(__obj, std::forward<_Up>(__new_val)); } + +#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 { }; + +#ifdef __has_builtin +# if __has_builtin(__make_integer_seq) +# define _GLIBCXX_USE_MAKE_INTEGER_SEQ 1 +# endif +#endif + + // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>. + template + struct _Build_index_tuple + { +#if _GLIBCXX_USE_MAKE_INTEGER_SEQ + template + using _IdxTuple = _Index_tuple<_Indices...>; + + using __type = __make_integer_seq<_IdxTuple, size_t, _Num>; +#else + using __type = _Index_tuple<__integer_pack(_Num)...>; +#endif + }; + +#if __cplusplus > 201103L + +#define __cpp_lib_integer_sequence 201304 + + /// 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 _GLIBCXX_USE_MAKE_INTEGER_SEQ + = __make_integer_seq; +#else + = integer_sequence<_Tp, __integer_pack(_Num)...>; +#endif + +#undef _GLIBCXX_USE_MAKE_INTEGER_SEQ + + /// 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; +#endif + +#if __cplusplus > 201402L + + 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 + struct __is_in_place_type_impl : false_type + { }; + + template + struct __is_in_place_type_impl> : true_type + { }; + + template + struct __is_in_place_type + : public __is_in_place_type_impl<_Tp> + { }; + +#define __cpp_lib_as_const 201510 + template + 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); + } +#endif // C++20 +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif + +#endif /* _GLIBCXX_UTILITY */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@utility.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@utility.blob new file mode 100644 index 0000000..54550ce Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@utility.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@variant b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@variant new file mode 100644 index 0000000..fa0284d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@variant @@ -0,0 +1,1800 @@ +// -*- C++ -*- + +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 variant + * This is the C++ Library header. + */ + +#ifndef _GLIBCXX_VARIANT +#define _GLIBCXX_VARIANT 1 + +#pragma GCC system_header + +#if __cplusplus >= 201703L + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if __cplusplus > 201703L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ +namespace __variant +{ + template + struct _Nth_type; + + template + struct _Nth_type<_Np, _First, _Rest...> + : _Nth_type<_Np-1, _Rest...> { }; + + template + struct _Nth_type<0, _First, _Rest...> + { using type = _First; }; + +} // namespace __variant +} // namespace __detail + +#define __cpp_lib_variant 201606L + + template class tuple; + template class variant; + template struct hash; + + template + struct variant_size; + + template + struct variant_size : variant_size<_Variant> {}; + + template + struct variant_size : variant_size<_Variant> {}; + + template + struct variant_size : variant_size<_Variant> {}; + + template + struct variant_size> + : std::integral_constant {}; + + template + inline constexpr size_t variant_size_v = variant_size<_Variant>::value; + + template + struct variant_alternative; + + template + struct variant_alternative<_Np, variant<_First, _Rest...>> + : variant_alternative<_Np-1, variant<_Rest...>> {}; + + template + struct variant_alternative<0, variant<_First, _Rest...>> + { using type = _First; }; + + template + using variant_alternative_t = + typename variant_alternative<_Np, _Variant>::type; + + template + struct variant_alternative<_Np, const _Variant> + { using type = add_const_t>; }; + + template + struct variant_alternative<_Np, volatile _Variant> + { using type = add_volatile_t>; }; + + template + struct variant_alternative<_Np, const volatile _Variant> + { using type = add_cv_t>; }; + + inline constexpr size_t variant_npos = -1; + + template + constexpr variant_alternative_t<_Np, variant<_Types...>>& + get(variant<_Types...>&); + + template + constexpr variant_alternative_t<_Np, variant<_Types...>>&& + get(variant<_Types...>&&); + + template + constexpr variant_alternative_t<_Np, variant<_Types...>> const& + get(const variant<_Types...>&); + + template + constexpr variant_alternative_t<_Np, variant<_Types...>> const&& + get(const variant<_Types...>&&); + + template + constexpr decltype(auto) + __do_visit(_Visitor&& __visitor, _Variants&&... __variants); + + template + decltype(auto) + __variant_cast(_Tp&& __rhs) + { + if constexpr (is_lvalue_reference_v<_Tp>) + { + if constexpr (is_const_v>) + return static_cast&>(__rhs); + else + return static_cast&>(__rhs); + } + else + return static_cast&&>(__rhs); + } + +namespace __detail +{ +namespace __variant +{ + // Returns the first appearence of _Tp in _Types. + // Returns sizeof...(_Types) if _Tp is not in _Types. + template + struct __index_of : std::integral_constant {}; + + template + inline constexpr size_t __index_of_v = __index_of<_Tp, _Types...>::value; + + template + struct __index_of<_Tp, _First, _Rest...> : + std::integral_constant + ? 0 : __index_of_v<_Tp, _Rest...> + 1> {}; + + // used for raw visitation + struct __variant_cookie {}; + // used for raw visitation with indices passed in + struct __variant_idx_cookie { using type = __variant_idx_cookie; }; + // Used to enable deduction (and same-type checking) for std::visit: + template struct __deduce_visit_result { }; + + // Visit variants that might be valueless. + template + constexpr void + __raw_visit(_Visitor&& __visitor, _Variants&&... __variants) + { + std::__do_visit<__variant_cookie>(std::forward<_Visitor>(__visitor), + std::forward<_Variants>(__variants)...); + } + + // Visit variants that might be valueless, passing indices to the visitor. + template + constexpr void + __raw_idx_visit(_Visitor&& __visitor, _Variants&&... __variants) + { + std::__do_visit<__variant_idx_cookie>(std::forward<_Visitor>(__visitor), + std::forward<_Variants>(__variants)...); + } + + // _Uninitialized is guaranteed to be a trivially destructible type, + // even if T is not. + template> + struct _Uninitialized; + + template + struct _Uninitialized<_Type, true> + { + template + constexpr + _Uninitialized(in_place_index_t<0>, _Args&&... __args) + : _M_storage(std::forward<_Args>(__args)...) + { } + + constexpr const _Type& _M_get() const & noexcept + { return _M_storage; } + + constexpr _Type& _M_get() & noexcept + { return _M_storage; } + + constexpr const _Type&& _M_get() const && noexcept + { return std::move(_M_storage); } + + constexpr _Type&& _M_get() && noexcept + { return std::move(_M_storage); } + + _Type _M_storage; + }; + + template + struct _Uninitialized<_Type, false> + { + template + constexpr + _Uninitialized(in_place_index_t<0>, _Args&&... __args) + { + ::new ((void*)std::addressof(_M_storage)) + _Type(std::forward<_Args>(__args)...); + } + + const _Type& _M_get() const & noexcept + { return *_M_storage._M_ptr(); } + + _Type& _M_get() & noexcept + { return *_M_storage._M_ptr(); } + + const _Type&& _M_get() const && noexcept + { return std::move(*_M_storage._M_ptr()); } + + _Type&& _M_get() && noexcept + { return std::move(*_M_storage._M_ptr()); } + + __gnu_cxx::__aligned_membuf<_Type> _M_storage; + }; + + template + constexpr decltype(auto) + __get(in_place_index_t<0>, _Union&& __u) noexcept + { return std::forward<_Union>(__u)._M_first._M_get(); } + + template + constexpr decltype(auto) + __get(in_place_index_t<_Np>, _Union&& __u) noexcept + { + return __variant::__get(in_place_index<_Np-1>, + std::forward<_Union>(__u)._M_rest); + } + + // Returns the typed storage for __v. + template + constexpr decltype(auto) + __get(_Variant&& __v) noexcept + { + return __variant::__get(std::in_place_index<_Np>, + std::forward<_Variant>(__v)._M_u); + } + + template + struct _Traits + { + static constexpr bool _S_default_ctor = + is_default_constructible_v::type>; + static constexpr bool _S_copy_ctor = + (is_copy_constructible_v<_Types> && ...); + static constexpr bool _S_move_ctor = + (is_move_constructible_v<_Types> && ...); + static constexpr bool _S_copy_assign = + _S_copy_ctor + && (is_copy_assignable_v<_Types> && ...); + static constexpr bool _S_move_assign = + _S_move_ctor + && (is_move_assignable_v<_Types> && ...); + + static constexpr bool _S_trivial_dtor = + (is_trivially_destructible_v<_Types> && ...); + static constexpr bool _S_trivial_copy_ctor = + (is_trivially_copy_constructible_v<_Types> && ...); + static constexpr bool _S_trivial_move_ctor = + (is_trivially_move_constructible_v<_Types> && ...); + static constexpr bool _S_trivial_copy_assign = + _S_trivial_dtor && _S_trivial_copy_ctor + && (is_trivially_copy_assignable_v<_Types> && ...); + static constexpr bool _S_trivial_move_assign = + _S_trivial_dtor && _S_trivial_move_ctor + && (is_trivially_move_assignable_v<_Types> && ...); + + // The following nothrow traits are for non-trivial SMFs. Trivial SMFs + // are always nothrow. + static constexpr bool _S_nothrow_default_ctor = + is_nothrow_default_constructible_v< + typename _Nth_type<0, _Types...>::type>; + static constexpr bool _S_nothrow_copy_ctor = false; + static constexpr bool _S_nothrow_move_ctor = + (is_nothrow_move_constructible_v<_Types> && ...); + static constexpr bool _S_nothrow_copy_assign = false; + static constexpr bool _S_nothrow_move_assign = + _S_nothrow_move_ctor + && (is_nothrow_move_assignable_v<_Types> && ...); + }; + + // Defines members and ctors. + template + union _Variadic_union { }; + + template + union _Variadic_union<_First, _Rest...> + { + constexpr _Variadic_union() : _M_rest() { } + + template + constexpr _Variadic_union(in_place_index_t<0>, _Args&&... __args) + : _M_first(in_place_index<0>, std::forward<_Args>(__args)...) + { } + + template + constexpr _Variadic_union(in_place_index_t<_Np>, _Args&&... __args) + : _M_rest(in_place_index<_Np-1>, std::forward<_Args>(__args)...) + { } + + _Uninitialized<_First> _M_first; + _Variadic_union<_Rest...> _M_rest; + }; + + // _Never_valueless_alt is true for variant alternatives that can + // always be placed in a variant without it becoming valueless. + + // For suitably-small, trivially copyable types we can create temporaries + // on the stack and then memcpy them into place. + template + struct _Never_valueless_alt + : __and_, is_trivially_copyable<_Tp>> + { }; + + // Specialize _Never_valueless_alt for other types which have a + // non-throwing and cheap move construction and move assignment operator, + // so that emplacing the type will provide the strong exception-safety + // guarantee, by creating and moving a temporary. + // Whether _Never_valueless_alt is true or not affects the ABI of a + // variant using that alternative, so we can't change the value later! + + // True if every alternative in _Types... can be emplaced in a variant + // without it becoming valueless. If this is true, variant<_Types...> + // can never be valueless, which enables some minor optimizations. + template + constexpr bool __never_valueless() + { + return _Traits<_Types...>::_S_move_assign + && (_Never_valueless_alt<_Types>::value && ...); + } + + // Defines index and the dtor, possibly trivial. + template + struct _Variant_storage; + + template + using __select_index = + typename __select_int::_Select_int_base::type::value_type; + + template + struct _Variant_storage + { + constexpr + _Variant_storage() + : _M_index(static_cast<__index_type>(variant_npos)) + { } + + template + constexpr + _Variant_storage(in_place_index_t<_Np>, _Args&&... __args) + : _M_u(in_place_index<_Np>, std::forward<_Args>(__args)...), + _M_index{_Np} + { } + + void _M_reset() + { + if (!_M_valid()) [[unlikely]] + return; + + std::__do_visit([](auto&& __this_mem) mutable + { + std::_Destroy(std::__addressof(__this_mem)); + }, __variant_cast<_Types...>(*this)); + + _M_index = static_cast<__index_type>(variant_npos); + } + + ~_Variant_storage() + { _M_reset(); } + + void* + _M_storage() const noexcept + { + return const_cast(static_cast( + std::addressof(_M_u))); + } + + constexpr bool + _M_valid() const noexcept + { + if constexpr (__variant::__never_valueless<_Types...>()) + return true; + return this->_M_index != __index_type(variant_npos); + } + + _Variadic_union<_Types...> _M_u; + using __index_type = __select_index<_Types...>; + __index_type _M_index; + }; + + template + struct _Variant_storage + { + constexpr + _Variant_storage() + : _M_index(static_cast<__index_type>(variant_npos)) + { } + + template + constexpr + _Variant_storage(in_place_index_t<_Np>, _Args&&... __args) + : _M_u(in_place_index<_Np>, std::forward<_Args>(__args)...), + _M_index{_Np} + { } + + void _M_reset() noexcept + { _M_index = static_cast<__index_type>(variant_npos); } + + void* + _M_storage() const noexcept + { + return const_cast(static_cast( + std::addressof(_M_u))); + } + + constexpr bool + _M_valid() const noexcept + { + if constexpr (__variant::__never_valueless<_Types...>()) + return true; + return this->_M_index != static_cast<__index_type>(variant_npos); + } + + _Variadic_union<_Types...> _M_u; + using __index_type = __select_index<_Types...>; + __index_type _M_index; + }; + + template + using _Variant_storage_alias = + _Variant_storage<_Traits<_Types...>::_S_trivial_dtor, _Types...>; + + template + void __variant_construct_single(_Tp&& __lhs, _Up&& __rhs_mem) + { + void* __storage = std::addressof(__lhs._M_u); + using _Type = remove_reference_t; + if constexpr (!is_same_v<_Type, __variant_cookie>) + ::new (__storage) + _Type(std::forward(__rhs_mem)); + } + + template + void __variant_construct(_Tp&& __lhs, _Up&& __rhs) + { + __lhs._M_index = __rhs._M_index; + __variant::__raw_visit([&__lhs](auto&& __rhs_mem) mutable + { + __variant_construct_single(std::forward<_Tp>(__lhs), + std::forward(__rhs_mem)); + }, __variant_cast<_Types...>(std::forward<_Up>(__rhs))); + } + + // The following are (Copy|Move) (ctor|assign) layers for forwarding + // triviality and handling non-trivial SMF behaviors. + + template + struct _Copy_ctor_base : _Variant_storage_alias<_Types...> + { + using _Base = _Variant_storage_alias<_Types...>; + using _Base::_Base; + + _Copy_ctor_base(const _Copy_ctor_base& __rhs) + noexcept(_Traits<_Types...>::_S_nothrow_copy_ctor) + { + __variant_construct<_Types...>(*this, __rhs); + } + + _Copy_ctor_base(_Copy_ctor_base&&) = default; + _Copy_ctor_base& operator=(const _Copy_ctor_base&) = default; + _Copy_ctor_base& operator=(_Copy_ctor_base&&) = default; + }; + + template + struct _Copy_ctor_base : _Variant_storage_alias<_Types...> + { + using _Base = _Variant_storage_alias<_Types...>; + using _Base::_Base; + }; + + template + using _Copy_ctor_alias = + _Copy_ctor_base<_Traits<_Types...>::_S_trivial_copy_ctor, _Types...>; + + template + struct _Move_ctor_base : _Copy_ctor_alias<_Types...> + { + using _Base = _Copy_ctor_alias<_Types...>; + using _Base::_Base; + + _Move_ctor_base(_Move_ctor_base&& __rhs) + noexcept(_Traits<_Types...>::_S_nothrow_move_ctor) + { + __variant_construct<_Types...>(*this, std::move(__rhs)); + } + + template + void _M_destructive_move(unsigned short __rhs_index, _Up&& __rhs) + { + this->_M_reset(); + __variant_construct_single(*this, std::forward<_Up>(__rhs)); + this->_M_index = __rhs_index; + } + + template + void _M_destructive_copy(unsigned short __rhs_index, const _Up& __rhs) + { + this->_M_reset(); + __variant_construct_single(*this, __rhs); + this->_M_index = __rhs_index; + } + + _Move_ctor_base(const _Move_ctor_base&) = default; + _Move_ctor_base& operator=(const _Move_ctor_base&) = default; + _Move_ctor_base& operator=(_Move_ctor_base&&) = default; + }; + + template + struct _Move_ctor_base : _Copy_ctor_alias<_Types...> + { + using _Base = _Copy_ctor_alias<_Types...>; + using _Base::_Base; + + template + void _M_destructive_move(unsigned short __rhs_index, _Up&& __rhs) + { + this->_M_reset(); + __variant_construct_single(*this, std::forward<_Up>(__rhs)); + this->_M_index = __rhs_index; + } + + template + void _M_destructive_copy(unsigned short __rhs_index, const _Up& __rhs) + { + this->_M_reset(); + __variant_construct_single(*this, __rhs); + this->_M_index = __rhs_index; + } + }; + + template + using _Move_ctor_alias = + _Move_ctor_base<_Traits<_Types...>::_S_trivial_move_ctor, _Types...>; + + template + struct _Copy_assign_base : _Move_ctor_alias<_Types...> + { + using _Base = _Move_ctor_alias<_Types...>; + using _Base::_Base; + + _Copy_assign_base& + operator=(const _Copy_assign_base& __rhs) + noexcept(_Traits<_Types...>::_S_nothrow_copy_assign) + { + __variant::__raw_idx_visit( + [this](auto&& __rhs_mem, auto __rhs_index) mutable + { + if constexpr (__rhs_index != variant_npos) + { + if (this->_M_index == __rhs_index) + __variant::__get<__rhs_index>(*this) = __rhs_mem; + else + { + using __rhs_type = __remove_cvref_t; + if constexpr (is_nothrow_copy_constructible_v<__rhs_type> + || !is_nothrow_move_constructible_v<__rhs_type>) + // The standard says this->emplace<__rhs_type>(__rhs_mem) + // should be used here, but _M_destructive_copy is + // equivalent in this case. Either copy construction + // doesn't throw, so _M_destructive_copy gives strong + // exception safety guarantee, or both copy construction + // and move construction can throw, so emplace only gives + // basic exception safety anyway. + this->_M_destructive_copy(__rhs_index, __rhs_mem); + else + __variant_cast<_Types...>(*this) + = variant<_Types...>(std::in_place_index<__rhs_index>, + __rhs_mem); + } + } + else + this->_M_reset(); + }, __variant_cast<_Types...>(__rhs)); + return *this; + } + + _Copy_assign_base(const _Copy_assign_base&) = default; + _Copy_assign_base(_Copy_assign_base&&) = default; + _Copy_assign_base& operator=(_Copy_assign_base&&) = default; + }; + + template + struct _Copy_assign_base : _Move_ctor_alias<_Types...> + { + using _Base = _Move_ctor_alias<_Types...>; + using _Base::_Base; + }; + + template + using _Copy_assign_alias = + _Copy_assign_base<_Traits<_Types...>::_S_trivial_copy_assign, _Types...>; + + template + struct _Move_assign_base : _Copy_assign_alias<_Types...> + { + using _Base = _Copy_assign_alias<_Types...>; + using _Base::_Base; + + _Move_assign_base& + operator=(_Move_assign_base&& __rhs) + noexcept(_Traits<_Types...>::_S_nothrow_move_assign) + { + __variant::__raw_idx_visit( + [this](auto&& __rhs_mem, auto __rhs_index) mutable + { + if constexpr (__rhs_index != variant_npos) + { + if (this->_M_index == __rhs_index) + __variant::__get<__rhs_index>(*this) = std::move(__rhs_mem); + else + __variant_cast<_Types...>(*this) + .template emplace<__rhs_index>(std::move(__rhs_mem)); + } + else + this->_M_reset(); + }, __variant_cast<_Types...>(__rhs)); + return *this; + } + + _Move_assign_base(const _Move_assign_base&) = default; + _Move_assign_base(_Move_assign_base&&) = default; + _Move_assign_base& operator=(const _Move_assign_base&) = default; + }; + + template + struct _Move_assign_base : _Copy_assign_alias<_Types...> + { + using _Base = _Copy_assign_alias<_Types...>; + using _Base::_Base; + }; + + template + using _Move_assign_alias = + _Move_assign_base<_Traits<_Types...>::_S_trivial_move_assign, _Types...>; + + template + struct _Variant_base : _Move_assign_alias<_Types...> + { + using _Base = _Move_assign_alias<_Types...>; + + constexpr + _Variant_base() + noexcept(_Traits<_Types...>::_S_nothrow_default_ctor) + : _Variant_base(in_place_index<0>) { } + + template + constexpr explicit + _Variant_base(in_place_index_t<_Np> __i, _Args&&... __args) + : _Base(__i, std::forward<_Args>(__args)...) + { } + + _Variant_base(const _Variant_base&) = default; + _Variant_base(_Variant_base&&) = default; + _Variant_base& operator=(const _Variant_base&) = default; + _Variant_base& operator=(_Variant_base&&) = default; + }; + + // For how many times does _Tp appear in _Tuple? + template + struct __tuple_count; + + template + inline constexpr size_t __tuple_count_v = + __tuple_count<_Tp, _Tuple>::value; + + template + struct __tuple_count<_Tp, tuple<_Types...>> + : integral_constant { }; + + template + struct __tuple_count<_Tp, tuple<_First, _Rest...>> + : integral_constant< + size_t, + __tuple_count_v<_Tp, tuple<_Rest...>> + is_same_v<_Tp, _First>> { }; + + // TODO: Reuse this in ? + template + inline constexpr bool __exactly_once = + __tuple_count_v<_Tp, tuple<_Types...>> == 1; + + // Helper used to check for valid conversions that don't involve narrowing. + template struct _Arr { _Ti _M_x[1]; }; + + // Build an imaginary function FUN(Ti) for each alternative type Ti + template, bool>, + typename = void> + struct _Build_FUN + { + // This function means 'using _Build_FUN::_S_fun;' is valid, + // but only static functions will be considered in the call below. + void _S_fun(); + }; + + // ... for which Ti x[] = {std::forward(t)}; is well-formed, + template + struct _Build_FUN<_Ind, _Tp, _Ti, false, + void_t{{std::declval<_Tp>()}})>> + { + // This is the FUN function for type _Ti, with index _Ind + static integral_constant _S_fun(_Ti); + }; + + // ... and if Ti is cv bool, remove_cvref_t is bool. + template + struct _Build_FUN<_Ind, _Tp, _Ti, true, + enable_if_t, bool>>> + { + // This is the FUN function for when _Ti is cv bool, with index _Ind + static integral_constant _S_fun(_Ti); + }; + + template>> + struct _Build_FUNs; + + template + struct _Build_FUNs<_Tp, variant<_Ti...>, index_sequence<_Ind...>> + : _Build_FUN<_Ind, _Tp, _Ti>... + { + using _Build_FUN<_Ind, _Tp, _Ti>::_S_fun...; + }; + + // The index j of the overload FUN(Tj) selected by overload resolution + // for FUN(std::forward<_Tp>(t)) + template + using _FUN_type + = decltype(_Build_FUNs<_Tp, _Variant>::_S_fun(std::declval<_Tp>())); + + // The index selected for FUN(std::forward(t)), or variant_npos if none. + template + struct __accepted_index + : integral_constant + { }; + + template + struct __accepted_index<_Tp, _Variant, void_t<_FUN_type<_Tp, _Variant>>> + : _FUN_type<_Tp, _Variant> + { }; + + // Returns the raw storage for __v. + template + void* __get_storage(_Variant&& __v) noexcept + { return __v._M_storage(); } + + template + struct _Extra_visit_slot_needed + { + template struct _Variant_never_valueless; + + template + struct _Variant_never_valueless> + : bool_constant<__variant::__never_valueless<_Types...>()> {}; + + static constexpr bool value = + (is_same_v<_Maybe_variant_cookie, __variant_cookie> + || is_same_v<_Maybe_variant_cookie, __variant_idx_cookie>) + && !_Variant_never_valueless<__remove_cvref_t<_Variant>>::value; + }; + + // Used for storing a multi-dimensional vtable. + template + struct _Multi_array; + + // Partial specialization with rank zero, stores a single _Tp element. + template + struct _Multi_array<_Tp> + { + template + struct __untag_result + : false_type + { using element_type = _Tp; }; + + template + struct __untag_result + : false_type + { using element_type = void(*)(_Args...); }; + + template + struct __untag_result<__variant_cookie(*)(_Args...)> + : false_type + { using element_type = void(*)(_Args...); }; + + template + struct __untag_result<__variant_idx_cookie(*)(_Args...)> + : false_type + { using element_type = void(*)(_Args...); }; + + template + struct __untag_result<__deduce_visit_result<_Res>(*)(_Args...)> + : true_type + { using element_type = _Res(*)(_Args...); }; + + using __result_is_deduced = __untag_result<_Tp>; + + constexpr const typename __untag_result<_Tp>::element_type& + _M_access() const + { return _M_data; } + + typename __untag_result<_Tp>::element_type _M_data; + }; + + // Partial specialization with rank >= 1. + template + struct _Multi_array<_Ret(*)(_Visitor, _Variants...), __first, __rest...> + { + static constexpr size_t __index = + sizeof...(_Variants) - sizeof...(__rest) - 1; + + using _Variant = typename _Nth_type<__index, _Variants...>::type; + + static constexpr int __do_cookie = + _Extra_visit_slot_needed<_Ret, _Variant>::value ? 1 : 0; + + using _Tp = _Ret(*)(_Visitor, _Variants...); + + template + constexpr decltype(auto) + _M_access(size_t __first_index, _Args... __rest_indices) const + { + return _M_arr[__first_index + __do_cookie] + ._M_access(__rest_indices...); + } + + _Multi_array<_Tp, __rest...> _M_arr[__first + __do_cookie]; + }; + + // Creates a multi-dimensional vtable recursively. + // + // For example, + // visit([](auto, auto){}, + // variant(), // typedef'ed as V1 + // variant()) // typedef'ed as V2 + // will trigger instantiations of: + // __gen_vtable_impl<_Multi_array, + // tuple, std::index_sequence<>> + // __gen_vtable_impl<_Multi_array, + // tuple, std::index_sequence<0>> + // __gen_vtable_impl<_Multi_array, + // tuple, std::index_sequence<0, 0>> + // __gen_vtable_impl<_Multi_array, + // tuple, std::index_sequence<0, 1>> + // __gen_vtable_impl<_Multi_array, + // tuple, std::index_sequence<0, 2>> + // __gen_vtable_impl<_Multi_array, + // tuple, std::index_sequence<1>> + // __gen_vtable_impl<_Multi_array, + // tuple, std::index_sequence<1, 0>> + // __gen_vtable_impl<_Multi_array, + // tuple, std::index_sequence<1, 1>> + // __gen_vtable_impl<_Multi_array, + // tuple, std::index_sequence<1, 2>> + // The returned multi-dimensional vtable can be fast accessed by the visitor + // using index calculation. + template + struct __gen_vtable_impl; + + // Defines the _S_apply() member that returns a _Multi_array populated + // with function pointers that perform the visitation expressions e(m) + // for each valid pack of indexes into the variant types _Variants. + // + // This partial specialization builds up the index sequences by recursively + // calling _S_apply() on the next specialization of __gen_vtable_impl. + // The base case of the recursion defines the actual function pointers. + template + struct __gen_vtable_impl< + _Multi_array<_Result_type (*)(_Visitor, _Variants...), __dimensions...>, + std::index_sequence<__indices...>> + { + using _Next = + remove_reference_t::type>; + using _Array_type = + _Multi_array<_Result_type (*)(_Visitor, _Variants...), + __dimensions...>; + + static constexpr _Array_type + _S_apply() + { + _Array_type __vtable{}; + _S_apply_all_alts( + __vtable, make_index_sequence>()); + return __vtable; + } + + template + static constexpr void + _S_apply_all_alts(_Array_type& __vtable, + std::index_sequence<__var_indices...>) + { + if constexpr (_Extra_visit_slot_needed<_Result_type, _Next>::value) + (_S_apply_single_alt( + __vtable._M_arr[__var_indices + 1], + &(__vtable._M_arr[0])), ...); + else + (_S_apply_single_alt( + __vtable._M_arr[__var_indices]), ...); + } + + template + static constexpr void + _S_apply_single_alt(_Tp& __element, _Tp* __cookie_element = nullptr) + { + if constexpr (__do_cookie) + { + __element = __gen_vtable_impl< + _Tp, + std::index_sequence<__indices..., __index>>::_S_apply(); + *__cookie_element = __gen_vtable_impl< + _Tp, + std::index_sequence<__indices..., variant_npos>>::_S_apply(); + } + else + { + __element = __gen_vtable_impl< + remove_reference_t, + std::index_sequence<__indices..., __index>>::_S_apply(); + } + } + }; + + // This partial specialization is the base case for the recursion. + // It populates a _Multi_array element with the address of a function + // that invokes the visitor with the alternatives specified by __indices. + template + struct __gen_vtable_impl< + _Multi_array<_Result_type (*)(_Visitor, _Variants...)>, + std::index_sequence<__indices...>> + { + using _Array_type = + _Multi_array<_Result_type (*)(_Visitor, _Variants...)>; + + template + static constexpr decltype(auto) + __element_by_index_or_cookie(_Variant&& __var) noexcept + { + if constexpr (__index != variant_npos) + return __variant::__get<__index>(std::forward<_Variant>(__var)); + else + return __variant_cookie{}; + } + + static constexpr decltype(auto) + __visit_invoke(_Visitor&& __visitor, _Variants... __vars) + { + if constexpr (is_same_v<_Result_type, __variant_idx_cookie>) + // For raw visitation using indices, pass the indices to the visitor + // and discard the return value: + std::__invoke(std::forward<_Visitor>(__visitor), + __element_by_index_or_cookie<__indices>( + std::forward<_Variants>(__vars))..., + integral_constant()...); + else if constexpr (is_same_v<_Result_type, __variant_cookie>) + // For raw visitation without indices, and discard the return value: + std::__invoke(std::forward<_Visitor>(__visitor), + __element_by_index_or_cookie<__indices>( + std::forward<_Variants>(__vars))...); + else if constexpr (_Array_type::__result_is_deduced::value) + // For the usual std::visit case deduce the return value: + return std::__invoke(std::forward<_Visitor>(__visitor), + __element_by_index_or_cookie<__indices>( + std::forward<_Variants>(__vars))...); + else // for std::visit use INVOKE + return std::__invoke_r<_Result_type>( + std::forward<_Visitor>(__visitor), + __variant::__get<__indices>(std::forward<_Variants>(__vars))...); + } + + static constexpr auto + _S_apply() + { return _Array_type{&__visit_invoke}; } + }; + + template + struct __gen_vtable + { + using _Array_type = + _Multi_array<_Result_type (*)(_Visitor, _Variants...), + variant_size_v>...>; + + static constexpr _Array_type _S_vtable + = __gen_vtable_impl<_Array_type, std::index_sequence<>>::_S_apply(); + }; + + template + struct _Base_dedup : public _Tp { }; + + template + struct _Variant_hash_base; + + template + struct _Variant_hash_base, + std::index_sequence<__indices...>> + : _Base_dedup<__indices, __poison_hash>>... { }; + +} // namespace __variant +} // namespace __detail + + template + void __variant_construct_by_index(_Variant& __v, _Args&&... __args) + { + __v._M_index = _Np; + auto&& __storage = __detail::__variant::__get<_Np>(__v); + ::new ((void*)std::addressof(__storage)) + remove_reference_t + (std::forward<_Args>(__args)...); + } + + template + constexpr bool + holds_alternative(const variant<_Types...>& __v) noexcept + { + static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, + "T must occur exactly once in alternatives"); + return __v.index() == __detail::__variant::__index_of_v<_Tp, _Types...>; + } + + template + constexpr _Tp& get(variant<_Types...>& __v) + { + static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, + "T must occur exactly once in alternatives"); + static_assert(!is_void_v<_Tp>, "_Tp must not be void"); + return std::get<__detail::__variant::__index_of_v<_Tp, _Types...>>(__v); + } + + template + constexpr _Tp&& get(variant<_Types...>&& __v) + { + static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, + "T must occur exactly once in alternatives"); + static_assert(!is_void_v<_Tp>, "_Tp must not be void"); + return std::get<__detail::__variant::__index_of_v<_Tp, _Types...>>( + std::move(__v)); + } + + template + constexpr const _Tp& get(const variant<_Types...>& __v) + { + static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, + "T must occur exactly once in alternatives"); + static_assert(!is_void_v<_Tp>, "_Tp must not be void"); + return std::get<__detail::__variant::__index_of_v<_Tp, _Types...>>(__v); + } + + template + constexpr const _Tp&& get(const variant<_Types...>&& __v) + { + static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, + "T must occur exactly once in alternatives"); + static_assert(!is_void_v<_Tp>, "_Tp must not be void"); + return std::get<__detail::__variant::__index_of_v<_Tp, _Types...>>( + std::move(__v)); + } + + template + constexpr add_pointer_t>> + get_if(variant<_Types...>* __ptr) noexcept + { + using _Alternative_type = variant_alternative_t<_Np, variant<_Types...>>; + static_assert(_Np < sizeof...(_Types), + "The index must be in [0, number of alternatives)"); + static_assert(!is_void_v<_Alternative_type>, "_Tp must not be void"); + if (__ptr && __ptr->index() == _Np) + return std::addressof(__detail::__variant::__get<_Np>(*__ptr)); + return nullptr; + } + + template + constexpr + add_pointer_t>> + get_if(const variant<_Types...>* __ptr) noexcept + { + using _Alternative_type = variant_alternative_t<_Np, variant<_Types...>>; + static_assert(_Np < sizeof...(_Types), + "The index must be in [0, number of alternatives)"); + static_assert(!is_void_v<_Alternative_type>, "_Tp must not be void"); + if (__ptr && __ptr->index() == _Np) + return std::addressof(__detail::__variant::__get<_Np>(*__ptr)); + return nullptr; + } + + template + constexpr add_pointer_t<_Tp> + get_if(variant<_Types...>* __ptr) noexcept + { + static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, + "T must occur exactly once in alternatives"); + static_assert(!is_void_v<_Tp>, "_Tp must not be void"); + return std::get_if<__detail::__variant::__index_of_v<_Tp, _Types...>>( + __ptr); + } + + template + constexpr add_pointer_t + get_if(const variant<_Types...>* __ptr) noexcept + { + static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>, + "T must occur exactly once in alternatives"); + static_assert(!is_void_v<_Tp>, "_Tp must not be void"); + return std::get_if<__detail::__variant::__index_of_v<_Tp, _Types...>>( + __ptr); + } + + struct monostate { }; + +#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP, __NAME) \ + template \ + constexpr bool operator __OP(const variant<_Types...>& __lhs, \ + const variant<_Types...>& __rhs) \ + { \ + bool __ret = true; \ + __detail::__variant::__raw_idx_visit( \ + [&__ret, &__lhs] (auto&& __rhs_mem, auto __rhs_index) mutable \ + { \ + if constexpr (__rhs_index != variant_npos) \ + { \ + if (__lhs.index() == __rhs_index) \ + { \ + auto& __this_mem = std::get<__rhs_index>(__lhs); \ + __ret = __this_mem __OP __rhs_mem; \ + } \ + else \ + __ret = (__lhs.index() + 1) __OP (__rhs_index + 1); \ + } \ + else \ + __ret = (__lhs.index() + 1) __OP (__rhs_index + 1); \ + }, __rhs); \ + return __ret; \ + } + + _VARIANT_RELATION_FUNCTION_TEMPLATE(<, less) + _VARIANT_RELATION_FUNCTION_TEMPLATE(<=, less_equal) + _VARIANT_RELATION_FUNCTION_TEMPLATE(==, equal) + _VARIANT_RELATION_FUNCTION_TEMPLATE(!=, not_equal) + _VARIANT_RELATION_FUNCTION_TEMPLATE(>=, greater_equal) + _VARIANT_RELATION_FUNCTION_TEMPLATE(>, greater) + +#undef _VARIANT_RELATION_FUNCTION_TEMPLATE + + constexpr bool operator==(monostate, monostate) noexcept { return true; } + +#ifdef __cpp_lib_three_way_comparison + template + requires (three_way_comparable<_Types> && ...) + constexpr + common_comparison_category_t...> + operator<=>(const variant<_Types...>& __v, const variant<_Types...>& __w) + { + common_comparison_category_t...> __ret + = strong_ordering::equal; + + __detail::__variant::__raw_idx_visit( + [&__ret, &__v] (auto&& __w_mem, auto __w_index) mutable + { + if constexpr (__w_index != variant_npos) + { + if (__v.index() == __w_index) + { + auto& __this_mem = std::get<__w_index>(__v); + __ret = __this_mem <=> __w_mem; + return; + } + } + __ret = (__v.index() + 1) <=> (__w_index + 1); + }, __w); + return __ret; + } + + constexpr strong_ordering + operator<=>(monostate, monostate) noexcept { return strong_ordering::equal; } +#else + constexpr bool operator!=(monostate, monostate) noexcept { return false; } + constexpr bool operator<(monostate, monostate) noexcept { return false; } + constexpr bool operator>(monostate, monostate) noexcept { return false; } + constexpr bool operator<=(monostate, monostate) noexcept { return true; } + constexpr bool operator>=(monostate, monostate) noexcept { return true; } +#endif + + template + constexpr decltype(auto) visit(_Visitor&&, _Variants&&...); + + template + inline enable_if_t<(is_move_constructible_v<_Types> && ...) + && (is_swappable_v<_Types> && ...)> + swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs) + noexcept(noexcept(__lhs.swap(__rhs))) + { __lhs.swap(__rhs); } + + template + enable_if_t && ...) + && (is_swappable_v<_Types> && ...))> + swap(variant<_Types...>&, variant<_Types...>&) = delete; + + class bad_variant_access : public exception + { + public: + bad_variant_access() noexcept { } + + const char* what() const noexcept override + { return _M_reason; } + + private: + bad_variant_access(const char* __reason) noexcept : _M_reason(__reason) { } + + // Must point to a string with static storage duration: + const char* _M_reason = "bad variant access"; + + friend void __throw_bad_variant_access(const char* __what); + }; + + // Must only be called with a string literal + inline void + __throw_bad_variant_access(const char* __what) + { _GLIBCXX_THROW_OR_ABORT(bad_variant_access(__what)); } + + inline void + __throw_bad_variant_access(bool __valueless) + { + if (__valueless) [[__unlikely__]] + __throw_bad_variant_access("std::get: variant is valueless"); + else + __throw_bad_variant_access("std::get: wrong index for variant"); + } + + template + class variant + : private __detail::__variant::_Variant_base<_Types...>, + private _Enable_default_constructor< + __detail::__variant::_Traits<_Types...>::_S_default_ctor, + variant<_Types...>>, + private _Enable_copy_move< + __detail::__variant::_Traits<_Types...>::_S_copy_ctor, + __detail::__variant::_Traits<_Types...>::_S_copy_assign, + __detail::__variant::_Traits<_Types...>::_S_move_ctor, + __detail::__variant::_Traits<_Types...>::_S_move_assign, + variant<_Types...>> + { + private: + template + friend decltype(auto) __variant_cast(_Tp&&); + template + friend void __variant_construct_by_index(_Variant& __v, + _Args&&... __args); + + static_assert(sizeof...(_Types) > 0, + "variant must have at least one alternative"); + static_assert(!(std::is_reference_v<_Types> || ...), + "variant must have no reference alternative"); + static_assert(!(std::is_void_v<_Types> || ...), + "variant must have no void alternative"); + + using _Base = __detail::__variant::_Variant_base<_Types...>; + using _Default_ctor_enabler = + _Enable_default_constructor< + __detail::__variant::_Traits<_Types...>::_S_default_ctor, + variant<_Types...>>; + + template + static constexpr bool __not_self + = !is_same_v<__remove_cvref_t<_Tp>, variant>; + + template + static constexpr bool + __exactly_once = __detail::__variant::__exactly_once<_Tp, _Types...>; + + template + static constexpr size_t __accepted_index + = __detail::__variant::__accepted_index<_Tp, variant>::value; + + template> + using __to_type = variant_alternative_t<_Np, variant>; + + template>> + using __accepted_type = __to_type<__accepted_index<_Tp>>; + + template + static constexpr size_t __index_of = + __detail::__variant::__index_of_v<_Tp, _Types...>; + + using _Traits = __detail::__variant::_Traits<_Types...>; + + template + struct __is_in_place_tag : false_type { }; + template + struct __is_in_place_tag> : true_type { }; + template + struct __is_in_place_tag> : true_type { }; + + template + static constexpr bool __not_in_place_tag + = !__is_in_place_tag<__remove_cvref_t<_Tp>>::value; + + public: + variant() = default; + variant(const variant& __rhs) = default; + variant(variant&&) = default; + variant& operator=(const variant&) = default; + variant& operator=(variant&&) = default; + ~variant() = default; + + template, + typename = enable_if_t<__not_in_place_tag<_Tp>>, + typename _Tj = __accepted_type<_Tp&&>, + typename = enable_if_t<__exactly_once<_Tj> + && is_constructible_v<_Tj, _Tp>>> + constexpr + variant(_Tp&& __t) + noexcept(is_nothrow_constructible_v<_Tj, _Tp>) + : variant(in_place_index<__accepted_index<_Tp>>, + std::forward<_Tp>(__t)) + { } + + template + && is_constructible_v<_Tp, _Args...>>> + constexpr explicit + variant(in_place_type_t<_Tp>, _Args&&... __args) + : variant(in_place_index<__index_of<_Tp>>, + std::forward<_Args>(__args)...) + { } + + template + && is_constructible_v<_Tp, + initializer_list<_Up>&, _Args...>>> + constexpr explicit + variant(in_place_type_t<_Tp>, initializer_list<_Up> __il, + _Args&&... __args) + : variant(in_place_index<__index_of<_Tp>>, __il, + std::forward<_Args>(__args)...) + { } + + template, + typename = enable_if_t>> + constexpr explicit + variant(in_place_index_t<_Np>, _Args&&... __args) + : _Base(in_place_index<_Np>, std::forward<_Args>(__args)...), + _Default_ctor_enabler(_Enable_default_constructor_tag{}) + { } + + template, + typename = enable_if_t&, + _Args...>>> + constexpr explicit + variant(in_place_index_t<_Np>, initializer_list<_Up> __il, + _Args&&... __args) + : _Base(in_place_index<_Np>, __il, std::forward<_Args>(__args)...), + _Default_ctor_enabler(_Enable_default_constructor_tag{}) + { } + + template + enable_if_t<__exactly_once<__accepted_type<_Tp&&>> + && is_constructible_v<__accepted_type<_Tp&&>, _Tp> + && is_assignable_v<__accepted_type<_Tp&&>&, _Tp>, + variant&> + operator=(_Tp&& __rhs) + noexcept(is_nothrow_assignable_v<__accepted_type<_Tp&&>&, _Tp> + && is_nothrow_constructible_v<__accepted_type<_Tp&&>, _Tp>) + { + constexpr auto __index = __accepted_index<_Tp>; + if (index() == __index) + std::get<__index>(*this) = std::forward<_Tp>(__rhs); + else + { + using _Tj = __accepted_type<_Tp&&>; + if constexpr (is_nothrow_constructible_v<_Tj, _Tp> + || !is_nothrow_move_constructible_v<_Tj>) + this->emplace<__index>(std::forward<_Tp>(__rhs)); + else + operator=(variant(std::forward<_Tp>(__rhs))); + } + return *this; + } + + template + enable_if_t && __exactly_once<_Tp>, + _Tp&> + emplace(_Args&&... __args) + { + constexpr size_t __index = __index_of<_Tp>; + return this->emplace<__index>(std::forward<_Args>(__args)...); + } + + template + enable_if_t&, _Args...> + && __exactly_once<_Tp>, + _Tp&> + emplace(initializer_list<_Up> __il, _Args&&... __args) + { + constexpr size_t __index = __index_of<_Tp>; + return this->emplace<__index>(__il, std::forward<_Args>(__args)...); + } + + template + enable_if_t, + _Args...>, + variant_alternative_t<_Np, variant>&> + emplace(_Args&&... __args) + { + static_assert(_Np < sizeof...(_Types), + "The index must be in [0, number of alternatives)"); + using type = variant_alternative_t<_Np, variant>; + // Provide the strong exception-safety guarantee when possible, + // to avoid becoming valueless. + if constexpr (is_nothrow_constructible_v) + { + this->_M_reset(); + __variant_construct_by_index<_Np>(*this, + std::forward<_Args>(__args)...); + } + else if constexpr (is_scalar_v) + { + // This might invoke a potentially-throwing conversion operator: + const type __tmp(std::forward<_Args>(__args)...); + // But these steps won't throw: + this->_M_reset(); + __variant_construct_by_index<_Np>(*this, __tmp); + } + else if constexpr (__detail::__variant::_Never_valueless_alt() + && _Traits::_S_move_assign) + { + // This construction might throw: + variant __tmp(in_place_index<_Np>, + std::forward<_Args>(__args)...); + // But _Never_valueless_alt means this won't: + *this = std::move(__tmp); + } + else + { + // This case only provides the basic exception-safety guarantee, + // i.e. the variant can become valueless. + this->_M_reset(); + __try + { + __variant_construct_by_index<_Np>(*this, + std::forward<_Args>(__args)...); + } + __catch (...) + { + this->_M_index = variant_npos; + __throw_exception_again; + } + } + return std::get<_Np>(*this); + } + + template + enable_if_t, + initializer_list<_Up>&, _Args...>, + variant_alternative_t<_Np, variant>&> + emplace(initializer_list<_Up> __il, _Args&&... __args) + { + static_assert(_Np < sizeof...(_Types), + "The index must be in [0, number of alternatives)"); + using type = variant_alternative_t<_Np, variant>; + // Provide the strong exception-safety guarantee when possible, + // to avoid becoming valueless. + if constexpr (is_nothrow_constructible_v&, + _Args...>) + { + this->_M_reset(); + __variant_construct_by_index<_Np>(*this, __il, + std::forward<_Args>(__args)...); + } + else if constexpr (__detail::__variant::_Never_valueless_alt() + && _Traits::_S_move_assign) + { + // This construction might throw: + variant __tmp(in_place_index<_Np>, __il, + std::forward<_Args>(__args)...); + // But _Never_valueless_alt means this won't: + *this = std::move(__tmp); + } + else + { + // This case only provides the basic exception-safety guarantee, + // i.e. the variant can become valueless. + this->_M_reset(); + __try + { + __variant_construct_by_index<_Np>(*this, __il, + std::forward<_Args>(__args)...); + } + __catch (...) + { + this->_M_index = variant_npos; + __throw_exception_again; + } + } + return std::get<_Np>(*this); + } + + constexpr bool valueless_by_exception() const noexcept + { return !this->_M_valid(); } + + constexpr size_t index() const noexcept + { + using __index_type = typename _Base::__index_type; + if constexpr (__detail::__variant::__never_valueless<_Types...>()) + return this->_M_index; + else if constexpr (sizeof...(_Types) <= __index_type(-1) / 2) + return make_signed_t<__index_type>(this->_M_index); + else + return size_t(__index_type(this->_M_index + 1)) - 1; + } + + void + swap(variant& __rhs) + noexcept((__is_nothrow_swappable<_Types>::value && ...) + && is_nothrow_move_constructible_v) + { + __detail::__variant::__raw_idx_visit( + [this, &__rhs](auto&& __rhs_mem, auto __rhs_index) mutable + { + if constexpr (__rhs_index != variant_npos) + { + if (this->index() == __rhs_index) + { + auto& __this_mem = + std::get<__rhs_index>(*this); + using std::swap; + swap(__this_mem, __rhs_mem); + } + else + { + if (!this->valueless_by_exception()) [[__likely__]] + { + auto __tmp(std::move(__rhs_mem)); + __rhs = std::move(*this); + this->_M_destructive_move(__rhs_index, + std::move(__tmp)); + } + else + { + this->_M_destructive_move(__rhs_index, + std::move(__rhs_mem)); + __rhs._M_reset(); + } + } + } + else + { + if (!this->valueless_by_exception()) [[__likely__]] + { + __rhs = std::move(*this); + this->_M_reset(); + } + } + }, __rhs); + } + + private: + +#if defined(__clang__) && __clang_major__ <= 7 + public: + using _Base::_M_u; // See https://bugs.llvm.org/show_bug.cgi?id=31852 + private: +#endif + + template + friend constexpr decltype(auto) + __detail::__variant::__get(_Vp&& __v) noexcept; + + template + friend void* + __detail::__variant::__get_storage(_Vp&& __v) noexcept; + +#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP) \ + template \ + friend constexpr bool \ + operator __OP(const variant<_Tp...>& __lhs, \ + const variant<_Tp...>& __rhs); + + _VARIANT_RELATION_FUNCTION_TEMPLATE(<) + _VARIANT_RELATION_FUNCTION_TEMPLATE(<=) + _VARIANT_RELATION_FUNCTION_TEMPLATE(==) + _VARIANT_RELATION_FUNCTION_TEMPLATE(!=) + _VARIANT_RELATION_FUNCTION_TEMPLATE(>=) + _VARIANT_RELATION_FUNCTION_TEMPLATE(>) + +#undef _VARIANT_RELATION_FUNCTION_TEMPLATE + }; + + template + constexpr variant_alternative_t<_Np, variant<_Types...>>& + get(variant<_Types...>& __v) + { + static_assert(_Np < sizeof...(_Types), + "The index must be in [0, number of alternatives)"); + if (__v.index() != _Np) + __throw_bad_variant_access(__v.valueless_by_exception()); + return __detail::__variant::__get<_Np>(__v); + } + + template + constexpr variant_alternative_t<_Np, variant<_Types...>>&& + get(variant<_Types...>&& __v) + { + static_assert(_Np < sizeof...(_Types), + "The index must be in [0, number of alternatives)"); + if (__v.index() != _Np) + __throw_bad_variant_access(__v.valueless_by_exception()); + return __detail::__variant::__get<_Np>(std::move(__v)); + } + + template + constexpr const variant_alternative_t<_Np, variant<_Types...>>& + get(const variant<_Types...>& __v) + { + static_assert(_Np < sizeof...(_Types), + "The index must be in [0, number of alternatives)"); + if (__v.index() != _Np) + __throw_bad_variant_access(__v.valueless_by_exception()); + return __detail::__variant::__get<_Np>(__v); + } + + template + constexpr const variant_alternative_t<_Np, variant<_Types...>>&& + get(const variant<_Types...>&& __v) + { + static_assert(_Np < sizeof...(_Types), + "The index must be in [0, number of alternatives)"); + if (__v.index() != _Np) + __throw_bad_variant_access(__v.valueless_by_exception()); + return __detail::__variant::__get<_Np>(std::move(__v)); + } + + template + constexpr decltype(auto) + __do_visit(_Visitor&& __visitor, _Variants&&... __variants) + { + constexpr auto& __vtable = __detail::__variant::__gen_vtable< + _Result_type, _Visitor&&, _Variants&&...>::_S_vtable; + + auto __func_ptr = __vtable._M_access(__variants.index()...); + return (*__func_ptr)(std::forward<_Visitor>(__visitor), + std::forward<_Variants>(__variants)...); + } + + template + constexpr decltype(auto) + visit(_Visitor&& __visitor, _Variants&&... __variants) + { + if ((__variants.valueless_by_exception() || ...)) + __throw_bad_variant_access("std::visit: variant is valueless"); + + using _Result_type = std::invoke_result_t<_Visitor, + decltype(std::get<0>(std::declval<_Variants>()))...>; + + using _Tag = __detail::__variant::__deduce_visit_result<_Result_type>; + + return std::__do_visit<_Tag>(std::forward<_Visitor>(__visitor), + std::forward<_Variants>(__variants)...); + } + +#if __cplusplus > 201703L + template + constexpr _Res + visit(_Visitor&& __visitor, _Variants&&... __variants) + { + if ((__variants.valueless_by_exception() || ...)) + __throw_bad_variant_access("std::visit: variant is valueless"); + + return std::__do_visit<_Res>(std::forward<_Visitor>(__visitor), + std::forward<_Variants>(__variants)...); + } +#endif + + template + struct __variant_hash_call_base_impl + { + size_t + operator()(const variant<_Types...>& __t) const + noexcept((is_nothrow_invocable_v>, _Types> && ...)) + { + size_t __ret; + __detail::__variant::__raw_visit( + [&__t, &__ret](auto&& __t_mem) mutable + { + using _Type = __remove_cvref_t; + if constexpr (!is_same_v<_Type, + __detail::__variant::__variant_cookie>) + __ret = std::hash{}(__t.index()) + + std::hash<_Type>{}(__t_mem); + else + __ret = std::hash{}(__t.index()); + }, __t); + return __ret; + } + }; + + template + struct __variant_hash_call_base_impl {}; + + template + using __variant_hash_call_base = + __variant_hash_call_base_impl<(__poison_hash>:: + __enable_hash_call &&...), _Types...>; + + template + struct hash> + : private __detail::__variant::_Variant_hash_base< + variant<_Types...>, std::index_sequence_for<_Types...>>, + public __variant_hash_call_base<_Types...> + { + using result_type [[__deprecated__]] = size_t; + using argument_type [[__deprecated__]] = variant<_Types...>; + }; + + template<> + struct hash + { + using result_type [[__deprecated__]] = size_t; + using argument_type [[__deprecated__]] = monostate; + + size_t + operator()(const monostate&) const noexcept + { + constexpr size_t __magic_monostate_hash = -7777; + return __magic_monostate_hash; + } + }; + + template + struct __is_fast_hash>> + : bool_constant<(__is_fast_hash<_Types>::value && ...)> + { }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++17 + +#endif // _GLIBCXX_VARIANT diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@variant.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@variant.blob new file mode 100644 index 0000000..27f31c6 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@variant.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@vector b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@vector new file mode 100644 index 0000000..6f587a8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@vector @@ -0,0 +1,129 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 +#if __cplusplus > 201703L +# include // For remove and remove_if +#endif // C++20 +#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 + inline typename vector<_Tp, _Alloc>::size_type + erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred) + { + const auto __osz = __cont.size(); + __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), + __cont.end()); + return __osz - __cont.size(); + } + + template + inline typename vector<_Tp, _Alloc>::size_type + erase(vector<_Tp, _Alloc>& __cont, const _Up& __value) + { + const auto __osz = __cont.size(); + __cont.erase(std::remove(__cont.begin(), __cont.end(), __value), + __cont.end()); + return __osz - __cont.size(); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif /* _GLIBCXX_VECTOR */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@vector.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@vector.blob new file mode 100644 index 0000000..2384b60 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@c++@10@vector.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@ctype.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@ctype.h new file mode 100644 index 0000000..351495a --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@ctype.h @@ -0,0 +1,329 @@ +/* Copyright (C) 1991-2020 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/@@home@ado@git@ssp/@usr@include@ctype.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@ctype.h.blob new file mode 100644 index 0000000..b6909a9 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@ctype.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@endian.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@endian.h new file mode 100644 index 0000000..0256ee4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@endian.h @@ -0,0 +1,72 @@ +/* Copyright (C) 1992-2020 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/@@home@ado@git@ssp/@usr@include@endian.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@endian.h.blob new file mode 100644 index 0000000..e939581 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@endian.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@errno.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@errno.h new file mode 100644 index 0000000..79e9185 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@errno.h @@ -0,0 +1,55 @@ +/* Copyright (C) 1991-2020 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/@@home@ado@git@ssp/@usr@include@errno.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@errno.h.blob new file mode 100644 index 0000000..3aace27 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@errno.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@features.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@features.h new file mode 100644 index 0000000..f334777 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@features.h @@ -0,0 +1,488 @@ +/* Copyright (C) 1991-2020 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. + + _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. + _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_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_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 +#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 + +#if defined _DEFAULT_SOURCE +# define __USE_MISC 1 +#endif + +#ifdef _ATFILE_SOURCE +# define __USE_ATFILE 1 +#endif + +#ifdef _GNU_SOURCE +# define __USE_GNU 1 +#endif + +#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \ + && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0 +# if _FORTIFY_SOURCE > 1 +# define __USE_FORTIFY_LEVEL 2 +# else +# define __USE_FORTIFY_LEVEL 1 +# endif +#else +# 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__ 31 + +#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/@@home@ado@git@ssp/@usr@include@features.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@features.h.blob new file mode 100644 index 0000000..7221d0a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@features.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@inttypes.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@inttypes.h new file mode 100644 index 0000000..685dfc1 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@inttypes.h @@ -0,0 +1,434 @@ +/* Copyright (C) 1997-2020 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; + +#ifdef __USE_EXTERN_INLINES + +# if __WORDSIZE == 64 + +extern long int __strtol_internal (const char *__restrict __nptr, + char **__restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `strtol' but convert to `intmax_t'. */ +__extern_inline intmax_t +__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtol_internal (nptr, endptr, base, 0); +} + +extern unsigned long int __strtoul_internal (const char *__restrict __nptr, + char ** __restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `strtoul' but convert to `uintmax_t'. */ +__extern_inline uintmax_t +__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtoul_internal (nptr, endptr, base, 0); +} + +extern long int __wcstol_internal (const __gwchar_t * __restrict __nptr, + __gwchar_t **__restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `wcstol' but convert to `intmax_t'. */ +__extern_inline intmax_t +__NTH (wcstoimax (const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstol_internal (nptr, endptr, base, 0); +} + +extern unsigned long int __wcstoul_internal (const __gwchar_t * + __restrict __nptr, + __gwchar_t ** + __restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `wcstoul' but convert to `uintmax_t'. */ +__extern_inline uintmax_t +__NTH (wcstoumax (const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstoul_internal (nptr, endptr, base, 0); +} + +# else /* __WORDSIZE == 32 */ + +__extension__ +extern long long int __strtoll_internal (const char *__restrict __nptr, + char **__restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `strtol' but convert to `intmax_t'. */ +__extern_inline intmax_t +__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtoll_internal (nptr, endptr, base, 0); +} + +__extension__ +extern unsigned long long int __strtoull_internal (const char * + __restrict __nptr, + char ** + __restrict __endptr, + int __base, + int __group) + __THROW __nonnull ((1)) __wur; +/* Like `strtoul' but convert to `uintmax_t'. */ +__extern_inline uintmax_t +__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtoull_internal (nptr, endptr, base, 0); +} + +__extension__ +extern long long int __wcstoll_internal (const __gwchar_t *__restrict __nptr, + __gwchar_t **__restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `wcstol' but convert to `intmax_t'. */ +__extern_inline intmax_t +__NTH (wcstoimax (const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstoll_internal (nptr, endptr, base, 0); +} + + +__extension__ +extern unsigned long long int __wcstoull_internal (const __gwchar_t * + __restrict __nptr, + __gwchar_t ** + __restrict __endptr, + int __base, + int __group) + __THROW __nonnull ((1)) __wur; +/* Like `wcstoul' but convert to `uintmax_t'. */ +__extern_inline uintmax_t +__NTH (wcstoumax (const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstoull_internal (nptr, endptr, base, 0); +} + +# endif /* __WORDSIZE == 32 */ +#endif /* Use extern inlines. */ + +__END_DECLS + +#endif /* inttypes.h */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@inttypes.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@inttypes.h.blob new file mode 100644 index 0000000..7326ba0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@inttypes.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@libintl.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@libintl.h new file mode 100644 index 0000000..2fd0a31 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@libintl.h @@ -0,0 +1,123 @@ +/* Message catalogs for internationalization. + Copyright (C) 1995-2020 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/@@home@ado@git@ssp/@usr@include@libintl.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@libintl.h.blob new file mode 100644 index 0000000..36f94ce Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@libintl.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@linux@errno.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@linux@errno.h new file mode 100644 index 0000000..70f2bd3 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@linux@errno.h @@ -0,0 +1 @@ +#include diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@linux@errno.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@linux@errno.h.blob new file mode 100644 index 0000000..a2c00f0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@linux@errno.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@locale.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@locale.h new file mode 100644 index 0000000..b013c8b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@locale.h @@ -0,0 +1,197 @@ +/* Copyright (C) 1991-2020 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/@@home@ado@git@ssp/@usr@include@locale.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@locale.h.blob new file mode 100644 index 0000000..428a82a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@locale.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@math.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@math.h new file mode 100644 index 0000000..fb211bb --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@math.h @@ -0,0 +1,1341 @@ +/* Declarations for math functions. + Copyright (C) 1991-2020 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_C2X) +/* 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) +# define SNANF16 (__builtin_nansf16 ("")) +#endif +#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define SNANF32 (__builtin_nansf32 ("")) +#endif +#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define SNANF64 (__builtin_nansf64 ("")) +#endif +#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define SNANF128 (__builtin_nansf128 ("")) +#endif +#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define SNANF32X (__builtin_nansf32x ("")) +#endif +#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) +# define SNANF64X (__builtin_nansf64x ("")) +#endif +#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) +# 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(type, function,suffix, args) \ + extern type __MATH_PRECNAME(function,suffix) args __THROW + +#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_2(type, function,suffix, args, alias) \ + extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \ + args, alias) +# define __MATHDECL_1(type, function,suffix, args) \ + __MATHDECL_2(type, function,suffix, args, __CONCAT(function,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 + +# 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 +#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 +# undef __MATHCALL_NARROW +# define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_REDIR (func, redir, nargs) +# endif +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# ifdef __LDBL_COMPAT +# undef __MATHCALL_REDIR_NAME +# 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 +# undef __MATHCALL_NARROW +# define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_REDIR (func, redir, nargs) +# endif +# include +# undef _Mret_ +# undef _Marg_ +# undef __MATHCALL_NAME +# ifdef __LDBL_COMPAT +# undef __MATHCALL_REDIR_NAME +# 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 + +/* 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 + +/* When compiling in strict ISO C compatible mode we must not use the + inline functions since they, among other things, do not set the + `errno' variable correctly. */ +#if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES +# define __NO_MATH_INLINES 1 +#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 + +/* Get machine-dependent inline versions (if there are any). */ +#ifdef __USE_EXTERN_INLINES +# include +#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/@@home@ado@git@ssp/@usr@include@math.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@math.h.blob new file mode 100644 index 0000000..5b22005 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@math.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@pthread.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@pthread.h new file mode 100644 index 0000000..44dd707 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@pthread.h @@ -0,0 +1,1173 @@ +/* Copyright (C) 2002-2020 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 + + +/* 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; + +/* 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); +#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)); + +/* 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 +/* Yield the processor to another thread or process. + This function is similar to the POSIX `sched_yield' function but + might be differently implemented in the case of a m-on-n thread + implementation. */ +extern int pthread_yield (void) __THROW; + + +/* 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. */ + +typedef struct +{ + struct + { + __jmp_buf __cancel_jmp_buf; + int __mask_was_saved; + } __cancel_jmp_buf[1]; + void *__pad[4]; +} __pthread_unwind_buf_t __attribute__ ((__aligned__)); + +/* 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 ((struct __jmp_buf_tag *) (void *) \ + __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 ((struct __jmp_buf_tag *) (void *) \ + __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. */ +struct __jmp_buf_tag; +extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL; + + +/* 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. */ +extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 2)); +#endif + +#ifdef __USE_GNU +extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +#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 +extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex) + __THROW __nonnull ((1)); +# 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 +extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr, + int *__robustness) + __THROW __nonnull ((1, 2)); +# 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 +extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr, + int __robustness) + __THROW __nonnull ((1)); +# 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. */ +extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 2)); +# endif + +# ifdef __USE_GNU +extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +# 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. */ +extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 2)); +# endif + +# ifdef __USE_GNU +extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +# 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. */ +extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, + pthread_mutex_t *__restrict __mutex, + const struct timespec *__restrict __abstime) + __nonnull ((1, 2, 3)); + +# 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. */ +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)); +# 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 ; + + +#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/@@home@ado@git@ssp/@usr@include@pthread.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@pthread.h.blob new file mode 100644 index 0000000..a0cbad2 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@pthread.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@sched.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@sched.h new file mode 100644 index 0000000..60c9c3c --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@sched.h @@ -0,0 +1,131 @@ +/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface. + Copyright (C) 1996-2020 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. */ +extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW; + + +#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/@@home@ado@git@ssp/@usr@include@sched.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@sched.h.blob new file mode 100644 index 0000000..3e18089 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@sched.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdc-predef.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdc-predef.h new file mode 100644 index 0000000..eaf0a6a --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdc-predef.h @@ -0,0 +1,60 @@ +/* Copyright (C) 1991-2020 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 +# endif +#else +# define __STDC_IEC_559__ 1 +#endif + +#ifdef __GCC_IEC_559_COMPLEX +# if __GCC_IEC_559_COMPLEX > 0 +# define __STDC_IEC_559_COMPLEX__ 1 +# endif +#else +# define __STDC_IEC_559_COMPLEX__ 1 +#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/@@home@ado@git@ssp/@usr@include@stdc-predef.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdc-predef.h.blob new file mode 100644 index 0000000..64f2fd4 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdc-predef.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdint.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdint.h new file mode 100644 index 0000000..2df07e4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdint.h @@ -0,0 +1,319 @@ +/* Copyright (C) 1997-2020 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/@@home@ado@git@ssp/@usr@include@stdint.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdint.h.blob new file mode 100644 index 0000000..2b69efd Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdint.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdio.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdio.h new file mode 100644 index 0000000..5a10a4d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdio.h @@ -0,0 +1,875 @@ +/* Define ISO C stdio on top of C++ iostreams. + Copyright (C) 1991-2020 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 + + +/* 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 + +/* 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) __wur; +#else +# ifdef __REDIRECT +extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur; +# else +# define tmpfile tmpfile64 +# endif +#endif + +#ifdef __USE_LARGEFILE64 +extern FILE *tmpfile64 (void) __wur; +#endif + +/* Generate a temporary filename. */ +extern char *tmpnam (char *__s) __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) __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; +#endif + + +/* Close STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fclose (FILE *__stream); +/* 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) __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) + __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) __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 __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 __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 __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 __wur; +#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 is in + effect, this is handled in bits/stdio-ldbl.h. */ +#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT +# 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 +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; + +#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; +#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); + +/* Provide the declarations for `sys_errlist' and `sys_nerr' if they + are available on this system. Even if available, these variables + should not be used directly. The `strerror' function provides + all the necessary functionality. */ +#include + + +#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 +/* 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) __wur; + +/* 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); +#endif + + +#ifdef __USE_POSIX +/* Return the name of the controlling terminal. */ +extern char *ctermid (char *__s) __THROW; +#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); +#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 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 +# include +#endif +#ifdef __LDBL_COMPAT +# include +#endif + +__END_DECLS + +#endif /* included. */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdio.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdio.h.blob new file mode 100644 index 0000000..5b784e9 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdio.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdlib.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdlib.h new file mode 100644 index 0000000..e347063 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdlib.h @@ -0,0 +1,1025 @@ +/* Copyright (C) 1991-2020 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.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 RAND_MAX 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)); + +#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)); +#endif + +/* Free a block allocated by `malloc', `realloc' or `calloc'. */ +extern void free (void *__ptr) __THROW; + +#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_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)) __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; +/* Convert a wide char string to multibyte string. */ +extern size_t wcstombs (char *__restrict __s, + const wchar_t *__restrict __pwcs, size_t __n) + __THROW; + + +#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)); + +/* 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 +#ifdef __LDBL_COMPAT +# include +#endif + +__END_DECLS + +#endif /* stdlib.h */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdlib.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdlib.h.blob new file mode 100644 index 0000000..dec276e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@stdlib.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@string.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@string.h new file mode 100644 index 0000000..a0f2860 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@string.h @@ -0,0 +1,501 @@ +/* Copyright (C) 1991-2020 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)); +#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)); + +/* 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)); +extern "C++" const void *memrchr (const void *__s, int __c, size_t __n) + __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1)); +# else +extern void *memrchr (const void *__s, int __c, size_t __n) + __THROW __attribute_pure__ __nonnull ((1)); +# 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)); + +#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)); +#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)); + +/* 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)); +# else +extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen) + __THROW __nonnull ((2)); +# 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; +# 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)); + +/* 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; + +/* 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)); + +# 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/@@home@ado@git@ssp/@usr@include@string.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@string.h.blob new file mode 100644 index 0000000..4d691fc Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@string.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@strings.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@strings.h new file mode 100644 index 0000000..87882ec --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@strings.h @@ -0,0 +1,148 @@ +/* Copyright (C) 1991-2020 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/@@home@ado@git@ssp/@usr@include@strings.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@strings.h.blob new file mode 100644 index 0000000..6e4e8d1 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@strings.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@time.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@time.h new file mode 100644 index 0000000..015bc1c --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@time.h @@ -0,0 +1,303 @@ +/* Copyright (C) 1991-2020 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; + +/* 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; + + +/* 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 + + +/* 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; + +#if defined __USE_POSIX || __GLIBC_USE (ISOC2X) +/* 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; +#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))'. */ +extern char *ctime (const time_t *__timer) __THROW; + +#if defined __USE_POSIX || __GLIBC_USE (ISOC2X) +/* 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)'. */ +extern char *ctime_r (const time_t *__restrict __timer, + char *__restrict __buf) __THROW; +#endif /* POSIX || C2X */ + + +/* 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. */ + +/* 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; + +/* Return the number of days in YEAR. */ +extern int dysize (int __year) __THROW __attribute__ ((__const__)); +#endif + + +#ifdef __USE_POSIX199309 +/* 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; + +# ifdef __USE_XOPEN2K +/* High-resolution sleep with the specified clock. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int clock_nanosleep (clockid_t __clock_id, int __flags, + const struct timespec *__req, + struct timespec *__rem); + +/* 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. */ +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; + +/* Get expiration overrun for timer TIMERID. */ +extern int timer_getoverrun (timer_t __timerid) __THROW; +#endif + + +#ifdef __USE_ISOC11 +/* Set TS to calendar time based in time base BASE. */ +extern int timespec_get (struct timespec *__ts, int __base) + __THROW __nonnull ((1)); +#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/@@home@ado@git@ssp/@usr@include@time.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@time.h.blob new file mode 100644 index 0000000..7668bb6 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@time.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@wchar.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@wchar.h new file mode 100644 index 0000000..5e0d65b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@wchar.h @@ -0,0 +1,858 @@ +/* Copyright (C) 1995-2020 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__; +#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) +/* 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; +#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 is in + effect, this is handled in bits/wchar-ldbl.h. */ +#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT +# 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) +# 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 +# include +#endif + +#ifdef __LDBL_COMPAT +# include +#endif + +__END_DECLS + +#endif /* wchar.h */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@wchar.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@wchar.h.blob new file mode 100644 index 0000000..697570e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@wchar.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@wctype.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@wctype.h new file mode 100644 index 0000000..06260c4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@wctype.h @@ -0,0 +1,148 @@ +/* Copyright (C) 1996-2020 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/@@home@ado@git@ssp/@usr@include@wctype.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@wctype.h.blob new file mode 100644 index 0000000..97bb027 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@wctype.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@asm@errno.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@asm@errno.h new file mode 100644 index 0000000..4c82b50 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@asm@errno.h @@ -0,0 +1 @@ +#include diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@asm@errno.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@asm@errno.h.blob new file mode 100644 index 0000000..7dc8a25 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@asm@errno.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@byteswap.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@byteswap.h new file mode 100644 index 0000000..ccf613a --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@byteswap.h @@ -0,0 +1,79 @@ +/* Macros and inline functions to swap the order of bytes in integer values. + Copyright (C) 1997-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@byteswap.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@byteswap.h.blob new file mode 100644 index 0000000..10db792 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@byteswap.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@cpu-set.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@cpu-set.h new file mode 100644 index 0000000..427a599 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@cpu-set.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@cpu-set.h.blob new file mode 100644 index 0000000..5431fd8 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@cpu-set.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endian.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endian.h new file mode 100644 index 0000000..1892b99 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endian.h @@ -0,0 +1,49 @@ +/* Endian macros for string.h functions + Copyright (C) 1992-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endian.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endian.h.blob new file mode 100644 index 0000000..12c2cab Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endian.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endianness.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endianness.h new file mode 100644 index 0000000..962a9ae --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endianness.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endianness.h.blob new file mode 100644 index 0000000..875afc3 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@endianness.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@errno.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@errno.h new file mode 100644 index 0000000..81308af --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@errno.h @@ -0,0 +1,53 @@ +/* Error constants. Linux specific version. + Copyright (C) 1996-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@errno.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@errno.h.blob new file mode 100644 index 0000000..48d7afd Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@errno.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn-common.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn-common.h new file mode 100644 index 0000000..6aa5ba1 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn-common.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn-common.h.blob new file mode 100644 index 0000000..88e5fb2 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn-common.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn.h new file mode 100644 index 0000000..b4dbe96 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn.h @@ -0,0 +1,122 @@ +/* Macros to control TS 18661-3 glibc features on x86. + Copyright (C) 2017-2020 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))) \ + && !defined(__CUDACC__) && !defined(__ICC) +# 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn.h.blob new file mode 100644 index 0000000..3bb3959 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@floatn.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@flt-eval-method.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@flt-eval-method.h new file mode 100644 index 0000000..2fbc6f3 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@flt-eval-method.h @@ -0,0 +1,33 @@ +/* Define __GLIBC_FLT_EVAL_METHOD. x86 version. + Copyright (C) 2016-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@flt-eval-method.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@flt-eval-method.h.blob new file mode 100644 index 0000000..0f886d9 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@flt-eval-method.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-fast.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-fast.h new file mode 100644 index 0000000..328d223 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-fast.h @@ -0,0 +1,39 @@ +/* Define FP_FAST_* macros. + Copyright (C) 2016-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-fast.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-fast.h.blob new file mode 100644 index 0000000..7bea3d3 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-fast.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-logb.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-logb.h new file mode 100644 index 0000000..f180a90 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-logb.h @@ -0,0 +1,24 @@ +/* Define __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN. x86 version. + Copyright (C) 2016-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-logb.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-logb.h.blob new file mode 100644 index 0000000..1f9cb99 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@fp-logb.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@iscanonical.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@iscanonical.h new file mode 100644 index 0000000..dd6f23f --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@iscanonical.h @@ -0,0 +1,54 @@ +/* Define iscanonical macro. ldbl-96 version. + Copyright (C) 2016-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@iscanonical.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@iscanonical.h.blob new file mode 100644 index 0000000..0c075c6 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@iscanonical.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libc-header-start.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libc-header-start.h new file mode 100644 index 0000000..b872a41 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libc-header-start.h @@ -0,0 +1,86 @@ +/* Handle feature test macros at the start of a header. + Copyright (C) 2016-2020 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; the symbols in Annex F + still require that macro in C2X. */ +#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 + +/* 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libc-header-start.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libc-header-start.h.blob new file mode 100644 index 0000000..e0f3e46 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libc-header-start.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libm-simd-decl-stubs.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libm-simd-decl-stubs.h new file mode 100644 index 0000000..ef3ed54 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libm-simd-decl-stubs.h @@ -0,0 +1,101 @@ +/* Empty definitions required for __MATHCALL_VEC unfolding in mathcalls.h. + Copyright (C) 2014-2020 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 +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libm-simd-decl-stubs.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libm-simd-decl-stubs.h.blob new file mode 100644 index 0000000..d6ac399 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@libm-simd-decl-stubs.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@locale.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@locale.h new file mode 100644 index 0000000..af720a0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@locale.h @@ -0,0 +1,40 @@ +/* Definition of locale category symbol values. + Copyright (C) 2001-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@locale.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@locale.h.blob new file mode 100644 index 0000000..a982d05 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@locale.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@long-double.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@long-double.h new file mode 100644 index 0000000..b77124f --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@long-double.h @@ -0,0 +1,21 @@ +/* Properties of long double type. ldbl-96 version. + Copyright (C) 2016-2020 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 __LONG_DOUBLE_USES_FLOAT128 0 diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@long-double.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@long-double.h.blob new file mode 100644 index 0000000..4cc2729 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@long-double.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@math-vector.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@math-vector.h new file mode 100644 index 0000000..0801905 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@math-vector.h @@ -0,0 +1,63 @@ +/* Platform-specific SIMD declarations of math functions. + Copyright (C) 2014-2020 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 + +# endif +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@math-vector.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@math-vector.h.blob new file mode 100644 index 0000000..bdccf71 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@math-vector.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-helper-functions.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-helper-functions.h new file mode 100644 index 0000000..5b1e9ed --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-helper-functions.h @@ -0,0 +1,43 @@ +/* Prototype declarations for math classification macros helpers. + Copyright (C) 2017-2020 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_1 (int, __fpclassify,, (_Mdouble_ __value)) + __attribute__ ((__const__)); + +/* Test for negative number. */ +__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value)) + __attribute__ ((__const__)); + +/* Return 0 if VALUE is finite or NaN, +1 if it + is +Infinity, -1 if it is -Infinity. */ +__MATHDECL_1 (int, __isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Return nonzero if VALUE is finite and not NaN. Used by isfinite macro. */ +__MATHDECL_1 (int, __finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Return nonzero if VALUE is not a number. */ +__MATHDECL_1 (int, __isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Test equality. */ +__MATHDECL_1 (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y)); + +/* Test for signaling NaN. */ +__MATHDECL_1 (int, __issignaling,, (_Mdouble_ __value)) + __attribute__ ((__const__)); diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-helper-functions.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-helper-functions.h.blob new file mode 100644 index 0000000..bc89334 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-helper-functions.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-narrow.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-narrow.h new file mode 100644 index 0000000..6d6ad2b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-narrow.h @@ -0,0 +1,33 @@ +/* Declare functions returning a narrower type. + Copyright (C) 2018-2020 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); + +/* Multiply. */ +__MATHCALL_NARROW (__MATHCALL_NAME (mul), __MATHCALL_REDIR_NAME (mul), 2); + +/* Subtract. */ +__MATHCALL_NARROW (__MATHCALL_NAME (sub), __MATHCALL_REDIR_NAME (sub), 2); diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-narrow.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-narrow.h.blob new file mode 100644 index 0000000..1456125 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls-narrow.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls.h new file mode 100644 index 0000000..43e5481 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls.h @@ -0,0 +1,401 @@ +/* Prototype declarations for math functions; helper file for . + Copyright (C) 1996-2020 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 (acos,, (_Mdouble_ __x)); +/* Arc sine of X. */ +__MATHCALL (asin,, (_Mdouble_ __x)); +/* Arc tangent of X. */ +__MATHCALL (atan,, (_Mdouble_ __x)); +/* Arc tangent of Y/X. */ +__MATHCALL (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 (tan,, (_Mdouble_ __x)); + +/* Hyperbolic functions. */ + +/* Hyperbolic cosine of X. */ +__MATHCALL (cosh,, (_Mdouble_ __x)); +/* Hyperbolic sine of X. */ +__MATHCALL (sinh,, (_Mdouble_ __x)); +/* Hyperbolic tangent of X. */ +__MATHCALL (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 (acosh,, (_Mdouble_ __x)); +/* Hyperbolic arc sine of X. */ +__MATHCALL (asinh,, (_Mdouble_ __x)); +/* Hyperbolic arc tangent of X. */ +__MATHCALL (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 (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 (exp10,, (_Mdouble_ __x)); +#endif + +#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +/* Return exp(X) - 1. */ +__MATHCALL (expm1,, (_Mdouble_ __x)); + +/* Return log(1 + X). */ +__MATHCALL (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 (exp2,, (_Mdouble_ __x)); + +/* Compute base-2 logarithm of X. */ +__MATHCALL (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 (hypot,, (_Mdouble_ __x, _Mdouble_ __y)); +#endif + +#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +/* Return the cube root of X. */ +__MATHCALL (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_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); +# endif + +# if !__MATH_DECLARING_FLOATN +/* Return nonzero if VALUE is finite and not NaN. */ +__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __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_1 (int,isnan,, (_Mdouble_ __value)) __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 (erf,, (_Mdouble_)); +__MATHCALL (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)); + +/* 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__)); + +/* 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)); + +/* Return value with maximum magnitude. */ +__MATHCALLX (fmaxmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Return value with minimum magnitude. */ +__MATHCALLX (fminmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); + +/* Canonicalize floating-point representation. */ +__MATHDECL_1 (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x)); +#endif + +#if __GLIBC_USE (IEC_60559_BFP_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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls.h.blob new file mode 100644 index 0000000..45a78e5 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@mathcalls.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes-arch.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes-arch.h new file mode 100644 index 0000000..399d486 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes-arch.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2002-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes-arch.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes-arch.h.blob new file mode 100644 index 0000000..1c94f0f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes-arch.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes.h new file mode 100644 index 0000000..ac65027 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes.h @@ -0,0 +1,121 @@ +/* Declaration of common pthread types for all architectures. + Copyright (C) 2017-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes.h.blob new file mode 100644 index 0000000..9080727 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@pthreadtypes.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sched.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sched.h new file mode 100644 index 0000000..5d93790 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sched.h @@ -0,0 +1,100 @@ +/* Definitions of constants and data structure for POSIX 1003.1b-1993 + scheduling interface. + Copyright (C) 1996-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sched.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sched.h.blob new file mode 100644 index 0000000..8711556 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sched.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@select.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@select.h new file mode 100644 index 0000000..b2e3ac8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@select.h @@ -0,0 +1,63 @@ +/* Copyright (C) 1997-2020 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 + +#include + + +#if defined __GNUC__ && __GNUC__ >= 2 + +# if __WORDSIZE == 64 +# define __FD_ZERO_STOS "stosq" +# else +# define __FD_ZERO_STOS "stosl" +# endif + +# define __FD_ZERO(fdsp) \ + do { \ + int __d0, __d1; \ + __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS \ + : "=c" (__d0), "=D" (__d1) \ + : "a" (0), "0" (sizeof (fd_set) \ + / sizeof (__fd_mask)), \ + "1" (&__FDS_BITS (fdsp)[0]) \ + : "memory"); \ + } while (0) + +#else /* ! GNU CC */ + +/* We don't use `memset' because this would require a prototype and + the array isn't too big. */ +# define __FD_ZERO(set) \ + do { \ + unsigned int __i; \ + fd_set *__arr = (set); \ + for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \ + __FDS_BITS (__arr)[__i] = 0; \ + } while (0) + +#endif /* GNU CC */ + +#define __FD_SET(d, set) \ + ((void) (__FDS_BITS (set)[__FD_ELT (d)] |= __FD_MASK (d))) +#define __FD_CLR(d, set) \ + ((void) (__FDS_BITS (set)[__FD_ELT (d)] &= ~__FD_MASK (d))) +#define __FD_ISSET(d, set) \ + ((__FDS_BITS (set)[__FD_ELT (d)] & __FD_MASK (d)) != 0) diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@select.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@select.h.blob new file mode 100644 index 0000000..faa1953 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@select.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@setjmp.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@setjmp.h new file mode 100644 index 0000000..9e9329d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@setjmp.h @@ -0,0 +1,40 @@ +/* Copyright (C) 2001-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@setjmp.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@setjmp.h.blob new file mode 100644 index 0000000..ac3df15 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@setjmp.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-intn.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-intn.h new file mode 100644 index 0000000..9e7bbc9 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-intn.h @@ -0,0 +1,29 @@ +/* Define intN_t types. + Copyright (C) 2017-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-intn.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-intn.h.blob new file mode 100644 index 0000000..82b4c10 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-intn.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-uintn.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-uintn.h new file mode 100644 index 0000000..cd9fd65 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-uintn.h @@ -0,0 +1,29 @@ +/* Define uintN_t types. + Copyright (C) 2017-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-uintn.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-uintn.h.blob new file mode 100644 index 0000000..25576e9 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdint-uintn.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdio_lim.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdio_lim.h new file mode 100644 index 0000000..573aac4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdio_lim.h @@ -0,0 +1,39 @@ +/* Copyright (C) 1994-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdio_lim.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdio_lim.h.blob new file mode 100644 index 0000000..630bb0d Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdio_lim.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdlib-float.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdlib-float.h new file mode 100644 index 0000000..4a414ae --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdlib-float.h @@ -0,0 +1,29 @@ +/* Floating-point inline functions for stdlib.h. + Copyright (C) 2012-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdlib-float.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdlib-float.h.blob new file mode 100644 index 0000000..cad0894 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@stdlib-float.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_mutex.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_mutex.h new file mode 100644 index 0000000..6a18f1e --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_mutex.h @@ -0,0 +1,63 @@ +/* x86 internal mutex struct definitions. + Copyright (C) 2019-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_mutex.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_mutex.h.blob new file mode 100644 index 0000000..8d275ed Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_mutex.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_rwlock.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_rwlock.h new file mode 100644 index 0000000..9b337c0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_rwlock.h @@ -0,0 +1,65 @@ +/* x86 internal rwlock struct definitions. + Copyright (C) 2019-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_rwlock.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_rwlock.h.blob new file mode 100644 index 0000000..7721534 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@struct_rwlock.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sys_errlist.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sys_errlist.h new file mode 100644 index 0000000..d6f5fa0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sys_errlist.h @@ -0,0 +1,32 @@ +/* Declare sys_errlist and sys_nerr, or don't. Compatibility (do) version. + Copyright (C) 2002-2020 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 _STDIO_H +# error "Never include directly; use instead." +#endif + +/* sys_errlist and sys_nerr are deprecated. Use strerror instead. */ + +#ifdef __USE_MISC +extern int sys_nerr; +extern const char *const sys_errlist[]; +#endif +#ifdef __USE_GNU +extern int _sys_nerr; +extern const char *const _sys_errlist[]; +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sys_errlist.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sys_errlist.h.blob new file mode 100644 index 0000000..8ec8e7f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@sys_errlist.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@thread-shared-types.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@thread-shared-types.h new file mode 100644 index 0000000..fd08b69 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@thread-shared-types.h @@ -0,0 +1,119 @@ +/* Common threading primitives definitions for both POSIX and C11. + Copyright (C) 2017-2020 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 + + +/* 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 +{ + __extension__ union + { + __extension__ unsigned long long int __wseq; + struct + { + unsigned int __low; + unsigned int __high; + } __wseq32; + }; + __extension__ union + { + __extension__ unsigned long long int __g1_start; + struct + { + unsigned int __low; + unsigned int __high; + } __g1_start32; + }; + 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]; +}; + +#endif /* _THREAD_SHARED_TYPES_H */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@thread-shared-types.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@thread-shared-types.h.blob new file mode 100644 index 0000000..a1a6283 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@thread-shared-types.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time.h new file mode 100644 index 0000000..e096274 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time.h @@ -0,0 +1,83 @@ +/* System-dependent timing definitions. Linux version. + Copyright (C) 1996-2020 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; + +__END_DECLS +#endif /* use GNU */ + +#endif /* bits/time.h */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time.h.blob new file mode 100644 index 0000000..3404902 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time64.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time64.h new file mode 100644 index 0000000..42f21fc --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time64.h @@ -0,0 +1,36 @@ +/* bits/time64.h -- underlying types for __time64_t. Generic version. + Copyright (C) 2018-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time64.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time64.h.blob new file mode 100644 index 0000000..6c85607 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@time64.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timesize.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timesize.h new file mode 100644 index 0000000..2cd0720 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timesize.h @@ -0,0 +1,25 @@ +/* Bit size of the time_t type at glibc build time, x86-64 and x32 case. + Copyright (C) 2018-2020 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 __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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timesize.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timesize.h.blob new file mode 100644 index 0000000..33961f2 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timesize.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timex.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timex.h new file mode 100644 index 0000000..9adb0bc --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timex.h @@ -0,0 +1,110 @@ +/* Copyright (C) 1995-2020 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 +{ + 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; +}; + +/* 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timex.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timex.h.blob new file mode 100644 index 0000000..4d76dcd Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@timex.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types.h new file mode 100644 index 0000000..adba926 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types.h @@ -0,0 +1,227 @@ +/* bits/types.h -- definitions of __*_t types underlying *_t types. + Copyright (C) 2002-2020 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 __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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types.h.blob new file mode 100644 index 0000000..4254325 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@FILE.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@FILE.h new file mode 100644 index 0000000..f268263 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@FILE.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@FILE.h.blob new file mode 100644 index 0000000..cca28b7 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@FILE.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__FILE.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__FILE.h new file mode 100644 index 0000000..06dd79b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__FILE.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__FILE.h.blob new file mode 100644 index 0000000..1f02ddb Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__FILE.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__fpos64_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__fpos64_t.h new file mode 100644 index 0000000..06a6891 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__fpos64_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__fpos64_t.h.blob new file mode 100644 index 0000000..8ad9310 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__fpos64_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__fpos_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__fpos_t.h new file mode 100644 index 0000000..bb04576 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__fpos_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__fpos_t.h.blob new file mode 100644 index 0000000..a07d5d7 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__fpos_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__locale_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__locale_t.h new file mode 100644 index 0000000..53e9a9c --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__locale_t.h @@ -0,0 +1,44 @@ +/* Definition of struct __locale_struct and __locale_t. + Copyright (C) 1997-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__locale_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__locale_t.h.blob new file mode 100644 index 0000000..5cd056b Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__locale_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__mbstate_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__mbstate_t.h new file mode 100644 index 0000000..1d8a4e2 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__mbstate_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__mbstate_t.h.blob new file mode 100644 index 0000000..adc4321 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__mbstate_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__sigset_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__sigset_t.h new file mode 100644 index 0000000..e2f18ac --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__sigset_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__sigset_t.h.blob new file mode 100644 index 0000000..271d4c1 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@__sigset_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@clock_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@clock_t.h new file mode 100644 index 0000000..ce97248 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@clock_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@clock_t.h.blob new file mode 100644 index 0000000..3956868 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@clock_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@clockid_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@clockid_t.h new file mode 100644 index 0000000..b17c7da --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@clockid_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@clockid_t.h.blob new file mode 100644 index 0000000..c107525 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@clockid_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@cookie_io_functions_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@cookie_io_functions_t.h new file mode 100644 index 0000000..2df6656 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@cookie_io_functions_t.h @@ -0,0 +1,63 @@ +/* Copyright (C) 1991-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@cookie_io_functions_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@cookie_io_functions_t.h.blob new file mode 100644 index 0000000..00a7446 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@cookie_io_functions_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@error_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@error_t.h new file mode 100644 index 0000000..63b452b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@error_t.h @@ -0,0 +1,24 @@ +/* Define error_t. + Copyright (C) 1991-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@error_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@error_t.h.blob new file mode 100644 index 0000000..ca6df84 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@error_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@locale_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@locale_t.h new file mode 100644 index 0000000..6156631 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@locale_t.h @@ -0,0 +1,26 @@ +/* Definition of locale_t. + Copyright (C) 2017-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@locale_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@locale_t.h.blob new file mode 100644 index 0000000..4a778c0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@locale_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@mbstate_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@mbstate_t.h new file mode 100644 index 0000000..8d1baa5 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@mbstate_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@mbstate_t.h.blob new file mode 100644 index 0000000..9ca92a8 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@mbstate_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@sigset_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@sigset_t.h new file mode 100644 index 0000000..8b27e91 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@sigset_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@sigset_t.h.blob new file mode 100644 index 0000000..954675c Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@sigset_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_FILE.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_FILE.h new file mode 100644 index 0000000..06feadf --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_FILE.h @@ -0,0 +1,120 @@ +/* Copyright (C) 1991-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_FILE.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_FILE.h.blob new file mode 100644 index 0000000..b8eeee3 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_FILE.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_itimerspec.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_itimerspec.h new file mode 100644 index 0000000..17cc1ac --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_itimerspec.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_itimerspec.h.blob new file mode 100644 index 0000000..cfd1190 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_itimerspec.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_sched_param.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_sched_param.h new file mode 100644 index 0000000..db228a8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_sched_param.h @@ -0,0 +1,28 @@ +/* Sched parameter structure. Generic version. + Copyright (C) 1996-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_sched_param.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_sched_param.h.blob new file mode 100644 index 0000000..40088b3 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_sched_param.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timespec.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timespec.h new file mode 100644 index 0000000..d11c69c --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timespec.h @@ -0,0 +1,28 @@ +/* NB: Include guard matches what uses. */ +#ifndef _STRUCT_TIMESPEC +#define _STRUCT_TIMESPEC 1 + +#include +#include + +/* POSIX.1b structure for a time value. This is like a `struct timeval' but + has nanoseconds instead of microseconds. */ +struct timespec +{ + __time_t tv_sec; /* Seconds. */ +#if __WORDSIZE == 64 \ + || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \ + || __TIMESIZE == 32 + __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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timespec.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timespec.h.blob new file mode 100644 index 0000000..1377a29 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timespec.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timeval.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timeval.h new file mode 100644 index 0000000..70394ce --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timeval.h @@ -0,0 +1,13 @@ +#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 +{ + __time_t tv_sec; /* Seconds. */ + __suseconds_t tv_usec; /* Microseconds. */ +}; +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timeval.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timeval.h.blob new file mode 100644 index 0000000..c1de1a3 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_timeval.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_tm.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_tm.h new file mode 100644 index 0000000..b13b631 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_tm.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_tm.h.blob new file mode 100644 index 0000000..63d4ed2 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@struct_tm.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@time_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@time_t.h new file mode 100644 index 0000000..ab8287c --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@time_t.h @@ -0,0 +1,9 @@ +#ifndef __time_t_defined +#define __time_t_defined 1 + +#include + +/* Returned by `time'. */ +typedef __time_t time_t; + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@time_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@time_t.h.blob new file mode 100644 index 0000000..2e49ccb Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@time_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@timer_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@timer_t.h new file mode 100644 index 0000000..d71a413 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@timer_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@timer_t.h.blob new file mode 100644 index 0000000..c726a7a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@timer_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@wint_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@wint_t.h new file mode 100644 index 0000000..fbd63db --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@wint_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@wint_t.h.blob new file mode 100644 index 0000000..a2349df Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@types@wint_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@typesizes.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@typesizes.h new file mode 100644 index 0000000..d084145 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@typesizes.h @@ -0,0 +1,100 @@ +/* bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. + Copyright (C) 2012-2020 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 __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 +#else +# define __RLIM_T_MATCHES_RLIM64_T 0 + +# define __STATFS_MATCHES_STATFS64 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@typesizes.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@typesizes.h.blob new file mode 100644 index 0000000..94eb83d Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@typesizes.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@uintn-identity.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@uintn-identity.h new file mode 100644 index 0000000..f2fc48b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@uintn-identity.h @@ -0,0 +1,50 @@ +/* Inline functions to return unsigned integer values unchanged. + Copyright (C) 2017-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@uintn-identity.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@uintn-identity.h.blob new file mode 100644 index 0000000..43b592d Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@uintn-identity.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitflags.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitflags.h new file mode 100644 index 0000000..33382cd --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitflags.h @@ -0,0 +1,59 @@ +/* Definitions of flag bits for `waitpid' et al. + Copyright (C) 1992-2020 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. */ + +/* The following values are used by the `waitid' function. */ +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +# ifndef __ENUM_IDTYPE_T +# define __ENUM_IDTYPE_T 1 + +/* The Linux kernel defines these bare, rather than an enum, + which causes a conflict if the include order is reversed. */ +# undef P_ALL +# undef P_PID +# undef P_PGID + +typedef enum +{ + P_ALL, /* Wait for any child. */ + P_PID, /* Wait for specified process. */ + P_PGID /* Wait for members of process group. */ +} idtype_t; +# endif +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitflags.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitflags.h.blob new file mode 100644 index 0000000..65c4b48 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitflags.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitstatus.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitstatus.h new file mode 100644 index 0000000..66d88a0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitstatus.h @@ -0,0 +1,59 @@ +/* Definitions of status bits for `wait' et al. + Copyright (C) 1992-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitstatus.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitstatus.h.blob new file mode 100644 index 0000000..888a82b Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@waitstatus.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wchar.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wchar.h new file mode 100644 index 0000000..c00c501 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wchar.h @@ -0,0 +1,49 @@ +/* wchar_t type related definitions. + Copyright (C) 2000-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wchar.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wchar.h.blob new file mode 100644 index 0000000..04f2156 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wchar.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wctype-wchar.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wctype-wchar.h new file mode 100644 index 0000000..7152463 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wctype-wchar.h @@ -0,0 +1,173 @@ +/* Copyright (C) 1996-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wctype-wchar.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wctype-wchar.h.blob new file mode 100644 index 0000000..35ed728 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wctype-wchar.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wordsize.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wordsize.h new file mode 100644 index 0000000..70f652b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wordsize.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wordsize.h.blob new file mode 100644 index 0000000..1c91d9e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@bits@wordsize.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@atomic_word.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@atomic_word.h new file mode 100644 index 0000000..c59f22e --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@atomic_word.h @@ -0,0 +1,40 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@atomic_word.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@atomic_word.h.blob new file mode 100644 index 0000000..e1284df Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@atomic_word.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@basic_file.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@basic_file.h new file mode 100644 index 0000000..fa39b78 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@basic_file.h @@ -0,0 +1,135 @@ +// Wrapper of C-language FILE struct -*- C++ -*- + +// Copyright (C) 2000-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@basic_file.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@basic_file.h.blob new file mode 100644 index 0000000..abd10a4 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@basic_file.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++allocator.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++allocator.h new file mode 100644 index 0000000..ea54255 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++allocator.h @@ -0,0 +1,59 @@ +// Base to std::allocator -*- C++ -*- + +// Copyright (C) 2004-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 + * __gnu_cxx::new_allocator. + * + * @ingroup allocators + * @tparam _Tp Type of allocated object. + */ + template + using __allocator_base = __gnu_cxx::new_allocator<_Tp>; +} +#else +// Define new_allocator as the base class to std::allocator. +# define __allocator_base __gnu_cxx::new_allocator +#endif + +#if defined(__SANITIZE_ADDRESS__) && !defined(_GLIBCXX_SANITIZE_STD_ALLOCATOR) +# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1 +#endif + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++allocator.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++allocator.h.blob new file mode 100644 index 0000000..d1e9361 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++allocator.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++config.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++config.h new file mode 100644 index 0000000..6f0c4ab --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++config.h @@ -0,0 +1,2094 @@ +// Predefined symbols and macros -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 10 + +// The datestamp of the C++ library in compressed ISO date format. +#define __GLIBCXX__ 20210110 + +// 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 +// _GLIBCXX17_DEPRECATED +// _GLIBCXX20_DEPRECATED( string-literal ) +#ifndef _GLIBCXX_USE_DEPRECATED +# define _GLIBCXX_USE_DEPRECATED 1 +#endif + +#if defined(__DEPRECATED) && (__cplusplus >= 201103L) +# 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 >= 201703L) +# define _GLIBCXX17_DEPRECATED [[__deprecated__]] +#else +# define _GLIBCXX17_DEPRECATED +#endif + +#if defined(__DEPRECATED) && (__cplusplus > 201703L) +# define _GLIBCXX20_DEPRECATED(MSG) [[deprecated(MSG)]] +#else +# define _GLIBCXX20_DEPRECATED(MSG) +#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 > 201703L +# define _GLIBCXX20_CONSTEXPR constexpr +# else +# define _GLIBCXX20_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 +} + +# 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 + +// Inline namespace for long double 128 mode. +#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 + +// 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 + +// Assert. +#if defined(_GLIBCXX_ASSERTIONS) \ + || defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS) +namespace std +{ + // Avoid the use of assert, because we're trying to keep the + // include out of the mix. + extern "C++" inline void + __replacement_assert(const char* __file, int __line, + const char* __function, const char* __condition) + { + __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, + __function, __condition); + __builtin_abort(); + } +} +#define __glibcxx_assert_impl(_Condition) \ + do \ + { \ + if (! (_Condition)) \ + std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ + #_Condition); \ + } while (false) +#endif + +#if defined(_GLIBCXX_ASSERTIONS) +# define __glibcxx_assert(_Condition) __glibcxx_assert_impl(_Condition) +#else +# define __glibcxx_assert(_Condition) +#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 + +#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__) +#define _GLIBCXX_USE_FLOAT128 1 +#endif + +#if __GNUC__ >= 7 +// Assume these are available if the compiler claims to be a recent GCC: +# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 +# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 +# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 +# define _GLIBCXX_BUILTIN_IS_SAME_AS(T, U) __is_same_as(T, U) +# if __GNUC__ >= 9 +# define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1 +# endif +#elif defined(__is_identifier) && defined(__has_builtin) +// For non-GNU compilers: +# if ! __is_identifier(__has_unique_object_representations) +# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 +# endif +# if ! __is_identifier(__is_aggregate) +# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 +# endif +# if __has_builtin(__builtin_launder) +# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 +# endif +# if __has_builtin(__builtin_is_constant_evaluated) +# define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1 +# endif +# if ! __is_identifier(__is_same) +# define _GLIBCXX_BUILTIN_IS_SAME_AS(T, U) __is_same(T, U) +# endif +#endif // GCC + +// 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 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 header file. */ +#define _GLIBCXX_HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_DLFCN_H 1 + +/* Define if EBADMSG exists. */ +#define _GLIBCXX_HAVE_EBADMSG 1 + +/* Define if ECANCELED exists. */ +#define _GLIBCXX_HAVE_ECANCELED 1 + +/* Define if ECHILD exists. */ +#define _GLIBCXX_HAVE_ECHILD 1 + +/* Define if EIDRM exists. */ +#define _GLIBCXX_HAVE_EIDRM 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_ENDIAN_H 1 + +/* Define if ENODATA exists. */ +#define _GLIBCXX_HAVE_ENODATA 1 + +/* Define if ENOLINK exists. */ +#define _GLIBCXX_HAVE_ENOLINK 1 + +/* Define if ENOSPC exists. */ +#define _GLIBCXX_HAVE_ENOSPC 1 + +/* Define if ENOSR exists. */ +#define _GLIBCXX_HAVE_ENOSR 1 + +/* Define if ENOSTR exists. */ +#define _GLIBCXX_HAVE_ENOSTR 1 + +/* Define if ENOTRECOVERABLE exists. */ +#define _GLIBCXX_HAVE_ENOTRECOVERABLE 1 + +/* Define if ENOTSUP exists. */ +#define _GLIBCXX_HAVE_ENOTSUP 1 + +/* Define if EOVERFLOW exists. */ +#define _GLIBCXX_HAVE_EOVERFLOW 1 + +/* Define if EOWNERDEAD exists. */ +#define _GLIBCXX_HAVE_EOWNERDEAD 1 + +/* Define if EPERM exists. */ +#define _GLIBCXX_HAVE_EPERM 1 + +/* Define if EPROTO exists. */ +#define _GLIBCXX_HAVE_EPROTO 1 + +/* Define if ETIME exists. */ +#define _GLIBCXX_HAVE_ETIME 1 + +/* Define if ETIMEDOUT exists. */ +#define _GLIBCXX_HAVE_ETIMEDOUT 1 + +/* Define if ETXTBSY exists. */ +#define _GLIBCXX_HAVE_ETXTBSY 1 + +/* Define if EWOULDBLOCK exists. */ +#define _GLIBCXX_HAVE_EWOULDBLOCK 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 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 _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 if int64_t is available in . */ +#define _GLIBCXX_HAVE_INT64_T 1 + +/* Define if int64_t is a long. */ +#define _GLIBCXX_HAVE_INT64_T_LONG 1 + +/* Define if int64_t is a long long. */ +/* #undef _GLIBCXX_HAVE_INT64_T_LONG_LONG */ + +/* 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 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 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 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 `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 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. */ +#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 */ +#define _GLIBCXX_HAVE_SYS_SDT_H 1 + +/* 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 + +/* 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 `_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 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 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 -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 */ + +/* 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 __int128 is supported on this host. */ +#define _GLIBCXX_USE_INT128 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 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 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++config.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++config.h.blob new file mode 100644 index 0000000..c595518 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++config.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++io.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++io.h new file mode 100644 index 0000000..4c9b5f0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++io.h @@ -0,0 +1,50 @@ +// Underlying io library details -*- C++ -*- + +// Copyright (C) 2000-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++io.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++io.h.blob new file mode 100644 index 0000000..94f43d7 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++io.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++locale.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++locale.h new file mode 100644 index 0000000..bf9fafa --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++locale.h @@ -0,0 +1,114 @@ +// Wrapper for underlying C-language localization -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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; + + // 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; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++locale.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++locale.h.blob new file mode 100644 index 0000000..6557e97 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@c++locale.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@cpu_defines.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@cpu_defines.h new file mode 100644 index 0000000..b40a4f0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@cpu_defines.h @@ -0,0 +1,33 @@ +// Specific definitions for generic platforms -*- C++ -*- + +// Copyright (C) 2005-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@cpu_defines.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@cpu_defines.h.blob new file mode 100644 index 0000000..4a13fe6 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@cpu_defines.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_base.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_base.h new file mode 100644 index 0000000..24bff55 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_base.h @@ -0,0 +1,66 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_base.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_base.h.blob new file mode 100644 index 0000000..697eb6c Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_base.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_inline.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_inline.h new file mode 100644 index 0000000..ae8a2f4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_inline.h @@ -0,0 +1,76 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2000-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_inline.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_inline.h.blob new file mode 100644 index 0000000..c76aa0f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@ctype_inline.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@error_constants.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@error_constants.h new file mode 100644 index 0000000..b5b0ea6 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@error_constants.h @@ -0,0 +1,178 @@ +// Specific definitions for generic platforms -*- C++ -*- + +// Copyright (C) 2007-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 _GLIBCXX_HAVE_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 _GLIBCXX_HAVE_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 _GLIBCXX_HAVE_ENOLINK + no_link = ENOLINK, +#endif + + no_lock_available = ENOLCK, + +#ifdef _GLIBCXX_HAVE_ENODATA + no_message_available = ENODATA, +#endif + + no_message = ENOMSG, + no_protocol_option = ENOPROTOOPT, + no_space_on_device = ENOSPC, + +#ifdef _GLIBCXX_HAVE_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 _GLIBCXX_HAVE_ENOSTR + not_a_stream = ENOSTR, +#endif + + not_connected = ENOTCONN, + not_enough_memory = ENOMEM, + +#ifdef _GLIBCXX_HAVE_ENOTSUP + not_supported = ENOTSUP, +#endif + +#ifdef _GLIBCXX_HAVE_ECANCELED + operation_canceled = ECANCELED, +#endif + + operation_in_progress = EINPROGRESS, + operation_not_permitted = EPERM, + operation_not_supported = EOPNOTSUPP, + operation_would_block = EWOULDBLOCK, + +#ifdef _GLIBCXX_HAVE_EOWNERDEAD + owner_dead = EOWNERDEAD, +#endif + + permission_denied = EACCES, + +#ifdef _GLIBCXX_HAVE_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 _GLIBCXX_HAVE_ENOTRECOVERABLE + state_not_recoverable = ENOTRECOVERABLE, +#endif + +#ifdef _GLIBCXX_HAVE_ETIME + stream_timeout = ETIME, +#endif + +#ifdef _GLIBCXX_HAVE_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 _GLIBCXX_HAVE_EOVERFLOW + value_too_large = EOVERFLOW, +#endif + + wrong_protocol_type = EPROTOTYPE + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@error_constants.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@error_constants.h.blob new file mode 100644 index 0000000..afe0037 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@error_constants.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr-default.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr-default.h new file mode 100644 index 0000000..dc72da3 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr-default.h @@ -0,0 +1,890 @@ +/* Threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr-default.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr-default.h.blob new file mode 100644 index 0000000..ccb7a77 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr-default.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr.h new file mode 100644 index 0000000..34ad976 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr.h @@ -0,0 +1,154 @@ +/* Threads compatibility routines for libgcc2. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr.h.blob new file mode 100644 index 0000000..7b164e7 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@gthr.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@messages_members.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@messages_members.h new file mode 100644 index 0000000..847de87 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@messages_members.h @@ -0,0 +1,151 @@ +// std::messages implementation details, GNU version -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@messages_members.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@messages_members.h.blob new file mode 100644 index 0000000..743c624 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@messages_members.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@os_defines.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@os_defines.h new file mode 100644 index 0000000..01bfa9d --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@os_defines.h @@ -0,0 +1,64 @@ +// Specific definitions for GNU/Linux -*- C++ -*- + +// Copyright (C) 2000-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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 isanum, 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 + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@os_defines.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@os_defines.h.blob new file mode 100644 index 0000000..1c76023 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@os_defines.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@time_members.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@time_members.h new file mode 100644 index 0000000..3ef2201 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@time_members.h @@ -0,0 +1,89 @@ +// std::time_get, std::time_put implementation, GNU version -*- C++ -*- + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@time_members.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@time_members.h.blob new file mode 100644 index 0000000..db32df2 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@c++@10@bits@time_members.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs-64.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs-64.h new file mode 100644 index 0000000..4f9c4ba --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs-64.h @@ -0,0 +1,19 @@ +/* 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_lchmod +#define __stub_revoke +#define __stub_setlogin +#define __stub_sigreturn +#define __stub_sstk +#define __stub_stty diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs-64.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs-64.h.blob new file mode 100644 index 0000000..f24059f Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs-64.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs.h new file mode 100644 index 0000000..70a1ba0 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs.h.blob new file mode 100644 index 0000000..0156271 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@gnu@stubs.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@cdefs.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@cdefs.h new file mode 100644 index 0000000..ff7144f --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@cdefs.h @@ -0,0 +1,517 @@ +/* Copyright (C) 1992-2020 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_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 + anymore supported. */ +#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 + +#ifdef __GNUC__ + +/* 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 works only with + gcc 2.8.x and egcs. For gcc 3.2 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, 3) +# 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) +# define __THROW throw () +# 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. */ + +# 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. */ + +/* Compilers that are not clang may object to + #if defined __clang__ && __has_extension(...) + even though they do not need to evaluate the right-hand side of the &&. */ +#if defined __clang__ && defined __has_extension +# define __glibc_clang_has_extension(ext) __has_extension (ext) +#else +# define __glibc_clang_has_extension(ext) 0 +#endif + +/* 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) + +#if __GNUC_PREREQ (4,3) +# define __warndecl(name, msg) \ + extern void name (void) __attribute__((__warning__ (msg))) +# define __warnattr(msg) __attribute__((__warning__ (msg))) +# define __errordecl(name, msg) \ + extern void name (void) __attribute__((__error__ (msg))) +#else +# define __warndecl(name, msg) extern void name (void) +# 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 +# define __flexarr [] +# define __glibc_c99_flexarr_available 1 +#elif __GNUC_PREREQ (2,97) +/* GCC 2.97 supports 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 + +# 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 has 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__ || __GNUC__ < 2 +# 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) +# 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 + +/* 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) +# 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) +# define __attribute_const__ __attribute__ ((__const__)) +#else +# define __attribute_const__ /* 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) +# 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) +# 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_clang_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) +# 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) +# define __attribute_format_strfmon__(a,b) \ + __attribute__ ((__format__ (__strfmon__, a, b))) +#else +# define __attribute_format_strfmon__(a,b) /* Ignore */ +#endif + +/* The nonull function attribute allows to mark pointer parameters which + must not be NULL. */ +#if __GNUC_PREREQ (3,3) +# define __nonnull(params) __attribute__ ((__nonnull__ params)) +#else +# define __nonnull(params) +#endif + +/* If fortification mode, we warn about unused results of certain + function calls which can lead to problems. */ +#if __GNUC_PREREQ (3,4) +# define __attribute_warn_unused_result__ \ + __attribute__ ((__warn_unused_result__)) +# if __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) +/* 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) +# 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) +# define __extension__ /* Ignore */ +#endif + +/* __restrict is known in EGCS 1.2 and above. */ +#if !__GNUC_PREREQ (2,92) +# 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 supports this. */ +#if __GNUC_PREREQ (3,1) && !defined __GNUG__ +# 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 +# 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 + +#ifdef __has_attribute +# define __glibc_has_attribute(attr) __has_attribute (attr) +#else +# define __glibc_has_attribute(attr) 0 +#endif + +#if (!defined _Noreturn \ + && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ + && !__GNUC_PREREQ (4,7)) +# 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) || defined __STRICT_ANSI__)) +# define _Static_assert(expr, diagnostic) \ + extern int (*__Static_assert_function (void)) \ + [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] +#endif + +#include +#include + +#if 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_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 || !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_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_clang_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 + +#endif /* sys/cdefs.h */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@cdefs.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@cdefs.h.blob new file mode 100644 index 0000000..13951bd Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@cdefs.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@select.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@select.h new file mode 100644 index 0000000..29d011c --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@select.h @@ -0,0 +1,128 @@ +/* `fd_set' type and related macros, and `select'/`pselect' declarations. + Copyright (C) 1996-2020 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. */ +extern int select (int __nfds, fd_set *__restrict __readfds, + fd_set *__restrict __writefds, + fd_set *__restrict __exceptfds, + struct timeval *__restrict __timeout); + +#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. */ +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); +#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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@select.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@select.h.blob new file mode 100644 index 0000000..d1db4e4 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@select.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@types.h b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@types.h new file mode 100644 index 0000000..c9241e4 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@types.h @@ -0,0 +1,232 @@ +/* Copyright (C) 1991-2020 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/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@types.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@types.h.blob new file mode 100644 index 0000000..cb59bcb Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@include@x86_64-linux-gnu@sys@types.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@__stddef_max_align_t.h b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@__stddef_max_align_t.h new file mode 100644 index 0000000..e3b4392 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@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/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@__stddef_max_align_t.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@__stddef_max_align_t.h.blob new file mode 100644 index 0000000..694bb99 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@__stddef_max_align_t.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@float.h b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@float.h new file mode 100644 index 0000000..ed610b2 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@float.h @@ -0,0 +1,152 @@ +/*===---- 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 to allow additional definitions and + * implementation-defined values. + */ +#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \ + __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 +# 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 +# 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 +# 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 +# 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/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@float.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@float.h.blob new file mode 100644 index 0000000..5aded39 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@float.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@inttypes.h b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@inttypes.h new file mode 100644 index 0000000..eac373c --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@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 + * +\*===----------------------------------------------------------------------===*/ + +#if !defined(__CLANG_INTTYPES_H) || !defined(_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/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@inttypes.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@inttypes.h.blob new file mode 100644 index 0000000..c3fcc04 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@inttypes.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdarg.h b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdarg.h new file mode 100644 index 0000000..0bc3940 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@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/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdarg.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdarg.h.blob new file mode 100644 index 0000000..b96fc85 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdarg.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stddef.h b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stddef.h new file mode 100644 index 0000000..15acd44 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@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/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stddef.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stddef.h.blob new file mode 100644 index 0000000..202a88e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stddef.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdint.h b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdint.h new file mode 100644 index 0000000..192f653 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdint.h @@ -0,0 +1,693 @@ +/*===---- 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) +# 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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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__ + +/* 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__ + +/* 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__) + +#endif /* __STDC_HOSTED__ */ +#endif /* __CLANG_STDINT_H */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdint.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdint.h.blob new file mode 100644 index 0000000..8151832 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@lib@llvm-11@lib@clang@11.0.1@include@stdint.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@ascii_number.h b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@ascii_number.h new file mode 100644 index 0000000..75432a3 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@ascii_number.h @@ -0,0 +1,284 @@ +#ifndef FASTFLOAT_ASCII_NUMBER_H +#define FASTFLOAT_ASCII_NUMBER_H + +#include +#include +#include +#include + +#include "float_common.h" + +namespace fast_float { + +// Next function can be micro-optimized, but compilers are entirely +// able to optimize it well. +fastfloat_really_inline bool is_integer(char c) noexcept { return c >= '0' && c <= '9'; } + + +// credit @aqrit +fastfloat_really_inline uint32_t parse_eight_digits_unrolled(uint64_t val) { + const uint64_t mask = 0x000000FF000000FF; + const uint64_t mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32) + const uint64_t mul2 = 0x0000271000000001; // 1 + (10000ULL << 32) + val -= 0x3030303030303030; + val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8; + val = (((val & mask) * mul1) + (((val >> 16) & mask) * mul2)) >> 32; + return uint32_t(val); +} + +fastfloat_really_inline uint32_t parse_eight_digits_unrolled(const char *chars) noexcept { + uint64_t val; + ::memcpy(&val, chars, sizeof(uint64_t)); + return parse_eight_digits_unrolled(val); +} + +// credit @aqrit +fastfloat_really_inline bool is_made_of_eight_digits_fast(uint64_t val) noexcept { + return !((((val + 0x4646464646464646) | (val - 0x3030303030303030)) & + 0x8080808080808080)); +} + +fastfloat_really_inline bool is_made_of_eight_digits_fast(const char *chars) noexcept { + uint64_t val; + ::memcpy(&val, chars, 8); + return is_made_of_eight_digits_fast(val); +} + +struct parsed_number_string { + int64_t exponent; + uint64_t mantissa; + const char *lastmatch; + bool negative; + bool valid; + bool too_many_digits; +}; + + +// Assuming that you use no more than 19 digits, this will +// parse an ASCII string. +fastfloat_really_inline +parsed_number_string parse_number_string(const char *p, const char *pend, chars_format fmt) noexcept { + parsed_number_string answer; + answer.valid = false; + answer.too_many_digits = false; + answer.negative = (*p == '-'); + if ((*p == '-') || (*p == '+')) { + ++p; + if (p == pend) { + return answer; + } + if (!is_integer(*p) && (*p != '.')) { // a sign must be followed by an integer or the dot + return answer; + } + } + const char *const start_digits = p; + + uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad) + + while ((p != pend) && is_integer(*p)) { + // a multiplication by 10 is cheaper than an arbitrary integer + // multiplication + i = 10 * i + + uint64_t(*p - '0'); // might overflow, we will handle the overflow later + ++p; + } + const char *const end_of_integer_part = p; + int64_t digit_count = int64_t(end_of_integer_part - start_digits); + int64_t exponent = 0; + if ((p != pend) && (*p == '.')) { + ++p; +#if FASTFLOAT_IS_BIG_ENDIAN == 0 + // Fast approach only tested under little endian systems + if ((p + 8 <= pend) && is_made_of_eight_digits_fast(p)) { + i = i * 100000000 + parse_eight_digits_unrolled(p); // in rare cases, this will overflow, but that's ok + p += 8; + if ((p + 8 <= pend) && is_made_of_eight_digits_fast(p)) { + i = i * 100000000 + parse_eight_digits_unrolled(p); // in rare cases, this will overflow, but that's ok + p += 8; + } + } +#endif + while ((p != pend) && is_integer(*p)) { + uint8_t digit = uint8_t(*p - '0'); + ++p; + i = i * 10 + digit; // in rare cases, this will overflow, but that's ok + } + exponent = end_of_integer_part + 1 - p; + digit_count -= exponent; + } + // we must have encountered at least one integer! + if (digit_count == 0) { + return answer; + } + int64_t exp_number = 0; // explicit exponential part + if ((fmt & chars_format::scientific) && (p != pend) && (('e' == *p) || ('E' == *p))) { + const char * location_of_e = p; + ++p; + bool neg_exp = false; + if ((p != pend) && ('-' == *p)) { + neg_exp = true; + ++p; + } else if ((p != pend) && ('+' == *p)) { + ++p; + } + if ((p == pend) || !is_integer(*p)) { + if(!(fmt & chars_format::fixed)) { + // We are in error. + return answer; + } + // Otherwise, we will be ignoring the 'e'. + p = location_of_e; + } else { + while ((p != pend) && is_integer(*p)) { + uint8_t digit = uint8_t(*p - '0'); + if (exp_number < 0x10000) { + exp_number = 10 * exp_number + digit; + } + ++p; + } + if(neg_exp) { exp_number = - exp_number; } + exponent += exp_number; + } + } else { + // If it scientific and not fixed, we have to bail out. + if((fmt & chars_format::scientific) && !(fmt & chars_format::fixed)) { return answer; } + } + answer.lastmatch = p; + answer.valid = true; + + // If we frequently had to deal with long strings of digits, + // we could extend our code by using a 128-bit integer instead + // of a 64-bit integer. However, this is uncommon. + // + // We can deal with up to 19 digits. + if (digit_count > 19) { // this is uncommon + // It is possible that the integer had an overflow. + // We have to handle the case where we have 0.0000somenumber. + // We need to be mindful of the case where we only have zeroes... + // E.g., 0.000000000...000. + const char *start = start_digits; + while ((start != pend) && (*start == '0' || *start == '.')) { + if(*start == '0') { digit_count --; } + start++; + } + if (digit_count > 19) { + answer.too_many_digits = true; + // Let us start again, this time, avoiding overflows. + i = 0; + p = start_digits; + const uint64_t minimal_nineteen_digit_integer{1000000000000000000}; + while((i < minimal_nineteen_digit_integer) && (p != pend) && is_integer(*p)) { + i = i * 10 + uint64_t(*p - '0'); + ++p; + } + if (i >= minimal_nineteen_digit_integer) { // We have a big integers + exponent = end_of_integer_part - p + exp_number; + } else { // We have a value with a fractional component. + p++; // skip the '.' + const char *first_after_period = p; + while((i < minimal_nineteen_digit_integer) && (p != pend) && is_integer(*p)) { + i = i * 10 + uint64_t(*p - '0'); + ++p; + } + exponent = first_after_period - p + exp_number; + } + // We have now corrected both exponent and i, to a truncated value + } + } + answer.exponent = exponent; + answer.mantissa = i; + return answer; +} + + +// This should always succeed since it follows a call to parse_number_string +// This function could be optimized. In particular, we could stop after 19 digits +// and try to bail out. Furthermore, we should be able to recover the computed +// exponent from the pass in parse_number_string. +fastfloat_really_inline decimal parse_decimal(const char *p, const char *pend) noexcept { + decimal answer; + answer.num_digits = 0; + answer.decimal_point = 0; + answer.truncated = false; + // any whitespace has been skipped. + answer.negative = (*p == '-'); + if ((*p == '-') || (*p == '+')) { + ++p; + } + // skip leading zeroes + while ((p != pend) && (*p == '0')) { + ++p; + } + while ((p != pend) && is_integer(*p)) { + if (answer.num_digits < max_digits) { + answer.digits[answer.num_digits] = uint8_t(*p - '0'); + } + answer.num_digits++; + ++p; + } + if ((p != pend) && (*p == '.')) { + ++p; + const char *first_after_period = p; + // if we have not yet encountered a zero, we have to skip it as well + if(answer.num_digits == 0) { + // skip zeros + while ((p != pend) && (*p == '0')) { + ++p; + } + } +#if FASTFLOAT_IS_BIG_ENDIAN == 0 + // We expect that this loop will often take the bulk of the running time + // because when a value has lots of digits, these digits often + while ((p + 8 <= pend) && (answer.num_digits + 8 < max_digits)) { + uint64_t val; + ::memcpy(&val, p, sizeof(uint64_t)); + if(! is_made_of_eight_digits_fast(val)) { break; } + // We have eight digits, process them in one go! + val -= 0x3030303030303030; + ::memcpy(answer.digits + answer.num_digits, &val, sizeof(uint64_t)); + answer.num_digits += 8; + p += 8; + } +#endif + while ((p != pend) && is_integer(*p)) { + if (answer.num_digits < max_digits) { + answer.digits[answer.num_digits] = uint8_t(*p - '0'); + } + answer.num_digits++; + ++p; + } + answer.decimal_point = int32_t(first_after_period - p); + } + if ((p != pend) && (('e' == *p) || ('E' == *p))) { + ++p; + bool neg_exp = false; + if ((p != pend) && ('-' == *p)) { + neg_exp = true; + ++p; + } else if ((p != pend) && ('+' == *p)) { + ++p; + } + int32_t exp_number = 0; // exponential part + while ((p != pend) && is_integer(*p)) { + uint8_t digit = uint8_t(*p - '0'); + if (exp_number < 0x10000) { + exp_number = 10 * exp_number + digit; + } + ++p; + } + answer.decimal_point += (neg_exp ? -exp_number : exp_number); + } + answer.decimal_point += int32_t(answer.num_digits); + if(answer.num_digits > max_digits) { + answer.truncated = true; + answer.num_digits = max_digits; + } + // In very rare cases, we may have fewer than 19 digits, we want to be able to reliably + // assume that all digits up to max_digit_without_overflow have been initialized. + for(uint32_t i = answer.num_digits; i < max_digit_without_overflow; i++) { answer.digits[i] = 0; } + + return answer; +} +} // namespace fast_float + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@ascii_number.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@ascii_number.h.blob new file mode 100644 index 0000000..31c4998 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@ascii_number.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@decimal_to_binary.h b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@decimal_to_binary.h new file mode 100644 index 0000000..0dd05a2 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@decimal_to_binary.h @@ -0,0 +1,174 @@ +#ifndef FASTFLOAT_DECIMAL_TO_BINARY_H +#define FASTFLOAT_DECIMAL_TO_BINARY_H + +#include "float_common.h" +#include "fast_table.h" +#include +#include +#include +#include +#include +#include +#include + +namespace fast_float { + +// This will compute or rather approximate w * 5**q and return a pair of 64-bit words approximating +// the result, with the "high" part corresponding to the most significant bits and the +// low part corresponding to the least significant bits. +// +template +fastfloat_really_inline +value128 compute_product_approximation(int64_t q, uint64_t w) { + const int index = 2 * int(q - smallest_power_of_five); + // For small values of q, e.g., q in [0,27], the answer is always exact because + // The line value128 firstproduct = full_multiplication(w, power_of_five_128[index]); + // gives the exact answer. + value128 firstproduct = full_multiplication(w, power_of_five_128[index]); + static_assert((bit_precision >= 0) && (bit_precision <= 64), " precision should be in (0,64]"); + constexpr uint64_t precision_mask = (bit_precision < 64) ? + (uint64_t(0xFFFFFFFFFFFFFFFF) >> bit_precision) + : uint64_t(0xFFFFFFFFFFFFFFFF); + if((firstproduct.high & precision_mask) == precision_mask) { // could further guard with (lower + w < lower) + // regarding the second product, we only need secondproduct.high, but our expectation is that the compiler will optimize this extra work away if needed. + value128 secondproduct = full_multiplication(w, power_of_five_128[index + 1]); + firstproduct.low += secondproduct.high; + if(secondproduct.high > firstproduct.low) { + firstproduct.high++; + } + } + return firstproduct; +} + +namespace { +/** + * For q in (0,350), we have that + * f = (((152170 + 65536) * q ) >> 16); + * is equal to + * floor(p) + q + * where + * p = log(5**q)/log(2) = q * log(5)/log(2) + * + * For negative values of q in (-400,0), we have that + * f = (((152170 + 65536) * q ) >> 16); + * is equal to + * -ceil(p) + q + * where + * p = log(5**-q)/log(2) = -q * log(5)/log(2) + */ + fastfloat_really_inline int power(int q) noexcept { + return (((152170 + 65536) * q) >> 16) + 63; + } +} // namespace + + +// w * 10 ** q +// The returned value should be a valid ieee64 number that simply need to be packed. +// However, in some very rare cases, the computation will fail. In such cases, we +// return an adjusted_mantissa with a negative power of 2: the caller should recompute +// in such cases. +template +fastfloat_really_inline +adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept { + adjusted_mantissa answer; + if ((w == 0) || (q < binary::smallest_power_of_ten())) { + answer.power2 = 0; + answer.mantissa = 0; + // result should be zero + return answer; + } + if (q > binary::largest_power_of_ten()) { + // we want to get infinity: + answer.power2 = binary::infinite_power(); + answer.mantissa = 0; + return answer; + } + // At this point in time q is in [smallest_power_of_five, largest_power_of_five]. + + // We want the most significant bit of i to be 1. Shift if needed. + int lz = leading_zeroes(w); + w <<= lz; + + // The required precision is binary::mantissa_explicit_bits() + 3 because + // 1. We need the implicit bit + // 2. We need an extra bit for rounding purposes + // 3. We might lose a bit due to the "upperbit" routine (result too small, requiring a shift) + + value128 product = compute_product_approximation(q, w); + if(product.low == 0xFFFFFFFFFFFFFFFF) { // could guard it further + // In some very rare cases, this could happen, in which case we might need a more accurate + // computation that what we can provide cheaply. This is very, very unlikely. + // + const bool inside_safe_exponent = (q >= -27) && (q <= 55); // always good because 5**q <2**128 when q>=0, + // and otherwise, for q<0, we have 5**-q<2**64 and the 128-bit reciprocal allows for exact computation. + if(!inside_safe_exponent) { + answer.power2 = -1; // This (a negative value) indicates an error condition. + return answer; + } + } + // The "compute_product_approximation" function can be slightly slower than a branchless approach: + // value128 product = compute_product(q, w); + // but in practice, we can win big with the compute_product_approximation if its additional branch + // is easily predicted. Which is best is data specific. + int upperbit = int(product.high >> 63); + + answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3); + + answer.power2 = int(power(int(q)) + upperbit - lz - binary::minimum_exponent()); + if (answer.power2 <= 0) { // we have a subnormal? + // Here have that answer.power2 <= 0 so -answer.power2 >= 0 + if(-answer.power2 + 1 >= 64) { // if we have more than 64 bits below the minimum exponent, you have a zero for sure. + answer.power2 = 0; + answer.mantissa = 0; + // result should be zero + return answer; + } + // next line is safe because -answer.power2 + 1 < 64 + answer.mantissa >>= -answer.power2 + 1; + // Thankfully, we can't have both "round-to-even" and subnormals because + // "round-to-even" only occurs for powers close to 0. + answer.mantissa += (answer.mantissa & 1); // round up + answer.mantissa >>= 1; + // There is a weird scenario where we don't have a subnormal but just. + // Suppose we start with 2.2250738585072013e-308, we end up + // with 0x3fffffffffffff x 2^-1023-53 which is technically subnormal + // whereas 0x40000000000000 x 2^-1023-53 is normal. Now, we need to round + // up 0x3fffffffffffff x 2^-1023-53 and once we do, we are no longer + // subnormal, but we can only know this after rounding. + // So we only declare a subnormal if we are smaller than the threshold. + answer.power2 = (answer.mantissa < (uint64_t(1) << binary::mantissa_explicit_bits())) ? 0 : 1; + return answer; + } + + // usually, we round *up*, but if we fall right in between and and we have an + // even basis, we need to round down + // We are only concerned with the cases where 5**q fits in single 64-bit word. + if ((product.low <= 1) && (q >= binary::min_exponent_round_to_even()) && (q <= binary::max_exponent_round_to_even()) && + ((answer.mantissa & 3) == 1) ) { // we may fall between two floats! + // To be in-between two floats we need that in doing + // answer.mantissa = product.high >> (upperbit + 64 - binary::mantissa_explicit_bits() - 3); + // ... we dropped out only zeroes. But if this happened, then we can go back!!! + if((answer.mantissa << (upperbit + 64 - binary::mantissa_explicit_bits() - 3)) == product.high) { + answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up + } + } + + answer.mantissa += (answer.mantissa & 1); // round up + answer.mantissa >>= 1; + if (answer.mantissa >= (uint64_t(2) << binary::mantissa_explicit_bits())) { + answer.mantissa = (uint64_t(1) << binary::mantissa_explicit_bits()); + answer.power2++; // undo previous addition + } + + answer.mantissa &= ~(uint64_t(1) << binary::mantissa_explicit_bits()); + if (answer.power2 >= binary::infinite_power()) { // infinity + answer.power2 = binary::infinite_power(); + answer.mantissa = 0; + } + return answer; +} + + +} // namespace fast_float + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@decimal_to_binary.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@decimal_to_binary.h.blob new file mode 100644 index 0000000..726b95d Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@decimal_to_binary.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_float.h b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_float.h new file mode 100644 index 0000000..ffad079 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_float.h @@ -0,0 +1,45 @@ +#ifndef FASTFLOAT_FAST_FLOAT_H +#define FASTFLOAT_FAST_FLOAT_H + +#include + +namespace fast_float { +enum chars_format { + scientific = 1<<0, + fixed = 1<<2, + hex = 1<<3, + general = fixed | scientific +}; + + +struct from_chars_result { + const char *ptr; + std::errc ec; +}; + +/** + * This function parses the character sequence [first,last) for a number. It parses floating-point numbers expecting + * a locale-indepent format equivalent to what is used by std::strtod in the default ("C") locale. + * The resulting floating-point value is the closest floating-point values (using either float or double), + * using the "round to even" convention for values that would otherwise fall right in-between two values. + * That is, we provide exact parsing according to the IEEE standard. + * + * Given a successful parse, the pointer (`ptr`) in the returned value is set to point right after the + * parsed number, and the `value` referenced is set to the parsed value. In case of error, the returned + * `ec` contains a representative error, otherwise the default (`std::errc()`) value is stored. + * + * The implementation does not throw and does not allocate memory (e.g., with `new` or `malloc`). + * + * Like the C++17 standard, the `fast_float::from_chars` functions take an optional last argument of + * the type `fast_float::chars_format`. It is a bitset value: we check whether + * `fmt & fast_float::chars_format::fixed` and `fmt & fast_float::chars_format::scientific` are set + * to determine whether we allowe the fixed point and scientific notation respectively. + * The default is `fast_float::chars_format::general` which allows both `fixed` and `scientific`. + */ +template +from_chars_result from_chars(const char *first, const char *last, + T &value, chars_format fmt = chars_format::general) noexcept; + +} +#include "parse_number.h" +#endif // FASTFLOAT_FAST_FLOAT_H \ No newline at end of file diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_float.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_float.h.blob new file mode 100644 index 0000000..0ab103d Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_float.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_table.h b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_table.h new file mode 100644 index 0000000..b68fcac --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_table.h @@ -0,0 +1,689 @@ +#ifndef FASTFLOAT_FAST_TABLE_H +#define FASTFLOAT_FAST_TABLE_H +#include + +namespace fast_float { + +/** + * When mapping numbers from decimal to binary, + * we go from w * 10^q to m * 2^p but we have + * 10^q = 5^q * 2^q, so effectively + * we are trying to match + * w * 2^q * 5^q to m * 2^p. Thus the powers of two + * are not a concern since they can be represented + * exactly using the binary notation, only the powers of five + * affect the binary significand. + */ + +/** + * The smallest non-zero float (binary64) is 2^−1074. + * We take as input numbers of the form w x 10^q where w < 2^64. + * We have that w * 10^-343 < 2^(64-344) 5^-343 < 2^-1076. + * However, we have that + * (2^64-1) * 10^-342 = (2^64-1) * 2^-342 * 5^-342 > 2^−1074. + * Thus it is possible for a number of the form w * 10^-342 where + * w is a 64-bit value to be a non-zero floating-point number. + ********* + * Any number of form w * 10^309 where w>= 1 is going to be + * infinite in binary64 so we never need to worry about powers + * of 5 greater than 308. + */ +constexpr int smallest_power_of_five = -342; +constexpr int largest_power_of_five = 308; +// Powers of five from 5^-342 all the way to 5^308 rounded toward one. +const uint64_t power_of_five_128[]= { + 0xeef453d6923bd65a,0x113faa2906a13b3f, + 0x9558b4661b6565f8,0x4ac7ca59a424c507, + 0xbaaee17fa23ebf76,0x5d79bcf00d2df649, + 0xe95a99df8ace6f53,0xf4d82c2c107973dc, + 0x91d8a02bb6c10594,0x79071b9b8a4be869, + 0xb64ec836a47146f9,0x9748e2826cdee284, + 0xe3e27a444d8d98b7,0xfd1b1b2308169b25, + 0x8e6d8c6ab0787f72,0xfe30f0f5e50e20f7, + 0xb208ef855c969f4f,0xbdbd2d335e51a935, + 0xde8b2b66b3bc4723,0xad2c788035e61382, + 0x8b16fb203055ac76,0x4c3bcb5021afcc31, + 0xaddcb9e83c6b1793,0xdf4abe242a1bbf3d, + 0xd953e8624b85dd78,0xd71d6dad34a2af0d, + 0x87d4713d6f33aa6b,0x8672648c40e5ad68, + 0xa9c98d8ccb009506,0x680efdaf511f18c2, + 0xd43bf0effdc0ba48,0x212bd1b2566def2, + 0x84a57695fe98746d,0x14bb630f7604b57, + 0xa5ced43b7e3e9188,0x419ea3bd35385e2d, + 0xcf42894a5dce35ea,0x52064cac828675b9, + 0x818995ce7aa0e1b2,0x7343efebd1940993, + 0xa1ebfb4219491a1f,0x1014ebe6c5f90bf8, + 0xca66fa129f9b60a6,0xd41a26e077774ef6, + 0xfd00b897478238d0,0x8920b098955522b4, + 0x9e20735e8cb16382,0x55b46e5f5d5535b0, + 0xc5a890362fddbc62,0xeb2189f734aa831d, + 0xf712b443bbd52b7b,0xa5e9ec7501d523e4, + 0x9a6bb0aa55653b2d,0x47b233c92125366e, + 0xc1069cd4eabe89f8,0x999ec0bb696e840a, + 0xf148440a256e2c76,0xc00670ea43ca250d, + 0x96cd2a865764dbca,0x380406926a5e5728, + 0xbc807527ed3e12bc,0xc605083704f5ecf2, + 0xeba09271e88d976b,0xf7864a44c633682e, + 0x93445b8731587ea3,0x7ab3ee6afbe0211d, + 0xb8157268fdae9e4c,0x5960ea05bad82964, + 0xe61acf033d1a45df,0x6fb92487298e33bd, + 0x8fd0c16206306bab,0xa5d3b6d479f8e056, + 0xb3c4f1ba87bc8696,0x8f48a4899877186c, + 0xe0b62e2929aba83c,0x331acdabfe94de87, + 0x8c71dcd9ba0b4925,0x9ff0c08b7f1d0b14, + 0xaf8e5410288e1b6f,0x7ecf0ae5ee44dd9, + 0xdb71e91432b1a24a,0xc9e82cd9f69d6150, + 0x892731ac9faf056e,0xbe311c083a225cd2, + 0xab70fe17c79ac6ca,0x6dbd630a48aaf406, + 0xd64d3d9db981787d,0x92cbbccdad5b108, + 0x85f0468293f0eb4e,0x25bbf56008c58ea5, + 0xa76c582338ed2621,0xaf2af2b80af6f24e, + 0xd1476e2c07286faa,0x1af5af660db4aee1, + 0x82cca4db847945ca,0x50d98d9fc890ed4d, + 0xa37fce126597973c,0xe50ff107bab528a0, + 0xcc5fc196fefd7d0c,0x1e53ed49a96272c8, + 0xff77b1fcbebcdc4f,0x25e8e89c13bb0f7a, + 0x9faacf3df73609b1,0x77b191618c54e9ac, + 0xc795830d75038c1d,0xd59df5b9ef6a2417, + 0xf97ae3d0d2446f25,0x4b0573286b44ad1d, + 0x9becce62836ac577,0x4ee367f9430aec32, + 0xc2e801fb244576d5,0x229c41f793cda73f, + 0xf3a20279ed56d48a,0x6b43527578c1110f, + 0x9845418c345644d6,0x830a13896b78aaa9, + 0xbe5691ef416bd60c,0x23cc986bc656d553, + 0xedec366b11c6cb8f,0x2cbfbe86b7ec8aa8, + 0x94b3a202eb1c3f39,0x7bf7d71432f3d6a9, + 0xb9e08a83a5e34f07,0xdaf5ccd93fb0cc53, + 0xe858ad248f5c22c9,0xd1b3400f8f9cff68, + 0x91376c36d99995be,0x23100809b9c21fa1, + 0xb58547448ffffb2d,0xabd40a0c2832a78a, + 0xe2e69915b3fff9f9,0x16c90c8f323f516c, + 0x8dd01fad907ffc3b,0xae3da7d97f6792e3, + 0xb1442798f49ffb4a,0x99cd11cfdf41779c, + 0xdd95317f31c7fa1d,0x40405643d711d583, + 0x8a7d3eef7f1cfc52,0x482835ea666b2572, + 0xad1c8eab5ee43b66,0xda3243650005eecf, + 0xd863b256369d4a40,0x90bed43e40076a82, + 0x873e4f75e2224e68,0x5a7744a6e804a291, + 0xa90de3535aaae202,0x711515d0a205cb36, + 0xd3515c2831559a83,0xd5a5b44ca873e03, + 0x8412d9991ed58091,0xe858790afe9486c2, + 0xa5178fff668ae0b6,0x626e974dbe39a872, + 0xce5d73ff402d98e3,0xfb0a3d212dc8128f, + 0x80fa687f881c7f8e,0x7ce66634bc9d0b99, + 0xa139029f6a239f72,0x1c1fffc1ebc44e80, + 0xc987434744ac874e,0xa327ffb266b56220, + 0xfbe9141915d7a922,0x4bf1ff9f0062baa8, + 0x9d71ac8fada6c9b5,0x6f773fc3603db4a9, + 0xc4ce17b399107c22,0xcb550fb4384d21d3, + 0xf6019da07f549b2b,0x7e2a53a146606a48, + 0x99c102844f94e0fb,0x2eda7444cbfc426d, + 0xc0314325637a1939,0xfa911155fefb5308, + 0xf03d93eebc589f88,0x793555ab7eba27ca, + 0x96267c7535b763b5,0x4bc1558b2f3458de, + 0xbbb01b9283253ca2,0x9eb1aaedfb016f16, + 0xea9c227723ee8bcb,0x465e15a979c1cadc, + 0x92a1958a7675175f,0xbfacd89ec191ec9, + 0xb749faed14125d36,0xcef980ec671f667b, + 0xe51c79a85916f484,0x82b7e12780e7401a, + 0x8f31cc0937ae58d2,0xd1b2ecb8b0908810, + 0xb2fe3f0b8599ef07,0x861fa7e6dcb4aa15, + 0xdfbdcece67006ac9,0x67a791e093e1d49a, + 0x8bd6a141006042bd,0xe0c8bb2c5c6d24e0, + 0xaecc49914078536d,0x58fae9f773886e18, + 0xda7f5bf590966848,0xaf39a475506a899e, + 0x888f99797a5e012d,0x6d8406c952429603, + 0xaab37fd7d8f58178,0xc8e5087ba6d33b83, + 0xd5605fcdcf32e1d6,0xfb1e4a9a90880a64, + 0x855c3be0a17fcd26,0x5cf2eea09a55067f, + 0xa6b34ad8c9dfc06f,0xf42faa48c0ea481e, + 0xd0601d8efc57b08b,0xf13b94daf124da26, + 0x823c12795db6ce57,0x76c53d08d6b70858, + 0xa2cb1717b52481ed,0x54768c4b0c64ca6e, + 0xcb7ddcdda26da268,0xa9942f5dcf7dfd09, + 0xfe5d54150b090b02,0xd3f93b35435d7c4c, + 0x9efa548d26e5a6e1,0xc47bc5014a1a6daf, + 0xc6b8e9b0709f109a,0x359ab6419ca1091b, + 0xf867241c8cc6d4c0,0xc30163d203c94b62, + 0x9b407691d7fc44f8,0x79e0de63425dcf1d, + 0xc21094364dfb5636,0x985915fc12f542e4, + 0xf294b943e17a2bc4,0x3e6f5b7b17b2939d, + 0x979cf3ca6cec5b5a,0xa705992ceecf9c42, + 0xbd8430bd08277231,0x50c6ff782a838353, + 0xece53cec4a314ebd,0xa4f8bf5635246428, + 0x940f4613ae5ed136,0x871b7795e136be99, + 0xb913179899f68584,0x28e2557b59846e3f, + 0xe757dd7ec07426e5,0x331aeada2fe589cf, + 0x9096ea6f3848984f,0x3ff0d2c85def7621, + 0xb4bca50b065abe63,0xfed077a756b53a9, + 0xe1ebce4dc7f16dfb,0xd3e8495912c62894, + 0x8d3360f09cf6e4bd,0x64712dd7abbbd95c, + 0xb080392cc4349dec,0xbd8d794d96aacfb3, + 0xdca04777f541c567,0xecf0d7a0fc5583a0, + 0x89e42caaf9491b60,0xf41686c49db57244, + 0xac5d37d5b79b6239,0x311c2875c522ced5, + 0xd77485cb25823ac7,0x7d633293366b828b, + 0x86a8d39ef77164bc,0xae5dff9c02033197, + 0xa8530886b54dbdeb,0xd9f57f830283fdfc, + 0xd267caa862a12d66,0xd072df63c324fd7b, + 0x8380dea93da4bc60,0x4247cb9e59f71e6d, + 0xa46116538d0deb78,0x52d9be85f074e608, + 0xcd795be870516656,0x67902e276c921f8b, + 0x806bd9714632dff6,0xba1cd8a3db53b6, + 0xa086cfcd97bf97f3,0x80e8a40eccd228a4, + 0xc8a883c0fdaf7df0,0x6122cd128006b2cd, + 0xfad2a4b13d1b5d6c,0x796b805720085f81, + 0x9cc3a6eec6311a63,0xcbe3303674053bb0, + 0xc3f490aa77bd60fc,0xbedbfc4411068a9c, + 0xf4f1b4d515acb93b,0xee92fb5515482d44, + 0x991711052d8bf3c5,0x751bdd152d4d1c4a, + 0xbf5cd54678eef0b6,0xd262d45a78a0635d, + 0xef340a98172aace4,0x86fb897116c87c34, + 0x9580869f0e7aac0e,0xd45d35e6ae3d4da0, + 0xbae0a846d2195712,0x8974836059cca109, + 0xe998d258869facd7,0x2bd1a438703fc94b, + 0x91ff83775423cc06,0x7b6306a34627ddcf, + 0xb67f6455292cbf08,0x1a3bc84c17b1d542, + 0xe41f3d6a7377eeca,0x20caba5f1d9e4a93, + 0x8e938662882af53e,0x547eb47b7282ee9c, + 0xb23867fb2a35b28d,0xe99e619a4f23aa43, + 0xdec681f9f4c31f31,0x6405fa00e2ec94d4, + 0x8b3c113c38f9f37e,0xde83bc408dd3dd04, + 0xae0b158b4738705e,0x9624ab50b148d445, + 0xd98ddaee19068c76,0x3badd624dd9b0957, + 0x87f8a8d4cfa417c9,0xe54ca5d70a80e5d6, + 0xa9f6d30a038d1dbc,0x5e9fcf4ccd211f4c, + 0xd47487cc8470652b,0x7647c3200069671f, + 0x84c8d4dfd2c63f3b,0x29ecd9f40041e073, + 0xa5fb0a17c777cf09,0xf468107100525890, + 0xcf79cc9db955c2cc,0x7182148d4066eeb4, + 0x81ac1fe293d599bf,0xc6f14cd848405530, + 0xa21727db38cb002f,0xb8ada00e5a506a7c, + 0xca9cf1d206fdc03b,0xa6d90811f0e4851c, + 0xfd442e4688bd304a,0x908f4a166d1da663, + 0x9e4a9cec15763e2e,0x9a598e4e043287fe, + 0xc5dd44271ad3cdba,0x40eff1e1853f29fd, + 0xf7549530e188c128,0xd12bee59e68ef47c, + 0x9a94dd3e8cf578b9,0x82bb74f8301958ce, + 0xc13a148e3032d6e7,0xe36a52363c1faf01, + 0xf18899b1bc3f8ca1,0xdc44e6c3cb279ac1, + 0x96f5600f15a7b7e5,0x29ab103a5ef8c0b9, + 0xbcb2b812db11a5de,0x7415d448f6b6f0e7, + 0xebdf661791d60f56,0x111b495b3464ad21, + 0x936b9fcebb25c995,0xcab10dd900beec34, + 0xb84687c269ef3bfb,0x3d5d514f40eea742, + 0xe65829b3046b0afa,0xcb4a5a3112a5112, + 0x8ff71a0fe2c2e6dc,0x47f0e785eaba72ab, + 0xb3f4e093db73a093,0x59ed216765690f56, + 0xe0f218b8d25088b8,0x306869c13ec3532c, + 0x8c974f7383725573,0x1e414218c73a13fb, + 0xafbd2350644eeacf,0xe5d1929ef90898fa, + 0xdbac6c247d62a583,0xdf45f746b74abf39, + 0x894bc396ce5da772,0x6b8bba8c328eb783, + 0xab9eb47c81f5114f,0x66ea92f3f326564, + 0xd686619ba27255a2,0xc80a537b0efefebd, + 0x8613fd0145877585,0xbd06742ce95f5f36, + 0xa798fc4196e952e7,0x2c48113823b73704, + 0xd17f3b51fca3a7a0,0xf75a15862ca504c5, + 0x82ef85133de648c4,0x9a984d73dbe722fb, + 0xa3ab66580d5fdaf5,0xc13e60d0d2e0ebba, + 0xcc963fee10b7d1b3,0x318df905079926a8, + 0xffbbcfe994e5c61f,0xfdf17746497f7052, + 0x9fd561f1fd0f9bd3,0xfeb6ea8bedefa633, + 0xc7caba6e7c5382c8,0xfe64a52ee96b8fc0, + 0xf9bd690a1b68637b,0x3dfdce7aa3c673b0, + 0x9c1661a651213e2d,0x6bea10ca65c084e, + 0xc31bfa0fe5698db8,0x486e494fcff30a62, + 0xf3e2f893dec3f126,0x5a89dba3c3efccfa, + 0x986ddb5c6b3a76b7,0xf89629465a75e01c, + 0xbe89523386091465,0xf6bbb397f1135823, + 0xee2ba6c0678b597f,0x746aa07ded582e2c, + 0x94db483840b717ef,0xa8c2a44eb4571cdc, + 0xba121a4650e4ddeb,0x92f34d62616ce413, + 0xe896a0d7e51e1566,0x77b020baf9c81d17, + 0x915e2486ef32cd60,0xace1474dc1d122e, + 0xb5b5ada8aaff80b8,0xd819992132456ba, + 0xe3231912d5bf60e6,0x10e1fff697ed6c69, + 0x8df5efabc5979c8f,0xca8d3ffa1ef463c1, + 0xb1736b96b6fd83b3,0xbd308ff8a6b17cb2, + 0xddd0467c64bce4a0,0xac7cb3f6d05ddbde, + 0x8aa22c0dbef60ee4,0x6bcdf07a423aa96b, + 0xad4ab7112eb3929d,0x86c16c98d2c953c6, + 0xd89d64d57a607744,0xe871c7bf077ba8b7, + 0x87625f056c7c4a8b,0x11471cd764ad4972, + 0xa93af6c6c79b5d2d,0xd598e40d3dd89bcf, + 0xd389b47879823479,0x4aff1d108d4ec2c3, + 0x843610cb4bf160cb,0xcedf722a585139ba, + 0xa54394fe1eedb8fe,0xc2974eb4ee658828, + 0xce947a3da6a9273e,0x733d226229feea32, + 0x811ccc668829b887,0x806357d5a3f525f, + 0xa163ff802a3426a8,0xca07c2dcb0cf26f7, + 0xc9bcff6034c13052,0xfc89b393dd02f0b5, + 0xfc2c3f3841f17c67,0xbbac2078d443ace2, + 0x9d9ba7832936edc0,0xd54b944b84aa4c0d, + 0xc5029163f384a931,0xa9e795e65d4df11, + 0xf64335bcf065d37d,0x4d4617b5ff4a16d5, + 0x99ea0196163fa42e,0x504bced1bf8e4e45, + 0xc06481fb9bcf8d39,0xe45ec2862f71e1d6, + 0xf07da27a82c37088,0x5d767327bb4e5a4c, + 0x964e858c91ba2655,0x3a6a07f8d510f86f, + 0xbbe226efb628afea,0x890489f70a55368b, + 0xeadab0aba3b2dbe5,0x2b45ac74ccea842e, + 0x92c8ae6b464fc96f,0x3b0b8bc90012929d, + 0xb77ada0617e3bbcb,0x9ce6ebb40173744, + 0xe55990879ddcaabd,0xcc420a6a101d0515, + 0x8f57fa54c2a9eab6,0x9fa946824a12232d, + 0xb32df8e9f3546564,0x47939822dc96abf9, + 0xdff9772470297ebd,0x59787e2b93bc56f7, + 0x8bfbea76c619ef36,0x57eb4edb3c55b65a, + 0xaefae51477a06b03,0xede622920b6b23f1, + 0xdab99e59958885c4,0xe95fab368e45eced, + 0x88b402f7fd75539b,0x11dbcb0218ebb414, + 0xaae103b5fcd2a881,0xd652bdc29f26a119, + 0xd59944a37c0752a2,0x4be76d3346f0495f, + 0x857fcae62d8493a5,0x6f70a4400c562ddb, + 0xa6dfbd9fb8e5b88e,0xcb4ccd500f6bb952, + 0xd097ad07a71f26b2,0x7e2000a41346a7a7, + 0x825ecc24c873782f,0x8ed400668c0c28c8, + 0xa2f67f2dfa90563b,0x728900802f0f32fa, + 0xcbb41ef979346bca,0x4f2b40a03ad2ffb9, + 0xfea126b7d78186bc,0xe2f610c84987bfa8, + 0x9f24b832e6b0f436,0xdd9ca7d2df4d7c9, + 0xc6ede63fa05d3143,0x91503d1c79720dbb, + 0xf8a95fcf88747d94,0x75a44c6397ce912a, + 0x9b69dbe1b548ce7c,0xc986afbe3ee11aba, + 0xc24452da229b021b,0xfbe85badce996168, + 0xf2d56790ab41c2a2,0xfae27299423fb9c3, + 0x97c560ba6b0919a5,0xdccd879fc967d41a, + 0xbdb6b8e905cb600f,0x5400e987bbc1c920, + 0xed246723473e3813,0x290123e9aab23b68, + 0x9436c0760c86e30b,0xf9a0b6720aaf6521, + 0xb94470938fa89bce,0xf808e40e8d5b3e69, + 0xe7958cb87392c2c2,0xb60b1d1230b20e04, + 0x90bd77f3483bb9b9,0xb1c6f22b5e6f48c2, + 0xb4ecd5f01a4aa828,0x1e38aeb6360b1af3, + 0xe2280b6c20dd5232,0x25c6da63c38de1b0, + 0x8d590723948a535f,0x579c487e5a38ad0e, + 0xb0af48ec79ace837,0x2d835a9df0c6d851, + 0xdcdb1b2798182244,0xf8e431456cf88e65, + 0x8a08f0f8bf0f156b,0x1b8e9ecb641b58ff, + 0xac8b2d36eed2dac5,0xe272467e3d222f3f, + 0xd7adf884aa879177,0x5b0ed81dcc6abb0f, + 0x86ccbb52ea94baea,0x98e947129fc2b4e9, + 0xa87fea27a539e9a5,0x3f2398d747b36224, + 0xd29fe4b18e88640e,0x8eec7f0d19a03aad, + 0x83a3eeeef9153e89,0x1953cf68300424ac, + 0xa48ceaaab75a8e2b,0x5fa8c3423c052dd7, + 0xcdb02555653131b6,0x3792f412cb06794d, + 0x808e17555f3ebf11,0xe2bbd88bbee40bd0, + 0xa0b19d2ab70e6ed6,0x5b6aceaeae9d0ec4, + 0xc8de047564d20a8b,0xf245825a5a445275, + 0xfb158592be068d2e,0xeed6e2f0f0d56712, + 0x9ced737bb6c4183d,0x55464dd69685606b, + 0xc428d05aa4751e4c,0xaa97e14c3c26b886, + 0xf53304714d9265df,0xd53dd99f4b3066a8, + 0x993fe2c6d07b7fab,0xe546a8038efe4029, + 0xbf8fdb78849a5f96,0xde98520472bdd033, + 0xef73d256a5c0f77c,0x963e66858f6d4440, + 0x95a8637627989aad,0xdde7001379a44aa8, + 0xbb127c53b17ec159,0x5560c018580d5d52, + 0xe9d71b689dde71af,0xaab8f01e6e10b4a6, + 0x9226712162ab070d,0xcab3961304ca70e8, + 0xb6b00d69bb55c8d1,0x3d607b97c5fd0d22, + 0xe45c10c42a2b3b05,0x8cb89a7db77c506a, + 0x8eb98a7a9a5b04e3,0x77f3608e92adb242, + 0xb267ed1940f1c61c,0x55f038b237591ed3, + 0xdf01e85f912e37a3,0x6b6c46dec52f6688, + 0x8b61313bbabce2c6,0x2323ac4b3b3da015, + 0xae397d8aa96c1b77,0xabec975e0a0d081a, + 0xd9c7dced53c72255,0x96e7bd358c904a21, + 0x881cea14545c7575,0x7e50d64177da2e54, + 0xaa242499697392d2,0xdde50bd1d5d0b9e9, + 0xd4ad2dbfc3d07787,0x955e4ec64b44e864, + 0x84ec3c97da624ab4,0xbd5af13bef0b113e, + 0xa6274bbdd0fadd61,0xecb1ad8aeacdd58e, + 0xcfb11ead453994ba,0x67de18eda5814af2, + 0x81ceb32c4b43fcf4,0x80eacf948770ced7, + 0xa2425ff75e14fc31,0xa1258379a94d028d, + 0xcad2f7f5359a3b3e,0x96ee45813a04330, + 0xfd87b5f28300ca0d,0x8bca9d6e188853fc, + 0x9e74d1b791e07e48,0x775ea264cf55347e, + 0xc612062576589dda,0x95364afe032a819e, + 0xf79687aed3eec551,0x3a83ddbd83f52205, + 0x9abe14cd44753b52,0xc4926a9672793543, + 0xc16d9a0095928a27,0x75b7053c0f178294, + 0xf1c90080baf72cb1,0x5324c68b12dd6339, + 0x971da05074da7bee,0xd3f6fc16ebca5e04, + 0xbce5086492111aea,0x88f4bb1ca6bcf585, + 0xec1e4a7db69561a5,0x2b31e9e3d06c32e6, + 0x9392ee8e921d5d07,0x3aff322e62439fd0, + 0xb877aa3236a4b449,0x9befeb9fad487c3, + 0xe69594bec44de15b,0x4c2ebe687989a9b4, + 0x901d7cf73ab0acd9,0xf9d37014bf60a11, + 0xb424dc35095cd80f,0x538484c19ef38c95, + 0xe12e13424bb40e13,0x2865a5f206b06fba, + 0x8cbccc096f5088cb,0xf93f87b7442e45d4, + 0xafebff0bcb24aafe,0xf78f69a51539d749, + 0xdbe6fecebdedd5be,0xb573440e5a884d1c, + 0x89705f4136b4a597,0x31680a88f8953031, + 0xabcc77118461cefc,0xfdc20d2b36ba7c3e, + 0xd6bf94d5e57a42bc,0x3d32907604691b4d, + 0x8637bd05af6c69b5,0xa63f9a49c2c1b110, + 0xa7c5ac471b478423,0xfcf80dc33721d54, + 0xd1b71758e219652b,0xd3c36113404ea4a9, + 0x83126e978d4fdf3b,0x645a1cac083126ea, + 0xa3d70a3d70a3d70a,0x3d70a3d70a3d70a4, + 0xcccccccccccccccc,0xcccccccccccccccd, + 0x8000000000000000,0x0, + 0xa000000000000000,0x0, + 0xc800000000000000,0x0, + 0xfa00000000000000,0x0, + 0x9c40000000000000,0x0, + 0xc350000000000000,0x0, + 0xf424000000000000,0x0, + 0x9896800000000000,0x0, + 0xbebc200000000000,0x0, + 0xee6b280000000000,0x0, + 0x9502f90000000000,0x0, + 0xba43b74000000000,0x0, + 0xe8d4a51000000000,0x0, + 0x9184e72a00000000,0x0, + 0xb5e620f480000000,0x0, + 0xe35fa931a0000000,0x0, + 0x8e1bc9bf04000000,0x0, + 0xb1a2bc2ec5000000,0x0, + 0xde0b6b3a76400000,0x0, + 0x8ac7230489e80000,0x0, + 0xad78ebc5ac620000,0x0, + 0xd8d726b7177a8000,0x0, + 0x878678326eac9000,0x0, + 0xa968163f0a57b400,0x0, + 0xd3c21bcecceda100,0x0, + 0x84595161401484a0,0x0, + 0xa56fa5b99019a5c8,0x0, + 0xcecb8f27f4200f3a,0x0, + 0x813f3978f8940984,0x4000000000000000, + 0xa18f07d736b90be5,0x5000000000000000, + 0xc9f2c9cd04674ede,0xa400000000000000, + 0xfc6f7c4045812296,0x4d00000000000000, + 0x9dc5ada82b70b59d,0xf020000000000000, + 0xc5371912364ce305,0x6c28000000000000, + 0xf684df56c3e01bc6,0xc732000000000000, + 0x9a130b963a6c115c,0x3c7f400000000000, + 0xc097ce7bc90715b3,0x4b9f100000000000, + 0xf0bdc21abb48db20,0x1e86d40000000000, + 0x96769950b50d88f4,0x1314448000000000, + 0xbc143fa4e250eb31,0x17d955a000000000, + 0xeb194f8e1ae525fd,0x5dcfab0800000000, + 0x92efd1b8d0cf37be,0x5aa1cae500000000, + 0xb7abc627050305ad,0xf14a3d9e40000000, + 0xe596b7b0c643c719,0x6d9ccd05d0000000, + 0x8f7e32ce7bea5c6f,0xe4820023a2000000, + 0xb35dbf821ae4f38b,0xdda2802c8a800000, + 0xe0352f62a19e306e,0xd50b2037ad200000, + 0x8c213d9da502de45,0x4526f422cc340000, + 0xaf298d050e4395d6,0x9670b12b7f410000, + 0xdaf3f04651d47b4c,0x3c0cdd765f114000, + 0x88d8762bf324cd0f,0xa5880a69fb6ac800, + 0xab0e93b6efee0053,0x8eea0d047a457a00, + 0xd5d238a4abe98068,0x72a4904598d6d880, + 0x85a36366eb71f041,0x47a6da2b7f864750, + 0xa70c3c40a64e6c51,0x999090b65f67d924, + 0xd0cf4b50cfe20765,0xfff4b4e3f741cf6d, + 0x82818f1281ed449f,0xbff8f10e7a8921a4, + 0xa321f2d7226895c7,0xaff72d52192b6a0d, + 0xcbea6f8ceb02bb39,0x9bf4f8a69f764490, + 0xfee50b7025c36a08,0x2f236d04753d5b4, + 0x9f4f2726179a2245,0x1d762422c946590, + 0xc722f0ef9d80aad6,0x424d3ad2b7b97ef5, + 0xf8ebad2b84e0d58b,0xd2e0898765a7deb2, + 0x9b934c3b330c8577,0x63cc55f49f88eb2f, + 0xc2781f49ffcfa6d5,0x3cbf6b71c76b25fb, + 0xf316271c7fc3908a,0x8bef464e3945ef7a, + 0x97edd871cfda3a56,0x97758bf0e3cbb5ac, + 0xbde94e8e43d0c8ec,0x3d52eeed1cbea317, + 0xed63a231d4c4fb27,0x4ca7aaa863ee4bdd, + 0x945e455f24fb1cf8,0x8fe8caa93e74ef6a, + 0xb975d6b6ee39e436,0xb3e2fd538e122b44, + 0xe7d34c64a9c85d44,0x60dbbca87196b616, + 0x90e40fbeea1d3a4a,0xbc8955e946fe31cd, + 0xb51d13aea4a488dd,0x6babab6398bdbe41, + 0xe264589a4dcdab14,0xc696963c7eed2dd1, + 0x8d7eb76070a08aec,0xfc1e1de5cf543ca2, + 0xb0de65388cc8ada8,0x3b25a55f43294bcb, + 0xdd15fe86affad912,0x49ef0eb713f39ebe, + 0x8a2dbf142dfcc7ab,0x6e3569326c784337, + 0xacb92ed9397bf996,0x49c2c37f07965404, + 0xd7e77a8f87daf7fb,0xdc33745ec97be906, + 0x86f0ac99b4e8dafd,0x69a028bb3ded71a3, + 0xa8acd7c0222311bc,0xc40832ea0d68ce0c, + 0xd2d80db02aabd62b,0xf50a3fa490c30190, + 0x83c7088e1aab65db,0x792667c6da79e0fa, + 0xa4b8cab1a1563f52,0x577001b891185938, + 0xcde6fd5e09abcf26,0xed4c0226b55e6f86, + 0x80b05e5ac60b6178,0x544f8158315b05b4, + 0xa0dc75f1778e39d6,0x696361ae3db1c721, + 0xc913936dd571c84c,0x3bc3a19cd1e38e9, + 0xfb5878494ace3a5f,0x4ab48a04065c723, + 0x9d174b2dcec0e47b,0x62eb0d64283f9c76, + 0xc45d1df942711d9a,0x3ba5d0bd324f8394, + 0xf5746577930d6500,0xca8f44ec7ee36479, + 0x9968bf6abbe85f20,0x7e998b13cf4e1ecb, + 0xbfc2ef456ae276e8,0x9e3fedd8c321a67e, + 0xefb3ab16c59b14a2,0xc5cfe94ef3ea101e, + 0x95d04aee3b80ece5,0xbba1f1d158724a12, + 0xbb445da9ca61281f,0x2a8a6e45ae8edc97, + 0xea1575143cf97226,0xf52d09d71a3293bd, + 0x924d692ca61be758,0x593c2626705f9c56, + 0xb6e0c377cfa2e12e,0x6f8b2fb00c77836c, + 0xe498f455c38b997a,0xb6dfb9c0f956447, + 0x8edf98b59a373fec,0x4724bd4189bd5eac, + 0xb2977ee300c50fe7,0x58edec91ec2cb657, + 0xdf3d5e9bc0f653e1,0x2f2967b66737e3ed, + 0x8b865b215899f46c,0xbd79e0d20082ee74, + 0xae67f1e9aec07187,0xecd8590680a3aa11, + 0xda01ee641a708de9,0xe80e6f4820cc9495, + 0x884134fe908658b2,0x3109058d147fdcdd, + 0xaa51823e34a7eede,0xbd4b46f0599fd415, + 0xd4e5e2cdc1d1ea96,0x6c9e18ac7007c91a, + 0x850fadc09923329e,0x3e2cf6bc604ddb0, + 0xa6539930bf6bff45,0x84db8346b786151c, + 0xcfe87f7cef46ff16,0xe612641865679a63, + 0x81f14fae158c5f6e,0x4fcb7e8f3f60c07e, + 0xa26da3999aef7749,0xe3be5e330f38f09d, + 0xcb090c8001ab551c,0x5cadf5bfd3072cc5, + 0xfdcb4fa002162a63,0x73d9732fc7c8f7f6, + 0x9e9f11c4014dda7e,0x2867e7fddcdd9afa, + 0xc646d63501a1511d,0xb281e1fd541501b8, + 0xf7d88bc24209a565,0x1f225a7ca91a4226, + 0x9ae757596946075f,0x3375788de9b06958, + 0xc1a12d2fc3978937,0x52d6b1641c83ae, + 0xf209787bb47d6b84,0xc0678c5dbd23a49a, + 0x9745eb4d50ce6332,0xf840b7ba963646e0, + 0xbd176620a501fbff,0xb650e5a93bc3d898, + 0xec5d3fa8ce427aff,0xa3e51f138ab4cebe, + 0x93ba47c980e98cdf,0xc66f336c36b10137, + 0xb8a8d9bbe123f017,0xb80b0047445d4184, + 0xe6d3102ad96cec1d,0xa60dc059157491e5, + 0x9043ea1ac7e41392,0x87c89837ad68db2f, + 0xb454e4a179dd1877,0x29babe4598c311fb, + 0xe16a1dc9d8545e94,0xf4296dd6fef3d67a, + 0x8ce2529e2734bb1d,0x1899e4a65f58660c, + 0xb01ae745b101e9e4,0x5ec05dcff72e7f8f, + 0xdc21a1171d42645d,0x76707543f4fa1f73, + 0x899504ae72497eba,0x6a06494a791c53a8, + 0xabfa45da0edbde69,0x487db9d17636892, + 0xd6f8d7509292d603,0x45a9d2845d3c42b6, + 0x865b86925b9bc5c2,0xb8a2392ba45a9b2, + 0xa7f26836f282b732,0x8e6cac7768d7141e, + 0xd1ef0244af2364ff,0x3207d795430cd926, + 0x8335616aed761f1f,0x7f44e6bd49e807b8, + 0xa402b9c5a8d3a6e7,0x5f16206c9c6209a6, + 0xcd036837130890a1,0x36dba887c37a8c0f, + 0x802221226be55a64,0xc2494954da2c9789, + 0xa02aa96b06deb0fd,0xf2db9baa10b7bd6c, + 0xc83553c5c8965d3d,0x6f92829494e5acc7, + 0xfa42a8b73abbf48c,0xcb772339ba1f17f9, + 0x9c69a97284b578d7,0xff2a760414536efb, + 0xc38413cf25e2d70d,0xfef5138519684aba, + 0xf46518c2ef5b8cd1,0x7eb258665fc25d69, + 0x98bf2f79d5993802,0xef2f773ffbd97a61, + 0xbeeefb584aff8603,0xaafb550ffacfd8fa, + 0xeeaaba2e5dbf6784,0x95ba2a53f983cf38, + 0x952ab45cfa97a0b2,0xdd945a747bf26183, + 0xba756174393d88df,0x94f971119aeef9e4, + 0xe912b9d1478ceb17,0x7a37cd5601aab85d, + 0x91abb422ccb812ee,0xac62e055c10ab33a, + 0xb616a12b7fe617aa,0x577b986b314d6009, + 0xe39c49765fdf9d94,0xed5a7e85fda0b80b, + 0x8e41ade9fbebc27d,0x14588f13be847307, + 0xb1d219647ae6b31c,0x596eb2d8ae258fc8, + 0xde469fbd99a05fe3,0x6fca5f8ed9aef3bb, + 0x8aec23d680043bee,0x25de7bb9480d5854, + 0xada72ccc20054ae9,0xaf561aa79a10ae6a, + 0xd910f7ff28069da4,0x1b2ba1518094da04, + 0x87aa9aff79042286,0x90fb44d2f05d0842, + 0xa99541bf57452b28,0x353a1607ac744a53, + 0xd3fa922f2d1675f2,0x42889b8997915ce8, + 0x847c9b5d7c2e09b7,0x69956135febada11, + 0xa59bc234db398c25,0x43fab9837e699095, + 0xcf02b2c21207ef2e,0x94f967e45e03f4bb, + 0x8161afb94b44f57d,0x1d1be0eebac278f5, + 0xa1ba1ba79e1632dc,0x6462d92a69731732, + 0xca28a291859bbf93,0x7d7b8f7503cfdcfe, + 0xfcb2cb35e702af78,0x5cda735244c3d43e, + 0x9defbf01b061adab,0x3a0888136afa64a7, + 0xc56baec21c7a1916,0x88aaa1845b8fdd0, + 0xf6c69a72a3989f5b,0x8aad549e57273d45, + 0x9a3c2087a63f6399,0x36ac54e2f678864b, + 0xc0cb28a98fcf3c7f,0x84576a1bb416a7dd, + 0xf0fdf2d3f3c30b9f,0x656d44a2a11c51d5, + 0x969eb7c47859e743,0x9f644ae5a4b1b325, + 0xbc4665b596706114,0x873d5d9f0dde1fee, + 0xeb57ff22fc0c7959,0xa90cb506d155a7ea, + 0x9316ff75dd87cbd8,0x9a7f12442d588f2, + 0xb7dcbf5354e9bece,0xc11ed6d538aeb2f, + 0xe5d3ef282a242e81,0x8f1668c8a86da5fa, + 0x8fa475791a569d10,0xf96e017d694487bc, + 0xb38d92d760ec4455,0x37c981dcc395a9ac, + 0xe070f78d3927556a,0x85bbe253f47b1417, + 0x8c469ab843b89562,0x93956d7478ccec8e, + 0xaf58416654a6babb,0x387ac8d1970027b2, + 0xdb2e51bfe9d0696a,0x6997b05fcc0319e, + 0x88fcf317f22241e2,0x441fece3bdf81f03, + 0xab3c2fddeeaad25a,0xd527e81cad7626c3, + 0xd60b3bd56a5586f1,0x8a71e223d8d3b074, + 0x85c7056562757456,0xf6872d5667844e49, + 0xa738c6bebb12d16c,0xb428f8ac016561db, + 0xd106f86e69d785c7,0xe13336d701beba52, + 0x82a45b450226b39c,0xecc0024661173473, + 0xa34d721642b06084,0x27f002d7f95d0190, + 0xcc20ce9bd35c78a5,0x31ec038df7b441f4, + 0xff290242c83396ce,0x7e67047175a15271, + 0x9f79a169bd203e41,0xf0062c6e984d386, + 0xc75809c42c684dd1,0x52c07b78a3e60868, + 0xf92e0c3537826145,0xa7709a56ccdf8a82, + 0x9bbcc7a142b17ccb,0x88a66076400bb691, + 0xc2abf989935ddbfe,0x6acff893d00ea435, + 0xf356f7ebf83552fe,0x583f6b8c4124d43, + 0x98165af37b2153de,0xc3727a337a8b704a, + 0xbe1bf1b059e9a8d6,0x744f18c0592e4c5c, + 0xeda2ee1c7064130c,0x1162def06f79df73, + 0x9485d4d1c63e8be7,0x8addcb5645ac2ba8, + 0xb9a74a0637ce2ee1,0x6d953e2bd7173692, + 0xe8111c87c5c1ba99,0xc8fa8db6ccdd0437, + 0x910ab1d4db9914a0,0x1d9c9892400a22a2, + 0xb54d5e4a127f59c8,0x2503beb6d00cab4b, + 0xe2a0b5dc971f303a,0x2e44ae64840fd61d, + 0x8da471a9de737e24,0x5ceaecfed289e5d2, + 0xb10d8e1456105dad,0x7425a83e872c5f47, + 0xdd50f1996b947518,0xd12f124e28f77719, + 0x8a5296ffe33cc92f,0x82bd6b70d99aaa6f, + 0xace73cbfdc0bfb7b,0x636cc64d1001550b, + 0xd8210befd30efa5a,0x3c47f7e05401aa4e, + 0x8714a775e3e95c78,0x65acfaec34810a71, + 0xa8d9d1535ce3b396,0x7f1839a741a14d0d, + 0xd31045a8341ca07c,0x1ede48111209a050, + 0x83ea2b892091e44d,0x934aed0aab460432, + 0xa4e4b66b68b65d60,0xf81da84d5617853f, + 0xce1de40642e3f4b9,0x36251260ab9d668e, + 0x80d2ae83e9ce78f3,0xc1d72b7c6b426019, + 0xa1075a24e4421730,0xb24cf65b8612f81f, + 0xc94930ae1d529cfc,0xdee033f26797b627, + 0xfb9b7cd9a4a7443c,0x169840ef017da3b1, + 0x9d412e0806e88aa5,0x8e1f289560ee864e, + 0xc491798a08a2ad4e,0xf1a6f2bab92a27e2, + 0xf5b5d7ec8acb58a2,0xae10af696774b1db, + 0x9991a6f3d6bf1765,0xacca6da1e0a8ef29, + 0xbff610b0cc6edd3f,0x17fd090a58d32af3, + 0xeff394dcff8a948e,0xddfc4b4cef07f5b0, + 0x95f83d0a1fb69cd9,0x4abdaf101564f98e, + 0xbb764c4ca7a4440f,0x9d6d1ad41abe37f1, + 0xea53df5fd18d5513,0x84c86189216dc5ed, + 0x92746b9be2f8552c,0x32fd3cf5b4e49bb4, + 0xb7118682dbb66a77,0x3fbc8c33221dc2a1, + 0xe4d5e82392a40515,0xfabaf3feaa5334a, + 0x8f05b1163ba6832d,0x29cb4d87f2a7400e, + 0xb2c71d5bca9023f8,0x743e20e9ef511012, + 0xdf78e4b2bd342cf6,0x914da9246b255416, + 0x8bab8eefb6409c1a,0x1ad089b6c2f7548e, + 0xae9672aba3d0c320,0xa184ac2473b529b1, + 0xda3c0f568cc4f3e8,0xc9e5d72d90a2741e, + 0x8865899617fb1871,0x7e2fa67c7a658892, + 0xaa7eebfb9df9de8d,0xddbb901b98feeab7, + 0xd51ea6fa85785631,0x552a74227f3ea565, + 0x8533285c936b35de,0xd53a88958f87275f, + 0xa67ff273b8460356,0x8a892abaf368f137, + 0xd01fef10a657842c,0x2d2b7569b0432d85, + 0x8213f56a67f6b29b,0x9c3b29620e29fc73, + 0xa298f2c501f45f42,0x8349f3ba91b47b8f, + 0xcb3f2f7642717713,0x241c70a936219a73, + 0xfe0efb53d30dd4d7,0xed238cd383aa0110, + 0x9ec95d1463e8a506,0xf4363804324a40aa, + 0xc67bb4597ce2ce48,0xb143c6053edcd0d5, + 0xf81aa16fdc1b81da,0xdd94b7868e94050a, + 0x9b10a4e5e9913128,0xca7cf2b4191c8326, + 0xc1d4ce1f63f57d72,0xfd1c2f611f63a3f0, + 0xf24a01a73cf2dccf,0xbc633b39673c8cec, + 0x976e41088617ca01,0xd5be0503e085d813, + 0xbd49d14aa79dbc82,0x4b2d8644d8a74e18, + 0xec9c459d51852ba2,0xddf8e7d60ed1219e, + 0x93e1ab8252f33b45,0xcabb90e5c942b503, + 0xb8da1662e7b00a17,0x3d6a751f3b936243, + 0xe7109bfba19c0c9d,0xcc512670a783ad4, + 0x906a617d450187e2,0x27fb2b80668b24c5, + 0xb484f9dc9641e9da,0xb1f9f660802dedf6, + 0xe1a63853bbd26451,0x5e7873f8a0396973, + 0x8d07e33455637eb2,0xdb0b487b6423e1e8, + 0xb049dc016abc5e5f,0x91ce1a9a3d2cda62, + 0xdc5c5301c56b75f7,0x7641a140cc7810fb, + 0x89b9b3e11b6329ba,0xa9e904c87fcb0a9d, + 0xac2820d9623bf429,0x546345fa9fbdcd44, + 0xd732290fbacaf133,0xa97c177947ad4095, + 0x867f59a9d4bed6c0,0x49ed8eabcccc485d, + 0xa81f301449ee8c70,0x5c68f256bfff5a74, + 0xd226fc195c6a2f8c,0x73832eec6fff3111, + 0x83585d8fd9c25db7,0xc831fd53c5ff7eab, + 0xa42e74f3d032f525,0xba3e7ca8b77f5e55, + 0xcd3a1230c43fb26f,0x28ce1bd2e55f35eb, + 0x80444b5e7aa7cf85,0x7980d163cf5b81b3, + 0xa0555e361951c366,0xd7e105bcc332621f, + 0xc86ab5c39fa63440,0x8dd9472bf3fefaa7, + 0xfa856334878fc150,0xb14f98f6f0feb951, + 0x9c935e00d4b9d8d2,0x6ed1bf9a569f33d3, + 0xc3b8358109e84f07,0xa862f80ec4700c8, + 0xf4a642e14c6262c8,0xcd27bb612758c0fa, + 0x98e7e9cccfbd7dbd,0x8038d51cb897789c, + 0xbf21e44003acdd2c,0xe0470a63e6bd56c3, + 0xeeea5d5004981478,0x1858ccfce06cac74, + 0x95527a5202df0ccb,0xf37801e0c43ebc8, + 0xbaa718e68396cffd,0xd30560258f54e6ba, + 0xe950df20247c83fd,0x47c6b82ef32a2069, + 0x91d28b7416cdd27e,0x4cdc331d57fa5441, + 0xb6472e511c81471d,0xe0133fe4adf8e952, + 0xe3d8f9e563a198e5,0x58180fddd97723a6, + 0x8e679c2f5e44ff8f,0x570f09eaa7ea7648,}; + +} + +#endif \ No newline at end of file diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_table.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_table.h.blob new file mode 100644 index 0000000..f8f23d0 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@fast_table.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@float_common.h b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@float_common.h new file mode 100644 index 0000000..cb15ac2 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@float_common.h @@ -0,0 +1,340 @@ +#ifndef FASTFLOAT_FLOAT_COMMON_H +#define FASTFLOAT_FLOAT_COMMON_H + +#include +#include +#include + +#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) \ + || defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) \ + || defined(__MINGW64__) \ + || defined(__s390x__) \ + || (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__))) +#define FASTFLOAT_64BIT +#elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) \ + || defined(__arm__) \ + || defined(__MINGW32__)) +#define FASTFLOAT_32BIT +#else +#error Unknown platform (not 32-bit, not 64-bit?) +#endif + +#if ((defined(_WIN32) || defined(_WIN64)) && !defined(__clang__)) +#include +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +#define FASTFLOAT_VISUAL_STUDIO 1 +#endif + +#ifdef _WIN32 +#define FASTFLOAT_IS_BIG_ENDIAN 0 +#else +#if defined(__APPLE__) || defined(__FreeBSD__) +#include +#else +#include +#endif +# +#ifndef __BYTE_ORDER__ +// safe choice +#define FASTFLOAT_IS_BIG_ENDIAN 0 +#endif +# +#ifndef __ORDER_LITTLE_ENDIAN__ +// safe choice +#define FASTFLOAT_IS_BIG_ENDIAN 0 +#endif +# +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define FASTFLOAT_IS_BIG_ENDIAN 0 +#else +#define FASTFLOAT_IS_BIG_ENDIAN 1 +#endif +#endif + +#ifdef FASTFLOAT_VISUAL_STUDIO +#define fastfloat_really_inline __forceinline +#else +#define fastfloat_really_inline inline __attribute__((always_inline)) +#endif + +namespace fast_float { + +// Compares two ASCII strings in a case insensitive manner. +inline bool fastfloat_strncasecmp(const char *input1, const char *input2, + size_t length) { + char running_diff{0}; + for (size_t i = 0; i < length; i++) { + running_diff |= (input1[i] ^ input2[i]); + } + return (running_diff == 0) || (running_diff == 32); +} + +#ifndef FLT_EVAL_METHOD +#error "FLT_EVAL_METHOD should be defined, please include cfloat." +#endif + +inline bool is_space(uint8_t c) { + static const bool table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + return table[c]; +} + +namespace { +constexpr uint32_t max_digits = 768; +constexpr uint32_t max_digit_without_overflow = 19; +constexpr int32_t decimal_point_range = 2047; +} // namespace + +struct value128 { + uint64_t low; + uint64_t high; + value128(uint64_t _low, uint64_t _high) : low(_low), high(_high) {} + value128() : low(0), high(0) {} +}; + +/* result might be undefined when input_num is zero */ +fastfloat_really_inline int leading_zeroes(uint64_t input_num) { + assert(input_num > 0); +#ifdef FASTFLOAT_VISUAL_STUDIO + #if defined(_M_X64) || defined(_M_ARM64) + unsigned long leading_zero = 0; + // Search the mask data from most significant bit (MSB) + // to least significant bit (LSB) for a set bit (1). + _BitScanReverse64(&leading_zero, input_num); + return (int)(63 - leading_zero); + #else + int last_bit = 0; + if(input_num & uint64_t(0xffffffff00000000)) input_num >>= 32, last_bit |= 32; + if(input_num & uint64_t( 0xffff0000)) input_num >>= 16, last_bit |= 16; + if(input_num & uint64_t( 0xff00)) input_num >>= 8, last_bit |= 8; + if(input_num & uint64_t( 0xf0)) input_num >>= 4, last_bit |= 4; + if(input_num & uint64_t( 0xc)) input_num >>= 2, last_bit |= 2; + if(input_num & uint64_t( 0x2)) input_num >>= 1, last_bit |= 1; + return 63 - last_bit; + #endif +#else + return __builtin_clzll(input_num); +#endif +} + +#ifdef FASTFLOAT_32BIT + +#if (!defined(_WIN32)) || defined(__MINGW32__) +// slow emulation routine for 32-bit +fastfloat_really_inline uint64_t __emulu(uint32_t x, uint32_t y) { + return x * (uint64_t)y; +} +#endif + +// slow emulation routine for 32-bit +#if !defined(__MINGW64__) +fastfloat_really_inline uint64_t _umul128(uint64_t ab, uint64_t cd, + uint64_t *hi) { + uint64_t ad = __emulu((uint32_t)(ab >> 32), (uint32_t)cd); + uint64_t bd = __emulu((uint32_t)ab, (uint32_t)cd); + uint64_t adbc = ad + __emulu((uint32_t)ab, (uint32_t)(cd >> 32)); + uint64_t adbc_carry = !!(adbc < ad); + uint64_t lo = bd + (adbc << 32); + *hi = __emulu((uint32_t)(ab >> 32), (uint32_t)(cd >> 32)) + (adbc >> 32) + + (adbc_carry << 32) + !!(lo < bd); + return lo; +} +#endif // !__MINGW64__ + +#endif // FASTFLOAT_32BIT + + +// compute 64-bit a*b +fastfloat_really_inline value128 full_multiplication(uint64_t a, + uint64_t b) { + value128 answer; +#ifdef _M_ARM64 + // ARM64 has native support for 64-bit multiplications, no need to emulate + answer.high = __umulh(a, b); + answer.low = a * b; +#elif defined(FASTFLOAT_32BIT) || (defined(_WIN64) && !defined(__clang__)) + answer.low = _umul128(a, b, &answer.high); // _umul128 not available on ARM64 +#elif defined(FASTFLOAT_64BIT) + __uint128_t r = ((__uint128_t)a) * b; + answer.low = uint64_t(r); + answer.high = uint64_t(r >> 64); +#else + #error Not implemented +#endif + return answer; +} + + +struct adjusted_mantissa { + uint64_t mantissa{0}; + int power2{0}; // a negative value indicates an invalid result + adjusted_mantissa() = default; + bool operator==(const adjusted_mantissa &o) const { + return mantissa == o.mantissa && power2 == o.power2; + } + bool operator!=(const adjusted_mantissa &o) const { + return mantissa != o.mantissa || power2 != o.power2; + } +}; + +struct decimal { + uint32_t num_digits{0}; + int32_t decimal_point{0}; + bool negative{false}; + bool truncated{false}; + uint8_t digits[max_digits]; + decimal() = default; + // Copies are not allowed since this is a fat object. + decimal(const decimal &) = delete; + // Copies are not allowed since this is a fat object. + decimal &operator=(const decimal &) = delete; + // Moves are allowed: + decimal(decimal &&) = default; + decimal &operator=(decimal &&other) = default; +}; + +constexpr static double powers_of_ten_double[] = { + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, + 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; +constexpr static float powers_of_ten_float[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5, + 1e6, 1e7, 1e8, 1e9, 1e10}; + +template struct binary_format { + static constexpr int mantissa_explicit_bits(); + static constexpr int minimum_exponent(); + static constexpr int infinite_power(); + static constexpr int sign_index(); + static constexpr int min_exponent_fast_path(); + static constexpr int max_exponent_fast_path(); + static constexpr int max_exponent_round_to_even(); + static constexpr int min_exponent_round_to_even(); + static constexpr uint64_t max_mantissa_fast_path(); + static constexpr int largest_power_of_ten(); + static constexpr int smallest_power_of_ten(); + static constexpr T exact_power_of_ten(int64_t power); +}; + +template <> constexpr int binary_format::mantissa_explicit_bits() { + return 52; +} +template <> constexpr int binary_format::mantissa_explicit_bits() { + return 23; +} + +template <> constexpr int binary_format::max_exponent_round_to_even() { + return 23; +} + +template <> constexpr int binary_format::max_exponent_round_to_even() { + return 10; +} + +template <> constexpr int binary_format::min_exponent_round_to_even() { + return -4; +} + +template <> constexpr int binary_format::min_exponent_round_to_even() { + return -17; +} + +template <> constexpr int binary_format::minimum_exponent() { + return -1023; +} +template <> constexpr int binary_format::minimum_exponent() { + return -127; +} + +template <> constexpr int binary_format::infinite_power() { + return 0x7FF; +} +template <> constexpr int binary_format::infinite_power() { + return 0xFF; +} + +template <> constexpr int binary_format::sign_index() { return 63; } +template <> constexpr int binary_format::sign_index() { return 31; } + +template <> constexpr int binary_format::min_exponent_fast_path() { +#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) + return 0; +#else + return -22; +#endif +} +template <> constexpr int binary_format::min_exponent_fast_path() { +#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) + return 0; +#else + return -10; +#endif +} + +template <> constexpr int binary_format::max_exponent_fast_path() { + return 22; +} +template <> constexpr int binary_format::max_exponent_fast_path() { + return 10; +} + +template <> constexpr uint64_t binary_format::max_mantissa_fast_path() { + return uint64_t(2) << mantissa_explicit_bits(); +} +template <> constexpr uint64_t binary_format::max_mantissa_fast_path() { + return uint64_t(2) << mantissa_explicit_bits(); +} + +template <> +constexpr double binary_format::exact_power_of_ten(int64_t power) { + return powers_of_ten_double[power]; +} +template <> +constexpr float binary_format::exact_power_of_ten(int64_t power) { + + return powers_of_ten_float[power]; +} + + +template <> +constexpr int binary_format::largest_power_of_ten() { + return 308; +} +template <> +constexpr int binary_format::largest_power_of_ten() { + return 38; +} + +template <> +constexpr int binary_format::smallest_power_of_ten() { + return -342; +} +template <> +constexpr int binary_format::smallest_power_of_ten() { + return -65; +} + +} // namespace fast_float + +// for convenience: +template +inline OStream& operator<<(OStream &out, const fast_float::decimal &d) { + out << "0."; + for (size_t i = 0; i < d.num_digits; i++) { + out << int32_t(d.digits[i]); + } + out << " * 10 ** " << d.decimal_point; + return out; +} + +#endif \ No newline at end of file diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@float_common.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@float_common.h.blob new file mode 100644 index 0000000..55ea47e Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@float_common.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@parse_number.h b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@parse_number.h new file mode 100644 index 0000000..f69b741 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@parse_number.h @@ -0,0 +1,136 @@ +#ifndef FASTFLOAT_PARSE_NUMBER_H +#define FASTFLOAT_PARSE_NUMBER_H +#include "ascii_number.h" +#include "decimal_to_binary.h" +#include "simple_decimal_conversion.h" + +#include +#include +#include +#include +#include + +namespace fast_float { + + +namespace { +/** + * Special case +inf, -inf, nan, infinity, -infinity. + * The case comparisons could be made much faster given that we know that the + * strings a null-free and fixed. + **/ +template +from_chars_result parse_infnan(const char *first, const char *last, T &value) noexcept { + from_chars_result answer; + answer.ec = std::errc(); // be optimistic + if (last - first >= 3) { + if (fastfloat_strncasecmp(first, "nan", 3)) { + answer.ptr = first + 3; + value = std::numeric_limits::quiet_NaN(); + return answer; + } + if (fastfloat_strncasecmp(first, "inf", 3)) { + if ((last - first >= 8) && fastfloat_strncasecmp(first, "infinity", 8)) { + answer.ptr = first + 8; + } else { + answer.ptr = first + 3; + } + value = std::numeric_limits::infinity(); + return answer; + } + if (last - first >= 4) { + if (fastfloat_strncasecmp(first, "+nan", 4) || fastfloat_strncasecmp(first, "-nan", 4)) { + answer.ptr = first + 4; + value = std::numeric_limits::quiet_NaN(); + if (first[0] == '-') { + value = -value; + } + return answer; + } + + if (fastfloat_strncasecmp(first, "+inf", 4) || fastfloat_strncasecmp(first, "-inf", 4)) { + if ((last - first >= 8) && fastfloat_strncasecmp(first + 1, "infinity", 8)) { + answer.ptr = first + 9; + } else { + answer.ptr = first + 4; + } + value = std::numeric_limits::infinity(); + if (first[0] == '-') { + value = -value; + } + return answer; + } + } + } + answer.ec = std::errc::invalid_argument; + answer.ptr = first; + return answer; +} + +template +fastfloat_really_inline void to_float(bool negative, adjusted_mantissa am, T &value) { + uint64_t word = am.mantissa; + word |= uint64_t(am.power2) << binary_format::mantissa_explicit_bits(); + word = negative + ? word | (uint64_t(1) << binary_format::sign_index()) : word; +#if FASTFLOAT_IS_BIG_ENDIAN == 1 + if (std::is_same::value) { + ::memcpy(&value, (char *)&word + 4, sizeof(T)); // extract value at offset 4-7 if float on big-endian + } else { + ::memcpy(&value, &word, sizeof(T)); + } +#else + // For little-endian systems: + ::memcpy(&value, &word, sizeof(T)); +#endif +} + +} // namespace + + + +template +from_chars_result from_chars(const char *first, const char *last, + T &value, chars_format fmt /*= chars_format::general*/) noexcept { + static_assert (std::is_same::value || std::is_same::value, "only float and double are supported"); + + + from_chars_result answer; + while ((first != last) && fast_float::is_space(uint8_t(*first))) { + first++; + } + if (first == last) { + answer.ec = std::errc::invalid_argument; + answer.ptr = first; + return answer; + } + parsed_number_string pns = parse_number_string(first, last, fmt); + if (!pns.valid) { + return parse_infnan(first, last, value); + } + answer.ec = std::errc(); // be optimistic + answer.ptr = pns.lastmatch; + // Next is Clinger's fast path. + if (binary_format::min_exponent_fast_path() <= pns.exponent && pns.exponent <= binary_format::max_exponent_fast_path() && pns.mantissa <=binary_format::max_mantissa_fast_path() && !pns.too_many_digits) { + value = T(pns.mantissa); + if (pns.exponent < 0) { value = value / binary_format::exact_power_of_ten(-pns.exponent); } + else { value = value * binary_format::exact_power_of_ten(pns.exponent); } + if (pns.negative) { value = -value; } + return answer; + } + adjusted_mantissa am = compute_float>(pns.exponent, pns.mantissa); + if(pns.too_many_digits) { + if(am != compute_float>(pns.exponent, pns.mantissa + 1)) { + am.power2 = -1; // value is invalid. + } + } + // If we called compute_float>(pns.exponent, pns.mantissa) and we have an invalid power (am.power2 < 0), + // then we need to go the long way around again. This is very uncommon. + if(am.power2 < 0) { am = parse_long_mantissa>(first,last); } + to_float(pns.negative, am, value); + return answer; +} + +} // namespace fast_float + +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@parse_number.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@parse_number.h.blob new file mode 100644 index 0000000..c6af3cd Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@parse_number.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@simple_decimal_conversion.h b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@simple_decimal_conversion.h new file mode 100644 index 0000000..bfb60b6 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@simple_decimal_conversion.h @@ -0,0 +1,360 @@ +#ifndef FASTFLOAT_GENERIC_DECIMAL_TO_BINARY_H +#define FASTFLOAT_GENERIC_DECIMAL_TO_BINARY_H + +/** + * This code is meant to handle the case where we have more than 19 digits. + * + * It is based on work by Nigel Tao (at https://github.com/google/wuffs/) + * who credits Ken Thompson for the design (via a reference to the Go source + * code). + * + * Rob Pike suggested that this algorithm be called "Simple Decimal Conversion". + * + * It is probably not very fast but it is a fallback that should almost never + * be used in real life. Though it is not fast, it is "easily" understood and debugged. + **/ +#include "ascii_number.h" +#include "decimal_to_binary.h" +#include + +namespace fast_float { + +namespace { + +// remove all final zeroes +inline void trim(decimal &h) { + while ((h.num_digits > 0) && (h.digits[h.num_digits - 1] == 0)) { + h.num_digits--; + } +} + + + +uint32_t number_of_digits_decimal_left_shift(const decimal &h, uint32_t shift) { + shift &= 63; + const static uint16_t number_of_digits_decimal_left_shift_table[65] = { + 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, + 0x181D, 0x2024, 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067, + 0x3073, 0x3080, 0x388E, 0x389C, 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF, + 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169, 0x5180, 0x5998, 0x59B0, + 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B, 0x72AA, + 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC, + 0x8C02, 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C, + 0x051C, 0x051C, + }; + uint32_t x_a = number_of_digits_decimal_left_shift_table[shift]; + uint32_t x_b = number_of_digits_decimal_left_shift_table[shift + 1]; + uint32_t num_new_digits = x_a >> 11; + uint32_t pow5_a = 0x7FF & x_a; + uint32_t pow5_b = 0x7FF & x_b; + const static uint8_t + number_of_digits_decimal_left_shift_table_powers_of_5[0x051C] = { + 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, + 9, 0, 6, 2, 5, 1, 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, + 1, 2, 5, 2, 4, 4, 1, 4, 0, 6, 2, 5, 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, + 0, 3, 5, 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2, 5, 1, 5, 2, 5, 8, + 7, 8, 9, 0, 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6, + 9, 7, 2, 6, 5, 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, + 3, 6, 7, 4, 3, 1, 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, + 1, 2, 5, 2, 3, 8, 4, 1, 8, 5, 7, 9, 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, + 9, 2, 8, 9, 5, 5, 0, 7, 8, 1, 2, 5, 5, 9, 6, 0, 4, 6, 4, 4, 7, 7, 5, 3, + 9, 0, 6, 2, 5, 2, 9, 8, 0, 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1, + 4, 9, 0, 1, 1, 6, 1, 1, 9, 3, 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, + 0, 5, 9, 6, 9, 2, 3, 8, 2, 8, 1, 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4, + 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6, 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, + 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5, 7, 4, 6, 1, 5, 4, 7, 8, 5, 1, 5, + 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0, 7, 7, 3, 9, 2, 5, 7, 8, 1, 2, + 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6, 9, 6, 2, 8, 9, 0, 6, 2, 5, + 1, 1, 6, 4, 1, 5, 3, 2, 1, 8, 2, 6, 9, 3, 4, 8, 1, 4, 4, 5, 3, 1, 2, 5, + 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4, 6, 7, 4, 0, 7, 2, 2, 6, 5, 6, 2, 5, + 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6, 1, 3, 2, 8, 1, 2, + 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8, 0, 6, 6, 4, 0, + 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9, 0, 3, 3, 2, + 0, 3, 1, 2, 5, 3, 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2, 9, 5, 1, + 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8, 9, 8, 9, 4, 0, 3, 5, 4, 5, 8, 5, 6, + 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4, 7, 0, 1, 7, 7, 2, + 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5, + 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5, 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, + 3, 7, 3, 6, 7, 5, 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, + 6, 2, 5, 1, 1, 3, 6, 8, 6, 8, 3, 7, 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, + 3, 7, 9, 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8, 8, 6, 0, 8, 0, 8, + 0, 1, 4, 8, 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0, + 9, 4, 3, 0, 4, 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, + 5, 1, 4, 2, 1, 0, 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, + 4, 8, 5, 3, 5, 1, 5, 6, 2, 5, 7, 1, 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, + 0, 1, 8, 5, 8, 7, 1, 1, 2, 4, 2, 6, 7, 5, 7, 8, 1, 2, 5, 3, 5, 5, 2, 7, + 1, 3, 6, 7, 8, 8, 0, 0, 5, 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8, + 9, 0, 6, 2, 5, 1, 7, 7, 6, 3, 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, + 6, 7, 7, 8, 1, 0, 6, 6, 8, 9, 4, 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, + 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3, 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, + 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8, 5, 0, 0, 6, 2, 6, 1, 6, 1, 6, 9, + 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2, 5, 2, 2, 2, 0, 4, 4, 6, 0, 4, + 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6, 3, 3, 3, 6, 1, 8, 1, 6, 4, + 0, 6, 2, 5, 1, 1, 1, 0, 2, 2, 3, 0, 2, 4, 6, 2, 5, 1, 5, 6, 5, 4, 0, 4, + 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8, 2, 0, 3, 1, 2, 5, 5, 5, 5, 1, 1, 1, + 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5, 8, 3, 4, 0, 4, 5, + 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5, 6, 2, 8, 9, 1, + 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8, 1, 2, 5, 1, + 3, 8, 7, 7, 7, 8, 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9, 5, 3, 9, + 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0, 6, 2, 5, 6, 9, 3, 8, 8, 9, 3, 9, 0, + 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2, 5, 5, 6, 7, 6, 2, + 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1, + 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, + 1, 7, 3, 4, 7, 2, 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, + 4, 4, 8, 1, 3, 9, 1, 9, 0, 6, 7, 3, 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, + 7, 3, 7, 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2, 2, 4, 0, 6, 9, 5, + 9, 5, 3, 3, 6, 9, 1, 4, 0, 6, 2, 5, + }; + const uint8_t *pow5 = + &number_of_digits_decimal_left_shift_table_powers_of_5[pow5_a]; + uint32_t i = 0; + uint32_t n = pow5_b - pow5_a; + for (; i < n; i++) { + if (i >= h.num_digits) { + return num_new_digits - 1; + } else if (h.digits[i] == pow5[i]) { + continue; + } else if (h.digits[i] < pow5[i]) { + return num_new_digits - 1; + } else { + return num_new_digits; + } + } + return num_new_digits; +} + +uint64_t round(decimal &h) { + if ((h.num_digits == 0) || (h.decimal_point < 0)) { + return 0; + } else if (h.decimal_point > 18) { + return UINT64_MAX; + } + // at this point, we know that h.decimal_point >= 0 + uint32_t dp = uint32_t(h.decimal_point); + uint64_t n = 0; + for (uint32_t i = 0; i < dp; i++) { + n = (10 * n) + ((i < h.num_digits) ? h.digits[i] : 0); + } + bool round_up = false; + if (dp < h.num_digits) { + round_up = h.digits[dp] >= 5; // normally, we round up + // but we may need to round to even! + if ((h.digits[dp] == 5) && (dp + 1 == h.num_digits)) { + round_up = h.truncated || ((dp > 0) && (1 & h.digits[dp - 1])); + } + } + if (round_up) { + n++; + } + return n; +} + +// computes h * 2^-shift +void decimal_left_shift(decimal &h, uint32_t shift) { + if (h.num_digits == 0) { + return; + } + uint32_t num_new_digits = number_of_digits_decimal_left_shift(h, shift); + int32_t read_index = int32_t(h.num_digits - 1); + uint32_t write_index = h.num_digits - 1 + num_new_digits; + uint64_t n = 0; + + while (read_index >= 0) { + n += uint64_t(h.digits[read_index]) << shift; + uint64_t quotient = n / 10; + uint64_t remainder = n - (10 * quotient); + if (write_index < max_digits) { + h.digits[write_index] = uint8_t(remainder); + } else if (remainder > 0) { + h.truncated = true; + } + n = quotient; + write_index--; + read_index--; + } + while (n > 0) { + uint64_t quotient = n / 10; + uint64_t remainder = n - (10 * quotient); + if (write_index < max_digits) { + h.digits[write_index] = uint8_t(remainder); + } else if (remainder > 0) { + h.truncated = true; + } + n = quotient; + write_index--; + } + h.num_digits += num_new_digits; + if (h.num_digits > max_digits) { + h.num_digits = max_digits; + } + h.decimal_point += int32_t(num_new_digits); + trim(h); +} + +// computes h * 2^shift +void decimal_right_shift(decimal &h, uint32_t shift) { + uint32_t read_index = 0; + uint32_t write_index = 0; + + uint64_t n = 0; + + while ((n >> shift) == 0) { + if (read_index < h.num_digits) { + n = (10 * n) + h.digits[read_index++]; + } else if (n == 0) { + return; + } else { + while ((n >> shift) == 0) { + n = 10 * n; + read_index++; + } + break; + } + } + h.decimal_point -= int32_t(read_index - 1); + if (h.decimal_point < -decimal_point_range) { // it is zero + h.num_digits = 0; + h.decimal_point = 0; + h.negative = false; + h.truncated = false; + return; + } + uint64_t mask = (uint64_t(1) << shift) - 1; + while (read_index < h.num_digits) { + uint8_t new_digit = uint8_t(n >> shift); + n = (10 * (n & mask)) + h.digits[read_index++]; + h.digits[write_index++] = new_digit; + } + while (n > 0) { + uint8_t new_digit = uint8_t(n >> shift); + n = 10 * (n & mask); + if (write_index < max_digits) { + h.digits[write_index++] = new_digit; + } else if (new_digit > 0) { + h.truncated = true; + } + } + h.num_digits = write_index; + trim(h); +} + +} // end of anonymous namespace + +template +adjusted_mantissa compute_float(decimal &d) { + adjusted_mantissa answer; + if (d.num_digits == 0) { + // should be zero + answer.power2 = 0; + answer.mantissa = 0; + return answer; + } + // At this point, going further, we can assume that d.num_digits > 0. + // + // We want to guard against excessive decimal point values because + // they can result in long running times. Indeed, we do + // shifts by at most 60 bits. We have that log(10**400)/log(2**60) ~= 22 + // which is fine, but log(10**299995)/log(2**60) ~= 16609 which is not + // fine (runs for a long time). + // + if(d.decimal_point < -324) { + // We have something smaller than 1e-324 which is always zero + // in binary64 and binary32. + // It should be zero. + answer.power2 = 0; + answer.mantissa = 0; + return answer; + } else if(d.decimal_point >= 310) { + // We have something at least as large as 0.1e310 which is + // always infinite. + answer.power2 = binary::infinite_power(); + answer.mantissa = 0; + return answer; + } + static const uint32_t max_shift = 60; + static const uint32_t num_powers = 19; + static const uint8_t powers[19] = { + 0, 3, 6, 9, 13, 16, 19, 23, 26, 29, // + 33, 36, 39, 43, 46, 49, 53, 56, 59, // + }; + int32_t exp2 = 0; + while (d.decimal_point > 0) { + uint32_t n = uint32_t(d.decimal_point); + uint32_t shift = (n < num_powers) ? powers[n] : max_shift; + decimal_right_shift(d, shift); + if (d.decimal_point < -decimal_point_range) { + // should be zero + answer.power2 = 0; + answer.mantissa = 0; + return answer; + } + exp2 += int32_t(shift); + } + // We shift left toward [1/2 ... 1]. + while (d.decimal_point <= 0) { + uint32_t shift; + if (d.decimal_point == 0) { + if (d.digits[0] >= 5) { + break; + } + shift = (d.digits[0] < 2) ? 2 : 1; + } else { + uint32_t n = uint32_t(-d.decimal_point); + shift = (n < num_powers) ? powers[n] : max_shift; + } + decimal_left_shift(d, shift); + if (d.decimal_point > decimal_point_range) { + // we want to get infinity: + answer.power2 = binary::infinite_power(); + answer.mantissa = 0; + return answer; + } + exp2 -= int32_t(shift); + } + // We are now in the range [1/2 ... 1] but the binary format uses [1 ... 2]. + exp2--; + constexpr int32_t minimum_exponent = binary::minimum_exponent(); + while ((minimum_exponent + 1) > exp2) { + uint32_t n = uint32_t((minimum_exponent + 1) - exp2); + if (n > max_shift) { + n = max_shift; + } + decimal_right_shift(d, n); + exp2 += int32_t(n); + } + if ((exp2 - minimum_exponent) >= binary::infinite_power()) { + answer.power2 = binary::infinite_power(); + answer.mantissa = 0; + return answer; + } + + const int mantissa_size_in_bits = binary::mantissa_explicit_bits() + 1; + decimal_left_shift(d, mantissa_size_in_bits); + + uint64_t mantissa = round(d); + // It is possible that we have an overflow, in which case we need + // to shift back. + if(mantissa >= (uint64_t(1) << mantissa_size_in_bits)) { + decimal_right_shift(d, 1); + exp2 += 1; + mantissa = round(d); + if ((exp2 - minimum_exponent) >= binary::infinite_power()) { + answer.power2 = binary::infinite_power(); + answer.mantissa = 0; + return answer; + } + } + answer.power2 = exp2 - binary::minimum_exponent(); + if(mantissa < (uint64_t(1) << binary::mantissa_explicit_bits())) { answer.power2--; } + answer.mantissa = mantissa & ((uint64_t(1) << binary::mantissa_explicit_bits()) - 1); + return answer; +} + +template +adjusted_mantissa parse_long_mantissa(const char *first, const char* last) { + decimal d = parse_decimal(first, last); + return compute_float(d); +} + +} // namespace fast_float +#endif diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@simple_decimal_conversion.h.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@simple_decimal_conversion.h.blob new file mode 100644 index 0000000..e87de7a Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@fast_float@simple_decimal_conversion.h.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@common.hpp b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@common.hpp new file mode 100644 index 0000000..0398a96 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@common.hpp @@ -0,0 +1,76 @@ +#pragma once +#include + +namespace ss { + +struct none {}; + +using string_range = std::pair; +using split_data = std::vector; + +constexpr inline auto default_delimiter = ","; + +template +inline void assert_string_error_defined() { + static_assert(StringError, + "'string_error' needs to be enabled to use 'error_msg'"); +} + +#if defined(_WIN64) || defined(_WIN32) +#include +using ssize_t = int64_t; +inline ssize_t get_line(char** lineptr, size_t* n, FILE* stream) { + size_t pos; + int c; + + if (lineptr == nullptr || stream == nullptr || n == nullptr) { + errno = EINVAL; + return -1; + } + + c = getc(stream); + if (c == EOF) { + return -1; + } + + if (*lineptr == nullptr) { + *lineptr = static_cast(malloc(128)); + if (*lineptr == nullptr) { + return -1; + } + *n = 128; + } + + pos = 0; + while (c != EOF) { + if (pos + 1 >= *n) { + size_t new_size = *n + (*n >> 2); + if (new_size < 128) { + new_size = 128; + } + char* new_ptr = static_cast( + realloc(static_cast(*lineptr), new_size)); + if (new_ptr == nullptr) { + return -1; + } + *n = new_size; + *lineptr = new_ptr; + } + + (*lineptr)[pos++] = c; + if (c == '\n') { + break; + } + c = getc(stream); + } + + (*lineptr)[pos] = '\0'; + return pos; +} +#else +inline ssize_t get_line(char** lineptr, size_t* n, FILE* stream) { + return getline(lineptr, n, stream); +} +#endif + +} /* ss */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@common.hpp.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@common.hpp.blob new file mode 100644 index 0000000..827c451 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@common.hpp.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@converter.hpp b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@converter.hpp new file mode 100644 index 0000000..b66002b --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@converter.hpp @@ -0,0 +1,384 @@ +#pragma once +#include "extract.hpp" +#include "function_traits.hpp" +#include "restrictions.hpp" +#include "splitter.hpp" +#include "type_traits.hpp" +#include +#include +#include + +namespace ss { +INIT_HAS_METHOD(tied) +INIT_HAS_METHOD(ss_valid) +INIT_HAS_METHOD(error) + +//////////////// +// replace validator +//////////////// + +// replace 'validator' types with elements they operate on +// eg. no_validator_tup_t> <=> std::tuple +// where ss::nx is a validator '(n)one e(x)cept' which +// checks if the returned character is either 'A' or 'B', returns error if not +// additionally if one element is left in the pack, it will be unwrapped from +// the tuple eg. no_void_validator_tup_t <=> int instead of std::tuple +template +struct no_validator; + +template +struct no_validator>> { + using type = typename member_wrapper::arg_type; +}; + +template +struct no_validator { + using type = T; +}; + +template +using no_validator_t = typename no_validator::type; + +template +struct no_validator_tup : apply_trait> {}; + +template +struct no_validator_tup> : no_validator_tup {}; + +template +struct no_validator_tup> : no_validator {}; + +template +using no_validator_tup_t = typename no_validator_tup::type; + +//////////////// +// no void tuple +//////////////// + +template +struct no_void_tup : filter_not> {}; + +template +using no_void_tup_t = filter_not_t; + +//////////////// +// no void or validator +//////////////// + +// replace 'validators' and remove void from tuple +template +struct no_void_validator_tup : no_validator_tup> {}; + +template +struct no_void_validator_tup> + : no_validator_tup> {}; + +template +using no_void_validator_tup_t = typename no_void_validator_tup::type; + +//////////////// +// tied class +//////////////// + +// check if the parameter pack is only one element which is a class and has +// the 'tied' method which is to be used for type deduction when converting +template +struct tied_class { + constexpr static bool value = + (sizeof...(Ts) == 0 && std::is_class_v && has_m_tied::value); +}; + +template +constexpr bool tied_class_v = tied_class::value; + +//////////////// +// converter +//////////////// + +template +class converter { + using line_ptr_type = typename splitter::line_ptr_type; + + constexpr static auto string_error = setup::string_error; + constexpr static auto default_delimiter = ","; + + using error_type = ss::ternary_t; + +public: + // parses line with given delimiter, returns a 'T' object created with + // extracted values of type 'Ts' + template + T convert_object(line_ptr_type line, + const std::string& delim = default_delimiter) { + return to_object(convert(line, delim)); + } + + // parses line with given delimiter, returns tuple of objects with + // extracted values of type 'Ts' + template + no_void_validator_tup_t convert( + line_ptr_type line, const std::string& delim = default_delimiter) { + split(line, delim); + return convert(splitter_.split_data_); + } + + // parses already split line, returns 'T' object with extracted values + template + T convert_object(const split_data& elems) { + return to_object(convert(elems)); + } + + // same as above, but uses cached split line + template + T convert_object() { + return to_object(convert()); + } + + // parses already split line, returns either a tuple of objects with + // parsed values (returns raw element (no tuple) if Ts is empty), or if + // one argument is given which is a class which has a tied + // method which returns a tuple, returns that type + template + no_void_validator_tup_t convert(const split_data& elems) { + if constexpr (sizeof...(Ts) == 0 && is_instance_of_v) { + return convert_impl(elems, static_cast(nullptr)); + } else if constexpr (tied_class_v) { + using arg_ref_tuple = std::result_of_t; + using arg_tuple = apply_trait_t; + + return to_object( + convert_impl(elems, static_cast(nullptr))); + } else { + return convert_impl(elems); + } + } + + // same as above, but uses cached split line + template + no_void_validator_tup_t convert() { + return convert(splitter_.split_data_); + } + + bool valid() const { + if constexpr (string_error) { + return error_.empty(); + } else { + return !error_; + } + } + + const std::string& error_msg() const { + assert_string_error_defined(); + return error_; + } + + bool unterminated_quote() const { + return splitter_.unterminated_quote(); + } + + // 'splits' string by given delimiter, returns vector of pairs which + // contain the beginnings and the ends of each column of the string + const split_data& split(line_ptr_type line, + const std::string& delim = default_delimiter) { + splitter_.split_data_.clear(); + if (line[0] == '\0') { + return splitter_.split_data_; + } + + return splitter_.split(line, delim); + } + +private: + //////////////// + // resplit + //////////////// + + const split_data& resplit(line_ptr_type new_line, ssize_t new_size, + const std::string& delim = default_delimiter) { + return splitter_.resplit(new_line, new_size, delim); + } + + size_t size_shifted() { + return splitter_.size_shifted(); + } + + //////////////// + // error + //////////////// + + void clear_error() { + if constexpr (string_error) { + error_.clear(); + } else { + error_ = false; + } + } + + std::string error_sufix(const string_range msg, size_t pos) const { + std::string error; + error.reserve(32); + error.append("at column ") + .append(std::to_string(pos + 1)) + .append(": \'") + .append(msg.first, msg.second) + .append("\'"); + return error; + } + + void set_error_unterminated_quote() { + if constexpr (string_error) { + error_.clear(); + error_.append(splitter_.error_msg()); + } else { + error_ = true; + } + } + + void set_error_multiline_limit_reached() { + if constexpr (string_error) { + error_.clear(); + error_.append("multiline limit reached."); + } else { + error_ = true; + } + } + + void set_error_invalid_conversion(const string_range msg, size_t pos) { + if constexpr (string_error) { + error_.clear(); + error_.append("invalid conversion for parameter ") + .append(error_sufix(msg, pos)); + } else { + error_ = true; + } + } + + void set_error_validate(const char* const error, const string_range msg, + size_t pos) { + if constexpr (string_error) { + error_.clear(); + error_.append(error).append(" ").append(error_sufix(msg, pos)); + } else { + error_ = true; + } + } + + void set_error_number_of_colums(size_t expected_pos, size_t pos) { + if constexpr (string_error) { + error_.clear(); + error_.append("invalid number of columns, expected: ") + .append(std::to_string(expected_pos)) + .append(", got: ") + .append(std::to_string(pos)); + } else { + error_ = true; + } + } + + //////////////// + // convert implementation + //////////////// + + template + no_void_validator_tup_t convert_impl(const split_data& elems) { + clear_error(); + + if (!splitter_.valid()) { + set_error_unterminated_quote(); + no_void_validator_tup_t ret{}; + return ret; + } + + if (sizeof...(Ts) != elems.size()) { + set_error_number_of_colums(sizeof...(Ts), elems.size()); + no_void_validator_tup_t ret{}; + return ret; + } + + return extract_tuple(elems); + } + + // do not know how to specialize by return type :( + template + no_void_validator_tup_t> convert_impl( + const split_data& elems, const std::tuple*) { + return convert_impl(elems); + } + + //////////////// + // conversion + //////////////// + + template + void extract_one(no_validator_t& dst, const string_range msg, + size_t pos) { + if (!valid()) { + return; + } + + if constexpr (std::is_same_v) { + extract(msg.first, msg.second, dst); + return; + } + + if (!extract(msg.first, msg.second, dst)) { + set_error_invalid_conversion(msg, pos); + return; + } + + if constexpr (has_m_ss_valid_t) { + if (T validator; !validator.ss_valid(dst)) { + if constexpr (has_m_error_t) { + set_error_validate(validator.error(), msg, pos); + } else { + set_error_validate("validation error", msg, pos); + } + return; + } + } + } + + template + void extract_multiple(no_void_validator_tup_t& tup, + const split_data& elems) { + using elem_t = std::tuple_element_t>; + + constexpr bool not_void = !std::is_void_v; + constexpr bool one_element = count_not_v == 1; + + if constexpr (not_void) { + if constexpr (one_element) { + extract_one(tup, elems[ArgN], ArgN); + } else { + auto& el = std::get(tup); + extract_one(el, elems[ArgN], ArgN); + } + } + + if constexpr (sizeof...(Ts) > ArgN + 1) { + constexpr size_t NewTupN = (not_void) ? TupN + 1 : TupN; + extract_multiple(tup, elems); + } + } + + template + no_void_validator_tup_t extract_tuple(const split_data& elems) { + static_assert(!all_of_v, + "at least one parameter must be non void"); + no_void_validator_tup_t ret{}; + extract_multiple<0, 0, Ts...>(ret, elems); + return ret; + } + + //////////////// + // members + //////////////// + + error_type error_{}; + splitter splitter_; + + template + friend class parser; +}; + +} /* ss */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@converter.hpp.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@converter.hpp.blob new file mode 100644 index 0000000..3013912 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@converter.hpp.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@extract.hpp b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@extract.hpp new file mode 100644 index 0000000..ebf7ef8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@extract.hpp @@ -0,0 +1,319 @@ +#pragma once + +#include "type_traits.hpp" +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ss { + +//////////////// +// number converters +//////////////// + +template +std::enable_if_t, std::optional> to_num( + const char* begin, const char* const end) { + T ret; + auto answer = fast_float::from_chars(begin, end, ret); + + if (answer.ec != std::errc() || answer.ptr != end) { + return std::nullopt; + } + return ret; +} + +inline std::optional from_char(char c) { + if (c >= '0' && c <= '9') { + return c - '0'; + } + return std::nullopt; +} + +#if defined(__clang__) || defined(__GNUC__) || defined(__GUNG__) +//////////////// +// mul overflow detection +//////////////// +template +bool mul_overflow(T& result, T operand) { + return __builtin_mul_overflow(result, operand, &result); +} + +template <> +inline bool mul_overflow(int& result, int operand) { + return __builtin_smul_overflow(result, operand, &result); +} + +template <> +inline bool mul_overflow(long& result, long operand) { + return __builtin_smull_overflow(result, operand, &result); +} + +template <> +inline bool mul_overflow(long long& result, long long operand) { + return __builtin_smulll_overflow(result, operand, &result); +} + +template <> +inline bool mul_overflow(unsigned int& result, unsigned int operand) { + return __builtin_umul_overflow(result, operand, &result); +} + +template <> +inline bool mul_overflow(unsigned long& result, unsigned long operand) { + return __builtin_umull_overflow(result, operand, &result); +} + +template <> +inline bool mul_overflow(unsigned long long& result, + unsigned long long operand) { + return __builtin_umulll_overflow(result, operand, &result); +} + +//////////////// +// addition overflow detection +//////////////// + +template +inline bool add_overflow(T& result, T operand) { + return __builtin_add_overflow(result, operand, &result); +} + +template <> +inline bool add_overflow(int& result, int operand) { + return __builtin_sadd_overflow(result, operand, &result); +} + +template <> +inline bool add_overflow(long& result, long operand) { + return __builtin_saddl_overflow(result, operand, &result); +} + +template <> +inline bool add_overflow(long long& result, long long operand) { + return __builtin_saddll_overflow(result, operand, &result); +} + +template <> +inline bool add_overflow(unsigned int& result, unsigned int operand) { + return __builtin_uadd_overflow(result, operand, &result); +} + +template <> +inline bool add_overflow(unsigned long& result, unsigned long operand) { + return __builtin_uaddl_overflow(result, operand, &result); +} + +template <> +inline bool add_overflow(unsigned long long& result, + unsigned long long operand) { + return __builtin_uaddll_overflow(result, operand, &result); +} + +//////////////// +// substraction overflow detection +//////////////// +template +inline bool sub_overflow(T& result, T operand) { + return __builtin_sub_overflow(result, operand, &result); +} + +template <> +inline bool sub_overflow(int& result, int operand) { + return __builtin_ssub_overflow(result, operand, &result); +} + +template <> +inline bool sub_overflow(long& result, long operand) { + return __builtin_ssubl_overflow(result, operand, &result); +} + +template <> +inline bool sub_overflow(long long& result, long long operand) { + return __builtin_ssubll_overflow(result, operand, &result); +} + +template <> +inline bool sub_overflow(unsigned int& result, unsigned int operand) { + return __builtin_usub_overflow(result, operand, &result); +} + +template <> +inline bool sub_overflow(unsigned long& result, unsigned long operand) { + return __builtin_usubl_overflow(result, operand, &result); +} + +template <> +inline bool sub_overflow(unsigned long long& result, + unsigned long long operand) { + return __builtin_usubll_overflow(result, operand, &result); +} + +template +bool shift_and_add_overflow(T& value, T digit, F add_last_digit_owerflow) { + if (mul_overflow(value, 10) || add_last_digit_owerflow(value, digit)) { + return true; + } + return false; +} +#else + +#warning "Use clang or gcc if possible." +template +bool shift_and_add_overflow(T& value, T digit, U is_negative) { + digit = (is_negative) ? -digit : digit; + T old_value = value; + value = 10 * value + digit; + + T expected_old_value = (value - digit) / 10; + if (old_value != expected_old_value) { + return true; + } + return false; +} + +#endif + +template +std::enable_if_t, std::optional> to_num( + const char* begin, const char* end) { + if (begin == end) { + return std::nullopt; + } + bool is_negative = false; + if constexpr (std::is_signed_v) { + is_negative = *begin == '-'; + if (is_negative) { + ++begin; + } + } + +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + auto add_last_digit_owerflow = + (is_negative) ? sub_overflow : add_overflow; +#else + auto add_last_digit_owerflow = is_negative; +#endif + + T value = 0; + for (auto i = begin; i != end; ++i) { + if (auto digit = from_char(*i); + !digit || shift_and_add_overflow(value, digit.value(), + add_last_digit_owerflow)) { + return std::nullopt; + } + } + + return value; +} + +//////////////// +// extract +//////////////// + +namespace error { +template +struct unsupported_type { + constexpr static bool value = false; +}; +} /* namespace */ + +template +std::enable_if_t && !std::is_floating_point_v && + !is_instance_of_v && + !is_instance_of_v, + bool> +extract(const char*, const char*, T&) { + static_assert(error::unsupported_type::value, + "Conversion for given type is not defined, an " + "\'extract\' function needs to be defined!"); +} + +template +std::enable_if_t || std::is_floating_point_v, bool> +extract(const char* begin, const char* end, T& value) { + auto optional_value = to_num(begin, end); + if (!optional_value) { + return false; + } + value = optional_value.value(); + return true; +} + +template +std::enable_if_t, bool> extract( + const char* begin, const char* end, T& value) { + typename T::value_type raw_value; + if (extract(begin, end, raw_value)) { + value = raw_value; + } else { + value = std::nullopt; + } + return true; +} + +template +bool extract_variant(const char* begin, const char* end, T& value) { + using IthType = std::variant_alternative_t>; + IthType ithValue; + if (extract(begin, end, ithValue)) { + value = ithValue; + return true; + } else if constexpr (I + 1 < std::variant_size_v) { + return extract_variant(begin, end, value); + } + return false; +} + +template +std::enable_if_t, bool> extract( + const char* begin, const char* end, T& value) { + return extract_variant(begin, end, value); +} + +//////////////// +// extract specialization +//////////////// + +template <> +inline bool extract(const char* begin, const char* end, bool& value) { + if (end == begin + 1) { + if (*begin == '1') { + value = true; + } else if (*begin == '0') { + value = false; + } else { + return false; + } + } else { + size_t size = end - begin; + if (size == 4 && strncmp(begin, "true", size) == 0) { + value = true; + } else if (size == 5 && strncmp(begin, "false", size) == 0) { + value = false; + } else { + return false; + } + } + + return true; +} + +template <> +inline bool extract(const char* begin, const char* end, char& value) { + value = *begin; + return (end == begin + 1); +} + +template <> +inline bool extract(const char* begin, const char* end, std::string& value) { + value = std::string(begin, end); + return true; +} + +} /* ss */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@extract.hpp.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@extract.hpp.blob new file mode 100644 index 0000000..c18e679 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@extract.hpp.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@function_traits.hpp b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@function_traits.hpp new file mode 100644 index 0000000..c22a936 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@function_traits.hpp @@ -0,0 +1,80 @@ +#pragma once + +#include +#include +#include + +namespace ss { + +//////////////// +// function traits +//////////////// + +template +struct decayed_arg_n { + static_assert(N - 1 != sizeof...(Ts), "index out of range"); + using type = typename decayed_arg_n::type; +}; + +template +struct decayed_arg_n<0, T, Ts...> { + using type = std::decay_t; +}; + +template +struct function_traits; + +template +struct function_traits> { + using arg_type = Arg; +}; + +template +struct function_traits { + using arg0 = typename decayed_arg_n<0, Ts...>::type; +}; + +template +struct function_traits : function_traits {}; + +template +struct function_traits : function_traits {}; + +template +struct function_traits : function_traits {}; + +template +struct function_traits : function_traits {}; + +template +struct function_traits : function_traits {}; + +template +struct member_wrapper; + +template +struct member_wrapper { + using arg_type = typename function_traits::arg0; +}; + +//////////////// +// has method +//////////////// + +#define INIT_HAS_METHOD(method) \ + template \ + class has_m_##method { \ + template \ + static std::true_type test(decltype(&C::method)); \ + \ + template \ + static std::false_type test(...); \ + \ + public: \ + constexpr static bool value = decltype(test(0))::value; \ + }; \ + \ + template \ + constexpr bool has_m_##method##_t = has_m_##method::value; + +} /* trait */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@function_traits.hpp.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@function_traits.hpp.blob new file mode 100644 index 0000000..15421c9 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@function_traits.hpp.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@parser.hpp b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@parser.hpp new file mode 100644 index 0000000..86f4e92 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@parser.hpp @@ -0,0 +1,546 @@ +#pragma once + +#include "common.hpp" +#include "converter.hpp" +#include "extract.hpp" +#include "restrictions.hpp" +#include +#include +#include +#include +#include + +namespace ss { + +template +class parser { + constexpr static auto string_error = setup::string_error; + + using multiline = typename setup::multiline; + using error_type = ss::ternary_t; + + constexpr static bool escaped_multiline_enabled = + multiline::enabled && setup::escape::enabled; + + constexpr static bool quoted_multiline_enabled = + multiline::enabled && setup::quote::enabled; + +public: + parser(const std::string& file_name, + const std::string& delim = ss::default_delimiter) + : file_name_{file_name}, reader_{file_name_, delim} { + if (reader_.file_) { + read_line(); + } else { + set_error_file_not_open(); + eof_ = true; + } + } + + parser(parser&& other) = default; + parser& operator=(parser&& other) = default; + + parser() = delete; + parser(const parser& other) = delete; + parser& operator=(const parser& other) = delete; + + bool valid() const { + if constexpr (string_error) { + return error_.empty(); + } else { + return !error_; + } + } + + const std::string& error_msg() const { + assert_string_error_defined(); + return error_; + } + + bool eof() const { + return eof_; + } + + bool ignore_next() { + return reader_.read_next(); + } + + template + T get_object() { + return to_object(get_next()); + } + + template + no_void_validator_tup_t get_next() { + reader_.update(); + clear_error(); + if (eof_) { + set_error_eof_reached(); + return {}; + } + + auto value = reader_.converter_.template convert(); + + if (!reader_.converter_.valid()) { + set_error_invalid_conversion(); + } + + read_line(); + return value; + } + + //////////////// + // composite conversion + //////////////// + template + class composite { + public: + composite(std::tuple&& values, parser& parser) + : values_{std::move(values)}, parser_{parser} { + } + + // tries to convert the same line with a different output type + // only if the previous conversion was not successful, + // returns composite containing itself and the new output + // as optional, additionally, if a parameter is passed, and + // that parameter can be invoked using the converted value, + // than it will be invoked in the case of a valid conversion + template + composite>> or_else( + Fun&& fun = none{}) { + using Value = no_void_validator_tup_t; + std::optional value; + try_convert_and_invoke(value, fun); + return composite_with(std::move(value)); + } + + // same as or_else, but saves the result into a 'U' object + // instead of a tuple + template + composite> or_object(Fun&& fun = none{}) { + std::optional value; + try_convert_and_invoke(value, fun); + return composite_with(std::move(value)); + } + + std::tuple values() { + return values_; + } + + template + auto on_error(Fun&& fun) { + if (!parser_.valid()) { + if constexpr (std::is_invocable_v) { + fun(); + } else { + static_assert(string_error, + "to enable error messages within the " + "on_error method " + "callback string_error needs to be enabled"); + std::invoke(std::forward(fun), parser_.error_msg()); + } + } + return *this; + } + + private: + template + composite composite_with(T&& new_value) { + auto merged_values = + std::tuple_cat(std::move(values_), + std::tuple{parser_.valid() + ? std::forward(new_value) + : std::nullopt}); + return {std::move(merged_values), parser_}; + } + + template + void try_convert_and_invoke(std::optional& value, Fun&& fun) { + if (!parser_.valid()) { + auto tuple_output = try_same(); + if (!parser_.valid()) { + return; + } + + if constexpr (!std::is_same_v) { + value = to_object(std::move(tuple_output)); + } else { + value = std::move(tuple_output); + } + + parser_.try_invoke(*value, std::forward(fun)); + } + } + + template + no_void_validator_tup_t try_same() { + parser_.clear_error(); + auto value = + parser_.reader_.converter_.template convert(); + if (!parser_.reader_.converter_.valid()) { + parser_.set_error_invalid_conversion(); + } + return value; + } + + //////////////// + // members + //////////////// + + std::tuple values_; + parser& parser_; + }; + + // tries to convert a line and returns a composite which is + // able to try additional conversions in case of failure + template + composite>> try_next( + Fun&& fun = none{}) { + using Ret = no_void_validator_tup_t; + return try_invoke_and_make_composite< + std::optional>(get_next(), std::forward(fun)); + } + + // identical to try_next but returns composite with object instead of a + // tuple + template + composite> try_object(Fun&& fun = none{}) { + return try_invoke_and_make_composite< + std::optional>(get_object(), std::forward(fun)); + } + +private: + // tries to invoke the given function (see below), if the function + // returns a value which can be used as a conditional, and it returns + // false, the function sets an error, and allows the invoke of the + // next possible conversion as if the validation of the current one + // failed + template + void try_invoke(Arg&& arg, Fun&& fun) { + constexpr bool is_none = std::is_same_v, none>; + if constexpr (!is_none) { + using Ret = decltype(try_invoke_impl(arg, std::forward(fun))); + constexpr bool returns_void = std::is_same_v; + if constexpr (!returns_void) { + if (!try_invoke_impl(arg, std::forward(fun))) { + set_error_failed_check(); + } + } else { + try_invoke_impl(arg, std::forward(fun)); + } + } + } + + // tries to invoke the function if not none + // it first tries to invoke the function without arguments, + // than with one argument if the function accepts the whole tuple + // as an argument, and finally tries to invoke it with the tuple + // laid out as a parameter pack + template + auto try_invoke_impl(Arg&& arg, Fun&& fun) { + constexpr bool is_none = std::is_same_v, none>; + if constexpr (!is_none) { + if constexpr (std::is_invocable_v) { + return fun(); + } else if constexpr (std::is_invocable_v) { + return std::invoke(std::forward(fun), + std::forward(arg)); + } else { + return std::apply(std::forward(fun), + std::forward(arg)); + } + } + } + + template + composite try_invoke_and_make_composite(T&& value, Fun&& fun) { + if (valid()) { + try_invoke(*value, std::forward(fun)); + } + return {valid() ? std::move(value) : std::nullopt, *this}; + } + + //////////////// + // error + //////////////// + + void clear_error() { + if constexpr (string_error) { + error_.clear(); + } else { + error_ = false; + } + } + + void set_error_failed_check() { + if constexpr (string_error) { + error_.append(file_name_).append(" failed check."); + } else { + error_ = true; + } + } + + void set_error_file_not_open() { + if constexpr (string_error) { + error_.append(file_name_).append(" could not be opened."); + } else { + error_ = true; + } + } + + void set_error_eof_reached() { + if constexpr (string_error) { + error_.append(file_name_).append(" reached end of file."); + } else { + error_ = true; + } + } + + void set_error_invalid_conversion() { + if constexpr (string_error) { + error_.append(file_name_) + .append(" ") + .append(std::to_string(line_number_)) + .append(": ") + .append(reader_.converter_.error_msg()) + .append(": \"") + .append(reader_.buffer_) + .append("\""); + } else { + error_ = true; + } + } + + //////////////// + // line reading + //////////////// + + void read_line() { + eof_ = !reader_.read_next(); + ++line_number_; + } + + struct reader { + reader(const std::string& file_name_, const std::string& delim) + : delim_{delim}, file_{fopen(file_name_.c_str(), "rb")} { + } + + reader(reader&& other) + : buffer_{other.buffer_}, + next_line_buffer_{other.next_line_buffer_}, + helper_buffer_{other.helper_buffer_}, converter_{std::move( + other.converter_)}, + next_line_converter_{std::move(other.next_line_converter_)}, + size_{other.size_}, next_line_size_{other.size_}, + helper_size_{other.helper_size_}, delim_{std::move(other.delim_)}, + file_{other.file_}, crlf_{other.crlf_} { + other.buffer_ = nullptr; + other.next_line_buffer_ = nullptr; + other.helper_buffer_ = nullptr; + other.file_ = nullptr; + } + + reader& operator=(reader&& other) { + if (this != &other) { + buffer_ = other.buffer_; + next_line_buffer_ = other.next_line_buffer_; + helper_buffer_ = other.helper_buffer_; + converter_ = std::move(other.converter_); + next_line_converter_ = std::move(other.next_line_converter_); + size_ = other.size_; + next_line_size_ = other.next_line_size_; + helper_size_ = other.helper_size_; + delim_ = std::move(other.delim_); + file_ = other.file_; + crlf_ = other.crlf_; + + other.buffer_ = nullptr; + other.next_line_buffer_ = nullptr; + other.helper_buffer_ = nullptr; + other.file_ = nullptr; + } + + return *this; + } + + ~reader() { + free(buffer_); + free(next_line_buffer_); + free(helper_buffer_); + + if (file_) { + fclose(file_); + } + } + + reader() = delete; + reader(const reader& other) = delete; + reader& operator=(const reader& other) = delete; + + bool read_next() { + memset(next_line_buffer_, '\0', next_line_size_); + ssize_t ssize = + get_line(&next_line_buffer_, &next_line_size_, file_); + + if (ssize == -1) { + return false; + } + + size_t size = remove_eol(next_line_buffer_, ssize); + size_t limit = 0; + + if constexpr (escaped_multiline_enabled) { + while (escaped_eol(size)) { + if (multiline_limit_reached(limit)) { + return true; + } + if (!append_next_line_to_buffer(next_line_buffer_, size)) { + return false; + } + } + } + + next_line_converter_.split(next_line_buffer_, delim_); + + if constexpr (quoted_multiline_enabled) { + while (unterminated_quote()) { + if (multiline_limit_reached(limit)) { + return true; + } + if (!append_next_line_to_buffer(next_line_buffer_, size)) { + return false; + } + + if constexpr (escaped_multiline_enabled) { + while (escaped_eol(size)) { + if (multiline_limit_reached(limit)) { + return true; + } + if (!append_next_line_to_buffer(next_line_buffer_, + size)) { + return false; + } + } + } + + next_line_converter_.resplit(next_line_buffer_, size); + } + } + + return true; + } + + void update() { + std::swap(buffer_, next_line_buffer_); + std::swap(size_, next_line_size_); + std::swap(converter_, next_line_converter_); + } + + bool multiline_limit_reached(size_t& limit) { + if constexpr (multiline::size > 0) { + if (limit++ >= multiline::size) { + next_line_converter_.set_error_multiline_limit_reached(); + return true; + } + } + return false; + } + + bool escaped_eol(size_t size) { + const char* curr; + for (curr = next_line_buffer_ + size - 1; + curr >= next_line_buffer_ && + setup::escape::match(*curr); + --curr) { + } + return (next_line_buffer_ - curr + size) % 2 == 0; + } + + bool unterminated_quote() { + if (next_line_converter_.unterminated_quote()) { + return true; + } + return false; + } + + void undo_remove_eol(char* buffer, size_t& string_end) { + if (next_line_converter_.unterminated_quote()) { + string_end -= next_line_converter_.size_shifted(); + } + if (crlf_) { + std::copy_n("\r\n\0", 3, buffer + string_end); + string_end += 2; + } else { + std::copy_n("\n\0", 2, buffer + string_end); + string_end += 1; + } + } + + size_t remove_eol(char*& buffer, size_t size) { + size_t new_size = size - 1; + if (size >= 2 && buffer[size - 2] == '\r') { + crlf_ = true; + new_size--; + } else { + crlf_ = false; + } + + buffer[new_size] = '\0'; + return new_size; + } + + void realloc_concat(char*& first, size_t& first_size, + const char* const second, size_t second_size) { + next_line_size_ = first_size + second_size + 2; + first = static_cast( + realloc(static_cast(first), next_line_size_)); + std::copy_n(second, second_size + 1, first + first_size); + first_size += second_size; + } + + bool append_next_line_to_buffer(char*& buffer, size_t& size) { + undo_remove_eol(buffer, size); + + ssize_t next_ssize = + get_line(&helper_buffer_, &helper_size_, file_); + if (next_ssize == -1) { + return false; + } + + size_t next_size = remove_eol(helper_buffer_, next_ssize); + realloc_concat(buffer, size, helper_buffer_, next_size); + return true; + } + + //////////////// + // members + //////////////// + char* buffer_{nullptr}; + char* next_line_buffer_{nullptr}; + char* helper_buffer_{nullptr}; + + converter converter_; + converter next_line_converter_; + + size_t size_{0}; + size_t next_line_size_{0}; + size_t helper_size_{0}; + + std::string delim_; + FILE* file_{nullptr}; + + bool crlf_; + }; + + //////////////// + // members + //////////////// + + std::string file_name_; + error_type error_{}; + reader reader_; + size_t line_number_{0}; + bool eof_{false}; +}; + +} /* ss */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@parser.hpp.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@parser.hpp.blob new file mode 100644 index 0000000..3f27526 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@parser.hpp.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@restrictions.hpp b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@restrictions.hpp new file mode 100644 index 0000000..e72611e --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@restrictions.hpp @@ -0,0 +1,127 @@ +#pragma once + +namespace ss { + +//////////////// +// all except +//////////////// + +template +struct ax { +private: + template + bool ss_valid_impl(const T& x) const { + if constexpr (sizeof...(Xs) != 0) { + return x != X && ss_valid_impl(x); + } + return x != X; + } + +public: + bool ss_valid(const T& value) const { + return ss_valid_impl(value); + } + + const char* error() const { + return "value excluded"; + } +}; + +//////////////// +// none except +//////////////// + +template +struct nx { +private: + template + bool ss_valid_impl(const T& x) const { + if constexpr (sizeof...(Xs) != 0) { + return x == X || ss_valid_impl(x); + } + return x == X; + } + +public: + bool ss_valid(const T& value) const { + return ss_valid_impl(value); + } + + const char* error() const { + return "value excluded"; + } +}; + +//////////////// +// greater than or equal to +// greater than +// less than +// less than or equal to +//////////////// + +template +struct gt { + bool ss_valid(const T& value) const { + return value > N; + } +}; + +template +struct gte { + bool ss_valid(const T& value) const { + return value >= N; + } +}; + +template +struct lt { + bool ss_valid(const T& value) const { + return value < N; + } +}; + +template +struct lte { + bool ss_valid(const T& value) const { + return value <= N; + } +}; + +//////////////// +// in range +//////////////// + +template +struct ir { + bool ss_valid(const T& value) const { + return value >= Min && value <= Max; + } +}; + +//////////////// +// out of range +//////////////// + +template +struct oor { + bool ss_valid(const T& value) const { + return value < Min || value > Max; + } +}; + +//////////////// +// non empty +//////////////// + +template +struct ne { + bool ss_valid(const T& value) const { + return !value.empty(); + } + + const char* error() const { + return "empty field"; + } +}; + +} /* ss */ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@restrictions.hpp.blob b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@restrictions.hpp.blob new file mode 100644 index 0000000..fa57036 Binary files /dev/null and b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@restrictions.hpp.blob differ diff --git a/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@setup.hpp b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@setup.hpp new file mode 100644 index 0000000..8f26eb8 --- /dev/null +++ b/.ccls-cache/@@home@ado@git@ssp/@usr@local@include@ss@setup.hpp @@ -0,0 +1,244 @@ +#pragma once +#include "type_traits.hpp" +#include + +namespace ss { + +//////////////// +// matcher +//////////////// + +template +struct matcher { +private: + template + static bool match_impl(char c) { + if constexpr (sizeof...(Xs) != 0) { + return (c == X) || match_impl(c); + } + return (c == X); + } + + constexpr static bool contains_string_terminator() { + for (const auto& match : matches) { + if (match == '\0') { + return false; + } + } + return true; + } + +public: + static bool match(char c) { + return match_impl(c); + } + + constexpr static bool enabled = true; + constexpr static std::array matches{Cs...}; + static_assert(contains_string_terminator(), + "string terminator cannot be used as a match character"); +}; + +template +inline constexpr bool matches_intersect() { + for (const auto& first_match : FirstMatcher::matches) { + for (const auto& second_match : SecondMatcher::matches) { + if (first_match != '\0' && first_match == second_match) { + return true; + } + } + } + return false; +} + +template +inline constexpr bool matches_intersect_union() { + return matches_intersect() || + matches_intersect(); +} + +template <> +class matcher<'\0'> { +public: + constexpr static bool enabled = false; + constexpr static std::array matches{'\0'}; + static bool match(char c) = delete; +}; + +//////////////// +// setup +//////////////// + +//////////////// +// matcher +//////////////// + +template +struct quote : matcher {}; + +template +struct trim : matcher {}; + +template +struct trim_left : matcher {}; + +template +struct trim_right : matcher {}; + +template +struct escape : matcher {}; + +template class Template> +struct is_instance_of_matcher : std::false_type {}; + +template class Template> +struct is_instance_of_matcher, Template> : std::true_type {}; + +template class Template> +using is_instance_of_matcher_t = + typename is_instance_of_matcher::type; + +template