atsds 0.0.3 → 0.0.4-alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ds.wasm.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/emsdk/emscripten/system/lib/libc/emscripten_memcpy_bulkmem.S","/emsdk/emscripten/system/lib/libc/emscripten_memcpy.c","/emsdk/emscripten/system/lib/libc/musl/src/string/strlen.c","/emsdk/emscripten/system/lib/libc/musl/src/errno/__errno_location.c","/emsdk/emscripten/system/lib/dlmalloc.c","/emsdk/emscripten/system/lib/libc/emscripten_get_heap_size.c","/emsdk/emscripten/system/lib/libc/sbrk.c","/emsdk/emscripten/system/lib/compiler-rt/stack_ops.S","/emsdk/emscripten/system/lib/embind/bind.cpp","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/emscripten/bind.h","ds.cc","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__vector/vector.h","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__new/allocate.h","/emsdk/emscripten/system/lib/libcxx/src/new.cpp","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__memory/construct_at.h","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__split_buffer","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__memory/uninitialized_algorithms.h","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__utility/swap.h","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/optional","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/emscripten/val.h","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/emscripten/wire.h","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/string","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__string/constexpr_c_functions.h","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__string/char_traits.h","../src/string.cc","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/string.h","../include/ds/helper.hh","../src/variable.cc","../src/list.cc","../src/term.cc","../src/rule.cc","../src/item.cc","../src/ground.cc","../src/rename.cc","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__memory/unique_ptr.h","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__tree","../src/search.cc","../src/utility.cc","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__utility/pair.h","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/__functional/function.h","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/map","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/set","../src/match.cc","/emsdk/emscripten/system/lib/libc/musl/src/thread/pthread_self.c","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/typeinfo","../emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/include/c++/v1/stdexcept","/emsdk/emscripten/system/lib/libcxxabi/src/cxa_noexception.cpp","/emsdk/emscripten/system/lib/libcxxabi/src/stdlib_stdexcept.cpp","/emsdk/emscripten/system/lib/libcxx/src/support/runtime/stdexcept_default.ipp","/emsdk/emscripten/system/lib/libc/musl/src/string/memchr.c","/emsdk/emscripten/system/lib/libc/musl/src/string/strcmp.c","/emsdk/emscripten/system/lib/libc/musl/src/string/memcmp.c","/emsdk/emscripten/system/lib/libcxx/src/functional.cpp","/emsdk/emscripten/cache/sysroot/include/emscripten/bind.h","/emsdk/emscripten/cache/sysroot/include/c++/v1/typeinfo","/emsdk/emscripten/system/lib/libc/musl/src/string/strdup.c","/emsdk/emscripten/system/lib/libcxxabi/src/stdlib_exception.cpp","/emsdk/emscripten/system/lib/pthread/pthread_self_stub.c","/emsdk/emscripten/system/lib/libcxxabi/src/cxa_handlers.cpp","/emsdk/emscripten/system/lib/libcxx/src/new_helpers.cpp","/emsdk/emscripten/system/lib/libc/musl/src/exit/abort.c","/emsdk/emscripten/cache/sysroot/include/c++/v1/__exception/exception.h","/emsdk/emscripten/system/lib/libcxx/src/support/runtime/../../include/refstring.h","/emsdk/emscripten/system/lib/libcxx/src/include/atomic_support.h","/emsdk/emscripten/system/lib/libcxxabi/src/abort_message.cpp","/emsdk/emscripten/system/lib/libcxxabi/src/cxa_default_handlers.cpp","/emsdk/emscripten/system/lib/libcxxabi/src/private_typeinfo.cpp","/emsdk/emscripten/system/lib/libcxx/src/include/refstring.h","/emsdk/emscripten/system/lib/libc/musl/src/signal/setitimer.c","/emsdk/emscripten/system/lib/libc/raise.c","/emsdk/emscripten/system/lib/libc/musl/src/exit/_Exit.c","/emsdk/emscripten/system/lib/libc/pthread_sigmask.c","/emsdk/emscripten/system/lib/libc/musl/src/signal/sigaddset.c","/emsdk/emscripten/system/lib/libc/musl/src/signal/sigismember.c"],"sourcesContent":["#ifdef __wasm64__\n#define PTR i64\n#else\n#define PTR i32\n#endif\n\n.globl _emscripten_memcpy_bulkmem\n_emscripten_memcpy_bulkmem:\n .functype _emscripten_memcpy_bulkmem (PTR, PTR, PTR) -> (PTR)\n local.get 2\n#ifdef __wasm64__\n i32.wrap_i64\n#endif\n // memory.copy traps on OOB zero-length copies, but memcpy must not.\n if\n local.get 0\n local.get 1\n local.get 2\n memory.copy 0, 0\n end_if\n local.get 0\n end_function\n\n.section .custom_section.target_features,\"\",@\n.int8 1\n.int8 43\n.int8 11\n.ascii \"bulk-memory\"\n","/*\n * A simple memcpy optimized for wasm.\n */\n\n#include <stdint.h>\n#include <string.h>\n#include <emscripten/emscripten.h>\n#include \"libc.h\"\n#include \"emscripten_internal.h\"\n\n// Use the simple/naive version of memcpy when building with asan\n#if __has_feature(address_sanitizer)\n\nstatic void *__memcpy(void *dest, const void *src, size_t n) {\n unsigned char *d = (unsigned char *)dest;\n const unsigned char *s = (const unsigned char *)src;\n while(n--) *d++ = *s++;\n return dest;\n}\n\n#elif defined(EMSCRIPTEN_OPTIMIZE_FOR_OZ)\n\nstatic void *__memcpy(void *restrict dest, const void *restrict src, size_t n) {\n // TODO: Ensure this is inlined with Binaryen or inline asm\n return _emscripten_memcpy_bulkmem(dest, src, n);\n}\n\n#else\n\nstatic void *__memcpy(void *restrict dest, const void *restrict src, size_t n) {\n unsigned char *d = dest;\n const unsigned char *s = src;\n\n unsigned char *aligned_d_end;\n unsigned char *block_aligned_d_end;\n unsigned char *d_end;\n\n if (n >= 512) {\n // TODO: Re-investigate the size threshold to enable this\n return _emscripten_memcpy_bulkmem(dest, src, n);\n }\n\n d_end = d + n;\n if ((((uintptr_t)d) & 3) == (((uintptr_t)s) & 3)) {\n // The initial unaligned < 4-byte front.\n while ((((uintptr_t)d) & 3) && d < d_end) {\n *d++ = *s++;\n }\n aligned_d_end = (unsigned char *)(((uintptr_t)d_end) & -4);\n if (((uintptr_t)aligned_d_end) >= 64) {\n block_aligned_d_end = aligned_d_end - 64;\n while (d <= block_aligned_d_end) {\n // TODO: we could use 64-bit ops here, but we'd need to make sure the\n // alignment is 64-bit, which might cost us\n *(((uint32_t*)d)) = *(((uint32_t*)s));\n *(((uint32_t*)d) + 1) = *(((uint32_t*)s) + 1);\n *(((uint32_t*)d) + 2) = *(((uint32_t*)s) + 2);\n *(((uint32_t*)d) + 3) = *(((uint32_t*)s) + 3);\n *(((uint32_t*)d) + 4) = *(((uint32_t*)s) + 4);\n *(((uint32_t*)d) + 5) = *(((uint32_t*)s) + 5);\n *(((uint32_t*)d) + 6) = *(((uint32_t*)s) + 6);\n *(((uint32_t*)d) + 7) = *(((uint32_t*)s) + 7);\n *(((uint32_t*)d) + 8) = *(((uint32_t*)s) + 8);\n *(((uint32_t*)d) + 9) = *(((uint32_t*)s) + 9);\n *(((uint32_t*)d) + 10) = *(((uint32_t*)s) + 10);\n *(((uint32_t*)d) + 11) = *(((uint32_t*)s) + 11);\n *(((uint32_t*)d) + 12) = *(((uint32_t*)s) + 12);\n *(((uint32_t*)d) + 13) = *(((uint32_t*)s) + 13);\n *(((uint32_t*)d) + 14) = *(((uint32_t*)s) + 14);\n *(((uint32_t*)d) + 15) = *(((uint32_t*)s) + 15);\n d += 64;\n s += 64;\n }\n }\n while (d < aligned_d_end) {\n *((uint32_t *)d) = *((uint32_t *)s);\n d += 4;\n s += 4;\n }\n } else {\n // In the unaligned copy case, unroll a bit as well.\n if (((uintptr_t)d_end) >= 4) {\n aligned_d_end = d_end - 4;\n while (d <= aligned_d_end) {\n *d = *s;\n *(d + 1) = *(s + 1);\n *(d + 2) = *(s + 2);\n *(d + 3) = *(s + 3);\n d += 4;\n s += 4;\n }\n }\n }\n // The remaining unaligned < 4 byte tail.\n while (d < d_end) {\n *d++ = *s++;\n }\n return dest;\n}\n\n#endif\n\nweak_alias(__memcpy, emscripten_builtin_memcpy);\nweak_alias(__memcpy, memcpy);\n","#include <string.h>\n#include <stdint.h>\n#include <limits.h>\n\n#define ALIGN (sizeof(size_t))\n#define ONES ((size_t)-1/UCHAR_MAX)\n#define HIGHS (ONES * (UCHAR_MAX/2+1))\n#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)\n\nsize_t strlen(const char *s)\n{\n\tconst char *a = s;\n/* XXX EMSCRIPTEN: add __has_feature check */\n#if defined(__GNUC__) && !__has_feature(address_sanitizer)\n\ttypedef size_t __attribute__((__may_alias__)) word;\n\tconst word *w;\n\tfor (; (uintptr_t)s % ALIGN; s++) if (!*s) return s-a;\n\tfor (w = (const void *)s; !HASZERO(*w); w++);\n\ts = (const void *)w;\n#endif\n\tfor (; *s; s++);\n\treturn s-a;\n}\n","#include <errno.h>\n#include \"pthread_impl.h\"\n\n#if __EMSCRIPTEN__\n// For emscripten we use TLS here instead of `__pthread_self`, so that in single\n// threaded builds this gets lowered away to normal global variable.\nstatic _Thread_local int __errno_storage = 0;\n#endif\n\nint *__errno_location(void)\n{\n#if __EMSCRIPTEN__\n\treturn &__errno_storage;\n#else\n\treturn &__pthread_self()->errno_val;\n#endif\n}\n\nweak_alias(__errno_location, ___errno_location);\n","\n/* XXX Emscripten XXX */\n#if __EMSCRIPTEN__\n// When building for wasm we export `malloc` and `emscripten_builtin_malloc` as\n// weak alias of the internal `dlmalloc` which is static to this file.\n#define DLMALLOC_EXPORT static\n/* mmap uses malloc, so malloc can't use mmap */\n#define HAVE_MMAP 0\n/* Emscripten's sbrk can interpret unsigned values greater than (MAX_SIZE_T / 2U) (2GB) correctly */\n#define UNSIGNED_MORECORE 1\n/* we can only grow the heap up anyhow, so don't try to trim */\n#define MORECORE_CANNOT_TRIM 1\n#ifndef DLMALLOC_DEBUG\n/* dlmalloc has many checks, calls to abort() increase code size,\n leave them only in debug builds */\n#define ABORT __builtin_unreachable()\n/* allow malloc stats only in debug builds, which brings in stdio code. */\n#define NO_MALLOC_STATS 1\n#endif\n/* XXX Emscripten Tracing API. This defines away the code if tracing is disabled. */\n#include <emscripten/trace.h>\n\n#ifdef __EMSCRIPTEN_SHARED_MEMORY__\n#define USE_LOCKS 1\n#endif\n\n/* Make malloc() and free() threadsafe by securing the memory allocations with pthread mutexes. */\n#if __EMSCRIPTEN_PTHREADS__\n#define USE_SPIN_LOCKS 0 // Ensure we use pthread_mutex_t.\n#endif\n\n#ifndef MALLOC_ALIGNMENT\n#include <stddef.h>\n/* `malloc`ed pointers must be aligned at least as strictly as max_align_t. */\n#define MALLOC_ALIGNMENT (__alignof__(max_align_t))\n/*\n Emscripten aligns even float128 to 64-bits, to save size and increase speed.\n See https://github.com/emscripten-core/emscripten/issues/10072\n*/\n_Static_assert(MALLOC_ALIGNMENT == 8, \"max_align_t must be 8\");\n#endif\n\n#endif // __EMSCRIPTEN__\n\n\n#define __THROW\n#define __attribute_malloc__\n#define __wur\n\n\n/*\n This is a version (aka dlmalloc) of malloc/free/realloc written by\n Doug Lea and released to the public domain, as explained at\n http://creativecommons.org/publicdomain/zero/1.0/ Send questions,\n comments, complaints, performance data, etc to dl@cs.oswego.edu\n \n * Version 2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea\n Note: There may be an updated version of this malloc obtainable at\n ftp://gee.cs.oswego.edu/pub/misc/malloc.c\n Check before installing!\n \n * Quickstart\n \n This library is all in one file to simplify the most common usage:\n ftp it, compile it (-O3), and link it into another program. All of\n the compile-time options default to reasonable values for use on\n most platforms. You might later want to step through various\n compile-time and dynamic tuning options.\n \n For convenience, an include file for code using this malloc is at:\n ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.6.h\n You don't really need this .h file unless you call functions not\n defined in your system include files. The .h file contains only the\n excerpts from this file needed for using this malloc on ANSI C/C++\n systems, so long as you haven't changed compile-time options about\n naming and tuning parameters. If you do, then you can create your\n own malloc.h that does include all settings by cutting at the point\n indicated below. Note that you may already by default be using a C\n library containing a malloc that is based on some version of this\n malloc (for example in linux). You might still want to use the one\n in this file to customize settings or to avoid overheads associated\n with library versions.\n \n * Vital statistics:\n \n Supported pointer/size_t representation: 4 or 8 bytes\n size_t MUST be an unsigned type of the same width as\n pointers. (If you are using an ancient system that declares\n size_t as a signed type, or need it to be a different width\n than pointers, you can use a previous release of this malloc\n (e.g. 2.7.2) supporting these.)\n \n Alignment: 8 bytes (minimum)\n This suffices for nearly all current machines and C compilers.\n However, you can define MALLOC_ALIGNMENT to be wider than this\n if necessary (up to 128bytes), at the expense of using more space.\n \n Minimum overhead per allocated chunk: 4 or 8 bytes (if 4byte sizes)\n 8 or 16 bytes (if 8byte sizes)\n Each malloced chunk has a hidden word of overhead holding size\n and status information, and additional cross-check word\n if FOOTERS is defined.\n \n Minimum allocated size: 4-byte ptrs: 16 bytes (including overhead)\n 8-byte ptrs: 32 bytes (including overhead)\n \n Even a request for zero bytes (i.e., malloc(0)) returns a\n pointer to something of the minimum allocatable size.\n The maximum overhead wastage (i.e., number of extra bytes\n allocated than were requested in malloc) is less than or equal\n to the minimum size, except for requests >= mmap_threshold that\n are serviced via mmap(), where the worst case wastage is about\n 32 bytes plus the remainder from a system page (the minimal\n mmap unit); typically 4096 or 8192 bytes.\n \n Security: static-safe; optionally more or less\n The \"security\" of malloc refers to the ability of malicious\n code to accentuate the effects of errors (for example, freeing\n space that is not currently malloc'ed or overwriting past the\n ends of chunks) in code that calls malloc. This malloc\n guarantees not to modify any memory locations below the base of\n heap, i.e., static variables, even in the presence of usage\n errors. The routines additionally detect most improper frees\n and reallocs. All this holds as long as the static bookkeeping\n for malloc itself is not corrupted by some other means. This\n is only one aspect of security -- these checks do not, and\n cannot, detect all possible programming errors.\n \n If FOOTERS is defined nonzero, then each allocated chunk\n carries an additional check word to verify that it was malloced\n from its space. These check words are the same within each\n execution of a program using malloc, but differ across\n executions, so externally crafted fake chunks cannot be\n freed. This improves security by rejecting frees/reallocs that\n could corrupt heap memory, in addition to the checks preventing\n writes to statics that are always on. This may further improve\n security at the expense of time and space overhead. (Note that\n FOOTERS may also be worth using with MSPACES.)\n \n By default detected errors cause the program to abort (calling\n \"abort()\"). You can override this to instead proceed past\n errors by defining PROCEED_ON_ERROR. In this case, a bad free\n has no effect, and a malloc that encounters a bad address\n caused by user overwrites will ignore the bad address by\n dropping pointers and indices to all known memory. This may\n be appropriate for programs that should continue if at all\n possible in the face of programming errors, although they may\n run out of memory because dropped memory is never reclaimed.\n \n If you don't like either of these options, you can define\n CORRUPTION_ERROR_ACTION and USAGE_ERROR_ACTION to do anything\n else. And if if you are sure that your program using malloc has\n no errors or vulnerabilities, you can define INSECURE to 1,\n which might (or might not) provide a small performance improvement.\n \n It is also possible to limit the maximum total allocatable\n space, using malloc_set_footprint_limit. This is not\n designed as a security feature in itself (calls to set limits\n are not screened or privileged), but may be useful as one\n aspect of a secure implementation.\n \n Thread-safety: NOT thread-safe unless USE_LOCKS defined non-zero\n When USE_LOCKS is defined, each public call to malloc, free,\n etc is surrounded with a lock. By default, this uses a plain\n pthread mutex, win32 critical section, or a spin-lock if if\n available for the platform and not disabled by setting\n USE_SPIN_LOCKS=0. However, if USE_RECURSIVE_LOCKS is defined,\n recursive versions are used instead (which are not required for\n base functionality but may be needed in layered extensions).\n Using a global lock is not especially fast, and can be a major\n bottleneck. It is designed only to provide minimal protection\n in concurrent environments, and to provide a basis for\n extensions. If you are using malloc in a concurrent program,\n consider instead using nedmalloc\n (http://www.nedprod.com/programs/portable/nedmalloc/) or\n ptmalloc (See http://www.malloc.de), which are derived from\n versions of this malloc.\n \n System requirements: Any combination of MORECORE and/or MMAP/MUNMAP\n This malloc can use unix sbrk or any emulation (invoked using\n the CALL_MORECORE macro) and/or mmap/munmap or any emulation\n (invoked using CALL_MMAP/CALL_MUNMAP) to get and release system\n memory. On most unix systems, it tends to work best if both\n MORECORE and MMAP are enabled. On Win32, it uses emulations\n based on VirtualAlloc. It also uses common C library functions\n like memset.\n \n Compliance: I believe it is compliant with the Single Unix Specification\n (See http://www.unix.org). Also SVID/XPG, ANSI C, and probably\n others as well.\n \n * Overview of algorithms\n \n This is not the fastest, most space-conserving, most portable, or\n most tunable malloc ever written. However it is among the fastest\n while also being among the most space-conserving, portable and\n tunable. Consistent balance across these factors results in a good\n general-purpose allocator for malloc-intensive programs.\n \n In most ways, this malloc is a best-fit allocator. Generally, it\n chooses the best-fitting existing chunk for a request, with ties\n broken in approximately least-recently-used order. (This strategy\n normally maintains low fragmentation.) However, for requests less\n than 256bytes, it deviates from best-fit when there is not an\n exactly fitting available chunk by preferring to use space adjacent\n to that used for the previous small request, as well as by breaking\n ties in approximately most-recently-used order. (These enhance\n locality of series of small allocations.) And for very large requests\n (>= 256Kb by default), it relies on system memory mapping\n facilities, if supported. (This helps avoid carrying around and\n possibly fragmenting memory used only for large chunks.)\n \n All operations (except malloc_stats and mallinfo) have execution\n times that are bounded by a constant factor of the number of bits in\n a size_t, not counting any clearing in calloc or copying in realloc,\n or actions surrounding MORECORE and MMAP that have times\n proportional to the number of non-contiguous regions returned by\n system allocation routines, which is often just 1. In real-time\n applications, you can optionally suppress segment traversals using\n NO_SEGMENT_TRAVERSAL, which assures bounded execution even when\n system allocators return non-contiguous spaces, at the typical\n expense of carrying around more memory and increased fragmentation.\n \n The implementation is not very modular and seriously overuses\n macros. Perhaps someday all C compilers will do as good a job\n inlining modular code as can now be done by brute-force expansion,\n but now, enough of them seem not to.\n \n Some compilers issue a lot of warnings about code that is\n dead/unreachable only on some platforms, and also about intentional\n uses of negation on unsigned types. All known cases of each can be\n ignored.\n \n For a longer but out of date high-level description, see\n http://gee.cs.oswego.edu/dl/html/malloc.html\n \n * MSPACES\n If MSPACES is defined, then in addition to malloc, free, etc.,\n this file also defines mspace_malloc, mspace_free, etc. These\n are versions of malloc routines that take an \"mspace\" argument\n obtained using create_mspace, to control all internal bookkeeping.\n If ONLY_MSPACES is defined, only these versions are compiled.\n So if you would like to use this allocator for only some allocations,\n and your system malloc for others, you can compile with\n ONLY_MSPACES and then do something like...\n static mspace mymspace = create_mspace(0,0); // for example\n #define mymalloc(bytes) mspace_malloc(mymspace, bytes)\n \n (Note: If you only need one instance of an mspace, you can instead\n use \"USE_DL_PREFIX\" to relabel the global malloc.)\n \n You can similarly create thread-local allocators by storing\n mspaces as thread-locals. For example:\n static __thread mspace tlms = 0;\n void* tlmalloc(size_t bytes) {\n if (tlms == 0) tlms = create_mspace(0, 0);\n return mspace_malloc(tlms, bytes);\n }\n void tlfree(void* mem) { mspace_free(tlms, mem); }\n \n Unless FOOTERS is defined, each mspace is completely independent.\n You cannot allocate from one and free to another (although\n conformance is only weakly checked, so usage errors are not always\n caught). If FOOTERS is defined, then each chunk carries around a tag\n indicating its originating mspace, and frees are directed to their\n originating spaces. Normally, this requires use of locks.\n \n ------------------------- Compile-time options ---------------------------\n \n Be careful in setting #define values for numerical constants of type\n size_t. On some systems, literal values are not automatically extended\n to size_t precision unless they are explicitly casted. You can also\n use the symbolic values MAX_SIZE_T, SIZE_T_ONE, etc below.\n \n WIN32 default: defined if _WIN32 defined\n Defining WIN32 sets up defaults for MS environment and compilers.\n Otherwise defaults are for unix. Beware that there seem to be some\n cases where this malloc might not be a pure drop-in replacement for\n Win32 malloc: Random-looking failures from Win32 GDI API's (eg;\n SetDIBits()) may be due to bugs in some video driver implementations\n when pixel buffers are malloc()ed, and the region spans more than\n one VirtualAlloc()ed region. Because dlmalloc uses a small (64Kb)\n default granularity, pixel buffers may straddle virtual allocation\n regions more often than when using the Microsoft allocator. You can\n avoid this by using VirtualAlloc() and VirtualFree() for all pixel\n buffers rather than using malloc(). If this is not possible,\n recompile this malloc with a larger DEFAULT_GRANULARITY. Note:\n in cases where MSC and gcc (cygwin) are known to differ on WIN32,\n conditions use _MSC_VER to distinguish them.\n \n DLMALLOC_EXPORT default: extern\n Defines how public APIs are declared. If you want to export via a\n Windows DLL, you might define this as\n #define DLMALLOC_EXPORT extern __declspec(dllexport)\n If you want a POSIX ELF shared object, you might use\n #define DLMALLOC_EXPORT extern __attribute__((visibility(\"default\")))\n \n MALLOC_ALIGNMENT default: (size_t)(2 * sizeof(void *))\n Controls the minimum alignment for malloc'ed chunks. It must be a\n power of two and at least 8, even on machines for which smaller\n alignments would suffice. It may be defined as larger than this\n though. Note however that code and data structures are optimized for\n the case of 8-byte alignment.\n \n MSPACES default: 0 (false)\n If true, compile in support for independent allocation spaces.\n This is only supported if HAVE_MMAP is true.\n \n ONLY_MSPACES default: 0 (false)\n If true, only compile in mspace versions, not regular versions.\n \n USE_LOCKS default: 0 (false)\n Causes each call to each public routine to be surrounded with\n pthread or WIN32 mutex lock/unlock. (If set true, this can be\n overridden on a per-mspace basis for mspace versions.) If set to a\n non-zero value other than 1, locks are used, but their\n implementation is left out, so lock functions must be supplied manually,\n as described below.\n \n USE_SPIN_LOCKS default: 1 iff USE_LOCKS and spin locks available\n If true, uses custom spin locks for locking. This is currently\n supported only gcc >= 4.1, older gccs on x86 platforms, and recent\n MS compilers. Otherwise, posix locks or win32 critical sections are\n used.\n \n USE_RECURSIVE_LOCKS default: not defined\n If defined nonzero, uses recursive (aka reentrant) locks, otherwise\n uses plain mutexes. This is not required for malloc proper, but may\n be needed for layered allocators such as nedmalloc.\n \n LOCK_AT_FORK default: not defined\n If defined nonzero, performs pthread_atfork upon initialization\n to initialize child lock while holding parent lock. The implementation\n assumes that pthread locks (not custom locks) are being used. In other\n cases, you may need to customize the implementation.\n \n FOOTERS default: 0\n If true, provide extra checking and dispatching by placing\n information in the footers of allocated chunks. This adds\n space and time overhead.\n \n INSECURE default: 0\n If true, omit checks for usage errors and heap space overwrites.\n \n USE_DL_PREFIX default: NOT defined\n Causes compiler to prefix all public routines with the string 'dl'.\n This can be useful when you only want to use this malloc in one part\n of a program, using your regular system malloc elsewhere.\n \n MALLOC_INSPECT_ALL default: NOT defined\n If defined, compiles malloc_inspect_all and mspace_inspect_all, that\n perform traversal of all heap space. Unless access to these\n functions is otherwise restricted, you probably do not want to\n include them in secure implementations.\n \n ABORT default: defined as abort()\n Defines how to abort on failed checks. On most systems, a failed\n check cannot die with an \"assert\" or even print an informative\n message, because the underlying print routines in turn call malloc,\n which will fail again. Generally, the best policy is to simply call\n abort(). It's not very useful to do more than this because many\n errors due to overwriting will show up as address faults (null, odd\n addresses etc) rather than malloc-triggered checks, so will also\n abort. Also, most compilers know that abort() does not return, so\n can better optimize code conditionally calling it.\n \n PROCEED_ON_ERROR default: defined as 0 (false)\n Controls whether detected bad addresses cause them to bypassed\n rather than aborting. If set, detected bad arguments to free and\n realloc are ignored. And all bookkeeping information is zeroed out\n upon a detected overwrite of freed heap space, thus losing the\n ability to ever return it from malloc again, but enabling the\n application to proceed. If PROCEED_ON_ERROR is defined, the\n static variable malloc_corruption_error_count is compiled in\n and can be examined to see if errors have occurred. This option\n generates slower code than the default abort policy.\n \n DEBUG default: NOT defined\n The DEBUG setting is mainly intended for people trying to modify\n this code or diagnose problems when porting to new platforms.\n However, it may also be able to better isolate user errors than just\n using runtime checks. The assertions in the check routines spell\n out in more detail the assumptions and invariants underlying the\n algorithms. The checking is fairly extensive, and will slow down\n execution noticeably. Calling malloc_stats or mallinfo with DEBUG\n set will attempt to check every non-mmapped allocated and free chunk\n in the course of computing the summaries.\n \n ABORT_ON_ASSERT_FAILURE default: defined as 1 (true)\n Debugging assertion failures can be nearly impossible if your\n version of the assert macro causes malloc to be called, which will\n lead to a cascade of further failures, blowing the runtime stack.\n ABORT_ON_ASSERT_FAILURE cause assertions failures to call abort(),\n which will usually make debugging easier.\n \n MALLOC_FAILURE_ACTION default: sets errno to ENOMEM, or no-op on win32\n The action to take before \"return 0\" when malloc fails to be able to\n return memory because there is none available.\n \n HAVE_MORECORE default: 1 (true) unless win32 or ONLY_MSPACES\n True if this system supports sbrk or an emulation of it.\n \n MORECORE default: sbrk\n The name of the sbrk-style system routine to call to obtain more\n memory. See below for guidance on writing custom MORECORE\n functions. The type of the argument to sbrk/MORECORE varies across\n systems. It cannot be size_t, because it supports negative\n arguments, so it is normally the signed type of the same width as\n size_t (sometimes declared as \"intptr_t\"). It doesn't much matter\n though. Internally, we only call it with arguments less than half\n the max value of a size_t, which should work across all reasonable\n possibilities, although sometimes generating compiler warnings.\n \n MORECORE_CONTIGUOUS default: 1 (true) if HAVE_MORECORE\n If true, take advantage of fact that consecutive calls to MORECORE\n with positive arguments always return contiguous increasing\n addresses. This is true of unix sbrk. It does not hurt too much to\n set it true anyway, since malloc copes with non-contiguities.\n Setting it false when definitely non-contiguous saves time\n and possibly wasted space it would take to discover this though.\n \n UNSIGNED_MORECORE default: 0 (false)\n True if MORECORE can only handle unsigned arguments. This sets\n MORECORE_CANNOT_TRIM to 1 (true).\n\n MORECORE_CANNOT_TRIM default: NOT defined\n True if MORECORE cannot release space back to the system when given\n negative arguments. This is generally necessary only if you are\n using a hand-crafted MORECORE function that cannot handle negative\n arguments.\n \n NO_SEGMENT_TRAVERSAL default: 0\n If non-zero, suppresses traversals of memory segments\n returned by either MORECORE or CALL_MMAP. This disables\n merging of segments that are contiguous, and selectively\n releasing them to the OS if unused, but bounds execution times.\n \n HAVE_MMAP default: 1 (true)\n True if this system supports mmap or an emulation of it. If so, and\n HAVE_MORECORE is not true, MMAP is used for all system\n allocation. If set and HAVE_MORECORE is true as well, MMAP is\n primarily used to directly allocate very large blocks. It is also\n used as a backup strategy in cases where MORECORE fails to provide\n space from system. Note: A single call to MUNMAP is assumed to be\n able to unmap memory that may have be allocated using multiple calls\n to MMAP, so long as they are adjacent.\n \n HAVE_MREMAP default: 1 on linux, else 0\n If true realloc() uses mremap() to re-allocate large blocks and\n extend or shrink allocation spaces.\n \n MMAP_CLEARS default: 1 except on WINCE.\n True if mmap clears memory so calloc doesn't need to. This is true\n for standard unix mmap using /dev/zero and on WIN32 except for WINCE.\n \n USE_BUILTIN_FFS default: 0 (i.e., not used)\n Causes malloc to use the builtin ffs() function to compute indices.\n Some compilers may recognize and intrinsify ffs to be faster than the\n supplied C version. Also, the case of x86 using gcc is special-cased\n to an asm instruction, so is already as fast as it can be, and so\n this setting has no effect. Similarly for Win32 under recent MS compilers.\n (On most x86s, the asm version is only slightly faster than the C version.)\n \n malloc_getpagesize default: derive from system includes, or 4096.\n The system page size. To the extent possible, this malloc manages\n memory from the system in page-size units. This may be (and\n usually is) a function rather than a constant. This is ignored\n if WIN32, where page size is determined using getSystemInfo during\n initialization.\n \n USE_DEV_RANDOM default: 0 (i.e., not used)\n Causes malloc to use /dev/random to initialize secure magic seed for\n stamping footers. Otherwise, the current time is used.\n \n NO_MALLINFO default: 0\n If defined, don't compile \"mallinfo\". This can be a simple way\n of dealing with mismatches between system declarations and\n those in this file.\n \n MALLINFO_FIELD_TYPE default: size_t\n The type of the fields in the mallinfo struct. This was originally\n defined as \"int\" in SVID etc, but is more usefully defined as\n size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set\n \n NO_MALLOC_STATS default: 0\n If defined, don't compile \"malloc_stats\". This avoids calls to\n fprintf and bringing in stdio dependencies you might not want.\n \n REALLOC_ZERO_BYTES_FREES default: not defined\n This should be set if a call to realloc with zero bytes should\n be the same as a call to free. Some people think it should. Otherwise,\n since this malloc returns a unique pointer for malloc(0), so does\n realloc(p, 0).\n \n LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H\n LACKS_STRINGS_H, LACKS_STRING_H, LACKS_SYS_TYPES_H, LACKS_ERRNO_H\n LACKS_STDLIB_H LACKS_SCHED_H LACKS_TIME_H default: NOT defined unless on WIN32\n Define these if your system does not have these header files.\n You might need to manually insert some of the declarations they provide.\n \n DEFAULT_GRANULARITY default: page size if MORECORE_CONTIGUOUS,\n system_info.dwAllocationGranularity in WIN32,\n otherwise 64K.\n Also settable using mallopt(M_GRANULARITY, x)\n The unit for allocating and deallocating memory from the system. On\n most systems with contiguous MORECORE, there is no reason to\n make this more than a page. However, systems with MMAP tend to\n either require or encourage larger granularities. You can increase\n this value to prevent system allocation functions to be called so\n often, especially if they are slow. The value must be at least one\n page and must be a power of two. Setting to 0 causes initialization\n to either page size or win32 region size. (Note: In previous\n versions of malloc, the equivalent of this option was called\n \"TOP_PAD\")\n \n DEFAULT_TRIM_THRESHOLD default: 2MB\n Also settable using mallopt(M_TRIM_THRESHOLD, x)\n The maximum amount of unused top-most memory to keep before\n releasing via malloc_trim in free(). Automatic trimming is mainly\n useful in long-lived programs using contiguous MORECORE. Because\n trimming via sbrk can be slow on some systems, and can sometimes be\n wasteful (in cases where programs immediately afterward allocate\n more large chunks) the value should be high enough so that your\n overall system performance would improve by releasing this much\n memory. As a rough guide, you might set to a value close to the\n average size of a process (program) running on your system.\n Releasing this much memory would allow such a process to run in\n memory. Generally, it is worth tuning trim thresholds when a\n program undergoes phases where several large chunks are allocated\n and released in ways that can reuse each other's storage, perhaps\n mixed with phases where there are no such chunks at all. The trim\n value must be greater than page size to have any useful effect. To\n disable trimming completely, you can set to MAX_SIZE_T. Note that the trick\n some people use of mallocing a huge space and then freeing it at\n program startup, in an attempt to reserve system memory, doesn't\n have the intended effect under automatic trimming, since that memory\n will immediately be returned to the system.\n \n DEFAULT_MMAP_THRESHOLD default: 256K\n Also settable using mallopt(M_MMAP_THRESHOLD, x)\n The request size threshold for using MMAP to directly service a\n request. Requests of at least this size that cannot be allocated\n using already-existing space will be serviced via mmap. (If enough\n normal freed space already exists it is used instead.) Using mmap\n segregates relatively large chunks of memory so that they can be\n individually obtained and released from the host system. A request\n serviced through mmap is never reused by any other request (at least\n not directly; the system may just so happen to remap successive\n requests to the same locations). Segregating space in this way has\n the benefits that: Mmapped space can always be individually released\n back to the system, which helps keep the system level memory demands\n of a long-lived program low. Also, mapped memory doesn't become\n `locked' between other chunks, as can happen with normally allocated\n chunks, which means that even trimming via malloc_trim would not\n release them. However, it has the disadvantage that the space\n cannot be reclaimed, consolidated, and then used to service later\n requests, as happens with normal chunks. The advantages of mmap\n nearly always outweigh disadvantages for \"large\" chunks, but the\n value of \"large\" may vary across systems. The default is an\n empirically derived value that works well in most systems. You can\n disable mmap by setting to MAX_SIZE_T.\n \n MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP\n The number of consolidated frees between checks to release\n unused segments when freeing. When using non-contiguous segments,\n especially with multiple mspaces, checking only for topmost space\n doesn't always suffice to trigger trimming. To compensate for this,\n free() will, with a period of MAX_RELEASE_CHECK_RATE (or the\n current number of segments, if greater) try to release unused\n segments to the OS when freeing chunks that result in\n consolidation. The best value for this parameter is a compromise\n between slowing down frees with relatively costly checks that\n rarely trigger versus holding on to unused memory. To effectively\n disable, set to MAX_SIZE_T. This may lead to a very slight speed\n improvement at the expense of carrying around more memory.\n */\n\n/* Version identifier to allow people to support multiple versions */\n#ifndef DLMALLOC_VERSION\n#define DLMALLOC_VERSION 20806\n#endif /* DLMALLOC_VERSION */\n\n#ifndef DLMALLOC_EXPORT\n#define DLMALLOC_EXPORT extern\n#endif\n\n#ifndef WIN32\n#ifdef _WIN32\n#define WIN32 1\n#endif /* _WIN32 */\n#ifdef _WIN32_WCE\n#define LACKS_FCNTL_H\n#define WIN32 1\n#endif /* _WIN32_WCE */\n#endif /* WIN32 */\n#ifdef WIN32\n#define WIN32_LEAN_AND_MEAN\n#include <windows.h>\n#include <tchar.h>\n#define HAVE_MMAP 1\n#define HAVE_MORECORE 0\n#define LACKS_UNISTD_H\n#define LACKS_SYS_PARAM_H\n#define LACKS_SYS_MMAN_H\n#define LACKS_STRING_H\n#define LACKS_STRINGS_H\n#define LACKS_SYS_TYPES_H\n#define LACKS_ERRNO_H\n#define LACKS_SCHED_H\n#ifndef MALLOC_FAILURE_ACTION\n#define MALLOC_FAILURE_ACTION\n#endif /* MALLOC_FAILURE_ACTION */\n#ifndef MMAP_CLEARS\n#ifdef _WIN32_WCE /* WINCE reportedly does not clear */\n#define MMAP_CLEARS 0\n#else\n#define MMAP_CLEARS 1\n#endif /* _WIN32_WCE */\n#endif /*MMAP_CLEARS */\n#endif /* WIN32 */\n\n#if defined(DARWIN) || defined(_DARWIN)\n/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */\n#ifndef HAVE_MORECORE\n#define HAVE_MORECORE 0\n#define HAVE_MMAP 1\n/* OSX allocators provide 16 byte alignment */\n#ifndef MALLOC_ALIGNMENT\n#define MALLOC_ALIGNMENT ((size_t)16U)\n#endif\n#endif /* HAVE_MORECORE */\n#endif /* DARWIN */\n\n#ifndef LACKS_SYS_TYPES_H\n#include <sys/types.h> /* For size_t */\n#endif /* LACKS_SYS_TYPES_H */\n\n/* The maximum possible size_t value has all bits set */\n#define MAX_SIZE_T (~(size_t)0)\n\n#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */\n/* XXX: The following block adapted locally to avoid\n clean up new Clang -Wexpansion-to-defined warnings.\n http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147239.html */\n#if (defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \\\n (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)\n#define USE_LOCKS 1\n#else\n#define USE_LOCKS 0\n#endif\n#endif /* USE_LOCKS */\n\n#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */\n#if ((defined(__GNUC__) && \\\n((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \\\ndefined(__i386__) || defined(__x86_64__))) || \\\n(defined(_MSC_VER) && _MSC_VER>=1310))\n#ifndef USE_SPIN_LOCKS\n#define USE_SPIN_LOCKS 1\n#endif /* USE_SPIN_LOCKS */\n#elif USE_SPIN_LOCKS\n#error \"USE_SPIN_LOCKS defined without implementation\"\n#endif /* ... locks available... */\n#elif !defined(USE_SPIN_LOCKS)\n#define USE_SPIN_LOCKS 0\n#endif /* USE_LOCKS */\n\n#ifndef ONLY_MSPACES\n#define ONLY_MSPACES 0\n#endif /* ONLY_MSPACES */\n#ifndef MSPACES\n#if ONLY_MSPACES\n#define MSPACES 1\n#else /* ONLY_MSPACES */\n#define MSPACES 0\n#endif /* ONLY_MSPACES */\n#endif /* MSPACES */\n#ifndef MALLOC_ALIGNMENT\n#define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *)))\n#endif /* MALLOC_ALIGNMENT */\n#ifndef FOOTERS\n#define FOOTERS 0\n#endif /* FOOTERS */\n#ifndef ABORT\n#define ABORT abort()\n#endif /* ABORT */\n#ifndef ABORT_ON_ASSERT_FAILURE\n#define ABORT_ON_ASSERT_FAILURE 1\n#endif /* ABORT_ON_ASSERT_FAILURE */\n#ifndef PROCEED_ON_ERROR\n#define PROCEED_ON_ERROR 0\n#endif /* PROCEED_ON_ERROR */\n\n#ifndef INSECURE\n#define INSECURE 0\n#endif /* INSECURE */\n#ifndef MALLOC_INSPECT_ALL\n#define MALLOC_INSPECT_ALL 0\n#endif /* MALLOC_INSPECT_ALL */\n#ifndef HAVE_MMAP\n#define HAVE_MMAP 1\n#endif /* HAVE_MMAP */\n#ifndef MMAP_CLEARS\n#define MMAP_CLEARS 1\n#endif /* MMAP_CLEARS */\n#ifndef HAVE_MREMAP\n#ifdef linux\n#define HAVE_MREMAP 1\n#define _GNU_SOURCE /* Turns on mremap() definition */\n#else /* linux */\n#define HAVE_MREMAP 0\n#endif /* linux */\n#endif /* HAVE_MREMAP */\n#ifndef MALLOC_FAILURE_ACTION\n#define MALLOC_FAILURE_ACTION errno = ENOMEM;\n#endif /* MALLOC_FAILURE_ACTION */\n#ifndef HAVE_MORECORE\n#if ONLY_MSPACES\n#define HAVE_MORECORE 0\n#else /* ONLY_MSPACES */\n#define HAVE_MORECORE 1\n#endif /* ONLY_MSPACES */\n#endif /* HAVE_MORECORE */\n#ifndef UNSIGNED_MORECORE\n#define UNSIGNED_MORECORE 0\n#endif /* UNSIGNED_MORECORE */\n#if UNSIGNED_MORECORE\n#define MORECORE_CANNOT_TRIM 1\n#endif /* UNSIGNED_MORECORE */\n#if !HAVE_MORECORE\n#define MORECORE_CONTIGUOUS 0\n#else /* !HAVE_MORECORE */\n#define MORECORE_DEFAULT sbrk\n#ifndef MORECORE_CONTIGUOUS\n#define MORECORE_CONTIGUOUS 1\n#endif /* MORECORE_CONTIGUOUS */\n#endif /* HAVE_MORECORE */\n#ifndef DEFAULT_GRANULARITY\n#if (MORECORE_CONTIGUOUS || defined(WIN32))\n#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */\n#else /* MORECORE_CONTIGUOUS */\n#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U)\n#endif /* MORECORE_CONTIGUOUS */\n#endif /* DEFAULT_GRANULARITY */\n#ifndef DEFAULT_TRIM_THRESHOLD\n#ifndef MORECORE_CANNOT_TRIM\n#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U)\n#else /* MORECORE_CANNOT_TRIM */\n#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T\n#endif /* MORECORE_CANNOT_TRIM */\n#endif /* DEFAULT_TRIM_THRESHOLD */\n#ifndef DEFAULT_MMAP_THRESHOLD\n#if HAVE_MMAP\n#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U)\n#else /* HAVE_MMAP */\n#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T\n#endif /* HAVE_MMAP */\n#endif /* DEFAULT_MMAP_THRESHOLD */\n#ifndef MAX_RELEASE_CHECK_RATE\n#if HAVE_MMAP\n#define MAX_RELEASE_CHECK_RATE 4095\n#else\n#define MAX_RELEASE_CHECK_RATE MAX_SIZE_T\n#endif /* HAVE_MMAP */\n#endif /* MAX_RELEASE_CHECK_RATE */\n#ifndef USE_BUILTIN_FFS\n#define USE_BUILTIN_FFS 0\n#endif /* USE_BUILTIN_FFS */\n#ifndef USE_DEV_RANDOM\n#define USE_DEV_RANDOM 0\n#endif /* USE_DEV_RANDOM */\n#ifndef NO_MALLINFO\n#define NO_MALLINFO 0\n#endif /* NO_MALLINFO */\n#ifndef MALLINFO_FIELD_TYPE\n#define MALLINFO_FIELD_TYPE size_t\n#endif /* MALLINFO_FIELD_TYPE */\n#ifndef NO_MALLOC_STATS\n#define NO_MALLOC_STATS 0\n#endif /* NO_MALLOC_STATS */\n#ifndef NO_SEGMENT_TRAVERSAL\n#define NO_SEGMENT_TRAVERSAL 0\n#endif /* NO_SEGMENT_TRAVERSAL */\n\n/*\n mallopt tuning options. SVID/XPG defines four standard parameter\n numbers for mallopt, normally defined in malloc.h. None of these\n are used in this malloc, so setting them has no effect. But this\n malloc does support the following options.\n */\n\n#define M_TRIM_THRESHOLD (-1)\n#define M_GRANULARITY (-2)\n#define M_MMAP_THRESHOLD (-3)\n\n/* ------------------------ Mallinfo declarations ------------------------ */\n\n#if !NO_MALLINFO\n/*\n This version of malloc supports the standard SVID/XPG mallinfo\n routine that returns a struct containing usage properties and\n statistics. It should work on any system that has a\n /usr/include/malloc.h defining struct mallinfo. The main\n declaration needed is the mallinfo struct that is returned (by-copy)\n by mallinfo(). The malloinfo struct contains a bunch of fields that\n are not even meaningful in this version of malloc. These fields are\n are instead filled by mallinfo() with other numbers that might be of\n interest.\n \n HAVE_USR_INCLUDE_MALLOC_H should be set if you have a\n /usr/include/malloc.h file that includes a declaration of struct\n mallinfo. If so, it is included; else a compliant version is\n declared below. These must be precisely the same for mallinfo() to\n work. The original SVID version of this struct, defined on most\n systems with mallinfo, declares all fields as ints. But some others\n define as unsigned long. If your system defines the fields using a\n type of different width than listed here, you MUST #include your\n system version and #define HAVE_USR_INCLUDE_MALLOC_H.\n */\n\n/* #define HAVE_USR_INCLUDE_MALLOC_H */\n\n#ifdef HAVE_USR_INCLUDE_MALLOC_H\n#include \"/usr/include/malloc.h\"\n#else /* HAVE_USR_INCLUDE_MALLOC_H */\n#ifndef STRUCT_MALLINFO_DECLARED\n/* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is defined */\n#define _STRUCT_MALLINFO\n#define STRUCT_MALLINFO_DECLARED 1\nstruct mallinfo {\n MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */\n MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */\n MALLINFO_FIELD_TYPE smblks; /* always 0 */\n MALLINFO_FIELD_TYPE hblks; /* always 0 */\n MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */\n MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */\n MALLINFO_FIELD_TYPE fsmblks; /* always 0 */\n MALLINFO_FIELD_TYPE uordblks; /* total allocated space */\n MALLINFO_FIELD_TYPE fordblks; /* total free space */\n MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */\n};\n#endif /* STRUCT_MALLINFO_DECLARED */\n#endif /* HAVE_USR_INCLUDE_MALLOC_H */\n#endif /* NO_MALLINFO */\n\n/*\n Try to persuade compilers to inline. The most critical functions for\n inlining are defined as macros, so these aren't used for them.\n */\n\n#ifndef FORCEINLINE\n#if defined(__GNUC__)\n#define FORCEINLINE __inline __attribute__ ((always_inline))\n#elif defined(_MSC_VER)\n#define FORCEINLINE __forceinline\n#endif\n#endif\n#ifndef NOINLINE\n#if defined(__GNUC__)\n#define NOINLINE __attribute__ ((noinline))\n#elif defined(_MSC_VER)\n#define NOINLINE __declspec(noinline)\n#else\n#define NOINLINE\n#endif\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#ifndef FORCEINLINE\n#define FORCEINLINE inline\n#endif\n#endif /* __cplusplus */\n#ifndef FORCEINLINE\n#define FORCEINLINE\n#endif\n \n#if !ONLY_MSPACES\n \n /* ------------------- Declarations of public routines ------------------- */\n \n#ifndef USE_DL_PREFIX\n// XXX Emscripten XXX\n#if defined(__EMSCRIPTEN__)\nvoid* __libc_malloc(size_t) __attribute__((weak, alias(\"dlmalloc\")));\nvoid __libc_free(void*) __attribute__((weak, alias(\"dlfree\")));\nvoid* __libc_calloc(size_t) __attribute__((weak, alias(\"dlcalloc\")));\nvoid* __libc_realloc(void*, size_t) __attribute__((weak, alias(\"dlrealloc\")));\nvoid* malloc(size_t) __attribute__((weak, alias(\"dlmalloc\")));\nvoid free(void*) __attribute__((weak, alias(\"dlfree\")));\nvoid* calloc(size_t, size_t) __attribute__((weak, alias(\"dlcalloc\")));\nvoid* realloc(void*, size_t) __attribute__((weak, alias(\"dlrealloc\")));\nvoid* realloc_in_place(void*, size_t) __attribute__((weak, alias(\"dlrealloc_in_place\")));\nvoid* memalign(size_t, size_t) __attribute__((weak, alias(\"dlmemalign\")));\nint posix_memalign(void**, size_t, size_t) __attribute__((weak, alias(\"dlposix_memalign\")));\nvoid* valloc(size_t) __attribute__((weak, alias(\"dlvalloc\")));\nvoid* pvalloc(size_t) __attribute__((weak, alias(\"dlpvalloc\")));\n#if !NO_MALLINFO\nstruct mallinfo mallinfo(void) __attribute__((weak, alias(\"dlmallinfo\")));\n#endif\nint mallopt(int, int) __attribute__((weak, alias(\"dlmallopt\")));\nint malloc_trim(size_t) __attribute__((weak, alias(\"dlmalloc_trim\")));\n#if !NO_MALLOC_STATS\nvoid malloc_stats(void) __attribute__((weak, alias(\"dlmalloc_stats\")));\n#endif\nsize_t malloc_usable_size(const void*) __attribute__((weak, alias(\"dlmalloc_usable_size\")));\nsize_t malloc_footprint(void) __attribute__((weak, alias(\"dlmalloc_footprint\")));\nsize_t malloc_max_footprint(void) __attribute__((weak, alias(\"dlmalloc_max_footprint\")));\nsize_t malloc_footprint_limit(void) __attribute__((weak, alias(\"dlmalloc_footprint_limit\")));\nsize_t malloc_set_footprint_limit(size_t bytes) __attribute__((weak, alias(\"dlmalloc_set_footprint_limit\")));\n#if MALLOC_INSPECT_ALL\nvoid malloc_inspect_all(void(*handler)(void*, void *, size_t, void*), void* arg) __attribute__((weak, alias(\"dlmalloc_inspect_all\")));\n#endif\nvoid** independent_calloc(size_t, size_t, void**) __attribute__((weak, alias(\"dlindependent_calloc\")));\nvoid** independent_comalloc(size_t, size_t*, void**) __attribute__((weak, alias(\"dlindependent_comalloc\")));\nsize_t bulk_free(void**, size_t n_elements) __attribute__((weak, alias(\"dlbulk_free\")));\n#endif /*__EMSCRIPTEN__*/\n#endif /* USE_DL_PREFIX */\n \n /*\n malloc(size_t n)\n Returns a pointer to a newly allocated chunk of at least n bytes, or\n null if no space is available, in which case errno is set to ENOMEM\n on ANSI C systems.\n \n If n is zero, malloc returns a minimum-sized chunk. (The minimum\n size is 16 bytes on most 32bit systems, and 32 bytes on 64bit\n systems.) Note that size_t is an unsigned type, so calls with\n arguments that would be negative if signed are interpreted as\n requests for huge amounts of space, which will often fail. The\n maximum supported value of n differs across systems, but is in all\n cases less than the maximum representable value of a size_t.\n */\n DLMALLOC_EXPORT void* dlmalloc(size_t);\n \n /*\n free(void* p)\n Releases the chunk of memory pointed to by p, that had been previously\n allocated using malloc or a related routine such as realloc.\n It has no effect if p is null. If p was not malloced or already\n freed, free(p) will by default cause the current program to abort.\n */\n DLMALLOC_EXPORT void dlfree(void*);\n \n /*\n calloc(size_t n_elements, size_t element_size);\n Returns a pointer to n_elements * element_size bytes, with all locations\n set to zero.\n */\n DLMALLOC_EXPORT void* dlcalloc(size_t, size_t);\n \n /*\n realloc(void* p, size_t n)\n Returns a pointer to a chunk of size n that contains the same data\n as does chunk p up to the minimum of (n, p's size) bytes, or null\n if no space is available.\n \n The returned pointer may or may not be the same as p. The algorithm\n prefers extending p in most cases when possible, otherwise it\n employs the equivalent of a malloc-copy-free sequence.\n \n If p is null, realloc is equivalent to malloc.\n \n If space is not available, realloc returns null, errno is set (if on\n ANSI) and p is NOT freed.\n \n if n is for fewer bytes than already held by p, the newly unused\n space is lopped off and freed if possible. realloc with a size\n argument of zero (re)allocates a minimum-sized chunk.\n \n The old unix realloc convention of allowing the last-free'd chunk\n to be used as an argument to realloc is not supported.\n */\n DLMALLOC_EXPORT void* dlrealloc(void*, size_t);\n \n /*\n realloc_in_place(void* p, size_t n)\n Resizes the space allocated for p to size n, only if this can be\n done without moving p (i.e., only if there is adjacent space\n available if n is greater than p's current allocated size, or n is\n less than or equal to p's size). This may be used instead of plain\n realloc if an alternative allocation strategy is needed upon failure\n to expand space; for example, reallocation of a buffer that must be\n memory-aligned or cleared. You can use realloc_in_place to trigger\n these alternatives only when needed.\n \n Returns p if successful; otherwise null.\n */\n DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t);\n \n /*\n memalign(size_t alignment, size_t n);\n Returns a pointer to a newly allocated chunk of n bytes, aligned\n in accord with the alignment argument.\n \n The alignment argument should be a power of two. If the argument is\n not a power of two, the nearest greater power is used.\n 8-byte alignment is guaranteed by normal malloc calls, so don't\n bother calling memalign with an argument of 8 or less.\n \n Overreliance on memalign is a sure way to fragment space.\n */\n DLMALLOC_EXPORT void* dlmemalign(size_t, size_t);\n \n /*\n int posix_memalign(void** pp, size_t alignment, size_t n);\n Allocates a chunk of n bytes, aligned in accord with the alignment\n argument. Differs from memalign only in that it (1) assigns the\n allocated memory to *pp rather than returning it, (2) fails and\n returns EINVAL if the alignment is not a power of two (3) fails and\n returns ENOMEM if memory cannot be allocated.\n */\n DLMALLOC_EXPORT int dlposix_memalign(void**, size_t, size_t);\n \n /*\n valloc(size_t n);\n Equivalent to memalign(pagesize, n), where pagesize is the page\n size of the system. If the pagesize is unknown, 4096 is used.\n */\n DLMALLOC_EXPORT void* dlvalloc(size_t);\n \n /*\n mallopt(int parameter_number, int parameter_value)\n Sets tunable parameters The format is to provide a\n (parameter-number, parameter-value) pair. mallopt then sets the\n corresponding parameter to the argument value if it can (i.e., so\n long as the value is meaningful), and returns 1 if successful else\n 0. To workaround the fact that mallopt is specified to use int,\n not size_t parameters, the value -1 is specially treated as the\n maximum unsigned size_t value.\n \n SVID/XPG/ANSI defines four standard param numbers for mallopt,\n normally defined in malloc.h. None of these are use in this malloc,\n so setting them has no effect. But this malloc also supports other\n options in mallopt. See below for details. Briefly, supported\n parameters are as follows (listed defaults are for \"typical\"\n configurations).\n \n Symbol param # default allowed param values\n M_TRIM_THRESHOLD -1 2*1024*1024 any (-1 disables)\n M_GRANULARITY -2 page size any power of 2 >= page size\n M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support)\n */\n DLMALLOC_EXPORT int dlmallopt(int, int);\n \n /*\n malloc_footprint();\n Returns the number of bytes obtained from the system. The total\n number of bytes allocated by malloc, realloc etc., is less than this\n value. Unlike mallinfo, this function returns only a precomputed\n result, so can be called frequently to monitor memory consumption.\n Even if locks are otherwise defined, this function does not use them,\n so results might not be up to date.\n */\n DLMALLOC_EXPORT size_t dlmalloc_footprint(void);\n \n /*\n malloc_max_footprint();\n Returns the maximum number of bytes obtained from the system. This\n value will be greater than current footprint if deallocated space\n has been reclaimed by the system. The peak number of bytes allocated\n by malloc, realloc etc., is less than this value. Unlike mallinfo,\n this function returns only a precomputed result, so can be called\n frequently to monitor memory consumption. Even if locks are\n otherwise defined, this function does not use them, so results might\n not be up to date.\n */\n DLMALLOC_EXPORT size_t dlmalloc_max_footprint(void);\n \n /*\n malloc_footprint_limit();\n Returns the number of bytes that the heap is allowed to obtain from\n the system, returning the last value returned by\n malloc_set_footprint_limit, or the maximum size_t value if\n never set. The returned value reflects a permission. There is no\n guarantee that this number of bytes can actually be obtained from\n the system.\n */\n DLMALLOC_EXPORT size_t dlmalloc_footprint_limit();\n \n /*\n malloc_set_footprint_limit();\n Sets the maximum number of bytes to obtain from the system, causing\n failure returns from malloc and related functions upon attempts to\n exceed this value. The argument value may be subject to page\n rounding to an enforceable limit; this actual value is returned.\n Using an argument of the maximum possible size_t effectively\n disables checks. If the argument is less than or equal to the\n current malloc_footprint, then all future allocations that require\n additional system memory will fail. However, invocation cannot\n retroactively deallocate existing used memory.\n */\n DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes);\n \n#if MALLOC_INSPECT_ALL\n /*\n malloc_inspect_all(void(*handler)(void *start,\n void *end,\n size_t used_bytes,\n void* callback_arg),\n void* arg);\n Traverses the heap and calls the given handler for each managed\n region, skipping all bytes that are (or may be) used for bookkeeping\n purposes. Traversal does not include include chunks that have been\n directly memory mapped. Each reported region begins at the start\n address, and continues up to but not including the end address. The\n first used_bytes of the region contain allocated data. If\n used_bytes is zero, the region is unallocated. The handler is\n invoked with the given callback argument. If locks are defined, they\n are held during the entire traversal. It is a bad idea to invoke\n other malloc functions from within the handler.\n \n For example, to count the number of in-use chunks with size greater\n than 1000, you could write:\n static int count = 0;\n void count_chunks(void* start, void* end, size_t used, void* arg) {\n if (used >= 1000) ++count;\n }\n then:\n malloc_inspect_all(count_chunks, NULL);\n \n malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined.\n */\n DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*),\n void* arg);\n \n#endif /* MALLOC_INSPECT_ALL */\n \n#if !NO_MALLINFO\n /*\n mallinfo()\n Returns (by copy) a struct containing various summary statistics:\n \n arena: current total non-mmapped bytes allocated from system\n ordblks: the number of free chunks\n smblks: always zero.\n hblks: current number of mmapped regions\n hblkhd: total bytes held in mmapped regions\n usmblks: the maximum total allocated space. This will be greater\n than current total if trimming has occurred.\n fsmblks: always zero\n uordblks: current total allocated space (normal or mmapped)\n fordblks: total free space\n keepcost: the maximum number of bytes that could ideally be released\n back to system via malloc_trim. (\"ideally\" means that\n it ignores page restrictions etc.)\n \n Because these fields are ints, but internal bookkeeping may\n be kept as longs, the reported values may wrap around zero and\n thus be inaccurate.\n */\n DLMALLOC_EXPORT struct mallinfo dlmallinfo(void);\n#endif /* NO_MALLINFO */\n \n /*\n independent_calloc(size_t n_elements, size_t element_size, void* chunks[]);\n \n independent_calloc is similar to calloc, but instead of returning a\n single cleared space, it returns an array of pointers to n_elements\n independent elements that can hold contents of size elem_size, each\n of which starts out cleared, and can be independently freed,\n realloc'ed etc. The elements are guaranteed to be adjacently\n allocated (this is not guaranteed to occur with multiple callocs or\n mallocs), which may also improve cache locality in some\n applications.\n \n The \"chunks\" argument is optional (i.e., may be null, which is\n probably the most typical usage). If it is null, the returned array\n is itself dynamically allocated and should also be freed when it is\n no longer needed. Otherwise, the chunks array must be of at least\n n_elements in length. It is filled in with the pointers to the\n chunks.\n \n In either case, independent_calloc returns this pointer array, or\n null if the allocation failed. If n_elements is zero and \"chunks\"\n is null, it returns a chunk representing an array with zero elements\n (which should be freed if not wanted).\n \n Each element must be freed when it is no longer needed. This can be\n done all at once using bulk_free.\n \n independent_calloc simplifies and speeds up implementations of many\n kinds of pools. It may also be useful when constructing large data\n structures that initially have a fixed number of fixed-sized nodes,\n but the number is not known at compile time, and some of the nodes\n may later need to be freed. For example:\n \n struct Node { int item; struct Node* next; };\n \n struct Node* build_list() {\n struct Node** pool;\n int n = read_number_of_nodes_needed();\n if (n <= 0) return 0;\n pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0);\n if (pool == 0) die();\n // organize into a linked list...\n struct Node* first = pool[0];\n for (i = 0; i < n-1; ++i)\n pool[i]->next = pool[i+1];\n free(pool); // Can now free the array (or not, if it is needed later)\n return first;\n }\n */\n DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**);\n \n /*\n independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]);\n \n independent_comalloc allocates, all at once, a set of n_elements\n chunks with sizes indicated in the \"sizes\" array. It returns\n an array of pointers to these elements, each of which can be\n independently freed, realloc'ed etc. The elements are guaranteed to\n be adjacently allocated (this is not guaranteed to occur with\n multiple callocs or mallocs), which may also improve cache locality\n in some applications.\n \n The \"chunks\" argument is optional (i.e., may be null). If it is null\n the returned array is itself dynamically allocated and should also\n be freed when it is no longer needed. Otherwise, the chunks array\n must be of at least n_elements in length. It is filled in with the\n pointers to the chunks.\n \n In either case, independent_comalloc returns this pointer array, or\n null if the allocation failed. If n_elements is zero and chunks is\n null, it returns a chunk representing an array with zero elements\n (which should be freed if not wanted).\n \n Each element must be freed when it is no longer needed. This can be\n done all at once using bulk_free.\n \n independent_comallac differs from independent_calloc in that each\n element may have a different size, and also that it does not\n automatically clear elements.\n \n independent_comalloc can be used to speed up allocation in cases\n where several structs or objects must always be allocated at the\n same time. For example:\n \n struct Head { ... }\n struct Foot { ... }\n \n void send_message(char* msg) {\n int msglen = strlen(msg);\n size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) };\n void* chunks[3];\n if (independent_comalloc(3, sizes, chunks) == 0)\n die();\n struct Head* head = (struct Head*)(chunks[0]);\n char* body = (char*)(chunks[1]);\n struct Foot* foot = (struct Foot*)(chunks[2]);\n // ...\n }\n \n In general though, independent_comalloc is worth using only for\n larger values of n_elements. For small values, you probably won't\n detect enough difference from series of malloc calls to bother.\n \n Overuse of independent_comalloc can increase overall memory usage,\n since it cannot reuse existing noncontiguous small chunks that\n might be available for some of the elements.\n */\n DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**);\n \n /*\n bulk_free(void* array[], size_t n_elements)\n Frees and clears (sets to null) each non-null pointer in the given\n array. This is likely to be faster than freeing them one-by-one.\n If footers are used, pointers that have been allocated in different\n mspaces are not freed or cleared, and the count of all such pointers\n is returned. For large arrays of pointers with poor locality, it\n may be worthwhile to sort this array before calling bulk_free.\n */\n DLMALLOC_EXPORT size_t dlbulk_free(void**, size_t n_elements);\n \n /*\n pvalloc(size_t n);\n Equivalent to valloc(minimum-page-that-holds(n)), that is,\n round up n to nearest pagesize.\n */\n DLMALLOC_EXPORT void* dlpvalloc(size_t);\n \n /*\n malloc_trim(size_t pad);\n \n If possible, gives memory back to the system (via negative arguments\n to sbrk) if there is unused memory at the `high' end of the malloc\n pool or in unused MMAP segments. You can call this after freeing\n large blocks of memory to potentially reduce the system-level memory\n requirements of a program. However, it cannot guarantee to reduce\n memory. Under some allocation patterns, some large free blocks of\n memory will be locked between two used chunks, so they cannot be\n given back to the system.\n \n The `pad' argument to malloc_trim represents the amount of free\n trailing space to leave untrimmed. If this argument is zero, only\n the minimum amount of memory to maintain internal data structures\n will be left. Non-zero arguments can be supplied to maintain enough\n trailing space to service future expected allocations without having\n to re-obtain memory from the system.\n \n Malloc_trim returns 1 if it actually released any memory, else 0.\n */\n DLMALLOC_EXPORT int dlmalloc_trim(size_t);\n \n /*\n malloc_stats();\n Prints on stderr the amount of space obtained from the system (both\n via sbrk and mmap), the maximum amount (which may be more than\n current if malloc_trim and/or munmap got called), and the current\n number of bytes allocated via malloc (or realloc, etc) but not yet\n freed. Note that this is the number of bytes allocated, not the\n number requested. It will be larger than the number requested\n because of alignment and bookkeeping overhead. Because it includes\n alignment wastage as being in use, this figure may be greater than\n zero even when no user-level chunks are allocated.\n \n The reported current and maximum system memory can be inaccurate if\n a program makes other calls to system memory allocation functions\n (normally sbrk) outside of malloc.\n \n malloc_stats prints only the most commonly interesting statistics.\n More information can be obtained by calling mallinfo.\n */\n DLMALLOC_EXPORT void dlmalloc_stats(void);\n \n /*\n malloc_usable_size(void* p);\n \n Returns the number of bytes you can actually use in\n an allocated chunk, which may be more than you requested (although\n often not) due to alignment and minimum size constraints.\n You can use this many bytes without worrying about\n overwriting other allocated objects. This is not a particularly great\n programming practice. malloc_usable_size can be more useful in\n debugging and assertions, for example:\n \n p = malloc(n);\n assert(malloc_usable_size(p) >= 256);\n */\n /* XXX EMSCRIPTEN: mark for export (and therefore weak) */\n DLMALLOC_EXPORT size_t dlmalloc_usable_size(void*);\n \n#endif /* ONLY_MSPACES */\n \n#if MSPACES\n \n /*\n mspace is an opaque type representing an independent\n region of space that supports mspace_malloc, etc.\n */\n typedef void* mspace;\n \n /*\n create_mspace creates and returns a new independent space with the\n given initial capacity, or, if 0, the default granularity size. It\n returns null if there is no system memory available to create the\n space. If argument locked is non-zero, the space uses a separate\n lock to control access. The capacity of the space will grow\n dynamically as needed to service mspace_malloc requests. You can\n control the sizes of incremental increases of this space by\n compiling with a different DEFAULT_GRANULARITY or dynamically\n setting with mallopt(M_GRANULARITY, value).\n */\n DLMALLOC_EXPORT mspace create_mspace(size_t capacity, int locked);\n \n /*\n destroy_mspace destroys the given space, and attempts to return all\n of its memory back to the system, returning the total number of\n bytes freed. After destruction, the results of access to all memory\n used by the space become undefined.\n */\n DLMALLOC_EXPORT size_t destroy_mspace(mspace msp);\n \n /*\n create_mspace_with_base uses the memory supplied as the initial base\n of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this\n space is used for bookkeeping, so the capacity must be at least this\n large. (Otherwise 0 is returned.) When this initial space is\n exhausted, additional memory will be obtained from the system.\n Destroying this space will deallocate all additionally allocated\n space (if possible) but not the initial base.\n */\n DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int locked);\n \n /*\n mspace_track_large_chunks controls whether requests for large chunks\n are allocated in their own untracked mmapped regions, separate from\n others in this mspace. By default large chunks are not tracked,\n which reduces fragmentation. However, such chunks are not\n necessarily released to the system upon destroy_mspace. Enabling\n tracking by setting to true may increase fragmentation, but avoids\n leakage when relying on destroy_mspace to release all memory\n allocated using this space. The function returns the previous\n setting.\n */\n DLMALLOC_EXPORT int mspace_track_large_chunks(mspace msp, int enable);\n \n \n /*\n mspace_malloc behaves as malloc, but operates within\n the given space.\n */\n DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes);\n \n /*\n mspace_free behaves as free, but operates within\n the given space.\n \n If compiled with FOOTERS==1, mspace_free is not actually needed.\n free may be called instead of mspace_free because freed chunks from\n any space are handled by their originating spaces.\n */\n DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem);\n \n /*\n mspace_realloc behaves as realloc, but operates within\n the given space.\n \n If compiled with FOOTERS==1, mspace_realloc is not actually\n needed. realloc may be called instead of mspace_realloc because\n realloced chunks from any space are handled by their originating\n spaces.\n */\n DLMALLOC_EXPORT void* mspace_realloc(mspace msp, void* mem, size_t newsize);\n \n /*\n mspace_calloc behaves as calloc, but operates within\n the given space.\n */\n DLMALLOC_EXPORT void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size);\n \n /*\n mspace_memalign behaves as memalign, but operates within\n the given space.\n */\n DLMALLOC_EXPORT void* mspace_memalign(mspace msp, size_t alignment, size_t bytes);\n \n /*\n mspace_independent_calloc behaves as independent_calloc, but\n operates within the given space.\n */\n DLMALLOC_EXPORT void** mspace_independent_calloc(mspace msp, size_t n_elements,\n size_t elem_size, void* chunks[]);\n \n /*\n mspace_independent_comalloc behaves as independent_comalloc, but\n operates within the given space.\n */\n DLMALLOC_EXPORT void** mspace_independent_comalloc(mspace msp, size_t n_elements,\n size_t sizes[], void* chunks[]);\n \n /*\n mspace_footprint() returns the number of bytes obtained from the\n system for this space.\n */\n DLMALLOC_EXPORT size_t mspace_footprint(mspace msp);\n \n /*\n mspace_max_footprint() returns the peak number of bytes obtained from the\n system for this space.\n */\n DLMALLOC_EXPORT size_t mspace_max_footprint(mspace msp);\n \n \n#if !NO_MALLINFO\n /*\n mspace_mallinfo behaves as mallinfo, but reports properties of\n the given space.\n */\n DLMALLOC_EXPORT struct mallinfo mspace_mallinfo(mspace msp);\n#endif /* NO_MALLINFO */\n \n /*\n malloc_usable_size(void* p) behaves the same as malloc_usable_size;\n */\n DLMALLOC_EXPORT size_t mspace_usable_size(const void* mem);\n \n /*\n mspace_malloc_stats behaves as malloc_stats, but reports\n properties of the given space.\n */\n DLMALLOC_EXPORT void mspace_malloc_stats(mspace msp);\n \n /*\n mspace_trim behaves as malloc_trim, but\n operates within the given space.\n */\n DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad);\n \n /*\n An alias for mallopt.\n */\n DLMALLOC_EXPORT int mspace_mallopt(int, int);\n \n#endif /* MSPACES */\n \n#ifdef __cplusplus\n} /* end of extern \"C\" */\n#endif /* __cplusplus */\n\n/*\n ========================================================================\n To make a fully customizable malloc.h header file, cut everything\n above this line, put into file malloc.h, edit to suit, and #include it\n on the next line, as well as in programs that use this malloc.\n ========================================================================\n */\n\n/* #include \"malloc.h\" */\n\n/*------------------------------ internal #includes ---------------------- */\n\n#ifdef _MSC_VER\n#pragma warning( disable : 4146 ) /* no \"unsigned\" warnings */\n#endif /* _MSC_VER */\n#if !NO_MALLOC_STATS\n#include <stdio.h> /* for printing in malloc_stats */\n#endif /* NO_MALLOC_STATS */\n#ifndef LACKS_ERRNO_H\n#include <errno.h> /* for MALLOC_FAILURE_ACTION */\n#endif /* LACKS_ERRNO_H */\n#ifdef DEBUG\n#if ABORT_ON_ASSERT_FAILURE\n#undef assert\n#define assert(x) if(!(x)) ABORT\n#else /* ABORT_ON_ASSERT_FAILURE */\n#include <assert.h>\n#endif /* ABORT_ON_ASSERT_FAILURE */\n#else /* DEBUG */\n#ifndef assert\n#define assert(x)\n#endif\n#define DEBUG 0\n#endif /* DEBUG */\n#if !defined(WIN32) && !defined(LACKS_TIME_H)\n#include <time.h> /* for magic initialization */\n#endif /* WIN32 */\n#ifndef LACKS_STDLIB_H\n#include <stdlib.h> /* for abort() */\n#endif /* LACKS_STDLIB_H */\n#ifndef LACKS_STRING_H\n#include <string.h> /* for memset etc */\n#endif /* LACKS_STRING_H */\n#if USE_BUILTIN_FFS\n#ifndef LACKS_STRINGS_H\n#include <strings.h> /* for ffs */\n#endif /* LACKS_STRINGS_H */\n#endif /* USE_BUILTIN_FFS */\n#if HAVE_MMAP\n#ifndef LACKS_SYS_MMAN_H\n/* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */\n#if (defined(linux) && !defined(__USE_GNU))\n#define __USE_GNU 1\n#include <sys/mman.h> /* for mmap */\n#undef __USE_GNU\n#else\n#include <sys/mman.h> /* for mmap */\n#endif /* linux */\n#endif /* LACKS_SYS_MMAN_H */\n#ifndef LACKS_FCNTL_H\n#include <fcntl.h>\n#endif /* LACKS_FCNTL_H */\n#endif /* HAVE_MMAP */\n#ifndef LACKS_UNISTD_H\n#include <unistd.h> /* for sbrk, sysconf */\n#else /* LACKS_UNISTD_H */\n#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)\nextern void* sbrk(ptrdiff_t);\n#endif /* FreeBSD etc */\n#endif /* LACKS_UNISTD_H */\n\n/* Declarations for locking */\n#if USE_LOCKS\n#ifndef WIN32\n#if defined (__SVR4) && defined (__sun) /* solaris */\n#include <thread.h>\n#elif !defined(LACKS_SCHED_H)\n#include <sched.h>\n#endif /* solaris or LACKS_SCHED_H */\n#if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || !USE_SPIN_LOCKS\n#include <pthread.h>\n#endif /* USE_RECURSIVE_LOCKS ... */\n#elif defined(_MSC_VER)\n#ifndef _M_AMD64\n/* These are already defined on AMD64 builds */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, LONG Comp);\n LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value);\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n#endif /* _M_AMD64 */\n#pragma intrinsic (_InterlockedCompareExchange)\n#pragma intrinsic (_InterlockedExchange)\n#define interlockedcompareexchange _InterlockedCompareExchange\n#define interlockedexchange _InterlockedExchange\n#elif defined(WIN32) && defined(__GNUC__)\n#define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b)\n#define interlockedexchange __sync_lock_test_and_set\n#endif /* Win32 */\n#else /* USE_LOCKS */\n#endif /* USE_LOCKS */\n\n#ifndef LOCK_AT_FORK\n#define LOCK_AT_FORK 0\n#endif\n\n/* Declarations for bit scanning on win32 */\n#if defined(_MSC_VER) && _MSC_VER>=1300\n#ifndef BitScanForward /* Try to avoid pulling in WinNT.h */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n unsigned char _BitScanForward(unsigned long *index, unsigned long mask);\n unsigned char _BitScanReverse(unsigned long *index, unsigned long mask);\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#define BitScanForward _BitScanForward\n#define BitScanReverse _BitScanReverse\n#pragma intrinsic(_BitScanForward)\n#pragma intrinsic(_BitScanReverse)\n#endif /* BitScanForward */\n#endif /* defined(_MSC_VER) && _MSC_VER>=1300 */\n\n#ifndef WIN32\n#ifndef malloc_getpagesize\n# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */\n# ifndef _SC_PAGE_SIZE\n# define _SC_PAGE_SIZE _SC_PAGESIZE\n# endif\n# endif\n# ifdef _SC_PAGE_SIZE\n# if defined(__EMSCRIPTEN__)\n# define malloc_getpagesize (4096) /* avoid sysconf calls during startup */\n# else\n# define malloc_getpagesize sysconf(_SC_PAGE_SIZE)\n# endif\n# else\n# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE)\nextern size_t getpagesize();\n# define malloc_getpagesize getpagesize()\n# else\n# ifdef WIN32 /* use supplied emulation of getpagesize */\n# define malloc_getpagesize getpagesize()\n# else\n# ifndef LACKS_SYS_PARAM_H\n# include <sys/param.h>\n# endif\n# ifdef EXEC_PAGESIZE\n# define malloc_getpagesize EXEC_PAGESIZE\n# else\n# ifdef NBPG\n# ifndef CLSIZE\n# define malloc_getpagesize NBPG\n# else\n# define malloc_getpagesize (NBPG * CLSIZE)\n# endif\n# else\n# ifdef NBPC\n# define malloc_getpagesize NBPC\n# else\n# ifdef PAGESIZE\n# define malloc_getpagesize PAGESIZE\n# else /* just guess */\n# define malloc_getpagesize ((size_t)4096U)\n# endif\n# endif\n# endif\n# endif\n# endif\n# endif\n# endif\n#endif\n#endif\n\n/* ------------------- size_t and alignment properties -------------------- */\n\n/* The byte and bit size of a size_t */\n#define SIZE_T_SIZE (sizeof(size_t))\n#define SIZE_T_BITSIZE (sizeof(size_t) << 3)\n\n/* Some constants coerced to size_t */\n/* Annoying but necessary to avoid errors on some platforms */\n#define SIZE_T_ZERO ((size_t)0)\n#define SIZE_T_ONE ((size_t)1)\n#define SIZE_T_TWO ((size_t)2)\n#define SIZE_T_FOUR ((size_t)4)\n#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1)\n#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2)\n#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)\n#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U)\n\n/* The bit mask value corresponding to MALLOC_ALIGNMENT */\n#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE)\n\n/* True if address a has acceptable alignment */\n#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0)\n\n/* the number of bytes to offset an address to align it */\n#define align_offset(A)\\\n((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\\\n((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK))\n\n/* -------------------------- MMAP preliminaries ------------------------- */\n\n/*\n If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and\n checks to fail so compiler optimizer can delete code rather than\n using so many \"#if\"s.\n */\n\n\n/* MORECORE and MMAP must return MFAIL on failure */\n#define MFAIL ((void*)(MAX_SIZE_T))\n#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */\n\n#if HAVE_MMAP\n\n#ifndef WIN32\n#define MUNMAP_DEFAULT(a, s) munmap((a), (s))\n#define MMAP_PROT (PROT_READ|PROT_WRITE)\n#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)\n#define MAP_ANONYMOUS MAP_ANON\n#endif /* MAP_ANON */\n#ifdef MAP_ANONYMOUS\n#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS)\n#define MMAP_DEFAULT(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0)\n#else /* MAP_ANONYMOUS */\n/*\n Nearly all versions of mmap support MAP_ANONYMOUS, so the following\n is unlikely to be needed, but is supplied just in case.\n */\n#define MMAP_FLAGS (MAP_PRIVATE)\nstatic int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */\n#define MMAP_DEFAULT(s) ((dev_zero_fd < 0) ? \\\n(dev_zero_fd = open(\"/dev/zero\", O_RDWR), \\\nmmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \\\nmmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0))\n#endif /* MAP_ANONYMOUS */\n\n#define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s)\n\n#else /* WIN32 */\n\n/* Win32 MMAP via VirtualAlloc */\nstatic FORCEINLINE void* win32mmap(size_t size) {\n void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);\n return (ptr != 0)? ptr: MFAIL;\n}\n\n/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */\nstatic FORCEINLINE void* win32direct_mmap(size_t size) {\n void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN,\n PAGE_READWRITE);\n return (ptr != 0)? ptr: MFAIL;\n}\n\n/* This function supports releasing coalesed segments */\nstatic FORCEINLINE int win32munmap(void* ptr, size_t size) {\n MEMORY_BASIC_INFORMATION minfo;\n char* cptr = (char*)ptr;\n while (size) {\n if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0)\n return -1;\n if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr ||\n minfo.State != MEM_COMMIT || minfo.RegionSize > size)\n return -1;\n if (VirtualFree(cptr, 0, MEM_RELEASE) == 0)\n return -1;\n cptr += minfo.RegionSize;\n size -= minfo.RegionSize;\n }\n return 0;\n}\n\n#define MMAP_DEFAULT(s) win32mmap(s)\n#define MUNMAP_DEFAULT(a, s) win32munmap((a), (s))\n#define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s)\n#endif /* WIN32 */\n#endif /* HAVE_MMAP */\n\n#if HAVE_MREMAP\n#ifndef WIN32\n#define MREMAP_DEFAULT(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))\n#endif /* WIN32 */\n#endif /* HAVE_MREMAP */\n\n/**\n * Define CALL_MORECORE\n */\n#if HAVE_MORECORE\n#ifdef MORECORE\n#define CALL_MORECORE(S) MORECORE(S)\n#else /* MORECORE */\n#define CALL_MORECORE(S) MORECORE_DEFAULT(S)\n#endif /* MORECORE */\n#else /* HAVE_MORECORE */\n#define CALL_MORECORE(S) MFAIL\n#endif /* HAVE_MORECORE */\n\n/**\n * Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP\n */\n#if HAVE_MMAP\n#define USE_MMAP_BIT (SIZE_T_ONE)\n\n#ifdef MMAP\n#define CALL_MMAP(s) MMAP(s)\n#else /* MMAP */\n#define CALL_MMAP(s) MMAP_DEFAULT(s)\n#endif /* MMAP */\n#ifdef MUNMAP\n#define CALL_MUNMAP(a, s) MUNMAP((a), (s))\n#else /* MUNMAP */\n#define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s))\n#endif /* MUNMAP */\n#ifdef DIRECT_MMAP\n#define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s)\n#else /* DIRECT_MMAP */\n#define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s)\n#endif /* DIRECT_MMAP */\n#else /* HAVE_MMAP */\n#define USE_MMAP_BIT (SIZE_T_ZERO)\n\n#define MMAP(s) MFAIL\n#define MUNMAP(a, s) (-1)\n#define DIRECT_MMAP(s) MFAIL\n#define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s)\n#define CALL_MMAP(s) MMAP(s)\n#define CALL_MUNMAP(a, s) MUNMAP((a), (s))\n#endif /* HAVE_MMAP */\n\n/**\n * Define CALL_MREMAP\n */\n#if HAVE_MMAP && HAVE_MREMAP\n#ifdef MREMAP\n#define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv))\n#else /* MREMAP */\n#define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv))\n#endif /* MREMAP */\n#else /* HAVE_MMAP && HAVE_MREMAP */\n#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL\n#endif /* HAVE_MMAP && HAVE_MREMAP */\n\n/* mstate bit set if continguous morecore disabled or failed */\n#define USE_NONCONTIGUOUS_BIT (4U)\n\n/* segment bit set in create_mspace_with_base */\n#define EXTERN_BIT (8U)\n\n\n/* --------------------------- Lock preliminaries ------------------------ */\n\n/*\n When locks are defined, there is one global lock, plus\n one per-mspace lock.\n \n The global lock_ensures that mparams.magic and other unique\n mparams values are initialized only once. It also protects\n sequences of calls to MORECORE. In many cases sys_alloc requires\n two calls, that should not be interleaved with calls by other\n threads. This does not protect against direct calls to MORECORE\n by other threads not using this lock, so there is still code to\n cope the best we can on interference.\n \n Per-mspace locks surround calls to malloc, free, etc.\n By default, locks are simple non-reentrant mutexes.\n \n Because lock-protected regions generally have bounded times, it is\n OK to use the supplied simple spinlocks. Spinlocks are likely to\n improve performance for lightly contended applications, but worsen\n performance under heavy contention.\n \n If USE_LOCKS is > 1, the definitions of lock routines here are\n bypassed, in which case you will need to define the type MLOCK_T,\n and at least INITIAL_LOCK, DESTROY_LOCK, ACQUIRE_LOCK, RELEASE_LOCK\n and TRY_LOCK. You must also declare a\n static MLOCK_T malloc_global_mutex = { initialization values };.\n \n */\n\n#if !USE_LOCKS\n#define USE_LOCK_BIT (0U)\n#define INITIAL_LOCK(l) (0)\n#define DESTROY_LOCK(l) (0)\n#define ACQUIRE_MALLOC_GLOBAL_LOCK()\n#define RELEASE_MALLOC_GLOBAL_LOCK()\n\n#else\n#if USE_LOCKS > 1\n/* ----------------------- User-defined locks ------------------------ */\n/* Define your own lock implementation here */\n/* #define INITIAL_LOCK(lk) ... */\n/* #define DESTROY_LOCK(lk) ... */\n/* #define ACQUIRE_LOCK(lk) ... */\n/* #define RELEASE_LOCK(lk) ... */\n/* #define TRY_LOCK(lk) ... */\n/* static MLOCK_T malloc_global_mutex = ... */\n\n#elif USE_SPIN_LOCKS\n\n/* First, define CAS_LOCK and CLEAR_LOCK on ints */\n/* Note CAS_LOCK defined to return 0 on success */\n\n#if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))\n#define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1)\n#define CLEAR_LOCK(sl) __sync_lock_release(sl)\n\n#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))\n/* Custom spin locks for older gcc on x86 */\nstatic FORCEINLINE int x86_cas_lock(int *sl) {\n int ret;\n int val = 1;\n int cmp = 0;\n __asm__ __volatile__ (\"lock; cmpxchgl %1, %2\"\n : \"=a\" (ret)\n : \"r\" (val), \"m\" (*(sl)), \"0\"(cmp)\n : \"memory\", \"cc\");\n return ret;\n}\n\nstatic FORCEINLINE void x86_clear_lock(int* sl) {\n assert(*sl != 0);\n int prev = 0;\n int ret;\n __asm__ __volatile__ (\"lock; xchgl %0, %1\"\n : \"=r\" (ret)\n : \"m\" (*(sl)), \"0\"(prev)\n : \"memory\");\n}\n\n#define CAS_LOCK(sl) x86_cas_lock(sl)\n#define CLEAR_LOCK(sl) x86_clear_lock(sl)\n\n#else /* Win32 MSC */\n#define CAS_LOCK(sl) interlockedexchange(sl, (LONG)1)\n#define CLEAR_LOCK(sl) interlockedexchange (sl, (LONG)0)\n\n#endif /* ... gcc spins locks ... */\n\n/* How to yield for a spin lock */\n#define SPINS_PER_YIELD 63\n#if defined(_MSC_VER)\n#define SLEEP_EX_DURATION 50 /* delay for yield/sleep */\n#define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE)\n#elif defined (__SVR4) && defined (__sun) /* solaris */\n#define SPIN_LOCK_YIELD thr_yield();\n#elif !defined(LACKS_SCHED_H)\n#define SPIN_LOCK_YIELD sched_yield();\n#else\n#define SPIN_LOCK_YIELD\n#endif /* ... yield ... */\n\n#if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0\n/* Plain spin locks use single word (embedded in malloc_states) */\nstatic int spin_acquire_lock(int *sl) {\n int spins = 0;\n while (*(volatile int *)sl != 0 || CAS_LOCK(sl)) {\n if ((++spins & SPINS_PER_YIELD) == 0) {\n SPIN_LOCK_YIELD;\n }\n }\n return 0;\n}\n\n#define MLOCK_T int\n#define TRY_LOCK(sl) !CAS_LOCK(sl)\n#define RELEASE_LOCK(sl) CLEAR_LOCK(sl)\n#define ACQUIRE_LOCK(sl) (CAS_LOCK(sl)? spin_acquire_lock(sl) : 0)\n#define INITIAL_LOCK(sl) (*sl = 0)\n#define DESTROY_LOCK(sl) (0)\nstatic MLOCK_T malloc_global_mutex = 0;\n\n#else /* USE_RECURSIVE_LOCKS */\n/* types for lock owners */\n#ifdef WIN32\n#define THREAD_ID_T DWORD\n#define CURRENT_THREAD GetCurrentThreadId()\n#define EQ_OWNER(X,Y) ((X) == (Y))\n#else\n/*\n Note: the following assume that pthread_t is a type that can be\n initialized to (casted) zero. If this is not the case, you will need to\n somehow redefine these or not use spin locks.\n */\n#define THREAD_ID_T pthread_t\n#define CURRENT_THREAD pthread_self()\n#define EQ_OWNER(X,Y) pthread_equal(X, Y)\n#endif\n\nstruct malloc_recursive_lock {\n int sl;\n unsigned int c;\n THREAD_ID_T threadid;\n};\n\n#define MLOCK_T struct malloc_recursive_lock\nstatic MLOCK_T malloc_global_mutex = { 0, 0, (THREAD_ID_T)0};\n\nstatic FORCEINLINE void recursive_release_lock(MLOCK_T *lk) {\n assert(lk->sl != 0);\n if (--lk->c == 0) {\n CLEAR_LOCK(&lk->sl);\n }\n}\n\nstatic FORCEINLINE int recursive_acquire_lock(MLOCK_T *lk) {\n THREAD_ID_T mythreadid = CURRENT_THREAD;\n int spins = 0;\n for (;;) {\n if (*((volatile int *)(&lk->sl)) == 0) {\n if (!CAS_LOCK(&lk->sl)) {\n lk->threadid = mythreadid;\n lk->c = 1;\n return 0;\n }\n }\n else if (EQ_OWNER(lk->threadid, mythreadid)) {\n ++lk->c;\n return 0;\n }\n if ((++spins & SPINS_PER_YIELD) == 0) {\n SPIN_LOCK_YIELD;\n }\n }\n}\n\nstatic FORCEINLINE int recursive_try_lock(MLOCK_T *lk) {\n THREAD_ID_T mythreadid = CURRENT_THREAD;\n if (*((volatile int *)(&lk->sl)) == 0) {\n if (!CAS_LOCK(&lk->sl)) {\n lk->threadid = mythreadid;\n lk->c = 1;\n return 1;\n }\n }\n else if (EQ_OWNER(lk->threadid, mythreadid)) {\n ++lk->c;\n return 1;\n }\n return 0;\n}\n\n#define RELEASE_LOCK(lk) recursive_release_lock(lk)\n#define TRY_LOCK(lk) recursive_try_lock(lk)\n#define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk)\n#define INITIAL_LOCK(lk) ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0)\n#define DESTROY_LOCK(lk) (0)\n#endif /* USE_RECURSIVE_LOCKS */\n\n#elif defined(WIN32) /* Win32 critical sections */\n#define MLOCK_T CRITICAL_SECTION\n#define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0)\n#define RELEASE_LOCK(lk) LeaveCriticalSection(lk)\n#define TRY_LOCK(lk) TryEnterCriticalSection(lk)\n#define INITIAL_LOCK(lk) (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000|4000))\n#define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0)\n#define NEED_GLOBAL_LOCK_INIT\n\nstatic MLOCK_T malloc_global_mutex;\nstatic volatile LONG malloc_global_mutex_status;\n\n/* Use spin loop to initialize global lock */\nstatic void init_malloc_global_mutex() {\n for (;;) {\n long stat = malloc_global_mutex_status;\n if (stat > 0)\n return;\n /* transition to < 0 while initializing, then to > 0) */\n if (stat == 0 &&\n interlockedcompareexchange(&malloc_global_mutex_status, (LONG)-1, (LONG)0) == 0) {\n InitializeCriticalSection(&malloc_global_mutex);\n interlockedexchange(&malloc_global_mutex_status, (LONG)1);\n return;\n }\n SleepEx(0, FALSE);\n }\n}\n\n#else /* pthreads-based locks */\n\n#define MLOCK_T pthread_mutex_t\n#define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk)\n#define RELEASE_LOCK(lk) pthread_mutex_unlock(lk)\n#define TRY_LOCK(lk) (!pthread_mutex_trylock(lk))\n#define INITIAL_LOCK(lk) pthread_init_lock(lk)\n#define DESTROY_LOCK(lk) pthread_mutex_destroy(lk)\n\n#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE)\n/* Cope with old-style linux recursive lock initialization by adding */\n/* skipped internal declaration from pthread.h */\nextern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr,\n int __kind));\n#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP\n#define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y)\n#endif /* USE_RECURSIVE_LOCKS ... */\n\nstatic MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER;\n\nstatic int pthread_init_lock (MLOCK_T *lk) {\n pthread_mutexattr_t attr;\n if (pthread_mutexattr_init(&attr)) return 1;\n#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0\n if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1;\n#endif\n if (pthread_mutex_init(lk, &attr)) return 1;\n if (pthread_mutexattr_destroy(&attr)) return 1;\n return 0;\n}\n\n#endif /* ... lock types ... */\n\n/* Common code for all lock types */\n#define USE_LOCK_BIT (2U)\n\n#ifndef ACQUIRE_MALLOC_GLOBAL_LOCK\n#define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex);\n#endif\n\n#ifndef RELEASE_MALLOC_GLOBAL_LOCK\n#define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex);\n#endif\n\n#endif /* USE_LOCKS */\n\n/* ----------------------- Chunk representations ------------------------ */\n\n/*\n (The following includes lightly edited explanations by Colin Plumb.)\n \n The malloc_chunk declaration below is misleading (but accurate and\n necessary). It declares a \"view\" into memory allowing access to\n necessary fields at known offsets from a given base.\n \n Chunks of memory are maintained using a `boundary tag' method as\n originally described by Knuth. (See the paper by Paul Wilson\n ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such\n techniques.) Sizes of free chunks are stored both in the front of\n each chunk and at the end. This makes consolidating fragmented\n chunks into bigger chunks fast. The head fields also hold bits\n representing whether chunks are free or in use.\n \n Here are some pictures to make it clearer. They are \"exploded\" to\n show that the state of a chunk can be thought of as extending from\n the high 31 bits of the head field of its header through the\n prev_foot and PINUSE_BIT bit of the following chunk header.\n \n A chunk that's in use looks like:\n \n chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of previous chunk (if P = 0) |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P|\n | Size of this chunk 1| +-+\n mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | |\n +- -+\n | |\n +- -+\n | :\n +- size - sizeof(size_t) available payload bytes -+\n : |\n chunk-> +- -+\n | |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1|\n | Size of next chunk (may or may not be in use) | +-+\n mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n \n And if it's free, it looks like this:\n \n chunk-> +- -+\n | User payload (must be in use, or we would have merged!) |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P|\n | Size of this chunk 0| +-+\n mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Next pointer |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Prev pointer |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | :\n +- size - sizeof(struct chunk) unused bytes -+\n : |\n chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of this chunk |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0|\n | Size of next chunk (must be in use, or we would have merged)| +-+\n mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | :\n +- User payload -+\n : |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n |0|\n +-+\n Note that since we always merge adjacent free chunks, the chunks\n adjacent to a free chunk must be in use.\n \n Given a pointer to a chunk (which can be derived trivially from the\n payload pointer) we can, in O(1) time, find out whether the adjacent\n chunks are free, and if so, unlink them from the lists that they\n are on and merge them with the current chunk.\n \n Chunks always begin on even word boundaries, so the mem portion\n (which is returned to the user) is also on an even word boundary, and\n thus at least double-word aligned.\n \n The P (PINUSE_BIT) bit, stored in the unused low-order bit of the\n chunk size (which is always a multiple of two words), is an in-use\n bit for the *previous* chunk. If that bit is *clear*, then the\n word before the current chunk size contains the previous chunk\n size, and can be used to find the front of the previous chunk.\n The very first chunk allocated always has this bit set, preventing\n access to non-existent (or non-owned) memory. If pinuse is set for\n any given chunk, then you CANNOT determine the size of the\n previous chunk, and might even get a memory addressing fault when\n trying to do so.\n \n The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of\n the chunk size redundantly records whether the current chunk is\n inuse (unless the chunk is mmapped). This redundancy enables usage\n checks within free and realloc, and reduces indirection when freeing\n and consolidating chunks.\n \n Each freshly allocated chunk must have both cinuse and pinuse set.\n That is, each allocated chunk borders either a previously allocated\n and still in-use chunk, or the base of its memory arena. This is\n ensured by making all allocations from the `lowest' part of any\n found chunk. Further, no free chunk physically borders another one,\n so each free chunk is known to be preceded and followed by either\n inuse chunks or the ends of memory.\n \n Note that the `foot' of the current chunk is actually represented\n as the prev_foot of the NEXT chunk. This makes it easier to\n deal with alignments etc but can be very confusing when trying\n to extend or adapt this code.\n \n The exceptions to all this are\n \n 1. The special chunk `top' is the top-most available chunk (i.e.,\n the one bordering the end of available memory). It is treated\n specially. Top is never included in any bin, is used only if\n no other chunk is available, and is released back to the\n system if it is very large (see M_TRIM_THRESHOLD). In effect,\n the top chunk is treated as larger (and thus less well\n fitting) than any other available chunk. The top chunk\n doesn't update its trailing size field since there is no next\n contiguous chunk that would have to index off it. However,\n space is still allocated for it (TOP_FOOT_SIZE) to enable\n separation or merging when space is extended.\n \n 3. Chunks allocated via mmap, have both cinuse and pinuse bits\n cleared in their head fields. Because they are allocated\n one-by-one, each must carry its own prev_foot field, which is\n also used to hold the offset this chunk has within its mmapped\n region, which is needed to preserve alignment. Each mmapped\n chunk is trailed by the first two fields of a fake next-chunk\n for sake of usage checks.\n \n */\n\nstruct malloc_chunk {\n size_t prev_foot; /* Size of previous chunk (if free). */\n size_t head; /* Size and inuse bits. */\n struct malloc_chunk* fd; /* double links -- used only if free. */\n struct malloc_chunk* bk;\n};\n\ntypedef struct malloc_chunk mchunk;\ntypedef struct malloc_chunk* mchunkptr;\ntypedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */\ntypedef unsigned int bindex_t; /* Described below */\ntypedef unsigned int binmap_t; /* Described below */\ntypedef unsigned int flag_t; /* The type of various bit flag sets */\n\n/* ------------------- Chunks sizes and alignments ----------------------- */\n\n#define MCHUNK_SIZE (sizeof(mchunk))\n\n#if FOOTERS\n#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)\n#else /* FOOTERS */\n#define CHUNK_OVERHEAD (SIZE_T_SIZE)\n#endif /* FOOTERS */\n\n/* MMapped chunks need a second word of overhead ... */\n#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)\n/* ... and additional padding for fake next-chunk at foot */\n#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES)\n\n/* The smallest size we can malloc is an aligned minimal chunk */\n#define MIN_CHUNK_SIZE \\\n((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)\n\n/* conversion from malloc headers to user pointers, and back */\n#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES))\n#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES))\n/* chunk associated with aligned address A */\n#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A)))\n\n/* Bounds on request (not chunk) sizes. */\n#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2)\n#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)\n\n/* pad request bytes into a usable size */\n#define pad_request(req) \\\n(((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)\n\n/* pad request, checking for minimum (but not maximum) */\n#define request2size(req) \\\n(((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))\n\n\n/* ------------------ Operations on head and foot fields ----------------- */\n\n/*\n The head field of a chunk is or'ed with PINUSE_BIT when previous\n adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in\n use, unless mmapped, in which case both bits are cleared.\n \n FLAG4_BIT is not used by this malloc, but might be useful in extensions.\n */\n\n#define PINUSE_BIT (SIZE_T_ONE)\n#define CINUSE_BIT (SIZE_T_TWO)\n#define FLAG4_BIT (SIZE_T_FOUR)\n#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT)\n#define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT)\n\n/* Head value for fenceposts */\n#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE)\n\n/* extraction of fields from head words */\n#define cinuse(p) ((p)->head & CINUSE_BIT)\n#define pinuse(p) ((p)->head & PINUSE_BIT)\n#define flag4inuse(p) ((p)->head & FLAG4_BIT)\n#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT)\n#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0)\n\n#define chunksize(p) ((p)->head & ~(FLAG_BITS))\n\n#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT)\n#define set_flag4(p) ((p)->head |= FLAG4_BIT)\n#define clear_flag4(p) ((p)->head &= ~FLAG4_BIT)\n\n/* Treat space at ptr +/- offset as a chunk */\n#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s)))\n#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s)))\n\n/* Ptr to next or previous physical malloc_chunk. */\n#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS)))\n#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) ))\n\n/* extract next chunk's pinuse bit */\n#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT)\n\n/* Get/set size at footer */\n#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot)\n#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s))\n\n/* Set size, pinuse bit, and foot */\n#define set_size_and_pinuse_of_free_chunk(p, s)\\\n((p)->head = (s|PINUSE_BIT), set_foot(p, s))\n\n/* Set size, pinuse bit, foot, and clear next pinuse */\n#define set_free_with_pinuse(p, s, n)\\\n(clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s))\n\n/* Get the internal overhead associated with chunk p */\n#define overhead_for(p)\\\n(is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD)\n\n/* Return true if malloced space is not necessarily cleared */\n#if MMAP_CLEARS\n#define calloc_must_clear(p) (!is_mmapped(p))\n#else /* MMAP_CLEARS */\n#define calloc_must_clear(p) (1)\n#endif /* MMAP_CLEARS */\n\n/* ---------------------- Overlaid data structures ----------------------- */\n\n/*\n When chunks are not in use, they are treated as nodes of either\n lists or trees.\n \n \"Small\" chunks are stored in circular doubly-linked lists, and look\n like this:\n \n chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of previous chunk |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n `head:' | Size of chunk, in bytes |P|\n mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Forward pointer to next chunk in list |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Back pointer to previous chunk in list |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Unused space (may be 0 bytes long) .\n . .\n . |\n nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n `foot:' | Size of chunk, in bytes |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n \n Larger chunks are kept in a form of bitwise digital trees (aka\n tries) keyed on chunksizes. Because malloc_tree_chunks are only for\n free chunks greater than 256 bytes, their size doesn't impose any\n constraints on user chunk sizes. Each node looks like:\n \n chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of previous chunk |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n `head:' | Size of chunk, in bytes |P|\n mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Forward pointer to next chunk of same size |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Back pointer to previous chunk of same size |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Pointer to left child (child[0]) |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Pointer to right child (child[1]) |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Pointer to parent |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | bin index of this chunk |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Unused space .\n . |\n nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n `foot:' | Size of chunk, in bytes |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n \n Each tree holding treenodes is a tree of unique chunk sizes. Chunks\n of the same size are arranged in a circularly-linked list, with only\n the oldest chunk (the next to be used, in our FIFO ordering)\n actually in the tree. (Tree members are distinguished by a non-null\n parent pointer.) If a chunk with the same size an an existing node\n is inserted, it is linked off the existing node using pointers that\n work in the same way as fd/bk pointers of small chunks.\n \n Each tree contains a power of 2 sized range of chunk sizes (the\n smallest is 0x100 <= x < 0x180), which is is divided in half at each\n tree level, with the chunks in the smaller half of the range (0x100\n <= x < 0x140 for the top nose) in the left subtree and the larger\n half (0x140 <= x < 0x180) in the right subtree. This is, of course,\n done by inspecting individual bits.\n \n Using these rules, each node's left subtree contains all smaller\n sizes than its right subtree. However, the node at the root of each\n subtree has no particular ordering relationship to either. (The\n dividing line between the subtree sizes is based on trie relation.)\n If we remove the last chunk of a given size from the interior of the\n tree, we need to replace it with a leaf node. The tree ordering\n rules permit a node to be replaced by any leaf below it.\n \n The smallest chunk in a tree (a common operation in a best-fit\n allocator) can be found by walking a path to the leftmost leaf in\n the tree. Unlike a usual binary tree, where we follow left child\n pointers until we reach a null, here we follow the right child\n pointer any time the left one is null, until we reach a leaf with\n both child pointers null. The smallest chunk in the tree will be\n somewhere along that path.\n \n The worst case number of steps to add, find, or remove a node is\n bounded by the number of bits differentiating chunks within\n bins. Under current bin calculations, this ranges from 6 up to 21\n (for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case\n is of course much better.\n */\n\nstruct malloc_tree_chunk {\n /* The first four fields must be compatible with malloc_chunk */\n size_t prev_foot;\n size_t head;\n struct malloc_tree_chunk* fd;\n struct malloc_tree_chunk* bk;\n \n struct malloc_tree_chunk* child[2];\n struct malloc_tree_chunk* parent;\n bindex_t index;\n};\n\ntypedef struct malloc_tree_chunk tchunk;\ntypedef struct malloc_tree_chunk* tchunkptr;\ntypedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */\n\n/* A little helper macro for trees */\n#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])\n\n/* ----------------------------- Segments -------------------------------- */\n\n/*\n Each malloc space may include non-contiguous segments, held in a\n list headed by an embedded malloc_segment record representing the\n top-most space. Segments also include flags holding properties of\n the space. Large chunks that are directly allocated by mmap are not\n included in this list. They are instead independently created and\n destroyed without otherwise keeping track of them.\n \n Segment management mainly comes into play for spaces allocated by\n MMAP. Any call to MMAP might or might not return memory that is\n adjacent to an existing segment. MORECORE normally contiguously\n extends the current space, so this space is almost always adjacent,\n which is simpler and faster to deal with. (This is why MORECORE is\n used preferentially to MMAP when both are available -- see\n sys_alloc.) When allocating using MMAP, we don't use any of the\n hinting mechanisms (inconsistently) supported in various\n implementations of unix mmap, or distinguish reserving from\n committing memory. Instead, we just ask for space, and exploit\n contiguity when we get it. It is probably possible to do\n better than this on some systems, but no general scheme seems\n to be significantly better.\n \n Management entails a simpler variant of the consolidation scheme\n used for chunks to reduce fragmentation -- new adjacent memory is\n normally prepended or appended to an existing segment. However,\n there are limitations compared to chunk consolidation that mostly\n reflect the fact that segment processing is relatively infrequent\n (occurring only when getting memory from system) and that we\n don't expect to have huge numbers of segments:\n \n * Segments are not indexed, so traversal requires linear scans. (It\n would be possible to index these, but is not worth the extra\n overhead and complexity for most programs on most platforms.)\n * New segments are only appended to old ones when holding top-most\n memory; if they cannot be prepended to others, they are held in\n different segments.\n \n Except for the top-most segment of an mstate, each segment record\n is kept at the tail of its segment. Segments are added by pushing\n segment records onto the list headed by &mstate.seg for the\n containing mstate.\n \n Segment flags control allocation/merge/deallocation policies:\n * If EXTERN_BIT set, then we did not allocate this segment,\n and so should not try to deallocate or merge with others.\n (This currently holds only for the initial segment passed\n into create_mspace_with_base.)\n * If USE_MMAP_BIT set, the segment may be merged with\n other surrounding mmapped segments and trimmed/de-allocated\n using munmap.\n * If neither bit is set, then the segment was obtained using\n MORECORE so can be merged with surrounding MORECORE'd segments\n and deallocated/trimmed using MORECORE with negative arguments.\n */\n\nstruct malloc_segment {\n char* base; /* base address */\n size_t size; /* allocated size */\n struct malloc_segment* next; /* ptr to next segment */\n flag_t sflags; /* mmap and extern flag */\n};\n\n#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT)\n#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT)\n\ntypedef struct malloc_segment msegment;\ntypedef struct malloc_segment* msegmentptr;\n\n/* ---------------------------- malloc_state ----------------------------- */\n\n/*\n A malloc_state holds all of the bookkeeping for a space.\n The main fields are:\n \n Top\n The topmost chunk of the currently active segment. Its size is\n cached in topsize. The actual size of topmost space is\n topsize+TOP_FOOT_SIZE, which includes space reserved for adding\n fenceposts and segment records if necessary when getting more\n space from the system. The size at which to autotrim top is\n cached from mparams in trim_check, except that it is disabled if\n an autotrim fails.\n \n Designated victim (dv)\n This is the preferred chunk for servicing small requests that\n don't have exact fits. It is normally the chunk split off most\n recently to service another small request. Its size is cached in\n dvsize. The link fields of this chunk are not maintained since it\n is not kept in a bin.\n \n SmallBins\n An array of bin headers for free chunks. These bins hold chunks\n with sizes less than MIN_LARGE_SIZE bytes. Each bin contains\n chunks of all the same size, spaced 8 bytes apart. To simplify\n use in double-linked lists, each bin header acts as a malloc_chunk\n pointing to the real first node, if it exists (else pointing to\n itself). This avoids special-casing for headers. But to avoid\n waste, we allocate only the fd/bk pointers of bins, and then use\n repositioning tricks to treat these as the fields of a chunk.\n \n TreeBins\n Treebins are pointers to the roots of trees holding a range of\n sizes. There are 2 equally spaced treebins for each power of two\n from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything\n larger.\n \n Bin maps\n There is one bit map for small bins (\"smallmap\") and one for\n treebins (\"treemap). Each bin sets its bit when non-empty, and\n clears the bit when empty. Bit operations are then used to avoid\n bin-by-bin searching -- nearly all \"search\" is done without ever\n looking at bins that won't be selected. The bit maps\n conservatively use 32 bits per map word, even if on 64bit system.\n For a good description of some of the bit-based techniques used\n here, see Henry S. Warren Jr's book \"Hacker's Delight\" (and\n supplement at http://hackersdelight.org/). Many of these are\n intended to reduce the branchiness of paths through malloc etc, as\n well as to reduce the number of memory locations read or written.\n \n Segments\n A list of segments headed by an embedded malloc_segment record\n representing the initial space.\n \n Address check support\n The least_addr field is the least address ever obtained from\n MORECORE or MMAP. Attempted frees and reallocs of any address less\n than this are trapped (unless INSECURE is defined).\n \n Magic tag\n A cross-check field that should always hold same value as mparams.magic.\n \n Max allowed footprint\n The maximum allowed bytes to allocate from system (zero means no limit)\n \n Flags\n Bits recording whether to use MMAP, locks, or contiguous MORECORE\n \n Statistics\n Each space keeps track of current and maximum system memory\n obtained via MORECORE or MMAP.\n \n Trim support\n Fields holding the amount of unused topmost memory that should trigger\n trimming, and a counter to force periodic scanning to release unused\n non-topmost segments.\n \n Locking\n If USE_LOCKS is defined, the \"mutex\" lock is acquired and released\n around every public call using this mspace.\n \n Extension support\n A void* pointer and a size_t field that can be used to help implement\n extensions to this malloc.\n */\n\n/* Bin types, widths and sizes */\n#define NSMALLBINS (32U)\n#define NTREEBINS (32U)\n#define SMALLBIN_SHIFT (3U)\n#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT)\n#define TREEBIN_SHIFT (8U)\n#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT)\n#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE)\n#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)\n\nstruct malloc_state {\n binmap_t smallmap;\n binmap_t treemap;\n size_t dvsize;\n size_t topsize;\n char* least_addr;\n mchunkptr dv;\n mchunkptr top;\n size_t trim_check;\n size_t release_checks;\n size_t magic;\n mchunkptr smallbins[(NSMALLBINS+1)*2];\n tbinptr treebins[NTREEBINS];\n size_t footprint;\n size_t max_footprint;\n size_t footprint_limit; /* zero means no limit */\n flag_t mflags;\n#if USE_LOCKS\n MLOCK_T mutex; /* locate lock among fields that rarely change */\n#endif /* USE_LOCKS */\n msegment seg;\n void* extp; /* Unused but available for extensions */\n size_t exts;\n};\n\ntypedef struct malloc_state* mstate;\n\n/* ------------- Global malloc_state and malloc_params ------------------- */\n\n/*\n malloc_params holds global properties, including those that can be\n dynamically set using mallopt. There is a single instance, mparams,\n initialized in init_mparams. Note that the non-zeroness of \"magic\"\n also serves as an initialization flag.\n */\n\nstruct malloc_params {\n size_t magic;\n size_t page_size;\n size_t granularity;\n size_t mmap_threshold;\n size_t trim_threshold;\n flag_t default_mflags;\n};\n\nstatic struct malloc_params mparams;\n\n/* Ensure mparams initialized */\n#define ensure_initialization() (void)(mparams.magic != 0 || init_mparams())\n\n#if !ONLY_MSPACES\n\n/* The global malloc_state used for all non-\"mspace\" calls */\nstatic struct malloc_state _gm_;\n#define gm (&_gm_)\n#define is_global(M) ((M) == &_gm_)\n\n#endif /* !ONLY_MSPACES */\n\n#define is_initialized(M) ((M)->top != 0)\n\n/* -------------------------- system alloc setup ------------------------- */\n\n/* Operations on mflags */\n\n#define use_lock(M) ((M)->mflags & USE_LOCK_BIT)\n#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT)\n#if USE_LOCKS\n#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT)\n#else\n#define disable_lock(M)\n#endif\n\n#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT)\n#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT)\n#if HAVE_MMAP\n#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT)\n#else\n#define disable_mmap(M)\n#endif\n\n#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT)\n#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT)\n\n#define set_lock(M,L)\\\n((M)->mflags = (L)?\\\n((M)->mflags | USE_LOCK_BIT) :\\\n((M)->mflags & ~USE_LOCK_BIT))\n\n/* page-align a size */\n#define page_align(S)\\\n(((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE))\n\n/* granularity-align a size */\n#define granularity_align(S)\\\n(((S) + (mparams.granularity - SIZE_T_ONE))\\\n& ~(mparams.granularity - SIZE_T_ONE))\n\n\n/* For mmap, use granularity alignment on windows, else page-align */\n#ifdef WIN32\n#define mmap_align(S) granularity_align(S)\n#else\n#define mmap_align(S) page_align(S)\n#endif\n\n/* For sys_alloc, enough padding to ensure can malloc request on success */\n#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT)\n\n#define is_page_aligned(S)\\\n(((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0)\n#define is_granularity_aligned(S)\\\n(((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0)\n\n/* True if segment S holds address A */\n#define segment_holds(S, A)\\\n((char*)(A) >= S->base && (char*)(A) < S->base + S->size)\n\n/* Return segment holding given address */\nstatic msegmentptr segment_holding(mstate m, char* addr) {\n msegmentptr sp = &m->seg;\n for (;;) {\n if (addr >= sp->base && addr < sp->base + sp->size)\n return sp;\n if ((sp = sp->next) == 0)\n return 0;\n }\n}\n\n/* Return true if segment contains a segment link */\nstatic int has_segment_link(mstate m, msegmentptr ss) {\n msegmentptr sp = &m->seg;\n for (;;) {\n if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size)\n return 1;\n if ((sp = sp->next) == 0)\n return 0;\n }\n}\n\n#ifndef MORECORE_CANNOT_TRIM\n#define should_trim(M,s) ((s) > (M)->trim_check)\n#else /* MORECORE_CANNOT_TRIM */\n#define should_trim(M,s) (0)\n#endif /* MORECORE_CANNOT_TRIM */\n\n/*\n TOP_FOOT_SIZE is padding at the end of a segment, including space\n that may be needed to place segment records and fenceposts when new\n noncontiguous segments are added.\n */\n#define TOP_FOOT_SIZE \\\n(align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)\n\n\n/* ------------------------------- Hooks -------------------------------- */\n\n/*\n PREACTION should be defined to return 0 on success, and nonzero on\n failure. If you are not using locking, you can redefine these to do\n anything you like.\n */\n\n#if USE_LOCKS\n#define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0)\n#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); }\n#else /* USE_LOCKS */\n\n#ifndef PREACTION\n#define PREACTION(M) (0)\n#endif /* PREACTION */\n\n#ifndef POSTACTION\n#define POSTACTION(M)\n#endif /* POSTACTION */\n\n#endif /* USE_LOCKS */\n\n/*\n CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses.\n USAGE_ERROR_ACTION is triggered on detected bad frees and\n reallocs. The argument p is an address that might have triggered the\n fault. It is ignored by the two predefined actions, but might be\n useful in custom actions that try to help diagnose errors.\n */\n\n#if PROCEED_ON_ERROR\n\n/* A count of the number of corruption errors causing resets */\nint malloc_corruption_error_count;\n\n/* default corruption action */\nstatic void reset_on_error(mstate m);\n\n#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m)\n#define USAGE_ERROR_ACTION(m, p)\n\n#else /* PROCEED_ON_ERROR */\n\n#ifndef CORRUPTION_ERROR_ACTION\n#define CORRUPTION_ERROR_ACTION(m) ABORT\n#endif /* CORRUPTION_ERROR_ACTION */\n\n#ifndef USAGE_ERROR_ACTION\n#define USAGE_ERROR_ACTION(m,p) ABORT\n#endif /* USAGE_ERROR_ACTION */\n\n#endif /* PROCEED_ON_ERROR */\n\n\n/* -------------------------- Debugging setup ---------------------------- */\n\n#if ! DEBUG\n\n#define check_free_chunk(M,P)\n#define check_inuse_chunk(M,P)\n#define check_malloced_chunk(M,P,N)\n#define check_mmapped_chunk(M,P)\n#define check_malloc_state(M)\n#define check_top_chunk(M,P)\n\n#else /* DEBUG */\n#define check_free_chunk(M,P) do_check_free_chunk(M,P)\n#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P)\n#define check_top_chunk(M,P) do_check_top_chunk(M,P)\n#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N)\n#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P)\n#define check_malloc_state(M) do_check_malloc_state(M)\n\nstatic void do_check_any_chunk(mstate m, mchunkptr p);\nstatic void do_check_top_chunk(mstate m, mchunkptr p);\nstatic void do_check_mmapped_chunk(mstate m, mchunkptr p);\nstatic void do_check_inuse_chunk(mstate m, mchunkptr p);\nstatic void do_check_free_chunk(mstate m, mchunkptr p);\nstatic void do_check_malloced_chunk(mstate m, void* mem, size_t s);\nstatic void do_check_tree(mstate m, tchunkptr t);\nstatic void do_check_treebin(mstate m, bindex_t i);\nstatic void do_check_smallbin(mstate m, bindex_t i);\nstatic void do_check_malloc_state(mstate m);\nstatic int bin_find(mstate m, mchunkptr x);\nstatic size_t traverse_and_check(mstate m);\n#endif /* DEBUG */\n\n/* ---------------------------- Indexing Bins ---------------------------- */\n\n#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS)\n#define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT)\n#define small_index2size(i) ((i) << SMALLBIN_SHIFT)\n#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE))\n\n/* addressing by index. See above about smallbin repositioning */\n#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1])))\n#define treebin_at(M,i) (&((M)->treebins[i]))\n\n/* assign tree index for size S to variable I. Use x86 asm if possible */\n#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__) || defined(__EMSCRIPTEN__))\n#define compute_tree_index(S, I)\\\n{\\\nunsigned int X = S >> TREEBIN_SHIFT;\\\nif (X == 0)\\\nI = 0;\\\nelse if (X > 0xFFFF)\\\nI = NTREEBINS-1;\\\nelse {\\\nunsigned int K = (unsigned) sizeof(X)*__CHAR_BIT__ - 1 - (unsigned) __builtin_clz(X); \\\nI = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\\\n}\\\n}\n\n#elif defined (__INTEL_COMPILER)\n#define compute_tree_index(S, I)\\\n{\\\nsize_t X = S >> TREEBIN_SHIFT;\\\nif (X == 0)\\\nI = 0;\\\nelse if (X > 0xFFFF)\\\nI = NTREEBINS-1;\\\nelse {\\\nunsigned int K = _bit_scan_reverse (X); \\\nI = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\\\n}\\\n}\n\n#elif defined(_MSC_VER) && _MSC_VER>=1300\n#define compute_tree_index(S, I)\\\n{\\\nsize_t X = S >> TREEBIN_SHIFT;\\\nif (X == 0)\\\nI = 0;\\\nelse if (X > 0xFFFF)\\\nI = NTREEBINS-1;\\\nelse {\\\nunsigned int K;\\\n_BitScanReverse((DWORD *) &K, (DWORD) X);\\\nI = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\\\n}\\\n}\n\n#else /* GNUC */\n#define compute_tree_index(S, I)\\\n{\\\nsize_t X = S >> TREEBIN_SHIFT;\\\nif (X == 0)\\\nI = 0;\\\nelse if (X > 0xFFFF)\\\nI = NTREEBINS-1;\\\nelse {\\\nunsigned int Y = (unsigned int)X;\\\nunsigned int N = ((Y - 0x100) >> 16) & 8;\\\nunsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\\\nN += K;\\\nN += K = (((Y <<= K) - 0x4000) >> 16) & 2;\\\nK = 14 - N + ((Y <<= K) >> 15);\\\nI = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\\\n}\\\n}\n#endif /* GNUC */\n\n/* Bit representing maximum resolved size in a treebin at i */\n#define bit_for_tree_index(i) \\\n(i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2)\n\n/* Shift placing maximum resolved bit in a treebin at i as sign bit */\n#define leftshift_for_tree_index(i) \\\n((i == NTREEBINS-1)? 0 : \\\n((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2)))\n\n/* The size of the smallest chunk held in bin with index i */\n#define minsize_for_tree_index(i) \\\n((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \\\n(((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1)))\n\n\n/* ------------------------ Operations on bin maps ----------------------- */\n\n/* bit corresponding to given index */\n#define idx2bit(i) ((binmap_t)(1) << (i))\n\n/* Mark/Clear bits with given index */\n#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i))\n#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i))\n#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i))\n\n#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i))\n#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i))\n#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i))\n\n/* isolate the least set bit of a bitmap */\n#define least_bit(x) ((x) & -(x))\n\n/* mask with all bits to left of least bit of x on */\n#define left_bits(x) ((x<<1) | -(x<<1))\n\n/* mask with all bits to left of or equal to least bit of x on */\n#define same_or_left_bits(x) ((x) | -(x))\n\n/* index corresponding to given bit. Use x86 asm if possible */\n\n#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__) || defined(__EMSCRIPTEN__))\n#define compute_bit2idx(X, I)\\\n{\\\nunsigned int J;\\\nJ = __builtin_ctz(X); \\\nI = (bindex_t)J;\\\n}\n\n#elif defined (__INTEL_COMPILER)\n#define compute_bit2idx(X, I)\\\n{\\\nunsigned int J;\\\nJ = _bit_scan_forward (X); \\\nI = (bindex_t)J;\\\n}\n\n#elif defined(_MSC_VER) && _MSC_VER>=1300\n#define compute_bit2idx(X, I)\\\n{\\\nunsigned int J;\\\n_BitScanForward((DWORD *) &J, X);\\\nI = (bindex_t)J;\\\n}\n\n#elif USE_BUILTIN_FFS\n#define compute_bit2idx(X, I) I = ffs(X)-1\n\n#else\n#define compute_bit2idx(X, I)\\\n{\\\nunsigned int Y = X - 1;\\\nunsigned int K = Y >> (16-4) & 16;\\\nunsigned int N = K; Y >>= K;\\\nN += K = Y >> (8-3) & 8; Y >>= K;\\\nN += K = Y >> (4-2) & 4; Y >>= K;\\\nN += K = Y >> (2-1) & 2; Y >>= K;\\\nN += K = Y >> (1-0) & 1; Y >>= K;\\\nI = (bindex_t)(N + Y);\\\n}\n#endif /* GNUC */\n\n\n/* ----------------------- Runtime Check Support ------------------------- */\n\n/*\n For security, the main invariant is that malloc/free/etc never\n writes to a static address other than malloc_state, unless static\n malloc_state itself has been corrupted, which cannot occur via\n malloc (because of these checks). In essence this means that we\n believe all pointers, sizes, maps etc held in malloc_state, but\n check all of those linked or offsetted from other embedded data\n structures. These checks are interspersed with main code in a way\n that tends to minimize their run-time cost.\n \n When FOOTERS is defined, in addition to range checking, we also\n verify footer fields of inuse chunks, which can be used guarantee\n that the mstate controlling malloc/free is intact. This is a\n streamlined version of the approach described by William Robertson\n et al in \"Run-time Detection of Heap-based Overflows\" LISA'03\n http://www.usenix.org/events/lisa03/tech/robertson.html The footer\n of an inuse chunk holds the xor of its mstate and a random seed,\n that is checked upon calls to free() and realloc(). This is\n (probabalistically) unguessable from outside the program, but can be\n computed by any code successfully malloc'ing any chunk, so does not\n itself provide protection against code that has already broken\n security through some other means. Unlike Robertson et al, we\n always dynamically check addresses of all offset chunks (previous,\n next, etc). This turns out to be cheaper than relying on hashes.\n */\n\n#if !INSECURE\n/* Check if address a is at least as high as any from MORECORE or MMAP */\n#define ok_address(M, a) ((char*)(a) >= (M)->least_addr)\n/* Check if address of next chunk n is higher than base chunk p */\n#define ok_next(p, n) ((char*)(p) < (char*)(n))\n/* Check if p has inuse status */\n#define ok_inuse(p) is_inuse(p)\n/* Check if p has its pinuse bit on */\n#define ok_pinuse(p) pinuse(p)\n\n#else /* !INSECURE */\n#define ok_address(M, a) (1)\n#define ok_next(b, n) (1)\n#define ok_inuse(p) (1)\n#define ok_pinuse(p) (1)\n#endif /* !INSECURE */\n\n#if (FOOTERS && !INSECURE)\n/* Check if (alleged) mstate m has expected magic field */\n#define ok_magic(M) ((M)->magic == mparams.magic)\n#else /* (FOOTERS && !INSECURE) */\n#define ok_magic(M) (1)\n#endif /* (FOOTERS && !INSECURE) */\n\n/* In gcc, use __builtin_expect to minimize impact of checks */\n#if !INSECURE\n#if defined(__GNUC__) && __GNUC__ >= 3\n#define RTCHECK(e) __builtin_expect(e, 1)\n#else /* GNUC */\n#define RTCHECK(e) (e)\n#endif /* GNUC */\n#else /* !INSECURE */\n#define RTCHECK(e) (1)\n#endif /* !INSECURE */\n\n/* macros to set up inuse chunks with or without footers */\n\n#if !FOOTERS\n\n#define mark_inuse_foot(M,p,s)\n\n/* Macros for setting head/foot of non-mmapped chunks */\n\n/* Set cinuse bit and pinuse bit of next chunk */\n#define set_inuse(M,p,s)\\\n((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\\\n((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)\n\n/* Set cinuse and pinuse of this chunk and pinuse of next chunk */\n#define set_inuse_and_pinuse(M,p,s)\\\n((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\\\n((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)\n\n/* Set size, cinuse and pinuse bit of this chunk */\n#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\\\n((p)->head = (s|PINUSE_BIT|CINUSE_BIT))\n\n#else /* FOOTERS */\n\n/* Set foot of inuse chunk to be xor of mstate and seed */\n#define mark_inuse_foot(M,p,s)\\\n(((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic))\n\n#define get_mstate_for(p)\\\n((mstate)(((mchunkptr)((char*)(p) +\\\n(chunksize(p))))->prev_foot ^ mparams.magic))\n\n#define set_inuse(M,p,s)\\\n((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\\\n(((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \\\nmark_inuse_foot(M,p,s))\n\n#define set_inuse_and_pinuse(M,p,s)\\\n((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\\\n(((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\\\nmark_inuse_foot(M,p,s))\n\n#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\\\n((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\\\nmark_inuse_foot(M, p, s))\n\n#endif /* !FOOTERS */\n\n/* ---------------------------- setting mparams -------------------------- */\n\n#if LOCK_AT_FORK\nstatic void pre_fork(void) { ACQUIRE_LOCK(&(gm)->mutex); }\nstatic void post_fork_parent(void) { RELEASE_LOCK(&(gm)->mutex); }\nstatic void post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); }\n#endif /* LOCK_AT_FORK */\n\n/* Initialize mparams */\nstatic int init_mparams(void) {\n#ifdef NEED_GLOBAL_LOCK_INIT\n if (malloc_global_mutex_status <= 0)\n init_malloc_global_mutex();\n#endif\n \n ACQUIRE_MALLOC_GLOBAL_LOCK();\n if (mparams.magic == 0) {\n size_t magic;\n size_t psize;\n size_t gsize;\n \n#ifndef WIN32\n psize = malloc_getpagesize;\n gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize);\n#else /* WIN32 */\n {\n SYSTEM_INFO system_info;\n GetSystemInfo(&system_info);\n psize = system_info.dwPageSize;\n gsize = ((DEFAULT_GRANULARITY != 0)?\n DEFAULT_GRANULARITY : system_info.dwAllocationGranularity);\n }\n#endif /* WIN32 */\n \n /* Sanity-check configuration:\n size_t must be unsigned and as wide as pointer type.\n ints must be at least 4 bytes.\n alignment must be at least 8.\n Alignment, min chunk size, and page size must all be powers of 2.\n */\n if ((sizeof(size_t) != sizeof(char*)) ||\n (MAX_SIZE_T < MIN_CHUNK_SIZE) ||\n (sizeof(int) < 4) ||\n (MALLOC_ALIGNMENT < (size_t)8U) ||\n ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) ||\n ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) ||\n ((gsize & (gsize-SIZE_T_ONE)) != 0) ||\n ((psize & (psize-SIZE_T_ONE)) != 0))\n ABORT;\n mparams.granularity = gsize;\n mparams.page_size = psize;\n mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD;\n mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD;\n#if MORECORE_CONTIGUOUS\n mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT;\n#else /* MORECORE_CONTIGUOUS */\n mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT;\n#endif /* MORECORE_CONTIGUOUS */\n \n#if !ONLY_MSPACES\n /* Set up lock for main malloc area */\n gm->mflags = mparams.default_mflags;\n (void)INITIAL_LOCK(&gm->mutex);\n#endif\n#if LOCK_AT_FORK\n pthread_atfork(&pre_fork, &post_fork_parent, &post_fork_child);\n#endif\n \n {\n#if USE_DEV_RANDOM\n int fd;\n unsigned char buf[sizeof(size_t)];\n /* Try to use /dev/urandom, else fall back on using time */\n if ((fd = open(\"/dev/urandom\", O_RDONLY)) >= 0 &&\n read(fd, buf, sizeof(buf)) == sizeof(buf)) {\n magic = *((size_t *) buf);\n close(fd);\n }\n else\n#endif /* USE_DEV_RANDOM */\n#ifdef WIN32\n magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U);\n#elif defined(LACKS_TIME_H) || defined(__EMSCRIPTEN__)\n magic = (size_t)&magic ^ (size_t)0x55555555U;\n#else\n magic = (size_t)(time(0) ^ (size_t)0x55555555U);\n#endif\n magic |= (size_t)8U; /* ensure nonzero */\n magic &= ~(size_t)7U; /* improve chances of fault for bad values */\n /* Until memory modes commonly available, use volatile-write */\n (*(volatile size_t *)(&(mparams.magic))) = magic;\n }\n }\n \n RELEASE_MALLOC_GLOBAL_LOCK();\n return 1;\n}\n\n/* support for mallopt */\nstatic int change_mparam(int param_number, int value) {\n size_t val;\n ensure_initialization();\n val = (value == -1)? MAX_SIZE_T : (size_t)value;\n switch(param_number) {\n case M_TRIM_THRESHOLD:\n mparams.trim_threshold = val;\n return 1;\n case M_GRANULARITY:\n if (val >= mparams.page_size && ((val & (val-1)) == 0)) {\n mparams.granularity = val;\n return 1;\n }\n else\n return 0;\n case M_MMAP_THRESHOLD:\n mparams.mmap_threshold = val;\n return 1;\n default:\n return 0;\n }\n}\n\n#if DEBUG\n/* ------------------------- Debugging Support --------------------------- */\n\n/* Check properties of any chunk, whether free, inuse, mmapped etc */\nstatic void do_check_any_chunk(mstate m, mchunkptr p) {\n assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));\n assert(ok_address(m, p));\n}\n\n/* Check properties of top chunk */\nstatic void do_check_top_chunk(mstate m, mchunkptr p) {\n msegmentptr sp = segment_holding(m, (char*)p);\n size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */\n assert(sp != 0);\n assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));\n assert(ok_address(m, p));\n assert(sz == m->topsize);\n assert(sz > 0);\n assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE);\n assert(pinuse(p));\n assert(!pinuse(chunk_plus_offset(p, sz)));\n}\n\n/* Check properties of (inuse) mmapped chunks */\nstatic void do_check_mmapped_chunk(mstate m, mchunkptr p) {\n size_t sz = chunksize(p);\n size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD);\n assert(is_mmapped(p));\n assert(use_mmap(m));\n assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));\n assert(ok_address(m, p));\n assert(!is_small(sz));\n assert((len & (mparams.page_size-SIZE_T_ONE)) == 0);\n assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD);\n assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0);\n}\n\n/* Check properties of inuse chunks */\nstatic void do_check_inuse_chunk(mstate m, mchunkptr p) {\n do_check_any_chunk(m, p);\n assert(is_inuse(p));\n assert(next_pinuse(p));\n /* If not pinuse and not mmapped, previous chunk has OK offset */\n assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p);\n if (is_mmapped(p))\n do_check_mmapped_chunk(m, p);\n}\n\n/* Check properties of free chunks */\nstatic void do_check_free_chunk(mstate m, mchunkptr p) {\n size_t sz = chunksize(p);\n mchunkptr next = chunk_plus_offset(p, sz);\n do_check_any_chunk(m, p);\n assert(!is_inuse(p));\n assert(!next_pinuse(p));\n assert (!is_mmapped(p));\n if (p != m->dv && p != m->top) {\n if (sz >= MIN_CHUNK_SIZE) {\n assert((sz & CHUNK_ALIGN_MASK) == 0);\n assert(is_aligned(chunk2mem(p)));\n assert(next->prev_foot == sz);\n assert(pinuse(p));\n assert (next == m->top || is_inuse(next));\n assert(p->fd->bk == p);\n assert(p->bk->fd == p);\n }\n else /* markers are always of size SIZE_T_SIZE */\n assert(sz == SIZE_T_SIZE);\n }\n}\n\n/* Check properties of malloced chunks at the point they are malloced */\nstatic void do_check_malloced_chunk(mstate m, void* mem, size_t s) {\n if (mem != 0) {\n mchunkptr p = mem2chunk(mem);\n size_t sz = p->head & ~INUSE_BITS;\n do_check_inuse_chunk(m, p);\n assert((sz & CHUNK_ALIGN_MASK) == 0);\n assert(sz >= MIN_CHUNK_SIZE);\n assert(sz >= s);\n /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */\n assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE));\n }\n}\n\n/* Check a tree and its subtrees. */\nstatic void do_check_tree(mstate m, tchunkptr t) {\n tchunkptr head = 0;\n tchunkptr u = t;\n bindex_t tindex = t->index;\n size_t tsize = chunksize(t);\n bindex_t idx;\n compute_tree_index(tsize, idx);\n assert(tindex == idx);\n assert(tsize >= MIN_LARGE_SIZE);\n assert(tsize >= minsize_for_tree_index(idx));\n assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1))));\n \n do { /* traverse through chain of same-sized nodes */\n do_check_any_chunk(m, ((mchunkptr)u));\n assert(u->index == tindex);\n assert(chunksize(u) == tsize);\n assert(!is_inuse(u));\n assert(!next_pinuse(u));\n assert(u->fd->bk == u);\n assert(u->bk->fd == u);\n if (u->parent == 0) {\n assert(u->child[0] == 0);\n assert(u->child[1] == 0);\n }\n else {\n assert(head == 0); /* only one node on chain has parent */\n head = u;\n assert(u->parent != u);\n assert (u->parent->child[0] == u ||\n u->parent->child[1] == u ||\n *((tbinptr*)(u->parent)) == u);\n if (u->child[0] != 0) {\n assert(u->child[0]->parent == u);\n assert(u->child[0] != u);\n do_check_tree(m, u->child[0]);\n }\n if (u->child[1] != 0) {\n assert(u->child[1]->parent == u);\n assert(u->child[1] != u);\n do_check_tree(m, u->child[1]);\n }\n if (u->child[0] != 0 && u->child[1] != 0) {\n assert(chunksize(u->child[0]) < chunksize(u->child[1]));\n }\n }\n u = u->fd;\n } while (u != t);\n assert(head != 0);\n}\n\n/* Check all the chunks in a treebin. */\nstatic void do_check_treebin(mstate m, bindex_t i) {\n tbinptr* tb = treebin_at(m, i);\n tchunkptr t = *tb;\n int empty = (m->treemap & (1U << i)) == 0;\n if (t == 0)\n assert(empty);\n if (!empty)\n do_check_tree(m, t);\n}\n\n/* Check all the chunks in a smallbin. */\nstatic void do_check_smallbin(mstate m, bindex_t i) {\n sbinptr b = smallbin_at(m, i);\n mchunkptr p = b->bk;\n unsigned int empty = (m->smallmap & (1U << i)) == 0;\n if (p == b)\n assert(empty);\n if (!empty) {\n for (; p != b; p = p->bk) {\n size_t size = chunksize(p);\n mchunkptr q;\n /* each chunk claims to be free */\n do_check_free_chunk(m, p);\n /* chunk belongs in bin */\n assert(small_index(size) == i);\n assert(p->bk == b || chunksize(p->bk) == chunksize(p));\n /* chunk is followed by an inuse chunk */\n q = next_chunk(p);\n if (q->head != FENCEPOST_HEAD)\n do_check_inuse_chunk(m, q);\n }\n }\n}\n\n/* Find x in a bin. Used in other check functions. */\nstatic int bin_find(mstate m, mchunkptr x) {\n size_t size = chunksize(x);\n if (is_small(size)) {\n bindex_t sidx = small_index(size);\n sbinptr b = smallbin_at(m, sidx);\n if (smallmap_is_marked(m, sidx)) {\n mchunkptr p = b;\n do {\n if (p == x)\n return 1;\n } while ((p = p->fd) != b);\n }\n }\n else {\n bindex_t tidx;\n compute_tree_index(size, tidx);\n if (treemap_is_marked(m, tidx)) {\n tchunkptr t = *treebin_at(m, tidx);\n size_t sizebits = size << leftshift_for_tree_index(tidx);\n while (t != 0 && chunksize(t) != size) {\n t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1];\n sizebits <<= 1;\n }\n if (t != 0) {\n tchunkptr u = t;\n do {\n if (u == (tchunkptr)x)\n return 1;\n } while ((u = u->fd) != t);\n }\n }\n }\n return 0;\n}\n\n/* Traverse each chunk and check it; return total */\nstatic size_t traverse_and_check(mstate m) {\n size_t sum = 0;\n if (is_initialized(m)) {\n msegmentptr s = &m->seg;\n sum += m->topsize + TOP_FOOT_SIZE;\n while (s != 0) {\n mchunkptr q = align_as_chunk(s->base);\n mchunkptr lastq = 0;\n assert(pinuse(q));\n while (segment_holds(s, q) &&\n q != m->top && q->head != FENCEPOST_HEAD) {\n sum += chunksize(q);\n if (is_inuse(q)) {\n assert(!bin_find(m, q));\n do_check_inuse_chunk(m, q);\n }\n else {\n assert(q == m->dv || bin_find(m, q));\n assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */\n do_check_free_chunk(m, q);\n }\n lastq = q;\n q = next_chunk(q);\n }\n s = s->next;\n }\n }\n return sum;\n}\n\n\n/* Check all properties of malloc_state. */\nstatic void do_check_malloc_state(mstate m) {\n bindex_t i;\n size_t total;\n /* check bins */\n for (i = 0; i < NSMALLBINS; ++i)\n do_check_smallbin(m, i);\n for (i = 0; i < NTREEBINS; ++i)\n do_check_treebin(m, i);\n \n if (m->dvsize != 0) { /* check dv chunk */\n do_check_any_chunk(m, m->dv);\n assert(m->dvsize == chunksize(m->dv));\n assert(m->dvsize >= MIN_CHUNK_SIZE);\n assert(bin_find(m, m->dv) == 0);\n }\n \n if (m->top != 0) { /* check top chunk */\n do_check_top_chunk(m, m->top);\n /*assert(m->topsize == chunksize(m->top)); redundant */\n assert(m->topsize > 0);\n assert(bin_find(m, m->top) == 0);\n }\n \n total = traverse_and_check(m);\n assert(total <= m->footprint);\n assert(m->footprint <= m->max_footprint);\n}\n#endif /* DEBUG */\n\n/* ----------------------------- statistics ------------------------------ */\n\n#if !NO_MALLINFO\nstatic struct mallinfo internal_mallinfo(mstate m) {\n struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\n ensure_initialization();\n if (!PREACTION(m)) {\n check_malloc_state(m);\n if (is_initialized(m)) {\n size_t nfree = SIZE_T_ONE; /* top always free */\n size_t mfree = m->topsize + TOP_FOOT_SIZE;\n size_t sum = mfree;\n msegmentptr s = &m->seg;\n while (s != 0) {\n mchunkptr q = align_as_chunk(s->base);\n while (segment_holds(s, q) &&\n q != m->top && q->head != FENCEPOST_HEAD) {\n size_t sz = chunksize(q);\n sum += sz;\n if (!is_inuse(q)) {\n mfree += sz;\n ++nfree;\n }\n q = next_chunk(q);\n }\n s = s->next;\n }\n \n nm.arena = sum;\n nm.ordblks = nfree;\n nm.hblkhd = m->footprint - sum;\n nm.usmblks = m->max_footprint;\n nm.uordblks = m->footprint - mfree;\n nm.fordblks = mfree;\n nm.keepcost = m->topsize;\n }\n \n POSTACTION(m);\n }\n return nm;\n}\n#endif /* !NO_MALLINFO */\n\n#if !NO_MALLOC_STATS\nstatic void internal_malloc_stats(mstate m) {\n ensure_initialization();\n if (!PREACTION(m)) {\n size_t maxfp = 0;\n size_t fp = 0;\n size_t used = 0;\n check_malloc_state(m);\n if (is_initialized(m)) {\n msegmentptr s = &m->seg;\n maxfp = m->max_footprint;\n fp = m->footprint;\n used = fp - (m->topsize + TOP_FOOT_SIZE);\n \n while (s != 0) {\n mchunkptr q = align_as_chunk(s->base);\n while (segment_holds(s, q) &&\n q != m->top && q->head != FENCEPOST_HEAD) {\n if (!is_inuse(q))\n used -= chunksize(q);\n q = next_chunk(q);\n }\n s = s->next;\n }\n }\n POSTACTION(m); /* drop lock */\n fprintf(stderr, \"max system bytes = %10lu\\n\", (unsigned long)(maxfp));\n fprintf(stderr, \"system bytes = %10lu\\n\", (unsigned long)(fp));\n fprintf(stderr, \"in use bytes = %10lu\\n\", (unsigned long)(used));\n }\n}\n#endif /* NO_MALLOC_STATS */\n\n/* ----------------------- Operations on smallbins ----------------------- */\n\n/*\n Various forms of linking and unlinking are defined as macros. Even\n the ones for trees, which are very long but have very short typical\n paths. This is ugly but reduces reliance on inlining support of\n compilers.\n */\n\n/* Link a free chunk into a smallbin */\n#define insert_small_chunk(M, P, S) {\\\nbindex_t I = small_index(S);\\\nmchunkptr B = smallbin_at(M, I);\\\nmchunkptr F = B;\\\nassert(S >= MIN_CHUNK_SIZE);\\\nif (!smallmap_is_marked(M, I))\\\nmark_smallmap(M, I);\\\nelse if (RTCHECK(ok_address(M, B->fd)))\\\nF = B->fd;\\\nelse {\\\nCORRUPTION_ERROR_ACTION(M);\\\n}\\\nB->fd = P;\\\nF->bk = P;\\\nP->fd = F;\\\nP->bk = B;\\\n}\n\n/* Unlink a chunk from a smallbin */\n#define unlink_small_chunk(M, P, S) {\\\nmchunkptr F = P->fd;\\\nmchunkptr B = P->bk;\\\nbindex_t I = small_index(S);\\\nassert(P != B);\\\nassert(P != F);\\\nassert(chunksize(P) == small_index2size(I));\\\nif (RTCHECK(F == smallbin_at(M,I) || (ok_address(M, F) && F->bk == P))) { \\\nif (B == F) {\\\nclear_smallmap(M, I);\\\n}\\\nelse if (RTCHECK(B == smallbin_at(M,I) ||\\\n(ok_address(M, B) && B->fd == P))) {\\\nF->bk = B;\\\nB->fd = F;\\\n}\\\nelse {\\\nCORRUPTION_ERROR_ACTION(M);\\\n}\\\n}\\\nelse {\\\nCORRUPTION_ERROR_ACTION(M);\\\n}\\\n}\n\n/* Unlink the first chunk from a smallbin */\n#define unlink_first_small_chunk(M, B, P, I) {\\\nmchunkptr F = P->fd;\\\nassert(P != B);\\\nassert(P != F);\\\nassert(chunksize(P) == small_index2size(I));\\\nif (B == F) {\\\nclear_smallmap(M, I);\\\n}\\\nelse if (RTCHECK(ok_address(M, F) && F->bk == P)) {\\\nF->bk = B;\\\nB->fd = F;\\\n}\\\nelse {\\\nCORRUPTION_ERROR_ACTION(M);\\\n}\\\n}\n\n/* Replace dv node, binning the old one */\n/* Used only when dvsize known to be small */\n#define replace_dv(M, P, S) {\\\nsize_t DVS = M->dvsize;\\\nassert(is_small(DVS));\\\nif (DVS != 0) {\\\nmchunkptr DV = M->dv;\\\ninsert_small_chunk(M, DV, DVS);\\\n}\\\nM->dvsize = S;\\\nM->dv = P;\\\n}\n\n/* ------------------------- Operations on trees ------------------------- */\n\n/* Insert chunk into tree */\n#define insert_large_chunk(M, X, S) {\\\ntbinptr* H;\\\nbindex_t I;\\\ncompute_tree_index(S, I);\\\nH = treebin_at(M, I);\\\nX->index = I;\\\nX->child[0] = X->child[1] = 0;\\\nif (!treemap_is_marked(M, I)) {\\\nmark_treemap(M, I);\\\n*H = X;\\\nX->parent = (tchunkptr)H;\\\nX->fd = X->bk = X;\\\n}\\\nelse {\\\ntchunkptr T = *H;\\\nsize_t K = S << leftshift_for_tree_index(I);\\\nfor (;;) {\\\nif (chunksize(T) != S) {\\\ntchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\\\nK <<= 1;\\\nif (*C != 0)\\\nT = *C;\\\nelse if (RTCHECK(ok_address(M, C))) {\\\n*C = X;\\\nX->parent = T;\\\nX->fd = X->bk = X;\\\nbreak;\\\n}\\\nelse {\\\nCORRUPTION_ERROR_ACTION(M);\\\nbreak;\\\n}\\\n}\\\nelse {\\\ntchunkptr F = T->fd;\\\nif (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\\\nT->fd = F->bk = X;\\\nX->fd = F;\\\nX->bk = T;\\\nX->parent = 0;\\\nbreak;\\\n}\\\nelse {\\\nCORRUPTION_ERROR_ACTION(M);\\\nbreak;\\\n}\\\n}\\\n}\\\n}\\\n}\n\n/*\n Unlink steps:\n \n 1. If x is a chained node, unlink it from its same-sized fd/bk links\n and choose its bk node as its replacement.\n 2. If x was the last node of its size, but not a leaf node, it must\n be replaced with a leaf node (not merely one with an open left or\n right), to make sure that lefts and rights of descendents\n correspond properly to bit masks. We use the rightmost descendent\n of x. We could use any other leaf, but this is easy to locate and\n tends to counteract removal of leftmosts elsewhere, and so keeps\n paths shorter than minimally guaranteed. This doesn't loop much\n because on average a node in a tree is near the bottom.\n 3. If x is the base of a chain (i.e., has parent links) relink\n x's parent and children to x's replacement (or null if none).\n */\n\n#define unlink_large_chunk(M, X) { \\\ntchunkptr XP = X->parent; \\\ntchunkptr R; \\\nif (X->bk != X) { \\\ntchunkptr F = X->fd; \\\nR = X->bk; \\\nif (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) { \\\nF->bk = R; \\\nR->fd = F; \\\n} \\\nelse { \\\nCORRUPTION_ERROR_ACTION(M); \\\n} \\\n} \\\nelse { \\\ntchunkptr* RP; \\\nif (((R = *(RP = &(X->child[1]))) != 0) || \\\n((R = *(RP = &(X->child[0]))) != 0)) { \\\ntchunkptr* CP; \\\nwhile ((*(CP = &(R->child[1])) != 0) || \\\n(*(CP = &(R->child[0])) != 0)) { \\\nR = *(RP = CP); \\\n} \\\nif (RTCHECK(ok_address(M, RP))) \\\n*RP = 0; \\\nelse { \\\nCORRUPTION_ERROR_ACTION(M); \\\n} \\\n} \\\n} \\\nif (XP != 0) { \\\ntbinptr* H = treebin_at(M, X->index); \\\nif (X == *H) { \\\nif ((*H = R) == 0) \\\nclear_treemap(M, X->index); \\\n} \\\nelse if (RTCHECK(ok_address(M, XP))) { \\\nif (XP->child[0] == X) \\\nXP->child[0] = R; \\\nelse \\\nXP->child[1] = R; \\\n} \\\nelse \\\nCORRUPTION_ERROR_ACTION(M); \\\nif (R != 0) { \\\nif (RTCHECK(ok_address(M, R))) { \\\ntchunkptr C0, C1; \\\nR->parent = XP; \\\nif ((C0 = X->child[0]) != 0) { \\\nif (RTCHECK(ok_address(M, C0))) { \\\nR->child[0] = C0; \\\nC0->parent = R; \\\n} \\\nelse \\\nCORRUPTION_ERROR_ACTION(M); \\\n} \\\nif ((C1 = X->child[1]) != 0) { \\\nif (RTCHECK(ok_address(M, C1))) { \\\nR->child[1] = C1; \\\nC1->parent = R; \\\n} \\\nelse \\\nCORRUPTION_ERROR_ACTION(M); \\\n} \\\n} \\\nelse \\\nCORRUPTION_ERROR_ACTION(M); \\\n} \\\n} \\\n}\n\n/* Relays to large vs small bin operations */\n\n#define insert_chunk(M, P, S) \\\nif (is_small(S)) insert_small_chunk(M, P, S) \\\nelse { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); }\n\n#define unlink_chunk(M, P, S) \\\nif (is_small(S)) unlink_small_chunk(M, P, S) \\\nelse { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); }\n\n\n/* Relays to internal calls to malloc/free from realloc, memalign etc */\n\n#if ONLY_MSPACES\n#define internal_malloc(m, b) mspace_malloc(m, b)\n#define internal_free(m, mem) mspace_free(m,mem);\n#else /* ONLY_MSPACES */\n#if MSPACES\n#define internal_malloc(m, b)\\\n((m == gm)? dlmalloc(b) : mspace_malloc(m, b))\n#define internal_free(m, mem)\\\nif (m == gm) dlfree(mem); else mspace_free(m,mem);\n#else /* MSPACES */\n#define internal_malloc(m, b) dlmalloc(b)\n#define internal_free(m, mem) dlfree(mem)\n#endif /* MSPACES */\n#endif /* ONLY_MSPACES */\n\n/* ----------------------- Direct-mmapping chunks ----------------------- */\n\n/*\n Directly mmapped chunks are set up with an offset to the start of\n the mmapped region stored in the prev_foot field of the chunk. This\n allows reconstruction of the required argument to MUNMAP when freed,\n and also allows adjustment of the returned chunk to meet alignment\n requirements (especially in memalign).\n */\n\n/* Malloc using mmap */\nstatic void* mmap_alloc(mstate m, size_t nb) {\n size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK);\n if (m->footprint_limit != 0) {\n size_t fp = m->footprint + mmsize;\n if (fp <= m->footprint || fp > m->footprint_limit)\n return 0;\n }\n if (mmsize > nb) { /* Check for wrap around 0 */\n char* mm = (char*)(CALL_DIRECT_MMAP(mmsize));\n if (mm != CMFAIL) {\n size_t offset = align_offset(chunk2mem(mm));\n size_t psize = mmsize - offset - MMAP_FOOT_PAD;\n mchunkptr p = (mchunkptr)(mm + offset);\n p->prev_foot = offset;\n p->head = psize;\n mark_inuse_foot(m, p, psize);\n chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD;\n chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0;\n \n if (m->least_addr == 0 || mm < m->least_addr)\n m->least_addr = mm;\n if ((m->footprint += mmsize) > m->max_footprint)\n m->max_footprint = m->footprint;\n assert(is_aligned(chunk2mem(p)));\n check_mmapped_chunk(m, p);\n return chunk2mem(p);\n }\n }\n return 0;\n}\n\n/* Realloc using mmap */\nstatic mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb, int flags) {\n size_t oldsize = chunksize(oldp);\n (void)flags; /* placate people compiling -Wunused */\n if (is_small(nb)) /* Can't shrink mmap regions below small size */\n return 0;\n /* Keep old chunk if big enough but not too big */\n if (oldsize >= nb + SIZE_T_SIZE &&\n (oldsize - nb) <= (mparams.granularity << 1))\n return oldp;\n else {\n size_t offset = oldp->prev_foot;\n size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD;\n size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK);\n char* cp = (char*)CALL_MREMAP((char*)oldp - offset,\n oldmmsize, newmmsize, flags);\n if (cp != CMFAIL) {\n mchunkptr newp = (mchunkptr)(cp + offset);\n size_t psize = newmmsize - offset - MMAP_FOOT_PAD;\n newp->head = psize;\n mark_inuse_foot(m, newp, psize);\n chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD;\n chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0;\n \n if (cp < m->least_addr)\n m->least_addr = cp;\n if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint)\n m->max_footprint = m->footprint;\n check_mmapped_chunk(m, newp);\n return newp;\n }\n }\n return 0;\n}\n\n\n/* -------------------------- mspace management -------------------------- */\n\n/* Initialize top chunk and its size */\nstatic void init_top(mstate m, mchunkptr p, size_t psize) {\n /* Ensure alignment */\n size_t offset = align_offset(chunk2mem(p));\n p = (mchunkptr)((char*)p + offset);\n psize -= offset;\n \n m->top = p;\n m->topsize = psize;\n p->head = psize | PINUSE_BIT;\n /* set size of fake trailing chunk holding overhead space only once */\n chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE;\n m->trim_check = mparams.trim_threshold; /* reset on each update */\n}\n\n/* Initialize bins for a new mstate that is otherwise zeroed out */\nstatic void init_bins(mstate m) {\n /* Establish circular links for smallbins */\n bindex_t i;\n for (i = 0; i < NSMALLBINS; ++i) {\n sbinptr bin = smallbin_at(m,i);\n bin->fd = bin->bk = bin;\n }\n}\n\n#if PROCEED_ON_ERROR\n\n/* default corruption action */\nstatic void reset_on_error(mstate m) {\n int i;\n ++malloc_corruption_error_count;\n /* Reinitialize fields to forget about all memory */\n m->smallmap = m->treemap = 0;\n m->dvsize = m->topsize = 0;\n m->seg.base = 0;\n m->seg.size = 0;\n m->seg.next = 0;\n m->top = m->dv = 0;\n for (i = 0; i < NTREEBINS; ++i)\n *treebin_at(m, i) = 0;\n init_bins(m);\n}\n#endif /* PROCEED_ON_ERROR */\n\n/* Allocate chunk and prepend remainder with chunk in successor base. */\nstatic void* prepend_alloc(mstate m, char* newbase, char* oldbase,\n size_t nb) {\n mchunkptr p = align_as_chunk(newbase);\n mchunkptr oldfirst = align_as_chunk(oldbase);\n size_t psize = (char*)oldfirst - (char*)p;\n mchunkptr q = chunk_plus_offset(p, nb);\n size_t qsize = psize - nb;\n set_size_and_pinuse_of_inuse_chunk(m, p, nb);\n \n assert((char*)oldfirst > (char*)q);\n assert(pinuse(oldfirst));\n assert(qsize >= MIN_CHUNK_SIZE);\n \n /* consolidate remainder with first chunk of old base */\n if (oldfirst == m->top) {\n size_t tsize = m->topsize += qsize;\n m->top = q;\n q->head = tsize | PINUSE_BIT;\n check_top_chunk(m, q);\n }\n else if (oldfirst == m->dv) {\n size_t dsize = m->dvsize += qsize;\n m->dv = q;\n set_size_and_pinuse_of_free_chunk(q, dsize);\n }\n else {\n if (!is_inuse(oldfirst)) {\n size_t nsize = chunksize(oldfirst);\n unlink_chunk(m, oldfirst, nsize);\n oldfirst = chunk_plus_offset(oldfirst, nsize);\n qsize += nsize;\n }\n set_free_with_pinuse(q, qsize, oldfirst);\n insert_chunk(m, q, qsize);\n check_free_chunk(m, q);\n }\n \n check_malloced_chunk(m, chunk2mem(p), nb);\n return chunk2mem(p);\n}\n\n/* Add a segment to hold a new noncontiguous region */\nstatic void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) {\n /* Determine locations and sizes of segment, fenceposts, old top */\n char* old_top = (char*)m->top;\n msegmentptr oldsp = segment_holding(m, old_top);\n char* old_end = oldsp->base + oldsp->size;\n size_t ssize = pad_request(sizeof(struct malloc_segment));\n char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK);\n size_t offset = align_offset(chunk2mem(rawsp));\n char* asp = rawsp + offset;\n char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp;\n mchunkptr sp = (mchunkptr)csp;\n msegmentptr ss = (msegmentptr)(chunk2mem(sp));\n mchunkptr tnext = chunk_plus_offset(sp, ssize);\n mchunkptr p = tnext;\n int nfences = 0;\n \n /* reset top to new space */\n init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);\n \n /* Set up segment record */\n assert(is_aligned(ss));\n set_size_and_pinuse_of_inuse_chunk(m, sp, ssize);\n *ss = m->seg; /* Push current record */\n m->seg.base = tbase;\n m->seg.size = tsize;\n m->seg.sflags = mmapped;\n m->seg.next = ss;\n \n /* Insert trailing fenceposts */\n for (;;) {\n mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE);\n p->head = FENCEPOST_HEAD;\n ++nfences;\n if ((char*)(&(nextp->head)) < old_end)\n p = nextp;\n else\n break;\n }\n assert(nfences >= 2);\n \n /* Insert the rest of old top into a bin as an ordinary free chunk */\n if (csp != old_top) {\n mchunkptr q = (mchunkptr)old_top;\n size_t psize = csp - old_top;\n mchunkptr tn = chunk_plus_offset(q, psize);\n set_free_with_pinuse(q, psize, tn);\n insert_chunk(m, q, psize);\n }\n \n check_top_chunk(m, m->top);\n}\n\n/* -------------------------- System allocation -------------------------- */\n\n/* Get memory from system using MORECORE or MMAP */\nstatic void* sys_alloc(mstate m, size_t nb) {\n char* tbase = CMFAIL;\n size_t tsize = 0;\n flag_t mmap_flag = 0;\n size_t asize; /* allocation size */\n \n ensure_initialization();\n \n /* Directly map large chunks, but only if already initialized */\n if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) {\n void* mem = mmap_alloc(m, nb);\n if (mem != 0)\n return mem;\n }\n \n asize = granularity_align(nb + SYS_ALLOC_PADDING);\n if (asize <= nb)\n return 0; /* wraparound */\n if (m->footprint_limit != 0) {\n size_t fp = m->footprint + asize;\n if (fp <= m->footprint || fp > m->footprint_limit)\n return 0;\n }\n \n /*\n Try getting memory in any of three ways (in most-preferred to\n least-preferred order):\n 1. A call to MORECORE that can normally contiguously extend memory.\n (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or\n or main space is mmapped or a previous contiguous call failed)\n 2. A call to MMAP new space (disabled if not HAVE_MMAP).\n Note that under the default settings, if MORECORE is unable to\n fulfill a request, and HAVE_MMAP is true, then mmap is\n used as a noncontiguous system allocator. This is a useful backup\n strategy for systems with holes in address spaces -- in this case\n sbrk cannot contiguously expand the heap, but mmap may be able to\n find space.\n 3. A call to MORECORE that cannot usually contiguously extend memory.\n (disabled if not HAVE_MORECORE)\n \n In all cases, we need to request enough bytes from system to ensure\n we can malloc nb bytes upon success, so pad with enough space for\n top_foot, plus alignment-pad to make sure we don't lose bytes if\n not on boundary, and round this up to a granularity unit.\n */\n \n if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) {\n char* br = CMFAIL;\n size_t ssize = asize; /* sbrk call size */\n msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top);\n ACQUIRE_MALLOC_GLOBAL_LOCK();\n \n if (ss == 0) { /* First time through or recovery */\n char* base = (char*)CALL_MORECORE(0);\n if (base != CMFAIL) {\n size_t fp;\n /* Adjust to end on a page boundary */\n if (!is_page_aligned(base))\n ssize += (page_align((size_t)base) - (size_t)base);\n fp = m->footprint + ssize; /* recheck limits */\n if (ssize > nb &&\n (UNSIGNED_MORECORE || ssize < HALF_MAX_SIZE_T) &&\n (m->footprint_limit == 0 ||\n (fp > m->footprint && fp <= m->footprint_limit)) &&\n (br = (char*)(CALL_MORECORE(ssize))) == base) {\n tbase = base;\n tsize = ssize;\n }\n }\n }\n else {\n /* Subtract out existing available top space from MORECORE request. */\n ssize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING);\n /* Use mem here only if it did continuously extend old space */\n if ((UNSIGNED_MORECORE || ssize < HALF_MAX_SIZE_T) &&\n (br = (char*)(CALL_MORECORE(ssize))) == ss->base+ss->size) {\n tbase = br;\n tsize = ssize;\n }\n }\n \n if (tbase == CMFAIL) { /* Cope with partial failure */\n if (br != CMFAIL) { /* Try to use/extend the space we did get */\n if ((UNSIGNED_MORECORE || ssize < HALF_MAX_SIZE_T) &&\n ssize < nb + SYS_ALLOC_PADDING) {\n size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - ssize);\n if (UNSIGNED_MORECORE || esize < HALF_MAX_SIZE_T) {\n char* end = (char*)CALL_MORECORE(esize);\n if (end != CMFAIL)\n ssize += esize;\n else { /* Can't use; try to release */\n if (!UNSIGNED_MORECORE) {\n (void) CALL_MORECORE(-ssize);\n }\n br = CMFAIL;\n }\n }\n }\n }\n if (br != CMFAIL) { /* Use the space we did get */\n tbase = br;\n tsize = ssize;\n }\n else\n disable_contiguous(m); /* Don't try contiguous path in the future */\n }\n \n RELEASE_MALLOC_GLOBAL_LOCK();\n }\n \n if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */\n char* mp = (char*)(CALL_MMAP(asize));\n if (mp != CMFAIL) {\n tbase = mp;\n tsize = asize;\n mmap_flag = USE_MMAP_BIT;\n }\n }\n \n if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */\n if (UNSIGNED_MORECORE || asize < HALF_MAX_SIZE_T) {\n char* br = CMFAIL;\n char* end = CMFAIL;\n ACQUIRE_MALLOC_GLOBAL_LOCK();\n br = (char*)(CALL_MORECORE(asize));\n end = (char*)(CALL_MORECORE(0));\n RELEASE_MALLOC_GLOBAL_LOCK();\n if (br != CMFAIL && end != CMFAIL && br < end) {\n size_t ssize = end - br;\n if (ssize > nb + TOP_FOOT_SIZE) {\n tbase = br;\n tsize = ssize;\n }\n }\n }\n }\n \n if (tbase != CMFAIL) {\n \n if ((m->footprint += tsize) > m->max_footprint)\n m->max_footprint = m->footprint;\n \n if (!is_initialized(m)) { /* first-time initialization */\n if (m->least_addr == 0 || tbase < m->least_addr)\n m->least_addr = tbase;\n m->seg.base = tbase;\n m->seg.size = tsize;\n m->seg.sflags = mmap_flag;\n m->magic = mparams.magic;\n m->release_checks = MAX_RELEASE_CHECK_RATE;\n init_bins(m);\n#if !ONLY_MSPACES\n if (is_global(m))\n init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);\n else\n#endif\n {\n /* Offset top by embedded malloc_state */\n mchunkptr mn = next_chunk(mem2chunk(m));\n init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE);\n }\n }\n \n else {\n /* Try to merge with an existing segment */\n msegmentptr sp = &m->seg;\n /* Only consider most recent segment if traversal suppressed */\n while (sp != 0 && tbase != sp->base + sp->size)\n sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next;\n if (sp != 0 &&\n !is_extern_segment(sp) &&\n (sp->sflags & USE_MMAP_BIT) == mmap_flag &&\n segment_holds(sp, m->top)) { /* append */\n sp->size += tsize;\n init_top(m, m->top, m->topsize + tsize);\n }\n else {\n if (tbase < m->least_addr)\n m->least_addr = tbase;\n sp = &m->seg;\n while (sp != 0 && sp->base != tbase + tsize)\n sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next;\n if (sp != 0 &&\n !is_extern_segment(sp) &&\n (sp->sflags & USE_MMAP_BIT) == mmap_flag) {\n char* oldbase = sp->base;\n sp->base = tbase;\n sp->size += tsize;\n return prepend_alloc(m, tbase, oldbase, nb);\n }\n else\n add_segment(m, tbase, tsize, mmap_flag);\n }\n }\n \n if (nb < m->topsize) { /* Allocate from new or extended top space */\n size_t rsize = m->topsize -= nb;\n mchunkptr p = m->top;\n mchunkptr r = m->top = chunk_plus_offset(p, nb);\n r->head = rsize | PINUSE_BIT;\n set_size_and_pinuse_of_inuse_chunk(m, p, nb);\n check_top_chunk(m, m->top);\n check_malloced_chunk(m, chunk2mem(p), nb);\n return chunk2mem(p);\n }\n }\n \n MALLOC_FAILURE_ACTION;\n return 0;\n}\n\n/* ----------------------- system deallocation -------------------------- */\n\n/* Unmap and unlink any mmapped segments that don't contain used chunks */\nstatic size_t release_unused_segments(mstate m) {\n size_t released = 0;\n int nsegs = 0;\n msegmentptr pred = &m->seg;\n msegmentptr sp = pred->next;\n while (sp != 0) {\n char* base = sp->base;\n size_t size = sp->size;\n msegmentptr next = sp->next;\n ++nsegs;\n if (is_mmapped_segment(sp) && !is_extern_segment(sp)) {\n mchunkptr p = align_as_chunk(base);\n size_t psize = chunksize(p);\n /* Can unmap if first chunk holds entire segment and not pinned */\n if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) {\n tchunkptr tp = (tchunkptr)p;\n assert(segment_holds(sp, (char*)sp));\n if (p == m->dv) {\n m->dv = 0;\n m->dvsize = 0;\n }\n else {\n unlink_large_chunk(m, tp);\n }\n if (CALL_MUNMAP(base, size) == 0) {\n released += size;\n m->footprint -= size;\n /* unlink obsoleted record */\n sp = pred;\n sp->next = next;\n }\n else { /* back out if cannot unmap */\n insert_large_chunk(m, tp, psize);\n }\n }\n }\n if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */\n break;\n pred = sp;\n sp = next;\n }\n /* Reset check counter */\n m->release_checks = (((size_t) nsegs > (size_t) MAX_RELEASE_CHECK_RATE)?\n (size_t) nsegs : (size_t) MAX_RELEASE_CHECK_RATE);\n return released;\n}\n\nstatic int sys_trim(mstate m, size_t pad) {\n size_t released = 0;\n ensure_initialization();\n if (pad < MAX_REQUEST && is_initialized(m)) {\n pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */\n \n if (m->topsize > pad) {\n /* Shrink top space in granularity-size units, keeping at least one */\n size_t unit = mparams.granularity;\n size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit -\n SIZE_T_ONE) * unit;\n msegmentptr sp = segment_holding(m, (char*)m->top);\n \n if (!is_extern_segment(sp)) {\n if (is_mmapped_segment(sp)) {\n if (HAVE_MMAP &&\n sp->size >= extra &&\n !has_segment_link(m, sp)) { /* can't shrink if pinned */\n size_t newsize = sp->size - extra;\n (void)newsize; /* placate people compiling -Wunused-variable */\n /* Prefer mremap, fall back to munmap */\n if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) ||\n (CALL_MUNMAP(sp->base + newsize, extra) == 0)) {\n released = extra;\n }\n }\n }\n else if (HAVE_MORECORE) {\n#ifndef MORECORE_CANNOT_TRIM\n if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */\n extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit;\n ACQUIRE_MALLOC_GLOBAL_LOCK();\n {\n /* Make sure end of memory is where we last set it. */\n char* old_br = (char*)(CALL_MORECORE(0));\n if (old_br == sp->base + sp->size) {\n char* rel_br = (char*)(CALL_MORECORE(-extra));\n char* new_br = (char*)(CALL_MORECORE(0));\n if (rel_br != CMFAIL && new_br < old_br)\n released = old_br - new_br;\n }\n }\n RELEASE_MALLOC_GLOBAL_LOCK();\n#endif\n }\n }\n \n if (released != 0) {\n sp->size -= released;\n m->footprint -= released;\n init_top(m, m->top, m->topsize - released);\n check_top_chunk(m, m->top);\n }\n }\n \n /* Unmap any unused mmapped segments */\n if (HAVE_MMAP)\n released += release_unused_segments(m);\n \n /* On failure, disable autotrim to avoid repeated failed future calls */\n if (released == 0 && m->topsize > m->trim_check)\n m->trim_check = MAX_SIZE_T;\n }\n \n return (released != 0)? 1 : 0;\n}\n\n/* Consolidate and bin a chunk. Differs from exported versions\n of free mainly in that the chunk need not be marked as inuse.\n */\nstatic void dispose_chunk(mstate m, mchunkptr p, size_t psize) {\n mchunkptr next = chunk_plus_offset(p, psize);\n if (!pinuse(p)) {\n mchunkptr prev;\n size_t prevsize = p->prev_foot;\n if (is_mmapped(p)) {\n psize += prevsize + MMAP_FOOT_PAD;\n if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)\n m->footprint -= psize;\n return;\n }\n prev = chunk_minus_offset(p, prevsize);\n psize += prevsize;\n p = prev;\n if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */\n if (p != m->dv) {\n unlink_chunk(m, p, prevsize);\n }\n else if ((next->head & INUSE_BITS) == INUSE_BITS) {\n m->dvsize = psize;\n set_free_with_pinuse(p, psize, next);\n return;\n }\n }\n else {\n CORRUPTION_ERROR_ACTION(m);\n return;\n }\n }\n if (RTCHECK(ok_address(m, next))) {\n if (!cinuse(next)) { /* consolidate forward */\n if (next == m->top) {\n size_t tsize = m->topsize += psize;\n m->top = p;\n p->head = tsize | PINUSE_BIT;\n if (p == m->dv) {\n m->dv = 0;\n m->dvsize = 0;\n }\n return;\n }\n else if (next == m->dv) {\n size_t dsize = m->dvsize += psize;\n m->dv = p;\n set_size_and_pinuse_of_free_chunk(p, dsize);\n return;\n }\n else {\n size_t nsize = chunksize(next);\n psize += nsize;\n unlink_chunk(m, next, nsize);\n set_size_and_pinuse_of_free_chunk(p, psize);\n if (p == m->dv) {\n m->dvsize = psize;\n return;\n }\n }\n }\n else {\n set_free_with_pinuse(p, psize, next);\n }\n insert_chunk(m, p, psize);\n }\n else {\n CORRUPTION_ERROR_ACTION(m);\n }\n}\n\n/* ---------------------------- malloc --------------------------- */\n\n/* allocate a large request from the best fitting chunk in a treebin */\nstatic void* tmalloc_large(mstate m, size_t nb) {\n tchunkptr v = 0;\n size_t rsize = -nb; /* Unsigned negation */\n tchunkptr t;\n bindex_t idx;\n compute_tree_index(nb, idx);\n if ((t = *treebin_at(m, idx)) != 0) {\n /* Traverse tree for this bin looking for node with size == nb */\n size_t sizebits = nb << leftshift_for_tree_index(idx);\n tchunkptr rst = 0; /* The deepest untaken right subtree */\n for (;;) {\n tchunkptr rt;\n size_t trem = chunksize(t) - nb;\n if (trem < rsize) {\n v = t;\n if ((rsize = trem) == 0)\n break;\n }\n rt = t->child[1];\n t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1];\n if (rt != 0 && rt != t)\n rst = rt;\n if (t == 0) {\n t = rst; /* set t to least subtree holding sizes > nb */\n break;\n }\n sizebits <<= 1;\n }\n }\n if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */\n binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap;\n if (leftbits != 0) {\n bindex_t i;\n binmap_t leastbit = least_bit(leftbits);\n compute_bit2idx(leastbit, i);\n t = *treebin_at(m, i);\n }\n }\n \n while (t != 0) { /* find smallest of tree or subtree */\n size_t trem = chunksize(t) - nb;\n if (trem < rsize) {\n rsize = trem;\n v = t;\n }\n t = leftmost_child(t);\n }\n \n /* If dv is a better fit, return 0 so malloc will use it */\n if (v != 0 && rsize < (size_t)(m->dvsize - nb)) {\n if (RTCHECK(ok_address(m, v))) { /* split */\n mchunkptr r = chunk_plus_offset(v, nb);\n assert(chunksize(v) == rsize + nb);\n if (RTCHECK(ok_next(v, r))) {\n unlink_large_chunk(m, v);\n if (rsize < MIN_CHUNK_SIZE)\n set_inuse_and_pinuse(m, v, (rsize + nb));\n else {\n set_size_and_pinuse_of_inuse_chunk(m, v, nb);\n set_size_and_pinuse_of_free_chunk(r, rsize);\n insert_chunk(m, r, rsize);\n }\n return chunk2mem(v);\n }\n }\n CORRUPTION_ERROR_ACTION(m);\n }\n return 0;\n}\n\n/* allocate a small request from the best fitting chunk in a treebin */\nstatic void* tmalloc_small(mstate m, size_t nb) {\n tchunkptr t, v;\n size_t rsize;\n bindex_t i;\n binmap_t leastbit = least_bit(m->treemap);\n compute_bit2idx(leastbit, i);\n v = t = *treebin_at(m, i);\n rsize = chunksize(t) - nb;\n \n while ((t = leftmost_child(t)) != 0) {\n size_t trem = chunksize(t) - nb;\n if (trem < rsize) {\n rsize = trem;\n v = t;\n }\n }\n \n if (RTCHECK(ok_address(m, v))) {\n mchunkptr r = chunk_plus_offset(v, nb);\n assert(chunksize(v) == rsize + nb);\n if (RTCHECK(ok_next(v, r))) {\n unlink_large_chunk(m, v);\n if (rsize < MIN_CHUNK_SIZE)\n set_inuse_and_pinuse(m, v, (rsize + nb));\n else {\n set_size_and_pinuse_of_inuse_chunk(m, v, nb);\n set_size_and_pinuse_of_free_chunk(r, rsize);\n replace_dv(m, r, rsize);\n }\n return chunk2mem(v);\n }\n }\n \n CORRUPTION_ERROR_ACTION(m);\n return 0;\n}\n\n#if !ONLY_MSPACES\n\nvoid* dlmalloc(size_t bytes) {\n /*\n Basic algorithm:\n If a small request (< 256 bytes minus per-chunk overhead):\n 1. If one exists, use a remainderless chunk in associated smallbin.\n (Remainderless means that there are too few excess bytes to\n represent as a chunk.)\n 2. If it is big enough, use the dv chunk, which is normally the\n chunk adjacent to the one used for the most recent small request.\n 3. If one exists, split the smallest available chunk in a bin,\n saving remainder in dv.\n 4. If it is big enough, use the top chunk.\n 5. If available, get memory from system and use it\n Otherwise, for a large request:\n 1. Find the smallest available binned chunk that fits, and use it\n if it is better fitting than dv chunk, splitting if necessary.\n 2. If better fitting than any binned chunk, use the dv chunk.\n 3. If it is big enough, use the top chunk.\n 4. If request size >= mmap threshold, try to directly mmap this chunk.\n 5. If available, get memory from system and use it\n \n The ugly goto's here ensure that postaction occurs along all paths.\n */\n \n#if USE_LOCKS\n ensure_initialization(); /* initialize in sys_alloc if not using locks */\n#endif\n \n if (!PREACTION(gm)) {\n void* mem;\n size_t nb;\n if (bytes <= MAX_SMALL_REQUEST) {\n bindex_t idx;\n binmap_t smallbits;\n nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes);\n idx = small_index(nb);\n smallbits = gm->smallmap >> idx;\n \n if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */\n mchunkptr b, p;\n idx += ~smallbits & 1; /* Uses next bin if idx empty */\n b = smallbin_at(gm, idx);\n p = b->fd;\n assert(chunksize(p) == small_index2size(idx));\n unlink_first_small_chunk(gm, b, p, idx);\n set_inuse_and_pinuse(gm, p, small_index2size(idx));\n mem = chunk2mem(p);\n check_malloced_chunk(gm, mem, nb);\n goto postaction;\n }\n \n else if (nb > gm->dvsize) {\n if (smallbits != 0) { /* Use chunk in next nonempty smallbin */\n mchunkptr b, p, r;\n size_t rsize;\n bindex_t i;\n binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx));\n binmap_t leastbit = least_bit(leftbits);\n compute_bit2idx(leastbit, i);\n b = smallbin_at(gm, i);\n p = b->fd;\n assert(chunksize(p) == small_index2size(i));\n unlink_first_small_chunk(gm, b, p, i);\n rsize = small_index2size(i) - nb;\n /* Fit here cannot be remainderless if 4byte sizes */\n if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE)\n set_inuse_and_pinuse(gm, p, small_index2size(i));\n else {\n set_size_and_pinuse_of_inuse_chunk(gm, p, nb);\n r = chunk_plus_offset(p, nb);\n set_size_and_pinuse_of_free_chunk(r, rsize);\n replace_dv(gm, r, rsize);\n }\n mem = chunk2mem(p);\n check_malloced_chunk(gm, mem, nb);\n goto postaction;\n }\n \n else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) {\n check_malloced_chunk(gm, mem, nb);\n goto postaction;\n }\n }\n }\n else if (bytes >= MAX_REQUEST)\n nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */\n else {\n nb = pad_request(bytes);\n if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) {\n check_malloced_chunk(gm, mem, nb);\n goto postaction;\n }\n }\n \n if (nb <= gm->dvsize) {\n size_t rsize = gm->dvsize - nb;\n mchunkptr p = gm->dv;\n if (rsize >= MIN_CHUNK_SIZE) { /* split dv */\n mchunkptr r = gm->dv = chunk_plus_offset(p, nb);\n gm->dvsize = rsize;\n set_size_and_pinuse_of_free_chunk(r, rsize);\n set_size_and_pinuse_of_inuse_chunk(gm, p, nb);\n }\n else { /* exhaust dv */\n size_t dvs = gm->dvsize;\n gm->dvsize = 0;\n gm->dv = 0;\n set_inuse_and_pinuse(gm, p, dvs);\n }\n mem = chunk2mem(p);\n check_malloced_chunk(gm, mem, nb);\n goto postaction;\n }\n \n else if (nb < gm->topsize) { /* Split top */\n size_t rsize = gm->topsize -= nb;\n mchunkptr p = gm->top;\n mchunkptr r = gm->top = chunk_plus_offset(p, nb);\n r->head = rsize | PINUSE_BIT;\n set_size_and_pinuse_of_inuse_chunk(gm, p, nb);\n mem = chunk2mem(p);\n check_top_chunk(gm, gm->top);\n check_malloced_chunk(gm, mem, nb);\n goto postaction;\n }\n \n mem = sys_alloc(gm, nb);\n \n postaction:\n POSTACTION(gm);\n#if __EMSCRIPTEN__\n /* XXX Emscripten Tracing API. */\n emscripten_trace_record_allocation(mem, bytes);\n#endif\n return mem;\n }\n \n return 0;\n}\n\n/* ---------------------------- free --------------------------- */\n\nvoid dlfree(void* mem) {\n /*\n Consolidate freed chunks with preceeding or succeeding bordering\n free chunks, if they exist, and then place in a bin. Intermixed\n with special cases for top, dv, mmapped chunks, and usage errors.\n */\n \n if (mem != 0) {\n#if __EMSCRIPTEN__\n /* XXX Emscripten Tracing API. */\n emscripten_trace_record_free(mem);\n#endif\n mchunkptr p = mem2chunk(mem);\n#if FOOTERS\n mstate fm = get_mstate_for(p);\n if (!ok_magic(fm)) {\n USAGE_ERROR_ACTION(fm, p);\n return;\n }\n#else /* FOOTERS */\n#define fm gm\n#endif /* FOOTERS */\n if (!PREACTION(fm)) {\n check_inuse_chunk(fm, p);\n if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) {\n size_t psize = chunksize(p);\n mchunkptr next = chunk_plus_offset(p, psize);\n if (!pinuse(p)) {\n size_t prevsize = p->prev_foot;\n if (is_mmapped(p)) {\n psize += prevsize + MMAP_FOOT_PAD;\n if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)\n fm->footprint -= psize;\n goto postaction;\n }\n else {\n mchunkptr prev = chunk_minus_offset(p, prevsize);\n psize += prevsize;\n p = prev;\n if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */\n if (p != fm->dv) {\n unlink_chunk(fm, p, prevsize);\n }\n else if ((next->head & INUSE_BITS) == INUSE_BITS) {\n fm->dvsize = psize;\n set_free_with_pinuse(p, psize, next);\n goto postaction;\n }\n }\n else\n goto erroraction;\n }\n }\n \n if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) {\n if (!cinuse(next)) { /* consolidate forward */\n if (next == fm->top) {\n size_t tsize = fm->topsize += psize;\n fm->top = p;\n p->head = tsize | PINUSE_BIT;\n if (p == fm->dv) {\n fm->dv = 0;\n fm->dvsize = 0;\n }\n if (should_trim(fm, tsize))\n sys_trim(fm, 0);\n goto postaction;\n }\n else if (next == fm->dv) {\n size_t dsize = fm->dvsize += psize;\n fm->dv = p;\n set_size_and_pinuse_of_free_chunk(p, dsize);\n goto postaction;\n }\n else {\n size_t nsize = chunksize(next);\n psize += nsize;\n unlink_chunk(fm, next, nsize);\n set_size_and_pinuse_of_free_chunk(p, psize);\n if (p == fm->dv) {\n fm->dvsize = psize;\n goto postaction;\n }\n }\n }\n else\n set_free_with_pinuse(p, psize, next);\n \n if (is_small(psize)) {\n insert_small_chunk(fm, p, psize);\n check_free_chunk(fm, p);\n }\n else {\n tchunkptr tp = (tchunkptr)p;\n insert_large_chunk(fm, tp, psize);\n check_free_chunk(fm, p);\n if (--fm->release_checks == 0)\n release_unused_segments(fm);\n }\n goto postaction;\n }\n }\n erroraction:\n USAGE_ERROR_ACTION(fm, p);\n postaction:\n POSTACTION(fm);\n }\n }\n#if !FOOTERS\n#undef fm\n#endif /* FOOTERS */\n}\n\nvoid* dlcalloc(size_t n_elements, size_t elem_size) {\n void* mem;\n size_t req = 0;\n if (n_elements != 0) {\n req = n_elements * elem_size;\n if (((n_elements | elem_size) & ~(size_t)0xffff) &&\n (req / n_elements != elem_size))\n req = MAX_SIZE_T; /* force downstream failure on overflow */\n }\n mem = dlmalloc(req);\n if (mem != 0 && calloc_must_clear(mem2chunk(mem)))\n memset(mem, 0, req);\n return mem;\n}\n\n#endif /* !ONLY_MSPACES */\n\n/* ------------ Internal support for realloc, memalign, etc -------------- */\n\n/* Try to realloc; only in-place unless can_move true */\nstatic mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb,\n int can_move) {\n mchunkptr newp = 0;\n size_t oldsize = chunksize(p);\n mchunkptr next = chunk_plus_offset(p, oldsize);\n if (RTCHECK(ok_address(m, p) && ok_inuse(p) &&\n ok_next(p, next) && ok_pinuse(next))) {\n if (is_mmapped(p)) {\n newp = mmap_resize(m, p, nb, can_move);\n }\n else if (oldsize >= nb) { /* already big enough */\n size_t rsize = oldsize - nb;\n if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */\n mchunkptr r = chunk_plus_offset(p, nb);\n set_inuse(m, p, nb);\n set_inuse(m, r, rsize);\n dispose_chunk(m, r, rsize);\n }\n newp = p;\n }\n else if (next == m->top) { /* extend into top */\n if (oldsize + m->topsize > nb) {\n size_t newsize = oldsize + m->topsize;\n size_t newtopsize = newsize - nb;\n mchunkptr newtop = chunk_plus_offset(p, nb);\n set_inuse(m, p, nb);\n newtop->head = newtopsize |PINUSE_BIT;\n m->top = newtop;\n m->topsize = newtopsize;\n newp = p;\n }\n }\n else if (next == m->dv) { /* extend into dv */\n size_t dvs = m->dvsize;\n if (oldsize + dvs >= nb) {\n size_t dsize = oldsize + dvs - nb;\n if (dsize >= MIN_CHUNK_SIZE) {\n mchunkptr r = chunk_plus_offset(p, nb);\n mchunkptr n = chunk_plus_offset(r, dsize);\n set_inuse(m, p, nb);\n set_size_and_pinuse_of_free_chunk(r, dsize);\n clear_pinuse(n);\n m->dvsize = dsize;\n m->dv = r;\n }\n else { /* exhaust dv */\n size_t newsize = oldsize + dvs;\n set_inuse(m, p, newsize);\n m->dvsize = 0;\n m->dv = 0;\n }\n newp = p;\n }\n }\n else if (!cinuse(next)) { /* extend into next free chunk */\n size_t nextsize = chunksize(next);\n if (oldsize + nextsize >= nb) {\n size_t rsize = oldsize + nextsize - nb;\n unlink_chunk(m, next, nextsize);\n if (rsize < MIN_CHUNK_SIZE) {\n size_t newsize = oldsize + nextsize;\n set_inuse(m, p, newsize);\n }\n else {\n mchunkptr r = chunk_plus_offset(p, nb);\n set_inuse(m, p, nb);\n set_inuse(m, r, rsize);\n dispose_chunk(m, r, rsize);\n }\n newp = p;\n }\n }\n }\n else {\n USAGE_ERROR_ACTION(m, chunk2mem(p));\n }\n return newp;\n}\n\nstatic void* internal_memalign(mstate m, size_t alignment, size_t bytes) {\n void* mem = 0;\n if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */\n alignment = MIN_CHUNK_SIZE;\n if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */\n size_t a = MALLOC_ALIGNMENT << 1;\n while (a < alignment) a <<= 1;\n alignment = a;\n }\n if (bytes >= MAX_REQUEST - alignment) {\n if (m != 0) { /* Test isn't needed but avoids compiler warning */\n MALLOC_FAILURE_ACTION;\n }\n }\n else {\n size_t nb = request2size(bytes);\n size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD;\n mem = internal_malloc(m, req);\n if (mem != 0) {\n mchunkptr p = mem2chunk(mem);\n if (PREACTION(m))\n return 0;\n if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */\n /*\n Find an aligned spot inside chunk. Since we need to give\n back leading space in a chunk of at least MIN_CHUNK_SIZE, if\n the first calculation places us at a spot with less than\n MIN_CHUNK_SIZE leader, we can move to the next aligned spot.\n We've allocated enough total room so that this is always\n possible.\n */\n char* br = (char*)mem2chunk((size_t)(((size_t)((char*)mem + alignment -\n SIZE_T_ONE)) &\n -alignment));\n char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)?\n br : br+alignment;\n mchunkptr newp = (mchunkptr)pos;\n size_t leadsize = pos - (char*)(p);\n size_t newsize = chunksize(p) - leadsize;\n \n if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */\n newp->prev_foot = p->prev_foot + leadsize;\n newp->head = newsize;\n }\n else { /* Otherwise, give back leader, use the rest */\n set_inuse(m, newp, newsize);\n set_inuse(m, p, leadsize);\n dispose_chunk(m, p, leadsize);\n }\n p = newp;\n }\n \n /* Give back spare room at the end */\n if (!is_mmapped(p)) {\n size_t size = chunksize(p);\n if (size > nb + MIN_CHUNK_SIZE) {\n size_t remainder_size = size - nb;\n mchunkptr remainder = chunk_plus_offset(p, nb);\n set_inuse(m, p, nb);\n set_inuse(m, remainder, remainder_size);\n dispose_chunk(m, remainder, remainder_size);\n }\n }\n \n mem = chunk2mem(p);\n assert (chunksize(p) >= nb);\n assert(((size_t)mem & (alignment - 1)) == 0);\n check_inuse_chunk(m, p);\n POSTACTION(m);\n }\n }\n return mem;\n}\n\n/*\n Common support for independent_X routines, handling\n all of the combinations that can result.\n The opts arg has:\n bit 0 set if all elements are same size (using sizes[0])\n bit 1 set if elements should be zeroed\n */\nstatic void** ialloc(mstate m,\n size_t n_elements,\n size_t* sizes,\n int opts,\n void* chunks[]) {\n \n size_t element_size; /* chunksize of each element, if all same */\n size_t contents_size; /* total size of elements */\n size_t array_size; /* request size of pointer array */\n void* mem; /* malloced aggregate space */\n mchunkptr p; /* corresponding chunk */\n size_t remainder_size; /* remaining bytes while splitting */\n void** marray; /* either \"chunks\" or malloced ptr array */\n mchunkptr array_chunk; /* chunk for malloced ptr array */\n flag_t was_enabled; /* to disable mmap */\n size_t size;\n size_t i;\n \n ensure_initialization();\n /* compute array length, if needed */\n if (chunks != 0) {\n if (n_elements == 0)\n return chunks; /* nothing to do */\n marray = chunks;\n array_size = 0;\n }\n else {\n /* if empty req, must still return chunk representing empty array */\n if (n_elements == 0)\n return (void**)internal_malloc(m, 0);\n marray = 0;\n array_size = request2size(n_elements * (sizeof(void*)));\n }\n \n /* compute total element size */\n if (opts & 0x1) { /* all-same-size */\n element_size = request2size(*sizes);\n contents_size = n_elements * element_size;\n }\n else { /* add up all the sizes */\n element_size = 0;\n contents_size = 0;\n for (i = 0; i != n_elements; ++i)\n contents_size += request2size(sizes[i]);\n }\n \n size = contents_size + array_size;\n \n /*\n Allocate the aggregate chunk. First disable direct-mmapping so\n malloc won't use it, since we would not be able to later\n free/realloc space internal to a segregated mmap region.\n */\n was_enabled = use_mmap(m);\n disable_mmap(m);\n mem = internal_malloc(m, size - CHUNK_OVERHEAD);\n if (was_enabled)\n enable_mmap(m);\n if (mem == 0)\n return 0;\n \n if (PREACTION(m)) return 0;\n p = mem2chunk(mem);\n remainder_size = chunksize(p);\n \n assert(!is_mmapped(p));\n \n if (opts & 0x2) { /* optionally clear the elements */\n memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size);\n }\n \n /* If not provided, allocate the pointer array as final part of chunk */\n if (marray == 0) {\n size_t array_chunk_size;\n array_chunk = chunk_plus_offset(p, contents_size);\n array_chunk_size = remainder_size - contents_size;\n marray = (void**) (chunk2mem(array_chunk));\n set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size);\n remainder_size = contents_size;\n }\n \n /* split out elements */\n for (i = 0; ; ++i) {\n marray[i] = chunk2mem(p);\n if (i != n_elements-1) {\n if (element_size != 0)\n size = element_size;\n else\n size = request2size(sizes[i]);\n remainder_size -= size;\n set_size_and_pinuse_of_inuse_chunk(m, p, size);\n p = chunk_plus_offset(p, size);\n }\n else { /* the final element absorbs any overallocation slop */\n set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size);\n break;\n }\n }\n \n#if DEBUG\n if (marray != chunks) {\n /* final element must have exactly exhausted chunk */\n if (element_size != 0) {\n assert(remainder_size == element_size);\n }\n else {\n assert(remainder_size == request2size(sizes[i]));\n }\n check_inuse_chunk(m, mem2chunk(marray));\n }\n for (i = 0; i != n_elements; ++i)\n check_inuse_chunk(m, mem2chunk(marray[i]));\n \n#endif /* DEBUG */\n \n POSTACTION(m);\n return marray;\n}\n\n/* Try to free all pointers in the given array.\n Note: this could be made faster, by delaying consolidation,\n at the price of disabling some user integrity checks, We\n still optimize some consolidations by combining adjacent\n chunks before freeing, which will occur often if allocated\n with ialloc or the array is sorted.\n */\nstatic size_t internal_bulk_free(mstate m, void* array[], size_t nelem) {\n size_t unfreed = 0;\n if (!PREACTION(m)) {\n void** a;\n void** fence = &(array[nelem]);\n for (a = array; a != fence; ++a) {\n void* mem = *a;\n if (mem != 0) {\n mchunkptr p = mem2chunk(mem);\n size_t psize = chunksize(p);\n#if FOOTERS\n if (get_mstate_for(p) != m) {\n ++unfreed;\n continue;\n }\n#endif\n check_inuse_chunk(m, p);\n *a = 0;\n if (RTCHECK(ok_address(m, p) && ok_inuse(p))) {\n void ** b = a + 1; /* try to merge with next chunk */\n mchunkptr next = next_chunk(p);\n if (b != fence && *b == chunk2mem(next)) {\n size_t newsize = chunksize(next) + psize;\n set_inuse(m, p, newsize);\n *b = chunk2mem(p);\n }\n else\n dispose_chunk(m, p, psize);\n }\n else {\n CORRUPTION_ERROR_ACTION(m);\n break;\n }\n }\n }\n if (should_trim(m, m->topsize))\n sys_trim(m, 0);\n POSTACTION(m);\n }\n return unfreed;\n}\n\n/* Traversal */\n#if MALLOC_INSPECT_ALL\nstatic void internal_inspect_all(mstate m,\n void(*handler)(void *start,\n void *end,\n size_t used_bytes,\n void* callback_arg),\n void* arg) {\n if (is_initialized(m)) {\n mchunkptr top = m->top;\n msegmentptr s;\n for (s = &m->seg; s != 0; s = s->next) {\n mchunkptr q = align_as_chunk(s->base);\n while (segment_holds(s, q) && q->head != FENCEPOST_HEAD) {\n mchunkptr next = next_chunk(q);\n size_t sz = chunksize(q);\n size_t used;\n void* start;\n if (is_inuse(q)) {\n used = sz - CHUNK_OVERHEAD; /* must not be mmapped */\n start = chunk2mem(q);\n }\n else {\n used = 0;\n if (is_small(sz)) { /* offset by possible bookkeeping */\n start = (void*)((char*)q + sizeof(struct malloc_chunk));\n }\n else {\n start = (void*)((char*)q + sizeof(struct malloc_tree_chunk));\n }\n }\n if (start < (void*)next) /* skip if all space is bookkeeping */\n handler(start, next, used, arg);\n if (q == top)\n break;\n q = next;\n }\n }\n }\n}\n#endif /* MALLOC_INSPECT_ALL */\n\n/* ------------------ Exported realloc, memalign, etc -------------------- */\n\n#if !ONLY_MSPACES\n\nvoid* dlrealloc(void* oldmem, size_t bytes) {\n void* mem = 0;\n if (oldmem == 0) {\n mem = dlmalloc(bytes);\n }\n else if (bytes >= MAX_REQUEST) {\n MALLOC_FAILURE_ACTION;\n }\n#ifdef REALLOC_ZERO_BYTES_FREES\n else if (bytes == 0) {\n dlfree(oldmem);\n }\n#endif /* REALLOC_ZERO_BYTES_FREES */\n else {\n size_t nb = request2size(bytes);\n mchunkptr oldp = mem2chunk(oldmem);\n#if ! FOOTERS\n mstate m = gm;\n#else /* FOOTERS */\n mstate m = get_mstate_for(oldp);\n if (!ok_magic(m)) {\n USAGE_ERROR_ACTION(m, oldmem);\n return 0;\n }\n#endif /* FOOTERS */\n if (!PREACTION(m)) {\n mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1);\n POSTACTION(m);\n if (newp != 0) {\n check_inuse_chunk(m, newp);\n mem = chunk2mem(newp);\n#if __EMSCRIPTEN__\n /* XXX Emscripten Tracing API. */\n emscripten_trace_record_reallocation(oldmem, mem, bytes);\n#endif\n }\n else {\n mem = internal_malloc(m, bytes);\n if (mem != 0) {\n size_t oc = chunksize(oldp) - overhead_for(oldp);\n memcpy(mem, oldmem, (oc < bytes)? oc : bytes);\n internal_free(m, oldmem);\n }\n }\n }\n }\n return mem;\n}\n\nvoid* dlrealloc_in_place(void* oldmem, size_t bytes) {\n void* mem = 0;\n if (oldmem != 0) {\n if (bytes >= MAX_REQUEST) {\n MALLOC_FAILURE_ACTION;\n }\n else {\n size_t nb = request2size(bytes);\n mchunkptr oldp = mem2chunk(oldmem);\n#if ! FOOTERS\n mstate m = gm;\n#else /* FOOTERS */\n mstate m = get_mstate_for(oldp);\n if (!ok_magic(m)) {\n USAGE_ERROR_ACTION(m, oldmem);\n return 0;\n }\n#endif /* FOOTERS */\n if (!PREACTION(m)) {\n mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0);\n POSTACTION(m);\n if (newp == oldp) {\n check_inuse_chunk(m, newp);\n mem = oldmem;\n }\n }\n }\n }\n#if __EMSCRIPTEN__\n /* XXX Emscripten Tracing API. */\n emscripten_trace_record_reallocation(oldmem, mem, bytes);\n#endif\n return mem;\n}\n\nvoid* dlmemalign(size_t alignment, size_t bytes) {\n if (alignment <= MALLOC_ALIGNMENT) {\n return dlmalloc(bytes);\n }\n return internal_memalign(gm, alignment, bytes);\n}\n\nint dlposix_memalign(void** pp, size_t alignment, size_t bytes) {\n void* mem = 0;\n if (alignment == MALLOC_ALIGNMENT)\n mem = dlmalloc(bytes);\n else {\n size_t d = alignment / sizeof(void*);\n size_t r = alignment % sizeof(void*);\n if (r != 0 || d == 0 || (d & (d-SIZE_T_ONE)) != 0)\n return EINVAL;\n else if (bytes <= MAX_REQUEST - alignment) {\n if (alignment < MIN_CHUNK_SIZE)\n alignment = MIN_CHUNK_SIZE;\n mem = internal_memalign(gm, alignment, bytes);\n }\n }\n if (mem == 0)\n return ENOMEM;\n else {\n *pp = mem;\n return 0;\n }\n}\n\nvoid* dlvalloc(size_t bytes) {\n size_t pagesz;\n ensure_initialization();\n pagesz = mparams.page_size;\n return dlmemalign(pagesz, bytes);\n}\n\nvoid* dlpvalloc(size_t bytes) {\n size_t pagesz;\n ensure_initialization();\n pagesz = mparams.page_size;\n return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE));\n}\n\nvoid** dlindependent_calloc(size_t n_elements, size_t elem_size,\n void* chunks[]) {\n size_t sz = elem_size; /* serves as 1-element array */\n return ialloc(gm, n_elements, &sz, 3, chunks);\n}\n\nvoid** dlindependent_comalloc(size_t n_elements, size_t sizes[],\n void* chunks[]) {\n return ialloc(gm, n_elements, sizes, 0, chunks);\n}\n\nsize_t dlbulk_free(void* array[], size_t nelem) {\n return internal_bulk_free(gm, array, nelem);\n}\n\n#if MALLOC_INSPECT_ALL\nvoid dlmalloc_inspect_all(void(*handler)(void *start,\n void *end,\n size_t used_bytes,\n void* callback_arg),\n void* arg) {\n ensure_initialization();\n if (!PREACTION(gm)) {\n internal_inspect_all(gm, handler, arg);\n POSTACTION(gm);\n }\n}\n#endif /* MALLOC_INSPECT_ALL */\n\nint dlmalloc_trim(size_t pad) {\n int result = 0;\n ensure_initialization();\n if (!PREACTION(gm)) {\n result = sys_trim(gm, pad);\n POSTACTION(gm);\n }\n return result;\n}\n\nsize_t dlmalloc_footprint(void) {\n return gm->footprint;\n}\n\nsize_t dlmalloc_max_footprint(void) {\n return gm->max_footprint;\n}\n\nsize_t dlmalloc_footprint_limit(void) {\n size_t maf = gm->footprint_limit;\n return maf == 0 ? MAX_SIZE_T : maf;\n}\n\nsize_t dlmalloc_set_footprint_limit(size_t bytes) {\n size_t result; /* invert sense of 0 */\n if (bytes == 0)\n result = granularity_align(1); /* Use minimal size */\n if (bytes == MAX_SIZE_T)\n result = 0; /* disable */\n else\n result = granularity_align(bytes);\n return gm->footprint_limit = result;\n}\n\n#if !NO_MALLINFO\nstruct mallinfo dlmallinfo(void) {\n return internal_mallinfo(gm);\n}\n#endif /* NO_MALLINFO */\n\n#if !NO_MALLOC_STATS\nvoid dlmalloc_stats() {\n internal_malloc_stats(gm);\n}\n#endif /* NO_MALLOC_STATS */\n\nint dlmallopt(int param_number, int value) {\n return change_mparam(param_number, value);\n}\n\nsize_t dlmalloc_usable_size(void* mem) {\n if (mem != 0) {\n mchunkptr p = mem2chunk(mem);\n if (is_inuse(p))\n return chunksize(p) - overhead_for(p);\n }\n return 0;\n}\n\n#endif /* !ONLY_MSPACES */\n\n/* ----------------------------- user mspaces ---------------------------- */\n\n#if MSPACES\n\nstatic mstate init_user_mstate(char* tbase, size_t tsize) {\n size_t msize = pad_request(sizeof(struct malloc_state));\n mchunkptr mn;\n mchunkptr msp = align_as_chunk(tbase);\n mstate m = (mstate)(chunk2mem(msp));\n memset(m, 0, msize);\n (void)INITIAL_LOCK(&m->mutex);\n msp->head = (msize|INUSE_BITS);\n m->seg.base = m->least_addr = tbase;\n m->seg.size = m->footprint = m->max_footprint = tsize;\n m->magic = mparams.magic;\n m->release_checks = MAX_RELEASE_CHECK_RATE;\n m->mflags = mparams.default_mflags;\n m->extp = 0;\n m->exts = 0;\n disable_contiguous(m);\n init_bins(m);\n mn = next_chunk(mem2chunk(m));\n init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE);\n check_top_chunk(m, m->top);\n return m;\n}\n\nmspace create_mspace(size_t capacity, int locked) {\n mstate m = 0;\n size_t msize;\n ensure_initialization();\n msize = pad_request(sizeof(struct malloc_state));\n if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) {\n size_t rs = ((capacity == 0)? mparams.granularity :\n (capacity + TOP_FOOT_SIZE + msize));\n size_t tsize = granularity_align(rs);\n char* tbase = (char*)(CALL_MMAP(tsize));\n if (tbase != CMFAIL) {\n m = init_user_mstate(tbase, tsize);\n m->seg.sflags = USE_MMAP_BIT;\n set_lock(m, locked);\n }\n }\n return (mspace)m;\n}\n\nmspace create_mspace_with_base(void* base, size_t capacity, int locked) {\n mstate m = 0;\n size_t msize;\n ensure_initialization();\n msize = pad_request(sizeof(struct malloc_state));\n if (capacity > msize + TOP_FOOT_SIZE &&\n capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) {\n m = init_user_mstate((char*)base, capacity);\n m->seg.sflags = EXTERN_BIT;\n set_lock(m, locked);\n }\n return (mspace)m;\n}\n\nint mspace_track_large_chunks(mspace msp, int enable) {\n int ret = 0;\n mstate ms = (mstate)msp;\n if (!PREACTION(ms)) {\n if (!use_mmap(ms)) {\n ret = 1;\n }\n if (!enable) {\n enable_mmap(ms);\n } else {\n disable_mmap(ms);\n }\n POSTACTION(ms);\n }\n return ret;\n}\n\nsize_t destroy_mspace(mspace msp) {\n size_t freed = 0;\n mstate ms = (mstate)msp;\n if (ok_magic(ms)) {\n msegmentptr sp = &ms->seg;\n (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */\n while (sp != 0) {\n char* base = sp->base;\n size_t size = sp->size;\n flag_t flag = sp->sflags;\n (void)base; /* placate people compiling -Wunused-variable */\n sp = sp->next;\n if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) &&\n CALL_MUNMAP(base, size) == 0)\n freed += size;\n }\n }\n else {\n USAGE_ERROR_ACTION(ms,ms);\n }\n return freed;\n}\n\n/*\n mspace versions of routines are near-clones of the global\n versions. This is not so nice but better than the alternatives.\n */\n\nvoid* mspace_malloc(mspace msp, size_t bytes) {\n mstate ms = (mstate)msp;\n if (!ok_magic(ms)) {\n USAGE_ERROR_ACTION(ms,ms);\n return 0;\n }\n if (!PREACTION(ms)) {\n void* mem;\n size_t nb;\n if (bytes <= MAX_SMALL_REQUEST) {\n bindex_t idx;\n binmap_t smallbits;\n nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes);\n idx = small_index(nb);\n smallbits = ms->smallmap >> idx;\n \n if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */\n mchunkptr b, p;\n idx += ~smallbits & 1; /* Uses next bin if idx empty */\n b = smallbin_at(ms, idx);\n p = b->fd;\n assert(chunksize(p) == small_index2size(idx));\n unlink_first_small_chunk(ms, b, p, idx);\n set_inuse_and_pinuse(ms, p, small_index2size(idx));\n mem = chunk2mem(p);\n check_malloced_chunk(ms, mem, nb);\n goto postaction;\n }\n \n else if (nb > ms->dvsize) {\n if (smallbits != 0) { /* Use chunk in next nonempty smallbin */\n mchunkptr b, p, r;\n size_t rsize;\n bindex_t i;\n binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx));\n binmap_t leastbit = least_bit(leftbits);\n compute_bit2idx(leastbit, i);\n b = smallbin_at(ms, i);\n p = b->fd;\n assert(chunksize(p) == small_index2size(i));\n unlink_first_small_chunk(ms, b, p, i);\n rsize = small_index2size(i) - nb;\n /* Fit here cannot be remainderless if 4byte sizes */\n if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE)\n set_inuse_and_pinuse(ms, p, small_index2size(i));\n else {\n set_size_and_pinuse_of_inuse_chunk(ms, p, nb);\n r = chunk_plus_offset(p, nb);\n set_size_and_pinuse_of_free_chunk(r, rsize);\n replace_dv(ms, r, rsize);\n }\n mem = chunk2mem(p);\n check_malloced_chunk(ms, mem, nb);\n goto postaction;\n }\n \n else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) {\n check_malloced_chunk(ms, mem, nb);\n goto postaction;\n }\n }\n }\n else if (bytes >= MAX_REQUEST)\n nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */\n else {\n nb = pad_request(bytes);\n if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) {\n check_malloced_chunk(ms, mem, nb);\n goto postaction;\n }\n }\n \n if (nb <= ms->dvsize) {\n size_t rsize = ms->dvsize - nb;\n mchunkptr p = ms->dv;\n if (rsize >= MIN_CHUNK_SIZE) { /* split dv */\n mchunkptr r = ms->dv = chunk_plus_offset(p, nb);\n ms->dvsize = rsize;\n set_size_and_pinuse_of_free_chunk(r, rsize);\n set_size_and_pinuse_of_inuse_chunk(ms, p, nb);\n }\n else { /* exhaust dv */\n size_t dvs = ms->dvsize;\n ms->dvsize = 0;\n ms->dv = 0;\n set_inuse_and_pinuse(ms, p, dvs);\n }\n mem = chunk2mem(p);\n check_malloced_chunk(ms, mem, nb);\n goto postaction;\n }\n \n else if (nb < ms->topsize) { /* Split top */\n size_t rsize = ms->topsize -= nb;\n mchunkptr p = ms->top;\n mchunkptr r = ms->top = chunk_plus_offset(p, nb);\n r->head = rsize | PINUSE_BIT;\n set_size_and_pinuse_of_inuse_chunk(ms, p, nb);\n mem = chunk2mem(p);\n check_top_chunk(ms, ms->top);\n check_malloced_chunk(ms, mem, nb);\n goto postaction;\n }\n \n mem = sys_alloc(ms, nb);\n \n postaction:\n POSTACTION(ms);\n return mem;\n }\n \n return 0;\n}\n\nvoid mspace_free(mspace msp, void* mem) {\n if (mem != 0) {\n mchunkptr p = mem2chunk(mem);\n#if FOOTERS\n mstate fm = get_mstate_for(p);\n (void)msp; /* placate people compiling -Wunused */\n#else /* FOOTERS */\n mstate fm = (mstate)msp;\n#endif /* FOOTERS */\n if (!ok_magic(fm)) {\n USAGE_ERROR_ACTION(fm, p);\n return;\n }\n if (!PREACTION(fm)) {\n check_inuse_chunk(fm, p);\n if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) {\n size_t psize = chunksize(p);\n mchunkptr next = chunk_plus_offset(p, psize);\n if (!pinuse(p)) {\n size_t prevsize = p->prev_foot;\n if (is_mmapped(p)) {\n psize += prevsize + MMAP_FOOT_PAD;\n if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)\n fm->footprint -= psize;\n goto postaction;\n }\n else {\n mchunkptr prev = chunk_minus_offset(p, prevsize);\n psize += prevsize;\n p = prev;\n if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */\n if (p != fm->dv) {\n unlink_chunk(fm, p, prevsize);\n }\n else if ((next->head & INUSE_BITS) == INUSE_BITS) {\n fm->dvsize = psize;\n set_free_with_pinuse(p, psize, next);\n goto postaction;\n }\n }\n else\n goto erroraction;\n }\n }\n \n if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) {\n if (!cinuse(next)) { /* consolidate forward */\n if (next == fm->top) {\n size_t tsize = fm->topsize += psize;\n fm->top = p;\n p->head = tsize | PINUSE_BIT;\n if (p == fm->dv) {\n fm->dv = 0;\n fm->dvsize = 0;\n }\n if (should_trim(fm, tsize))\n sys_trim(fm, 0);\n goto postaction;\n }\n else if (next == fm->dv) {\n size_t dsize = fm->dvsize += psize;\n fm->dv = p;\n set_size_and_pinuse_of_free_chunk(p, dsize);\n goto postaction;\n }\n else {\n size_t nsize = chunksize(next);\n psize += nsize;\n unlink_chunk(fm, next, nsize);\n set_size_and_pinuse_of_free_chunk(p, psize);\n if (p == fm->dv) {\n fm->dvsize = psize;\n goto postaction;\n }\n }\n }\n else\n set_free_with_pinuse(p, psize, next);\n \n if (is_small(psize)) {\n insert_small_chunk(fm, p, psize);\n check_free_chunk(fm, p);\n }\n else {\n tchunkptr tp = (tchunkptr)p;\n insert_large_chunk(fm, tp, psize);\n check_free_chunk(fm, p);\n if (--fm->release_checks == 0)\n release_unused_segments(fm);\n }\n goto postaction;\n }\n }\n erroraction:\n USAGE_ERROR_ACTION(fm, p);\n postaction:\n POSTACTION(fm);\n }\n }\n}\n\nvoid* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) {\n void* mem;\n size_t req = 0;\n mstate ms = (mstate)msp;\n if (!ok_magic(ms)) {\n USAGE_ERROR_ACTION(ms,ms);\n return 0;\n }\n if (n_elements != 0) {\n req = n_elements * elem_size;\n if (((n_elements | elem_size) & ~(size_t)0xffff) &&\n (req / n_elements != elem_size))\n req = MAX_SIZE_T; /* force downstream failure on overflow */\n }\n mem = internal_malloc(ms, req);\n if (mem != 0 && calloc_must_clear(mem2chunk(mem)))\n memset(mem, 0, req);\n return mem;\n}\n\nvoid* mspace_realloc(mspace msp, void* oldmem, size_t bytes) {\n void* mem = 0;\n if (oldmem == 0) {\n mem = mspace_malloc(msp, bytes);\n }\n else if (bytes >= MAX_REQUEST) {\n MALLOC_FAILURE_ACTION;\n }\n#ifdef REALLOC_ZERO_BYTES_FREES\n else if (bytes == 0) {\n mspace_free(msp, oldmem);\n }\n#endif /* REALLOC_ZERO_BYTES_FREES */\n else {\n size_t nb = request2size(bytes);\n mchunkptr oldp = mem2chunk(oldmem);\n#if ! FOOTERS\n mstate m = (mstate)msp;\n#else /* FOOTERS */\n mstate m = get_mstate_for(oldp);\n if (!ok_magic(m)) {\n USAGE_ERROR_ACTION(m, oldmem);\n return 0;\n }\n#endif /* FOOTERS */\n if (!PREACTION(m)) {\n mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1);\n POSTACTION(m);\n if (newp != 0) {\n check_inuse_chunk(m, newp);\n mem = chunk2mem(newp);\n }\n else {\n mem = mspace_malloc(m, bytes);\n if (mem != 0) {\n size_t oc = chunksize(oldp) - overhead_for(oldp);\n memcpy(mem, oldmem, (oc < bytes)? oc : bytes);\n mspace_free(m, oldmem);\n }\n }\n }\n }\n return mem;\n}\n\nvoid* mspace_realloc_in_place(mspace msp, void* oldmem, size_t bytes) {\n void* mem = 0;\n if (oldmem != 0) {\n if (bytes >= MAX_REQUEST) {\n MALLOC_FAILURE_ACTION;\n }\n else {\n size_t nb = request2size(bytes);\n mchunkptr oldp = mem2chunk(oldmem);\n#if ! FOOTERS\n mstate m = (mstate)msp;\n#else /* FOOTERS */\n mstate m = get_mstate_for(oldp);\n (void)msp; /* placate people compiling -Wunused */\n if (!ok_magic(m)) {\n USAGE_ERROR_ACTION(m, oldmem);\n return 0;\n }\n#endif /* FOOTERS */\n if (!PREACTION(m)) {\n mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0);\n POSTACTION(m);\n if (newp == oldp) {\n check_inuse_chunk(m, newp);\n mem = oldmem;\n }\n }\n }\n }\n return mem;\n}\n\nvoid* mspace_memalign(mspace msp, size_t alignment, size_t bytes) {\n mstate ms = (mstate)msp;\n if (!ok_magic(ms)) {\n USAGE_ERROR_ACTION(ms,ms);\n return 0;\n }\n if (alignment <= MALLOC_ALIGNMENT)\n return mspace_malloc(msp, bytes);\n return internal_memalign(ms, alignment, bytes);\n}\n\nvoid** mspace_independent_calloc(mspace msp, size_t n_elements,\n size_t elem_size, void* chunks[]) {\n size_t sz = elem_size; /* serves as 1-element array */\n mstate ms = (mstate)msp;\n if (!ok_magic(ms)) {\n USAGE_ERROR_ACTION(ms,ms);\n return 0;\n }\n return ialloc(ms, n_elements, &sz, 3, chunks);\n}\n\nvoid** mspace_independent_comalloc(mspace msp, size_t n_elements,\n size_t sizes[], void* chunks[]) {\n mstate ms = (mstate)msp;\n if (!ok_magic(ms)) {\n USAGE_ERROR_ACTION(ms,ms);\n return 0;\n }\n return ialloc(ms, n_elements, sizes, 0, chunks);\n}\n\nsize_t mspace_bulk_free(mspace msp, void* array[], size_t nelem) {\n return internal_bulk_free((mstate)msp, array, nelem);\n}\n\n#if MALLOC_INSPECT_ALL\nvoid mspace_inspect_all(mspace msp,\n void(*handler)(void *start,\n void *end,\n size_t used_bytes,\n void* callback_arg),\n void* arg) {\n mstate ms = (mstate)msp;\n if (ok_magic(ms)) {\n if (!PREACTION(ms)) {\n internal_inspect_all(ms, handler, arg);\n POSTACTION(ms);\n }\n }\n else {\n USAGE_ERROR_ACTION(ms,ms);\n }\n}\n#endif /* MALLOC_INSPECT_ALL */\n\nint mspace_trim(mspace msp, size_t pad) {\n int result = 0;\n mstate ms = (mstate)msp;\n if (ok_magic(ms)) {\n if (!PREACTION(ms)) {\n result = sys_trim(ms, pad);\n POSTACTION(ms);\n }\n }\n else {\n USAGE_ERROR_ACTION(ms,ms);\n }\n return result;\n}\n\n#if !NO_MALLOC_STATS\nvoid mspace_malloc_stats(mspace msp) {\n mstate ms = (mstate)msp;\n if (ok_magic(ms)) {\n internal_malloc_stats(ms);\n }\n else {\n USAGE_ERROR_ACTION(ms,ms);\n }\n}\n#endif /* NO_MALLOC_STATS */\n\nsize_t mspace_footprint(mspace msp) {\n size_t result = 0;\n mstate ms = (mstate)msp;\n if (ok_magic(ms)) {\n result = ms->footprint;\n }\n else {\n USAGE_ERROR_ACTION(ms,ms);\n }\n return result;\n}\n\nsize_t mspace_max_footprint(mspace msp) {\n size_t result = 0;\n mstate ms = (mstate)msp;\n if (ok_magic(ms)) {\n result = ms->max_footprint;\n }\n else {\n USAGE_ERROR_ACTION(ms,ms);\n }\n return result;\n}\n\nsize_t mspace_footprint_limit(mspace msp) {\n size_t result = 0;\n mstate ms = (mstate)msp;\n if (ok_magic(ms)) {\n size_t maf = ms->footprint_limit;\n result = (maf == 0) ? MAX_SIZE_T : maf;\n }\n else {\n USAGE_ERROR_ACTION(ms,ms);\n }\n return result;\n}\n\nsize_t mspace_set_footprint_limit(mspace msp, size_t bytes) {\n size_t result = 0;\n mstate ms = (mstate)msp;\n if (ok_magic(ms)) {\n if (bytes == 0)\n result = granularity_align(1); /* Use minimal size */\n if (bytes == MAX_SIZE_T)\n result = 0; /* disable */\n else\n result = granularity_align(bytes);\n ms->footprint_limit = result;\n }\n else {\n USAGE_ERROR_ACTION(ms,ms);\n }\n return result;\n}\n\n#if !NO_MALLINFO\nstruct mallinfo mspace_mallinfo(mspace msp) {\n mstate ms = (mstate)msp;\n if (!ok_magic(ms)) {\n USAGE_ERROR_ACTION(ms,ms);\n }\n return internal_mallinfo(ms);\n}\n#endif /* NO_MALLINFO */\n\nsize_t mspace_usable_size(const void* mem) {\n if (mem != 0) {\n mchunkptr p = mem2chunk(mem);\n if (is_inuse(p))\n return chunksize(p) - overhead_for(p);\n }\n return 0;\n}\n\nint mspace_mallopt(int param_number, int value) {\n return change_mparam(param_number, value);\n}\n\n#endif /* MSPACES */\n\n// Export malloc and free as duplicate names emscripten_builtin_malloc and\n// emscripten_builtin_free so that applications can replace malloc and free\n// in their code, and make those replacements refer to the original dlmalloc\n// and dlfree from this file.\n// This allows an easy mechanism for hooking into memory allocation.\n#if defined(__EMSCRIPTEN__) && !ONLY_MSPACES\nextern __typeof(malloc) emscripten_builtin_malloc __attribute__((alias(\"dlmalloc\")));\nextern __typeof(realloc) emscripten_builtin_realloc __attribute__((alias(\"dlrealloc\")));\nextern __typeof(calloc) emscripten_builtin_calloc __attribute__((alias(\"dlcalloc\")));\nextern __typeof(free) emscripten_builtin_free __attribute__((alias(\"dlfree\")));\nextern __typeof(memalign) emscripten_builtin_memalign __attribute__((alias(\"dlmemalign\")));\n#endif\n\n/* -------------------- Alternative MORECORE functions ------------------- */\n\n/*\n Guidelines for creating a custom version of MORECORE:\n \n * For best performance, MORECORE should allocate in multiples of pagesize.\n * MORECORE may allocate more memory than requested. (Or even less,\n but this will usually result in a malloc failure.)\n * MORECORE must not allocate memory when given argument zero, but\n instead return one past the end address of memory from previous\n nonzero call.\n * For best performance, consecutive calls to MORECORE with positive\n arguments should return increasing addresses, indicating that\n space has been contiguously extended.\n * Even though consecutive calls to MORECORE need not return contiguous\n addresses, it must be OK for malloc'ed chunks to span multiple\n regions in those cases where they do happen to be contiguous.\n * MORECORE need not handle negative arguments -- it may instead\n just return MFAIL when given negative arguments.\n Negative arguments are always multiples of pagesize. MORECORE\n must not misinterpret negative args as large positive unsigned\n args unless UNSIGNED_MORECORE is defined. You can suppress all such calls\n from even occurring by defining MORECORE_CANNOT_TRIM,\n \n As an example alternative MORECORE, here is a custom allocator\n kindly contributed for pre-OSX macOS. It uses virtually but not\n necessarily physically contiguous non-paged memory (locked in,\n present and won't get swapped out). You can use it by uncommenting\n this section, adding some #includes, and setting up the appropriate\n defines above:\n \n #define MORECORE osMoreCore\n \n There is also a shutdown routine that should somehow be called for\n cleanup upon program exit.\n \n #define MAX_POOL_ENTRIES 100\n #define MINIMUM_MORECORE_SIZE (64 * 1024U)\n static int next_os_pool;\n void *our_os_pools[MAX_POOL_ENTRIES];\n \n void *osMoreCore(int size)\n {\n void *ptr = 0;\n static void *sbrk_top = 0;\n \n if (size > 0)\n {\n if (size < MINIMUM_MORECORE_SIZE)\n size = MINIMUM_MORECORE_SIZE;\n if (CurrentExecutionLevel() == kTaskLevel)\n ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0);\n if (ptr == 0)\n {\n return (void *) MFAIL;\n }\n // save ptrs so they can be freed during cleanup\n our_os_pools[next_os_pool] = ptr;\n next_os_pool++;\n ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK);\n sbrk_top = (char *) ptr + size;\n return ptr;\n }\n else if (size < 0)\n {\n // we don't currently support shrink behavior\n return (void *) MFAIL;\n }\n else\n {\n return sbrk_top;\n }\n }\n \n // cleanup any allocated memory pools\n // called as last thing before shutting down driver\n \n void osCleanupMem(void)\n {\n void **ptr;\n \n for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++)\n if (*ptr)\n {\n PoolDeallocate(*ptr);\n *ptr = 0;\n }\n }\n \n */\n\n\n/* -----------------------------------------------------------------------\n History:\n v2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea\n * fix bad comparison in dlposix_memalign\n * don't reuse adjusted asize in sys_alloc\n * add LOCK_AT_FORK -- thanks to Kirill Artamonov for the suggestion\n * reduce compiler warnings -- thanks to all who reported/suggested these\n \n v2.8.5 Sun May 22 10:26:02 2011 Doug Lea (dl at gee)\n * Always perform unlink checks unless INSECURE\n * Add posix_memalign.\n * Improve realloc to expand in more cases; expose realloc_in_place.\n Thanks to Peter Buhr for the suggestion.\n * Add footprint_limit, inspect_all, bulk_free. Thanks\n to Barry Hayes and others for the suggestions.\n * Internal refactorings to avoid calls while holding locks\n * Use non-reentrant locks by default. Thanks to Roland McGrath\n for the suggestion.\n * Small fixes to mspace_destroy, reset_on_error.\n * Various configuration extensions/changes. Thanks\n to all who contributed these.\n \n V2.8.4a Thu Apr 28 14:39:43 2011 (dl at gee.cs.oswego.edu)\n * Update Creative Commons URL\n \n V2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee)\n * Use zeros instead of prev foot for is_mmapped\n * Add mspace_track_large_chunks; thanks to Jean Brouwers\n * Fix set_inuse in internal_realloc; thanks to Jean Brouwers\n * Fix insufficient sys_alloc padding when using 16byte alignment\n * Fix bad error check in mspace_footprint\n * Adaptations for ptmalloc; thanks to Wolfram Gloger.\n * Reentrant spin locks; thanks to Earl Chew and others\n * Win32 improvements; thanks to Niall Douglas and Earl Chew\n * Add NO_SEGMENT_TRAVERSAL and MAX_RELEASE_CHECK_RATE options\n * Extension hook in malloc_state\n * Various small adjustments to reduce warnings on some compilers\n * Various configuration extensions/changes for more platforms. Thanks\n to all who contributed these.\n \n V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee)\n * Add max_footprint functions\n * Ensure all appropriate literals are size_t\n * Fix conditional compilation problem for some #define settings\n * Avoid concatenating segments with the one provided\n in create_mspace_with_base\n * Rename some variables to avoid compiler shadowing warnings\n * Use explicit lock initialization.\n * Better handling of sbrk interference.\n * Simplify and fix segment insertion, trimming and mspace_destroy\n * Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x\n * Thanks especially to Dennis Flanagan for help on these.\n \n V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee)\n * Fix memalign brace error.\n \n V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee)\n * Fix improper #endif nesting in C++\n * Add explicit casts needed for C++\n \n V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee)\n * Use trees for large bins\n * Support mspaces\n * Use segments to unify sbrk-based and mmap-based system allocation,\n removing need for emulation on most platforms without sbrk.\n * Default safety checks\n * Optional footer checks. Thanks to William Robertson for the idea.\n * Internal code refactoring\n * Incorporate suggestions and platform-specific changes.\n Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas,\n Aaron Bachmann, Emery Berger, and others.\n * Speed up non-fastbin processing enough to remove fastbins.\n * Remove useless cfree() to avoid conflicts with other apps.\n * Remove internal memcpy, memset. Compilers handle builtins better.\n * Remove some options that no one ever used and rename others.\n \n V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee)\n * Fix malloc_state bitmap array misdeclaration\n \n V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee)\n * Allow tuning of FIRST_SORTED_BIN_SIZE\n * Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte.\n * Better detection and support for non-contiguousness of MORECORE.\n Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger\n * Bypass most of malloc if no frees. Thanks To Emery Berger.\n * Fix freeing of old top non-contiguous chunk im sysmalloc.\n * Raised default trim and map thresholds to 256K.\n * Fix mmap-related #defines. Thanks to Lubos Lunak.\n * Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield.\n * Branch-free bin calculation\n * Default trim and mmap thresholds now 256K.\n \n V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee)\n * Introduce independent_comalloc and independent_calloc.\n Thanks to Michael Pachos for motivation and help.\n * Make optional .h file available\n * Allow > 2GB requests on 32bit systems.\n * new WIN32 sbrk, mmap, munmap, lock code from <Walter@GeNeSys-e.de>.\n Thanks also to Andreas Mueller <a.mueller at paradatec.de>,\n and Anonymous.\n * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for\n helping test this.)\n * memalign: check alignment arg\n * realloc: don't try to shift chunks backwards, since this\n leads to more fragmentation in some programs and doesn't\n seem to help in any others.\n * Collect all cases in malloc requiring system memory into sysmalloc\n * Use mmap as backup to sbrk\n * Place all internal state in malloc_state\n * Introduce fastbins (although similar to 2.5.1)\n * Many minor tunings and cosmetic improvements\n * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK\n * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS\n Thanks to Tony E. Bennett <tbennett@nvidia.com> and others.\n * Include errno.h to support default failure action.\n \n V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee)\n * return null for negative arguments\n * Added Several WIN32 cleanups from Martin C. Fong <mcfong at yahoo.com>\n * Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h'\n (e.g. WIN32 platforms)\n * Cleanup header file inclusion for WIN32 platforms\n * Cleanup code to avoid Microsoft Visual C++ compiler complaints\n * Add 'USE_DL_PREFIX' to quickly allow co-existence with existing\n memory allocation routines\n * Set 'malloc_getpagesize' for WIN32 platforms (needs more work)\n * Use 'assert' rather than 'ASSERT' in WIN32 code to conform to\n usage of 'assert' in non-WIN32 code\n * Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to\n avoid infinite loop\n * Always call 'fREe()' rather than 'free()'\n \n V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee)\n * Fixed ordering problem with boundary-stamping\n \n V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee)\n * Added pvalloc, as recommended by H.J. Liu\n * Added 64bit pointer support mainly from Wolfram Gloger\n * Added anonymously donated WIN32 sbrk emulation\n * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen\n * malloc_extend_top: fix mask error that caused wastage after\n foreign sbrks\n * Add linux mremap support code from HJ Liu\n \n V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee)\n * Integrated most documentation with the code.\n * Add support for mmap, with help from\n Wolfram Gloger (Gloger@lrz.uni-muenchen.de).\n * Use last_remainder in more cases.\n * Pack bins using idea from colin@nyx10.cs.du.edu\n * Use ordered bins instead of best-fit threshhold\n * Eliminate block-local decls to simplify tracing and debugging.\n * Support another case of realloc via move into top\n * Fix error occuring when initial sbrk_base not word-aligned.\n * Rely on page size for units instead of SBRK_UNIT to\n avoid surprises about sbrk alignment conventions.\n * Add mallinfo, mallopt. Thanks to Raymond Nijssen\n (raymond@es.ele.tue.nl) for the suggestion.\n * Add `pad' argument to malloc_trim and top_pad mallopt parameter.\n * More precautions for cases where other routines call sbrk,\n courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de).\n * Added macros etc., allowing use in linux libc from\n H.J. Lu (hjl@gnu.ai.mit.edu)\n * Inverted this history list\n \n V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee)\n * Re-tuned and fixed to behave more nicely with V2.6.0 changes.\n * Removed all preallocation code since under current scheme\n the work required to undo bad preallocations exceeds\n the work saved in good cases for most test programs.\n * No longer use return list or unconsolidated bins since\n no scheme using them consistently outperforms those that don't\n given above changes.\n * Use best fit for very large chunks to prevent some worst-cases.\n * Added some support for debugging\n \n V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee)\n * Removed footers when chunks are in use. Thanks to\n Paul Wilson (wilson@cs.texas.edu) for the suggestion.\n \n V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee)\n * Added malloc_trim, with help from Wolfram Gloger\n (wmglo@Dent.MED.Uni-Muenchen.DE).\n \n V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g)\n \n V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g)\n * realloc: try to expand in both directions\n * malloc: swap order of clean-bin strategy;\n * realloc: only conditionally expand backwards\n * Try not to scavenge used bins\n * Use bin counts as a guide to preallocation\n * Occasionally bin return list chunks in first scan\n * Add a few optimizations from colin@nyx10.cs.du.edu\n \n V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g)\n * faster bin computation & slightly different binning\n * merged all consolidations to one part of malloc proper\n (eliminating old malloc_find_space & malloc_clean_bin)\n * Scan 2 returns chunks (not just 1)\n * Propagate failure in realloc if malloc returns 0\n * Add stuff to allow compilation on non-ANSI compilers\n from kpv@research.att.com\n \n V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu)\n * removed potential for odd address access in prev_chunk\n * removed dependency on getpagesize.h\n * misc cosmetics and a bit more internal documentation\n * anticosmetics: mangled names in macros to evade debugger strangeness\n * tested on sparc, hp-700, dec-mips, rs6000\n with gcc & native cc (hp, dec only) allowing\n Detlefs & Zorn comparison study (in SIGPLAN Notices.)\n \n Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu)\n * Based loosely on libg++-1.2X malloc. (It retains some of the overall\n structure of old version, but most details differ.)\n \n */\n","/*\n * Copyright 2021 The Emscripten Authors. All rights reserved.\n * Emscripten is available under two separate licenses, the MIT license and the\n * University of Illinois/NCSA Open Source License. Both these licenses can be\n * found in the LICENSE file.\n */\n\n#include <emscripten/heap.h>\n#include <stddef.h>\n\nsize_t emscripten_get_heap_size() {\n return __builtin_wasm_memory_size(0) << 16;\n}\n","/*\n * Copyright 2019 The Emscripten Authors. All rights reserved.\n * Emscripten is available under two separate licenses, the MIT license and the\n * University of Illinois/NCSA Open Source License. Both these licenses can be\n * found in the LICENSE file.\n *\n*/\n\n// libc files are compiled as -std=c99 which doesn't normally declare\n// max_align_t.\n#if __STDC_VERSION__ < 201112L\n#define __NEED_max_align_t\n#endif\n\n#include <errno.h>\n#include <limits.h>\n#include <stddef.h>\n#include <stdint.h>\n#ifdef __EMSCRIPTEN_SHARED_MEMORY__ // for error handling, see below\n#include <stdio.h>\n#include <stdlib.h>\n#endif\n\n#ifdef __EMSCRIPTEN_TRACING__\nvoid emscripten_memprof_sbrk_grow(intptr_t old, intptr_t new);\n#else\n#define emscripten_memprof_sbrk_grow(...) ((void)0)\n#endif\n\n#include <emscripten/heap.h>\n\nextern size_t __heap_base;\n\nstatic uintptr_t sbrk_val = (uintptr_t)&__heap_base;\n\nuintptr_t* emscripten_get_sbrk_ptr() {\n#ifdef __PIC__\n // In relocatable code we may call emscripten_get_sbrk_ptr() during startup,\n // potentially *before* the setup of the dynamically-linked __heap_base, when\n // using SAFE_HEAP. (SAFE_HEAP instruments *all* memory accesses, so even the\n // code doing dynamic linking itself ends up instrumented, which is why we can\n // get such an instrumented call before sbrk_val has its proper value.)\n if (sbrk_val == 0) {\n sbrk_val = (uintptr_t)&__heap_base;\n }\n#endif\n return &sbrk_val;\n}\n\n// Enforce preserving a minimal alignof(maxalign_t) alignment for sbrk.\n#define SBRK_ALIGNMENT (__alignof__(max_align_t))\n\n#ifdef __EMSCRIPTEN_SHARED_MEMORY__\n#define READ_SBRK_PTR(sbrk_ptr) (__c11_atomic_load((_Atomic(uintptr_t)*)(sbrk_ptr), __ATOMIC_SEQ_CST))\n#else\n#define READ_SBRK_PTR(sbrk_ptr) (*(sbrk_ptr))\n#endif\n\nvoid *_sbrk64(int64_t increment) {\n if (increment >= 0) {\n increment = (increment + (SBRK_ALIGNMENT-1)) & ~((int64_t)SBRK_ALIGNMENT-1);\n } else {\n increment = -(-increment & ~((int64_t)SBRK_ALIGNMENT-1));\n }\n\n uintptr_t *sbrk_ptr = (uintptr_t*)emscripten_get_sbrk_ptr();\n\n // To make sbrk thread-safe, implement a CAS loop to update the\n // value of sbrk_ptr.\n while (1) {\n uintptr_t old_brk = READ_SBRK_PTR(sbrk_ptr);\n int64_t new_brk64 = (int64_t)old_brk + increment;\n uintptr_t new_brk = (uintptr_t)new_brk64;\n // Check for a) an over/underflow, which would indicate that we are\n // allocating over maximum addressable memory. and b) if necessary,\n // increase the WebAssembly Memory size, and abort if that fails.\n if (new_brk < 0 || new_brk64 != (int64_t)new_brk\n || (new_brk > emscripten_get_heap_size() && !emscripten_resize_heap(new_brk))) {\n errno = ENOMEM;\n return (void*)-1;\n }\n#ifdef __EMSCRIPTEN_SHARED_MEMORY__\n // Attempt to update the dynamic top to new value. Another thread may have\n // beat this one to the update, in which case we will need to start over\n // by iterating the loop body again.\n uintptr_t expected = old_brk;\n\n __c11_atomic_compare_exchange_strong((_Atomic(uintptr_t)*)sbrk_ptr,\n &expected, new_brk, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);\n\n if (expected != old_brk) continue; // CAS failed, another thread raced in between.\n#else\n *sbrk_ptr = new_brk;\n#endif\n\n emscripten_memprof_sbrk_grow(old_brk, new_brk);\n return (void*)old_brk;\n }\n}\n\nvoid *sbrk(intptr_t increment_) {\n#if defined(__wasm64__) // TODO || !defined(wasm2gb)\n // In the correct https://linux.die.net/man/2/sbrk spec, sbrk() parameter is\n // intended to be treated as signed, meaning that it is not possible in a\n // 32-bit program to sbrk alloc (or dealloc) more than 2GB of memory at once.\n\n // Treat sbrk() parameter as signed.\n return _sbrk64((int64_t)increment_);\n#else\n // BUG: Currently the Emscripten test suite codifies expectations that sbrk()\n // values passed to this function are to be treated as unsigned, which means\n // that in 2GB and 4GB build modes, it is not possible to shrink memory.\n // To satisfy that mode, treat sbrk() parameters in 32-bit builds as unsigned.\n // https://github.com/emscripten-core/emscripten/issues/25138\n\n // Treat sbrk() parameter as unsigned.\n return _sbrk64((int64_t)(uintptr_t)increment_);\n#endif\n}\n\nint brk(void* ptr) {\n#ifdef __EMSCRIPTEN_SHARED_MEMORY__\n // FIXME\n printf(\"brk() is not theadsafe yet, https://github.com/emscripten-core/emscripten/issues/10006\");\n abort();\n#else\n uintptr_t last = (uintptr_t)sbrk(0);\n if (sbrk((uintptr_t)ptr - last) == (void*)-1) {\n return -1;\n }\n return 0;\n#endif\n}\n",".globl _emscripten_stack_restore\n.globl _emscripten_stack_alloc\n.globl emscripten_stack_get_current\n\n#ifdef __wasm64__\n#define PTR i64\n#define MASK 0xfffffffffffffff0\n#else\n#define PTR i32\n#define MASK 0xfffffff0\n#endif\n\n.globaltype __stack_pointer, PTR\n\n_emscripten_stack_restore:\n .functype _emscripten_stack_restore(PTR) -> ()\n local.get 0\n global.set __stack_pointer\n end_function\n\n_emscripten_stack_alloc:\n .functype _emscripten_stack_alloc(PTR) -> (PTR)\n .local PTR, PTR\n global.get __stack_pointer\n # Get arg 0 -> number of bytes to allocate\n local.get 0\n # Stack grows down. Subtract arg0 from __stack_pointer\n PTR.sub\n # Align result by anding with ~15\n PTR.const MASK\n PTR.and\n local.tee 1\n global.set __stack_pointer\n local.get 1\n end_function\n\nemscripten_stack_get_current:\n .functype emscripten_stack_get_current () -> (PTR)\n global.get __stack_pointer\n end_function\n","// Copyright 2012 The Emscripten Authors. All rights reserved.\n// Emscripten is available under two separate licenses, the MIT license and the\n// University of Illinois/NCSA Open Source License. Both these licenses can be\n// found in the LICENSE file.\n\n#include <emscripten/bind.h>\n#ifdef USE_CXA_DEMANGLE\n#include <../lib/libcxxabi/include/cxxabi.h>\n#endif\n#include <algorithm>\n#include <climits>\n#include <emscripten/emscripten.h>\n#include <emscripten/wire.h>\n#include <limits>\n#include <list>\n#include <typeinfo>\n#include <vector>\n\nusing namespace emscripten;\nusing namespace internal;\n\nextern \"C\" {\n\nconst char* __getTypeName(const std::type_info* ti) {\n if (has_unbound_type_names) {\n#ifdef USE_CXA_DEMANGLE\n int stat;\n char* demangled = abi::__cxa_demangle(ti->name(), NULL, NULL, &stat);\n if (stat == 0 && demangled) {\n return demangled;\n }\n\n switch (stat) {\n case -1:\n return strdup(\"<allocation failure>\");\n case -2:\n return strdup(\"<invalid C++ symbol>\");\n case -3:\n return strdup(\"<invalid argument>\");\n default:\n return strdup(\"<unknown error>\");\n }\n#else\n return strdup(ti->name());\n#endif\n } else {\n char str[80];\n sprintf(str, \"%p\", reinterpret_cast<const void*>(ti));\n return strdup(str);\n }\n}\n\nstatic InitFunc* init_funcs = nullptr;\n\nvoid _embind_initialize_bindings() {\n for (auto* f = init_funcs; f; f = f->next) {\n f->init_func();\n }\n}\n\nvoid _embind_register_bindings(InitFunc* f) {\n f->next = init_funcs;\n init_funcs = f;\n}\n\nvoid _emval_coro_resume(val::awaiter* awaiter, EM_VAL result) {\n awaiter->resume_with(val::take_ownership(result));\n}\n\nvoid _emval_coro_reject(val::awaiter* awaiter, EM_VAL error) {\n awaiter->reject_with(val::take_ownership(error));\n}\n\n}\n\nnamespace {\ntemplate <typename T> static void register_integer(const char* name) {\n using namespace internal;\n _embind_register_integer(TypeID<T>::get(), name, sizeof(T), std::numeric_limits<T>::min(),\n std::numeric_limits<T>::max());\n}\n\ntemplate <typename T> static void register_bigint(const char* name) {\n using namespace internal;\n _embind_register_bigint(TypeID<T>::get(), name, sizeof(T), std::numeric_limits<T>::min(),\n std::numeric_limits<T>::max());\n}\n\ntemplate <typename T> static void register_float(const char* name) {\n using namespace internal;\n _embind_register_float(TypeID<T>::get(), name, sizeof(T));\n}\n\n// matches typeMapping in embind.js\nenum TypedArrayIndex {\n Int8Array,\n Uint8Array,\n Int16Array,\n Uint16Array,\n Int32Array,\n Uint32Array,\n Float32Array,\n Float64Array,\n // Only available if WASM_BIGINT\n Int64Array,\n Uint64Array,\n};\n\ntemplate <typename T> constexpr TypedArrayIndex getTypedArrayIndex() {\n static_assert(internal::typeSupportsMemoryView<T>(), \"type does not map to a typed array\");\n return std::is_floating_point<T>::value\n ? (sizeof(T) == 4 ? Float32Array : Float64Array)\n : (sizeof(T) == 1\n ? (std::is_signed<T>::value ? Int8Array : Uint8Array)\n : (sizeof(T) == 2 ? (std::is_signed<T>::value ? Int16Array : Uint16Array)\n : (sizeof(T) == 4 ? (std::is_signed<T>::value ? Int32Array : Uint32Array)\n : (std::is_signed<T>::value ? Int64Array : Uint64Array))));\n}\n\ntemplate <typename T> static void register_memory_view(const char* name) {\n using namespace internal;\n _embind_register_memory_view(TypeID<memory_view<T>>::get(), getTypedArrayIndex<T>(), name);\n}\n} // namespace\n\nEMSCRIPTEN_BINDINGS(builtin) {\n using namespace emscripten::internal;\n\n _embind_register_void(TypeID<void>::get(), \"void\");\n\n _embind_register_bool(TypeID<bool>::get(), \"bool\", true, false);\n static_assert(sizeof(bool) == 1);\n\n register_integer<char>(\"char\");\n register_integer<signed char>(\"signed char\");\n register_integer<unsigned char>(\"unsigned char\");\n register_integer<signed short>(\"short\");\n register_integer<unsigned short>(\"unsigned short\");\n register_integer<signed int>(\"int\");\n register_integer<unsigned int>(\"unsigned int\");\n#if __wasm64__\n register_bigint<signed long>(\"long\");\n register_bigint<unsigned long>(\"unsigned long\");\n#else\n register_integer<signed long>(\"long\");\n register_integer<unsigned long>(\"unsigned long\");\n#endif\n\n register_bigint<signed long long>(\"long long\");\n register_bigint<unsigned long long>(\"unsigned long long\");\n\n register_float<float>(\"float\");\n register_float<double>(\"double\");\n\n _embind_register_std_string(TypeID<std::string>::get(), \"std::string\");\n _embind_register_std_wstring(TypeID<std::wstring>::get(), sizeof(wchar_t), \"std::wstring\");\n _embind_register_std_wstring(TypeID<std::u16string>::get(), sizeof(char16_t), \"std::u16string\");\n _embind_register_std_wstring(TypeID<std::u32string>::get(), sizeof(char32_t), \"std::u32string\");\n _embind_register_emval(TypeID<val>::get());\n\n // Some of these types are aliases for each other. Luckily,\n // embind.js's _embind_register_memory_view ignores duplicate\n // registrations rather than asserting, so the first\n // register_memory_view call for a particular type will take\n // precedence.\n\n register_memory_view<char>(\"emscripten::memory_view<char>\");\n register_memory_view<signed char>(\"emscripten::memory_view<signed char>\");\n register_memory_view<unsigned char>(\"emscripten::memory_view<unsigned char>\");\n\n register_memory_view<short>(\"emscripten::memory_view<short>\");\n register_memory_view<unsigned short>(\"emscripten::memory_view<unsigned short>\");\n register_memory_view<int>(\"emscripten::memory_view<int>\");\n register_memory_view<unsigned int>(\"emscripten::memory_view<unsigned int>\");\n register_memory_view<long>(\"emscripten::memory_view<long>\");\n register_memory_view<unsigned long>(\"emscripten::memory_view<unsigned long>\");\n\n register_memory_view<int8_t>(\"emscripten::memory_view<int8_t>\");\n register_memory_view<uint8_t>(\"emscripten::memory_view<uint8_t>\");\n register_memory_view<int16_t>(\"emscripten::memory_view<int16_t>\");\n register_memory_view<uint16_t>(\"emscripten::memory_view<uint16_t>\");\n register_memory_view<int32_t>(\"emscripten::memory_view<int32_t>\");\n register_memory_view<uint32_t>(\"emscripten::memory_view<uint32_t>\");\n register_memory_view<int64_t>(\"emscripten::memory_view<int64_t>\");\n register_memory_view<uint64_t>(\"emscripten::memory_view<uint64_t>\");\n\n register_memory_view<float>(\"emscripten::memory_view<float>\");\n register_memory_view<double>(\"emscripten::memory_view<double>\");\n}\n","/*\n * Copyright 2012 The Emscripten Authors. All rights reserved.\n * Emscripten is available under two separate licenses, the MIT license and the\n * University of Illinois/NCSA Open Source License. Both these licenses can be\n * found in the LICENSE file.\n */\n\n#pragma once\n\n#include <cassert>\n#include <cstddef>\n#include <functional>\n#include <map>\n#include <string>\n#include <type_traits>\n#include <vector>\n#if __cplusplus >= 201703L\n#include <optional>\n#endif\n\n#include <emscripten/em_asm.h>\n#include <emscripten/val.h>\n#include <emscripten/wire.h>\n\n#if __has_feature(leak_sanitizer) || __has_feature(address_sanitizer)\n#include <sanitizer/lsan_interface.h>\n#endif\n\nnamespace emscripten {\n\nenum class sharing_policy {\n NONE = 0,\n INTRUSIVE = 1,\n BY_EMVAL = 2,\n};\n\nnamespace internal {\n\ntypedef int GenericEnumValue;\n\ntypedef void* GenericFunction;\ntypedef void (*VoidFunctionPtr)(void);\n\n// Implemented in JavaScript. Don't call these directly.\nextern \"C\" {\n\nvoid _embind_fatal_error(\n const char* name,\n const char* payload) __attribute__((__noreturn__));\n\nvoid _embind_register_void(\n TYPEID voidType,\n const char* name);\n\nvoid _embind_register_bool(\n TYPEID boolType,\n const char* name,\n bool trueValue,\n bool falseValue);\n\nvoid _embind_register_integer(\n TYPEID integerType,\n const char* name,\n size_t size,\n int32_t minRange,\n uint32_t maxRange);\n\nvoid _embind_register_bigint(\n TYPEID integerType,\n const char* name,\n size_t size,\n int64_t minRange,\n uint64_t maxRange);\n\nvoid _embind_register_float(\n TYPEID floatType,\n const char* name,\n size_t size);\n\nvoid _embind_register_std_string(\n TYPEID stringType,\n const char* name);\n\nvoid _embind_register_std_wstring(\n TYPEID stringType,\n size_t charSize,\n const char* name);\n\nvoid _embind_register_emval(\n TYPEID emvalType);\n\nvoid _embind_register_memory_view(\n TYPEID memoryViewType,\n unsigned typedArrayIndex,\n const char* name);\n\nvoid _embind_register_function(\n const char* name,\n unsigned argCount,\n const TYPEID argTypes[],\n const char* signature,\n GenericFunction invoker,\n GenericFunction function,\n bool isAsync,\n bool isNonnullReturn);\n\nvoid _embind_register_value_array(\n TYPEID tupleType,\n const char* name,\n const char* constructorSignature,\n GenericFunction constructor,\n const char* destructorSignature,\n GenericFunction destructor);\n\nvoid _embind_register_value_array_element(\n TYPEID tupleType,\n TYPEID getterReturnType,\n const char* getterSignature,\n GenericFunction getter,\n void* getterContext,\n TYPEID setterArgumentType,\n const char* setterSignature,\n GenericFunction setter,\n void* setterContext);\n\nvoid _embind_finalize_value_array(TYPEID tupleType);\n\nvoid _embind_register_value_object(\n TYPEID structType,\n const char* fieldName,\n const char* constructorSignature,\n GenericFunction constructor,\n const char* destructorSignature,\n GenericFunction destructor);\n\nvoid _embind_register_value_object_field(\n TYPEID structType,\n const char* fieldName,\n TYPEID getterReturnType,\n const char* getterSignature,\n GenericFunction getter,\n void* getterContext,\n TYPEID setterArgumentType,\n const char* setterSignature,\n GenericFunction setter,\n void* setterContext);\n\nvoid _embind_finalize_value_object(TYPEID structType);\n\nvoid _embind_register_class(\n TYPEID classType,\n TYPEID pointerType,\n TYPEID constPointerType,\n TYPEID baseClassType,\n const char* getActualTypeSignature,\n GenericFunction getActualType,\n const char* upcastSignature,\n GenericFunction upcast,\n const char* downcastSignature,\n GenericFunction downcast,\n const char* className,\n const char* destructorSignature,\n GenericFunction destructor);\n\nvoid _embind_register_class_constructor(\n TYPEID classType,\n unsigned argCount,\n const TYPEID argTypes[],\n const char* invokerSignature,\n GenericFunction invoker,\n GenericFunction constructor);\n\nvoid _embind_register_class_function(\n TYPEID classType,\n const char* methodName,\n unsigned argCount,\n const TYPEID argTypes[],\n const char* invokerSignature,\n GenericFunction invoker,\n void* context,\n unsigned isPureVirtual,\n bool isAsync,\n bool isNonnullReturn);\n\nvoid _embind_register_class_property(\n TYPEID classType,\n const char* fieldName,\n TYPEID getterReturnType,\n const char* getterSignature,\n GenericFunction getter,\n void* getterContext,\n TYPEID setterArgumentType,\n const char* setterSignature,\n GenericFunction setter,\n void* setterContext);\n\nvoid _embind_register_class_class_function(\n TYPEID classType,\n const char* methodName,\n unsigned argCount,\n const TYPEID argTypes[],\n const char* invokerSignature,\n GenericFunction invoker,\n GenericFunction method,\n bool isAsync,\n bool isNonnullReturn);\n\nvoid _embind_register_class_class_property(\n TYPEID classType,\n const char* fieldName,\n TYPEID fieldType,\n const void* fieldContext,\n const char* getterSignature,\n GenericFunction getter,\n const char* setterSignature,\n GenericFunction setter);\n\nEM_VAL _embind_create_inheriting_constructor(\n const char* constructorName,\n TYPEID wrapperType,\n EM_VAL properties);\n\nvoid _embind_register_enum(\n TYPEID enumType,\n const char* name,\n size_t size,\n bool isSigned);\n\nvoid _embind_register_smart_ptr(\n TYPEID pointerType,\n TYPEID pointeeType,\n const char* pointerName,\n sharing_policy sharingPolicy,\n const char* getPointeeSignature,\n GenericFunction getPointee,\n const char* constructorSignature,\n GenericFunction constructor,\n const char* shareSignature,\n GenericFunction share,\n const char* destructorSignature,\n GenericFunction destructor);\n\nvoid _embind_register_enum_value(\n TYPEID enumType,\n const char* valueName,\n GenericEnumValue value);\n\nvoid _embind_register_constant(\n const char* name,\n TYPEID constantType,\n double value);\n\nvoid _embind_register_optional(\n TYPEID optionalType,\n TYPEID type);\n\nvoid _embind_register_user_type(\n TYPEID type,\n const char* typeName);\n\nvoid _embind_register_user_type_definition(\n TYPEID type,\n const char* typeName,\n const char* typeDefinition);\n\n// Register an InitFunc in the global linked list of init functions.\nvoid _embind_register_bindings(struct InitFunc* f);\n\n// Binding initialization functions registered by EMSCRIPTEN_BINDINGS macro\n// below. Stored as linked list of static data object avoiding std containers\n// to avoid static constructor ordering issues.\nstruct InitFunc {\n InitFunc(void (*init_func)()) : init_func(init_func) {\n // This the function immediately upon constructions, and also register\n // it so that it can be called again on each worker that starts.\n init_func();\n _embind_register_bindings(this);\n }\n void (*init_func)();\n InitFunc* next = nullptr;\n};\n\n} // end extern \"C\"\n\n} // end namespace internal\n\n////////////////////////////////////////////////////////////////////////////////\n// select_overload and select_const\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename Signature>\nSignature* select_overload(Signature* fn) {\n return fn;\n}\n\ntemplate<typename Signature, typename ClassType>\nauto select_overload(Signature (ClassType::*fn)) -> decltype(fn) {\n return fn;\n}\n\ntemplate<typename ClassType, typename ReturnType, typename... Args>\nauto select_const(ReturnType (ClassType::*method)(Args...) const) -> decltype(method) {\n return method;\n}\n\nnamespace internal {\n// this should be in <type_traits>, but alas, it's not\ntemplate<typename T> struct remove_class;\ntemplate<typename C, typename R, typename... A>\nstruct remove_class<R(C::*)(A...)> { using type = R(A...); };\ntemplate<typename C, typename R, typename... A>\nstruct remove_class<R(C::*)(A...) const> { using type = R(A...); };\ntemplate<typename C, typename R, typename... A>\nstruct remove_class<R(C::*)(A...) volatile> { using type = R(A...); };\ntemplate<typename C, typename R, typename... A>\nstruct remove_class<R(C::*)(A...) const volatile> { using type = R(A...); };\n\ntemplate<typename LambdaType>\nusing LambdaSignature = typename remove_class<\n decltype(&LambdaType::operator())\n>::type;\n} // end namespace internal\n\n// requires captureless lambda because implicitly coerces to function pointer\ntemplate<typename LambdaType>\ninternal::LambdaSignature<LambdaType>* optional_override(const LambdaType& fp) {\n return fp;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// Invoker\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\ntemplate<typename ReturnPolicy, typename ReturnType, typename... Args>\nstruct Invoker {\n static typename internal::BindingType<ReturnType>::WireType invoke(\n ReturnType (*fn)(Args...),\n typename internal::BindingType<Args>::WireType... args\n ) {\n return internal::BindingType<ReturnType>::toWireType(\n fn(internal::BindingType<Args>::fromWireType(args)...),\n ReturnPolicy{}\n );\n }\n};\n\ntemplate<typename ReturnPolicy, typename... Args>\nstruct Invoker<ReturnPolicy, void, Args...> {\n static void invoke(\n void (*fn)(Args...),\n typename internal::BindingType<Args>::WireType... args\n ) {\n return fn(\n internal::BindingType<Args>::fromWireType(args)...\n );\n }\n};\n\ntemplate<typename ReturnPolicy, typename FunctorType, typename ReturnType, typename... Args>\nstruct FunctorInvoker {\n static typename internal::BindingType<ReturnType>::WireType invoke(\n FunctorType& function,\n typename internal::BindingType<Args>::WireType... args\n ) {\n return internal::BindingType<ReturnType>::toWireType(\n function(\n internal::BindingType<Args>::fromWireType(args)...)\n , ReturnPolicy{}\n );\n }\n};\n\ntemplate<typename ReturnPolicy, typename FunctorType, typename... Args>\nstruct FunctorInvoker<ReturnPolicy, FunctorType, void, Args...> {\n static void invoke(\n FunctorType& function,\n typename internal::BindingType<Args>::WireType... args\n ) {\n function(\n internal::BindingType<Args>::fromWireType(args)...);\n }\n};\n\n} // end namespace internal\n\n////////////////////////////////////////////////////////////////////////////////\n// SignatureCode, SignatureString\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\n// TODO: this is a historical default, but we should probably use 'p' instead,\n// and only enable it for smart_ptr_trait<> descendants.\ntemplate<typename T, typename = decltype(__em_asm_sig<int>::value)>\nstruct SignatureCode : __em_asm_sig<int> {};\n\ntemplate<typename T>\nstruct SignatureCode<T, decltype(__em_asm_sig<T>::value)> : __em_asm_sig<T> {};\n\ntemplate<typename T>\nstruct SignatureCode<T&> : SignatureCode<T*> {};\n\ntemplate<>\nstruct SignatureCode<void> {\n static constexpr char value = 'v';\n};\n\ntemplate<typename... Args>\nconstexpr const char Signature[] = { SignatureCode<Args>::value..., 0 };\n\ntemplate<typename Return, typename... Args>\nconstexpr const char* getSignature(Return (*)(Args...)) {\n return Signature<Return, Args...>;\n}\n\n} // end namespace internal\n\n////////////////////////////////////////////////////////////////////////////////\n// FUNCTIONS\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename ReturnType, typename... Args, typename... Policies>\nvoid function(const char* name, ReturnType (*fn)(Args...), Policies...) {\n using namespace internal;\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = Invoker<ReturnPolicy, ReturnType, Args...>::invoke;\n _embind_register_function(\n name,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(fn),\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n}\n\nnamespace internal {\n\ntemplate<typename ClassType, typename... Args>\nClassType* operator_new(Args&&... args) {\n return new ClassType(std::forward<Args>(args)...);\n}\n\ntemplate<typename WrapperType, typename ClassType, typename... Args>\nWrapperType wrapped_new(Args&&... args) {\n return WrapperType(new ClassType(std::forward<Args>(args)...));\n}\n\ntemplate<typename ClassType, typename... Args>\nClassType* raw_constructor(\n typename internal::BindingType<Args>::WireType... args\n) {\n return new ClassType(\n internal::BindingType<Args>::fromWireType(args)...\n );\n}\n\ntemplate<typename ClassType>\nvoid raw_destructor(ClassType* ptr) {\n delete ptr;\n}\n\ntemplate<typename ReturnPolicy, typename FunctionPointerType, typename ReturnType, typename ThisType, typename... Args>\nstruct FunctionInvoker {\n static typename internal::BindingType<ReturnType>::WireType invoke(\n FunctionPointerType* function,\n typename internal::BindingType<ThisType>::WireType wireThis,\n typename internal::BindingType<Args>::WireType... args\n ) {\n return internal::BindingType<ReturnType>::toWireType(\n (*function)(\n internal::BindingType<ThisType>::fromWireType(wireThis),\n internal::BindingType<Args>::fromWireType(args)...),\n ReturnPolicy{}\n );\n }\n};\n\ntemplate<typename ReturnPolicy, typename FunctionPointerType, typename ThisType, typename... Args>\nstruct FunctionInvoker<ReturnPolicy, FunctionPointerType, void, ThisType, Args...> {\n static void invoke(\n FunctionPointerType* function,\n typename internal::BindingType<ThisType>::WireType wireThis,\n typename internal::BindingType<Args>::WireType... args\n ) {\n (*function)(\n internal::BindingType<ThisType>::fromWireType(wireThis),\n internal::BindingType<Args>::fromWireType(args)...);\n }\n};\n\ntemplate<typename ReturnPolicy,\n typename MemberPointer,\n typename ReturnType,\n typename ThisType,\n typename... Args>\nstruct MethodInvoker {\n static typename internal::BindingType<ReturnType>::WireType invoke(\n const MemberPointer& method,\n typename internal::BindingType<ThisType>::WireType wireThis,\n typename internal::BindingType<Args>::WireType... args\n ) {\n return internal::BindingType<ReturnType>::toWireType(\n (internal::BindingType<ThisType>::fromWireType(wireThis)->*method)(\n internal::BindingType<Args>::fromWireType(args)...\n )\n ,\n ReturnPolicy{}\n );\n }\n};\n\ntemplate<typename ReturnPolicy,\n typename MemberPointer,\n typename ThisType,\n typename... Args>\nstruct MethodInvoker<ReturnPolicy, MemberPointer, void, ThisType, Args...> {\n static void invoke(\n const MemberPointer& method,\n typename internal::BindingType<ThisType>::WireType wireThis,\n typename internal::BindingType<Args>::WireType... args\n ) {\n return (internal::BindingType<ThisType>::fromWireType(wireThis)->*method)(\n internal::BindingType<Args>::fromWireType(args)...\n );\n }\n};\n\ntemplate<typename InstanceType, typename MemberType>\nstruct MemberAccess {\n typedef MemberType InstanceType::*MemberPointer;\n typedef internal::BindingType<MemberType> MemberBinding;\n typedef typename MemberBinding::WireType WireType;\n\n template<typename ClassType, typename ReturnPolicy = rvp::default_tag>\n static WireType getWire(\n const MemberPointer& field,\n ClassType& ptr\n ) {\n return MemberBinding::toWireType(ptr.*field, ReturnPolicy{});\n }\n\n template<typename ClassType>\n static void setWire(\n const MemberPointer& field,\n ClassType& ptr,\n WireType value\n ) {\n ptr.*field = MemberBinding::fromWireType(value);\n }\n};\n\ntemplate<typename FieldType>\nstruct GlobalAccess {\n typedef internal::BindingType<FieldType> MemberBinding;\n typedef typename MemberBinding::WireType WireType;\n\n static WireType get(FieldType* context) {\n return MemberBinding::toWireType(*context, rvp::default_tag{});\n }\n\n static void set(FieldType* context, WireType value) {\n *context = MemberBinding::fromWireType(value);\n }\n};\n\n// TODO: This could do a reinterpret-cast if sizeof(T) === sizeof(void*)\ntemplate<typename T>\ninline T* getContext(const T& t) {\n // not a leak because this is called once per binding\n auto* ret = new T(t);\n#if __has_feature(leak_sanitizer) || __has_feature(address_sanitizer)\n __lsan_ignore_object(ret);\n#endif\n return ret;\n}\n\ntemplate<typename Func, typename ValueTypeOrSignature>\nstruct FunctionTag {};\n\ntemplate<typename T>\nstruct GetterPolicy;\n\ntemplate<typename GetterReturnType, typename GetterThisType>\nstruct GetterPolicy<GetterReturnType (GetterThisType::*)() const> {\n typedef GetterReturnType ReturnType;\n typedef GetterReturnType (GetterThisType::*Context)() const;\n\n typedef internal::BindingType<ReturnType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType, typename ReturnPolicy>\n static WireType get(const Context& context, const ClassType& ptr) {\n return Binding::toWireType((ptr.*context)(), ReturnPolicy{});\n }\n\n static void* getContext(Context context) {\n return internal::getContext(context);\n }\n};\n\n#ifdef __cpp_noexcept_function_type\ntemplate<typename GetterReturnType, typename GetterThisType>\nstruct GetterPolicy<GetterReturnType (GetterThisType::*)() const noexcept>\n : GetterPolicy<GetterReturnType (GetterThisType::*)() const> {};\n#endif\n\ntemplate<typename GetterReturnType, typename GetterThisType>\nstruct GetterPolicy<GetterReturnType (*)(const GetterThisType&)> {\n typedef GetterReturnType ReturnType;\n typedef GetterReturnType (*Context)(const GetterThisType&);\n\n typedef internal::BindingType<ReturnType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType, typename ReturnPolicy>\n static WireType get(const Context& context, const ClassType& ptr) {\n return Binding::toWireType(context(ptr), ReturnPolicy{});\n }\n\n static void* getContext(Context context) {\n return internal::getContext(context);\n }\n};\n\ntemplate<typename GetterReturnType, typename GetterThisType>\nstruct GetterPolicy<std::function<GetterReturnType(const GetterThisType&)>> {\n typedef GetterReturnType ReturnType;\n typedef std::function<GetterReturnType(const GetterThisType&)> Context;\n\n typedef internal::BindingType<ReturnType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType, typename ReturnPolicy>\n static WireType get(const Context& context, const ClassType& ptr) {\n return Binding::toWireType(context(ptr), ReturnPolicy{});\n }\n\n static void* getContext(const Context& context) {\n return internal::getContext(context);\n }\n};\n\ntemplate<typename Getter, typename GetterReturnType>\nstruct GetterPolicy<FunctionTag<Getter, GetterReturnType>> {\n typedef GetterReturnType ReturnType;\n typedef Getter Context;\n\n typedef internal::BindingType<ReturnType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType, typename ReturnPolicy>\n static WireType get(const Context& context, const ClassType& ptr) {\n return Binding::toWireType(context(ptr), ReturnPolicy{});\n }\n\n static void* getContext(const Context& context) {\n return internal::getContext(context);\n }\n};\n\ntemplate<typename T>\nstruct SetterPolicy;\n\ntemplate<typename SetterReturnType, typename SetterThisType, typename SetterArgumentType>\nstruct SetterPolicy<SetterReturnType (SetterThisType::*)(SetterArgumentType)> {\n typedef SetterArgumentType ArgumentType;\n typedef SetterReturnType (SetterThisType::*Context)(SetterArgumentType);\n\n typedef internal::BindingType<SetterArgumentType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType>\n static void set(const Context& context, ClassType& ptr, WireType wt) {\n (ptr.*context)(Binding::fromWireType(wt));\n }\n\n static void* getContext(Context context) {\n return internal::getContext(context);\n }\n};\n\n#ifdef __cpp_noexcept_function_type\ntemplate<typename SetterReturnType, typename SetterThisType, typename SetterArgumentType>\nstruct SetterPolicy<SetterReturnType (SetterThisType::*)(SetterArgumentType) noexcept>\n : SetterPolicy<SetterReturnType (SetterThisType::*)(SetterArgumentType)> {};\n#endif\n\ntemplate<typename SetterReturnType, typename SetterThisType, typename SetterArgumentType>\nstruct SetterPolicy<SetterReturnType (*)(SetterThisType&, SetterArgumentType)> {\n typedef SetterArgumentType ArgumentType;\n typedef SetterReturnType (*Context)(SetterThisType&, SetterArgumentType);\n\n typedef internal::BindingType<SetterArgumentType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType>\n static void set(const Context& context, ClassType& ptr, WireType wt) {\n context(ptr, Binding::fromWireType(wt));\n }\n\n static void* getContext(Context context) {\n return internal::getContext(context);\n }\n};\n\ntemplate<typename SetterReturnType, typename SetterThisType, typename SetterArgumentType>\nstruct SetterPolicy<std::function<SetterReturnType(SetterThisType&, SetterArgumentType)>> {\n typedef SetterArgumentType ArgumentType;\n typedef std::function<SetterReturnType(SetterThisType&, SetterArgumentType)> Context;\n\n typedef internal::BindingType<SetterArgumentType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType>\n static void set(const Context& context, ClassType& ptr, WireType wt) {\n context(ptr, Binding::fromWireType(wt));\n }\n\n static void* getContext(const Context& context) {\n return internal::getContext(context);\n }\n};\n\ntemplate<typename Setter, typename SetterArgumentType>\nstruct SetterPolicy<FunctionTag<Setter, SetterArgumentType>> {\n typedef SetterArgumentType ArgumentType;\n typedef Setter Context;\n\n typedef internal::BindingType<SetterArgumentType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType>\n static void set(const Context& context, ClassType& ptr, WireType wt) {\n context(ptr, Binding::fromWireType(wt));\n }\n\n static void* getContext(const Context& context) {\n return internal::getContext(context);\n }\n};\n\nclass noncopyable {\nprotected:\n noncopyable() {}\n ~noncopyable() {}\nprivate:\n noncopyable(const noncopyable&) = delete;\n const noncopyable& operator=(const noncopyable&) = delete;\n};\n\ntemplate<typename ClassType, typename ElementType>\ntypename BindingType<ElementType>::WireType get_by_index(int index, ClassType& ptr) {\n return BindingType<ElementType>::toWireType(ptr[index], rvp::default_tag{});\n}\n\ntemplate<typename ClassType, typename ElementType>\nvoid set_by_index(int index, ClassType& ptr, typename BindingType<ElementType>::WireType wt) {\n ptr[index] = BindingType<ElementType>::fromWireType(wt);\n}\n\n} // end namespace internal\n\ntemplate<int Index>\nstruct index {\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// VALUE TUPLES\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename ClassType>\nclass value_array : public internal::noncopyable {\npublic:\n typedef ClassType class_type;\n\n value_array(const char* name) {\n using namespace internal;\n\n auto constructor = &raw_constructor<ClassType>;\n auto destructor = &raw_destructor<ClassType>;\n _embind_register_value_array(\n TypeID<ClassType>::get(),\n name,\n getSignature(constructor),\n reinterpret_cast<GenericFunction>(constructor),\n getSignature(destructor),\n reinterpret_cast<GenericFunction>(destructor));\n }\n\n ~value_array() {\n using namespace internal;\n _embind_finalize_value_array(TypeID<ClassType>::get());\n }\n\n template<typename InstanceType, typename ElementType>\n value_array& element(ElementType InstanceType::*field) {\n using namespace internal;\n\n auto getter = &MemberAccess<InstanceType, ElementType>\n ::template getWire<ClassType>;\n auto setter = &MemberAccess<InstanceType, ElementType>\n ::template setWire<ClassType>;\n\n _embind_register_value_array_element(\n TypeID<ClassType>::get(),\n TypeID<ElementType>::get(),\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getContext(field),\n TypeID<ElementType>::get(),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n getContext(field));\n return *this;\n }\n\n template<typename Getter, typename Setter>\n value_array& element(Getter getter, Setter setter) {\n using namespace internal;\n typedef GetterPolicy<Getter> GP;\n typedef SetterPolicy<Setter> SP;\n\n auto g = &GP::template get<ClassType, rvp::default_tag>;\n auto s = &SP::template set<ClassType>;\n\n _embind_register_value_array_element(\n TypeID<ClassType>::get(),\n TypeID<typename GP::ReturnType>::get(),\n getSignature(g),\n reinterpret_cast<GenericFunction>(g),\n GP::getContext(getter),\n TypeID<typename SP::ArgumentType>::get(),\n getSignature(s),\n reinterpret_cast<GenericFunction>(s),\n SP::getContext(setter));\n return *this;\n }\n\n template<int Index>\n value_array& element(index<Index>) {\n using namespace internal;\n ClassType* null = 0;\n typedef typename std::remove_reference<decltype((*null)[Index])>::type ElementType;\n auto getter = &internal::get_by_index<ClassType, ElementType>;\n auto setter = &internal::set_by_index<ClassType, ElementType>;\n\n _embind_register_value_array_element(\n TypeID<ClassType>::get(),\n TypeID<ElementType>::get(),\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n reinterpret_cast<void*>(Index),\n TypeID<ElementType>::get(),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n reinterpret_cast<void*>(Index));\n return *this;\n }\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// VALUE STRUCTS\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename ClassType>\nclass value_object : public internal::noncopyable {\npublic:\n typedef ClassType class_type;\n\n value_object(const char* name) {\n using namespace internal;\n\n auto ctor = &raw_constructor<ClassType>;\n auto dtor = &raw_destructor<ClassType>;\n\n _embind_register_value_object(\n TypeID<ClassType>::get(),\n name,\n getSignature(ctor),\n reinterpret_cast<GenericFunction>(ctor),\n getSignature(dtor),\n reinterpret_cast<GenericFunction>(dtor));\n }\n\n ~value_object() {\n using namespace internal;\n _embind_finalize_value_object(internal::TypeID<ClassType>::get());\n }\n\n template<typename InstanceType, typename FieldType>\n value_object& field(const char* fieldName, FieldType InstanceType::*field) {\n using namespace internal;\n\n auto getter = &MemberAccess<InstanceType, FieldType>\n ::template getWire<ClassType>;\n auto setter = &MemberAccess<InstanceType, FieldType>\n ::template setWire<ClassType>;\n\n _embind_register_value_object_field(\n TypeID<ClassType>::get(),\n fieldName,\n TypeID<FieldType>::get(),\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getContext(field),\n TypeID<FieldType>::get(),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n getContext(field));\n return *this;\n }\n\n template<typename InstanceType, typename ElementType, int N>\n value_object& field(const char* fieldName, ElementType (InstanceType::*field)[N]) {\n using namespace internal;\n\n typedef std::array<ElementType, N> FieldType;\n static_assert(sizeof(FieldType) == sizeof(ElementType[N]));\n\n auto getter = &MemberAccess<InstanceType, FieldType>\n ::template getWire<ClassType>;\n auto setter = &MemberAccess<InstanceType, FieldType>\n ::template setWire<ClassType>;\n\n _embind_register_value_object_field(\n TypeID<ClassType>::get(),\n fieldName,\n TypeID<FieldType>::get(),\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getContext(field),\n TypeID<FieldType>::get(),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n getContext(field));\n return *this;\n }\n\n template<typename Getter, typename Setter>\n value_object& field(\n const char* fieldName,\n Getter getter,\n Setter setter\n ) {\n using namespace internal;\n typedef GetterPolicy<Getter> GP;\n typedef SetterPolicy<Setter> SP;\n\n auto g = &GP::template get<ClassType, rvp::default_tag>;\n auto s = &SP::template set<ClassType>;\n\n _embind_register_value_object_field(\n TypeID<ClassType>::get(),\n fieldName,\n TypeID<typename GP::ReturnType>::get(),\n getSignature(g),\n reinterpret_cast<GenericFunction>(g),\n GP::getContext(getter),\n TypeID<typename SP::ArgumentType>::get(),\n getSignature(s),\n reinterpret_cast<GenericFunction>(s),\n SP::getContext(setter));\n return *this;\n }\n\n template<int Index>\n value_object& field(const char* fieldName, index<Index>) {\n using namespace internal;\n ClassType* null = 0;\n typedef typename std::remove_reference<decltype((*null)[Index])>::type ElementType;\n\n auto getter = &internal::get_by_index<ClassType, ElementType>;\n auto setter = &internal::set_by_index<ClassType, ElementType>;\n\n _embind_register_value_object_field(\n TypeID<ClassType>::get(),\n fieldName,\n TypeID<ElementType>::get(),\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n reinterpret_cast<void*>(Index),\n TypeID<ElementType>::get(),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n reinterpret_cast<void*>(Index));\n return *this;\n }\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// SMART POINTERS\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename PointerType>\nstruct default_smart_ptr_trait {\n static sharing_policy get_sharing_policy() {\n return sharing_policy::NONE;\n }\n\n static void* share(void* v) {\n return 0; // no sharing\n }\n\n static PointerType* construct_null() {\n return new PointerType;\n }\n};\n\n// specialize if you have a different pointer type\ntemplate<typename PointerType>\nstruct smart_ptr_trait : public default_smart_ptr_trait<PointerType> {\n typedef typename PointerType::element_type element_type;\n\n static element_type* get(const PointerType& ptr) {\n return ptr.get();\n }\n};\n\ntemplate<typename PointeeType>\nstruct smart_ptr_trait<std::shared_ptr<PointeeType>> {\n typedef std::shared_ptr<PointeeType> PointerType;\n typedef typename PointerType::element_type element_type;\n\n static element_type* get(const PointerType& ptr) {\n return ptr.get();\n }\n\n static sharing_policy get_sharing_policy() {\n return sharing_policy::BY_EMVAL;\n }\n\n static std::shared_ptr<PointeeType>* share(PointeeType* p, EM_VAL v) {\n return new std::shared_ptr<PointeeType>(\n p,\n val_deleter(val::take_ownership(v)));\n }\n\n static PointerType* construct_null() {\n return new PointerType;\n }\n\nprivate:\n class val_deleter {\n public:\n val_deleter() = delete;\n explicit val_deleter(val v)\n : v(v)\n {}\n void operator()(void const*) {\n v();\n // eventually we'll need to support emptied out val\n v = val::undefined();\n }\n private:\n val v;\n };\n};\n\n\n////////////////////////////////////////////////////////////////////////////////\n// CLASSES\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\nclass WrapperBase {\npublic:\n void setNotifyJSOnDestruction(bool notify) {\n notifyJSOnDestruction = notify;\n }\n\nprotected:\n bool notifyJSOnDestruction = false;\n};\n\n} // end namespace internal\n\n// abstract classes\ntemplate<typename T>\nclass wrapper : public T, public internal::WrapperBase {\npublic:\n typedef T class_type;\n\n template<typename... Args>\n explicit wrapper(val&& wrapped, Args&&... args)\n : T(std::forward<Args>(args)...)\n , wrapped(std::forward<val>(wrapped))\n {}\n\n ~wrapper() {\n if (notifyJSOnDestruction) {\n call<void>(\"__destruct\");\n }\n }\n\n template<typename ReturnType, typename... Args>\n ReturnType call(const char* name, Args&&... args) const {\n return wrapped.call<ReturnType>(name, std::forward<Args>(args)...);\n }\n\nprivate:\n val wrapped;\n};\n\n#define EMSCRIPTEN_WRAPPER(T) \\\ntemplate<typename... Args> \\\nT(::emscripten::val&& v, Args&&... args) \\\n : wrapper(std::forward<::emscripten::val>(v), std::forward<Args>(args)...) \\\n{}\n\nnamespace internal {\n\nstruct NoBaseClass {\n template<typename ClassType>\n static void verify() {\n }\n\n static TYPEID get() {\n return nullptr;\n }\n\n template<typename ClassType>\n static VoidFunctionPtr getUpcaster() {\n return nullptr;\n }\n\n template<typename ClassType>\n static VoidFunctionPtr getDowncaster() {\n return nullptr;\n }\n};\n\n// NOTE: this returns the class type, not the pointer type\ntemplate<typename T>\ninline TYPEID getActualType(T* ptr) {\n return getLightTypeID(*ptr);\n};\n\n} // end namespace internal\n\ntemplate<typename BaseClass>\nstruct base {\n typedef BaseClass class_type;\n\n template<typename ClassType>\n static void verify() {\n static_assert(!std::is_same<ClassType, BaseClass>::value, \"Base must not have same type as class\");\n static_assert(std::is_base_of<BaseClass, ClassType>::value, \"Derived class must derive from base\");\n }\n\n static internal::TYPEID get() {\n return internal::TypeID<BaseClass>::get();\n }\n\n template<typename ClassType>\n using Upcaster = BaseClass* (*)(ClassType*);\n\n template<typename ClassType>\n using Downcaster = ClassType* (*)(BaseClass*);\n\n template<typename ClassType>\n static Upcaster<ClassType> getUpcaster() {\n return &convertPointer<ClassType, BaseClass>;\n }\n\n template<typename ClassType>\n static Downcaster<ClassType> getDowncaster() {\n return &convertPointer<BaseClass, ClassType>;\n }\n\n template<typename From, typename To>\n static To* convertPointer(From* ptr) {\n return static_cast<To*>(ptr);\n }\n};\n\nnamespace internal {\n\ntemplate<typename WrapperType>\nval wrapped_extend(const std::string& name, const val& properties) {\n return val::take_ownership(_embind_create_inheriting_constructor(\n name.c_str(),\n TypeID<WrapperType>::get(),\n properties.as_handle()));\n}\n\n} // end namespace internal\n\nnamespace internal {\n\ntemplate<typename... Policies>\nstruct isPureVirtual;\n\ntemplate<typename... Rest>\nstruct isPureVirtual<pure_virtual, Rest...> {\n static constexpr bool value = true;\n};\n\ntemplate<typename T, typename... Rest>\nstruct isPureVirtual<T, Rest...> {\n static constexpr bool value = isPureVirtual<Rest...>::value;\n};\n\ntemplate<>\nstruct isPureVirtual<> {\n static constexpr bool value = false;\n};\n\nstruct DeduceArgumentsTag {};\n\n////////////////////////////////////////////////////////////////////////////\n// RegisterClassConstructor\n////////////////////////////////////////////////////////////////////////////\n\ntemplate <typename T>\nstruct RegisterClassConstructor;\n\ntemplate<typename ReturnType, typename... Args>\nstruct RegisterClassConstructor<ReturnType (*)(Args...)> {\n\n template <typename ClassType, typename... Policies>\n static void invoke(ReturnType (*factory)(Args...)) {\n typename WithPolicies<allow_raw_pointers, Policies...>::template ArgTypeList<ReturnType, Args...> args;\n using ReturnPolicy = rvp::take_ownership;\n auto invoke = &Invoker<ReturnPolicy, ReturnType, Args...>::invoke;\n _embind_register_class_constructor(\n TypeID<ClassType>::get(),\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(factory));\n }\n};\n\ntemplate<typename ReturnType, typename... Args>\nstruct RegisterClassConstructor<std::function<ReturnType (Args...)>> {\n\n template <typename ClassType, typename... Policies>\n static void invoke(std::function<ReturnType (Args...)> factory) {\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, Args...> args;\n using ReturnPolicy = rvp::take_ownership;\n auto invoke = &FunctorInvoker<ReturnPolicy, decltype(factory), ReturnType, Args...>::invoke;\n _embind_register_class_constructor(\n TypeID<ClassType>::get(),\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(getContext(factory)));\n }\n};\n\ntemplate<typename Callable, typename ReturnType, typename... Args>\nstruct RegisterClassConstructor<FunctionTag<Callable, ReturnType (Args...)>> {\n template <typename ClassType, typename... Policies>\n static void invoke(Callable& factory) {\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, Args...> args;\n using ReturnPolicy = rvp::take_ownership;\n auto invoke = &FunctorInvoker<ReturnPolicy, decltype(factory), ReturnType, Args...>::invoke;\n _embind_register_class_constructor(\n TypeID<ClassType>::get(),\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(getContext(factory)));\n }\n};\n\n////////////////////////////////////////////////////////////////////////////\n// RegisterClassMethod\n////////////////////////////////////////////////////////////////////////////\n\ntemplate <typename T>\nstruct RegisterClassMethod;\n\ntemplate<typename ClassType, typename ReturnType, typename... Args>\nstruct RegisterClassMethod<ReturnType (ClassType::*)(Args...)> {\n\n template <typename CT, typename... Policies>\n static void invoke(const char* methodName,\n ReturnType (ClassType::*memberFunction)(Args...)) {\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = MethodInvoker<ReturnPolicy, decltype(memberFunction), ReturnType, ClassType*, Args...>::invoke;\n\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, AllowedRawPointer<ClassType>, Args...> args;\n _embind_register_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n getContext(memberFunction),\n isPureVirtual<Policies...>::value,\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n }\n};\n\n#ifdef __cpp_noexcept_function_type\ntemplate<typename ClassType, typename ReturnType, typename... Args>\nstruct RegisterClassMethod<ReturnType (ClassType::*)(Args...) noexcept>\n : RegisterClassMethod<ReturnType (ClassType::*)(Args...)> {};\n#endif\n\ntemplate<typename ClassType, typename ReturnType, typename... Args>\nstruct RegisterClassMethod<ReturnType (ClassType::*)(Args...) const> {\n\n template <typename CT, typename... Policies>\n static void invoke(const char* methodName,\n ReturnType (ClassType::*memberFunction)(Args...) const) {\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = MethodInvoker<ReturnPolicy, decltype(memberFunction), ReturnType, const ClassType*, Args...>::invoke;\n\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, AllowedRawPointer<const ClassType>, Args...> args;\n _embind_register_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n getContext(memberFunction),\n isPureVirtual<Policies...>::value,\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n }\n};\n\n#ifdef __cpp_noexcept_function_type\ntemplate<typename ClassType, typename ReturnType, typename... Args>\nstruct RegisterClassMethod<ReturnType (ClassType::*)(Args...) const noexcept>\n : RegisterClassMethod<ReturnType (ClassType::*)(Args...) const> {};\n#endif\n\ntemplate<typename ReturnType, typename ThisType, typename... Args>\nstruct RegisterClassMethod<ReturnType (*)(ThisType, Args...)> {\n\n template <typename ClassType, typename... Policies>\n static void invoke(const char* methodName,\n ReturnType (*function)(ThisType, Args...)) {\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, ThisType, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = FunctionInvoker<ReturnPolicy, decltype(function), ReturnType, ThisType, Args...>::invoke;\n _embind_register_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n getContext(function),\n false,\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n }\n};\n\n#ifdef __cpp_noexcept_function_type\ntemplate<typename ReturnType, typename ThisType, typename... Args>\nstruct RegisterClassMethod<ReturnType (*)(ThisType, Args...) noexcept>\n : RegisterClassMethod<ReturnType (*)(ThisType, Args...)> {};\n#endif\n\ntemplate<typename ReturnType, typename ThisType, typename... Args>\nstruct RegisterClassMethod<std::function<ReturnType (ThisType, Args...)>> {\n\n template <typename ClassType, typename... Policies>\n static void invoke(const char* methodName,\n std::function<ReturnType (ThisType, Args...)> function) {\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, ThisType, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = FunctorInvoker<ReturnPolicy, decltype(function), ReturnType, ThisType, Args...>::invoke;\n _embind_register_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n getContext(function),\n false,\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n }\n};\n\ntemplate<typename Callable, typename ReturnType, typename ThisType, typename... Args>\nstruct RegisterClassMethod<FunctionTag<Callable, ReturnType (ThisType, Args...)>> {\n\n template <typename ClassType, typename... Policies>\n static void invoke(const char* methodName,\n Callable& callable) {\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, ThisType, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = FunctorInvoker<ReturnPolicy, decltype(callable), ReturnType, ThisType, Args...>::invoke;\n _embind_register_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n getContext(callable),\n false,\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n }\n};\n\n} // end namespace internal\n\ntemplate<typename... ConstructorArgs>\nstruct constructor {\n};\n\ntemplate<typename ClassType, typename BaseSpecifier = internal::NoBaseClass>\nclass class_ {\npublic:\n typedef ClassType class_type;\n typedef BaseSpecifier base_specifier;\n\n class_() = delete;\n\n EMSCRIPTEN_ALWAYS_INLINE explicit class_(const char* name) {\n using namespace internal;\n\n BaseSpecifier::template verify<ClassType>();\n\n auto _getActualType = &getActualType<ClassType>;\n auto upcast = BaseSpecifier::template getUpcaster<ClassType>();\n auto downcast = BaseSpecifier::template getDowncaster<ClassType>();\n auto destructor = &raw_destructor<ClassType>;\n\n _embind_register_class(\n TypeID<ClassType>::get(),\n TypeID<AllowedRawPointer<ClassType>>::get(),\n TypeID<AllowedRawPointer<const ClassType>>::get(),\n BaseSpecifier::get(),\n getSignature(_getActualType),\n reinterpret_cast<GenericFunction>(_getActualType),\n getSignature(upcast),\n reinterpret_cast<GenericFunction>(upcast),\n getSignature(downcast),\n reinterpret_cast<GenericFunction>(downcast),\n name,\n getSignature(destructor),\n reinterpret_cast<GenericFunction>(destructor));\n }\n\n template<typename PointerType>\n EMSCRIPTEN_ALWAYS_INLINE const class_& smart_ptr(const char* name) const {\n using namespace internal;\n\n typedef smart_ptr_trait<PointerType> PointerTrait;\n typedef typename PointerTrait::element_type PointeeType;\n\n static_assert(std::is_same<ClassType, typename std::remove_cv<PointeeType>::type>::value, \"smart pointer must point to this class\");\n\n auto get = &PointerTrait::get;\n auto construct_null = &PointerTrait::construct_null;\n auto share = &PointerTrait::share;\n auto destructor = &raw_destructor<PointerType>;\n\n _embind_register_smart_ptr(\n TypeID<PointerType>::get(),\n TypeID<PointeeType>::get(),\n name,\n PointerTrait::get_sharing_policy(),\n getSignature(get),\n reinterpret_cast<GenericFunction>(get),\n getSignature(construct_null),\n reinterpret_cast<GenericFunction>(construct_null),\n getSignature(share),\n reinterpret_cast<GenericFunction>(share),\n getSignature(destructor),\n reinterpret_cast<GenericFunction>(destructor));\n return *this;\n };\n\n template<typename... ConstructorArgs, typename... Policies>\n EMSCRIPTEN_ALWAYS_INLINE const class_& constructor(Policies... policies) const {\n return constructor(\n &internal::operator_new<ClassType, ConstructorArgs...>,\n policies...);\n }\n\n template<typename Signature = internal::DeduceArgumentsTag, typename Callable, typename... Policies>\n EMSCRIPTEN_ALWAYS_INLINE const class_& constructor(Callable callable, Policies...) const {\n\n using invoker = internal::RegisterClassConstructor<\n typename std::conditional<std::is_same<Signature, internal::DeduceArgumentsTag>::value,\n Callable,\n internal::FunctionTag<Callable, Signature>>::type>;\n\n invoker::template invoke<ClassType, Policies...>(callable);\n return *this;\n }\n\n template<typename SmartPtr, typename... Args, typename... Policies>\n EMSCRIPTEN_ALWAYS_INLINE const class_& smart_ptr_constructor(const char* smartPtrName, SmartPtr (*factory)(Args...), Policies...) const {\n using namespace internal;\n\n smart_ptr<SmartPtr>(smartPtrName);\n\n typename WithPolicies<Policies...>::template ArgTypeList<SmartPtr, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<SmartPtr, return_value_policy::take_ownership>::tag;\n auto invoke = &Invoker<ReturnPolicy, SmartPtr, Args...>::invoke;\n _embind_register_class_constructor(\n TypeID<ClassType>::get(),\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(factory));\n return *this;\n }\n\n template<typename WrapperType, typename... ConstructorArgs>\n EMSCRIPTEN_ALWAYS_INLINE const class_& allow_subclass(\n const char* wrapperClassName,\n ::emscripten::constructor<ConstructorArgs...> = ::emscripten::constructor<>()\n ) const {\n using namespace internal;\n\n auto cls = class_<WrapperType, base<ClassType>>(wrapperClassName)\n .function(\"notifyOnDestruction\", select_overload<void(WrapperType&)>([](WrapperType& wrapper) {\n wrapper.setNotifyJSOnDestruction(true);\n }))\n ;\n\n return\n class_function(\n \"implement\",\n &wrapped_new<WrapperType*, WrapperType, val, ConstructorArgs...>,\n allow_raw_pointer<ret_val>(), nonnull<ret_val>())\n .class_function(\n \"extend\",\n &wrapped_extend<WrapperType>)\n ;\n }\n\n template<typename WrapperType, typename PointerType, typename... ConstructorArgs>\n EMSCRIPTEN_ALWAYS_INLINE const class_& allow_subclass(\n const char* wrapperClassName,\n const char* pointerName,\n ::emscripten::constructor<ConstructorArgs...> = ::emscripten::constructor<>()\n ) const {\n using namespace internal;\n\n auto cls = class_<WrapperType, base<ClassType>>(wrapperClassName)\n .function(\"notifyOnDestruction\", select_overload<void(WrapperType&)>([](WrapperType& wrapper) {\n wrapper.setNotifyJSOnDestruction(true);\n }))\n .template smart_ptr<PointerType>(pointerName)\n ;\n\n return\n class_function(\n \"implement\",\n &wrapped_new<PointerType, WrapperType, val, ConstructorArgs...>,\n allow_raw_pointer<ret_val>())\n .class_function(\n \"extend\",\n &wrapped_extend<WrapperType>)\n ;\n }\n\n template<typename Signature = internal::DeduceArgumentsTag, typename Callable, typename... Policies>\n EMSCRIPTEN_ALWAYS_INLINE const class_& function(const char* methodName, Callable callable, Policies...) const {\n using invoker = internal::RegisterClassMethod<\n typename std::conditional<std::is_same<Signature, internal::DeduceArgumentsTag>::value,\n Callable,\n internal::FunctionTag<Callable, Signature>>::type>;\n\n invoker::template invoke<ClassType, Policies...>(methodName, callable);\n return *this;\n }\n\n template<\n typename FieldType,\n typename... Policies,\n // Prevent the template from wrongly matching the getter function\n // overload.\n typename = typename std::enable_if<\n !std::is_function<FieldType>::value &&\n internal::conjunction<internal::isPolicy<Policies>...>::value>::type>\n EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, const FieldType ClassType::*field, Policies...) const {\n using namespace internal;\n using ReturnPolicy = GetReturnValuePolicy<FieldType, Policies...>::tag;\n typename WithPolicies<Policies...>::template ArgTypeList<FieldType> returnType;\n\n auto getter = &MemberAccess<ClassType, FieldType>::template getWire<ClassType, ReturnPolicy>;\n _embind_register_class_property(\n TypeID<ClassType>::get(),\n fieldName,\n returnType.getTypes()[0],\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getContext(field),\n 0,\n 0,\n 0,\n 0);\n return *this;\n }\n\n template<\n typename FieldType,\n typename... Policies,\n // Prevent the template from wrongly matching the getter function\n // overload.\n typename = typename std::enable_if<\n !std::is_function<FieldType>::value &&\n internal::conjunction<internal::isPolicy<Policies>...>::value>::type>\n EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, FieldType ClassType::*field, Policies...) const {\n using namespace internal;\n using ReturnPolicy = GetReturnValuePolicy<FieldType, Policies...>::tag;\n typename WithPolicies<Policies...>::template ArgTypeList<FieldType> returnType;\n\n auto getter = &MemberAccess<ClassType, FieldType>::template getWire<ClassType, ReturnPolicy>;\n auto setter = &MemberAccess<ClassType, FieldType>::template setWire<ClassType>;\n _embind_register_class_property(\n TypeID<ClassType>::get(),\n fieldName,\n returnType.getTypes()[0],\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getContext(field),\n returnType.getTypes()[0],\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n getContext(field));\n return *this;\n }\n\n template<\n typename PropertyType = internal::DeduceArgumentsTag,\n typename Getter,\n typename... Policies,\n // Prevent the template from wrongly matching the getter/setter overload\n // of this function.\n typename = typename std::enable_if<\n internal::conjunction<internal::isPolicy<Policies>...>::value>::type>\n EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, Getter getter, Policies...) const {\n using namespace internal;\n\n typedef GetterPolicy<\n typename std::conditional<std::is_same<PropertyType, internal::DeduceArgumentsTag>::value,\n Getter,\n FunctionTag<Getter, PropertyType>>::type> GP;\n using ReturnPolicy = GetReturnValuePolicy<typename GP::ReturnType, Policies...>::tag;\n auto gter = &GP::template get<ClassType, ReturnPolicy>;\n typename WithPolicies<Policies...>::template ArgTypeList<typename GP::ReturnType> returnType;\n _embind_register_class_property(\n TypeID<ClassType>::get(),\n fieldName,\n returnType.getTypes()[0],\n getSignature(gter),\n reinterpret_cast<GenericFunction>(gter),\n GP::getContext(getter),\n 0,\n 0,\n 0,\n 0);\n return *this;\n }\n\n template<\n typename PropertyType = internal::DeduceArgumentsTag,\n typename Getter,\n typename Setter,\n typename... Policies,\n // Similar to the other variadic property overloads this can greedily\n // match the wrong overload so we need to ensure the setter is not a\n // policy argument.\n typename = typename std::enable_if<!internal::isPolicy<Setter>::value>::type>\n EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, Getter getter, Setter setter, Policies...) const {\n using namespace internal;\n\n typedef GetterPolicy<\n typename std::conditional<std::is_same<PropertyType, internal::DeduceArgumentsTag>::value,\n Getter,\n FunctionTag<Getter, PropertyType>>::type> GP;\n typedef SetterPolicy<\n typename std::conditional<std::is_same<PropertyType, internal::DeduceArgumentsTag>::value,\n Setter,\n FunctionTag<Setter, PropertyType>>::type> SP;\n\n\n using ReturnPolicy = GetReturnValuePolicy<typename GP::ReturnType, Policies...>::tag;\n auto gter = &GP::template get<ClassType, ReturnPolicy>;\n auto ster = &SP::template set<ClassType>;\n\n typename WithPolicies<Policies...>::template ArgTypeList<typename GP::ReturnType> returnType;\n // XXX: This currently applies all the polices (including return value polices) to the\n // setter function argument to allow pointers. Using return value polices doesn't really\n // make sense on an argument, but we don't have separate argument policies yet.\n typename WithPolicies<Policies...>::template ArgTypeList<typename SP::ArgumentType> argType;\n\n _embind_register_class_property(\n TypeID<ClassType>::get(),\n fieldName,\n returnType.getTypes()[0],\n getSignature(gter),\n reinterpret_cast<GenericFunction>(gter),\n GP::getContext(getter),\n argType.getTypes()[0],\n getSignature(ster),\n reinterpret_cast<GenericFunction>(ster),\n SP::getContext(setter));\n return *this;\n }\n\n template<typename ReturnType, typename... Args, typename... Policies>\n EMSCRIPTEN_ALWAYS_INLINE const class_& class_function(const char* methodName, ReturnType (*classMethod)(Args...), Policies...) const {\n using namespace internal;\n\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = internal::Invoker<ReturnPolicy, ReturnType, Args...>::invoke;\n _embind_register_class_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(classMethod),\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n return *this;\n }\n\n template<typename FieldType>\n EMSCRIPTEN_ALWAYS_INLINE const class_& class_property(const char* name, const FieldType* field) const {\n using namespace internal;\n\n auto getter = &GlobalAccess<FieldType>::get;\n _embind_register_class_class_property(\n TypeID<ClassType>::get(),\n name,\n TypeID<FieldType>::get(),\n field,\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n 0,\n 0);\n return *this;\n }\n\n template<typename FieldType>\n EMSCRIPTEN_ALWAYS_INLINE const class_& class_property(const char* name, FieldType* field) const {\n using namespace internal;\n\n auto getter = &GlobalAccess<FieldType>::get;\n auto setter = &GlobalAccess<FieldType>::set;\n _embind_register_class_class_property(\n TypeID<ClassType>::get(),\n name,\n TypeID<FieldType>::get(),\n field,\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter));\n return *this;\n }\n};\n\n#if __cplusplus >= 201703L\ntemplate<typename T>\nvoid register_optional() {\n // Optional types are automatically registered for some internal types so\n // only run the register method once so we don't conflict with a user's\n // bindings if they also register the optional type.\n thread_local bool hasRun;\n if (hasRun) {\n return;\n }\n hasRun = true;\n internal::_embind_register_optional(\n internal::TypeID<std::optional<T>>::get(),\n internal::TypeID<typename std::remove_pointer<T>::type>::get());\n}\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n// VECTORS\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\ntemplate<typename VectorType>\nstruct VectorAccess {\n// This nearly duplicated code is used for generating more specific TypeScript\n// types when using more modern C++ versions.\n#if __cplusplus >= 201703L\n static std::optional<typename VectorType::value_type> get(\n const VectorType& v,\n unsigned int index\n ) {\n if (index < v.size()) {\n return v[index];\n } else {\n return {};\n }\n }\n#else\n static val get(\n const VectorType& v,\n unsigned int index\n ) {\n if (index < v.size()) {\n return val(v[index], allow_raw_pointers());\n } else {\n return val::undefined();\n }\n }\n#endif\n\n static bool set(\n VectorType& v,\n unsigned int index,\n const typename VectorType::value_type& value\n ) {\n v[index] = value;\n return true;\n }\n\n static unsigned int size(const VectorType& v) {\n return v.size();\n }\n\n static void resize(\n VectorType& v,\n unsigned int len,\n const typename VectorType::value_type& value\n ) {\n v.resize(len, value);\n }\n\n static void push_back(\n VectorType& v,\n typename VectorType::value_type&& value\n ) {\n v.push_back(std::move(value));\n }\n};\n\n} // end namespace internal\n\ntemplate<typename T, class Allocator=std::allocator<T>>\nclass_<std::vector<T, Allocator>> register_vector(const char* name) {\n typedef std::vector<T, Allocator> VecType;\n#if __cplusplus >= 201703L\n register_optional<T>();\n#endif\n\n return class_<VecType>(name)\n .template constructor<>()\n .function(\"push_back\", internal::VectorAccess<VecType>::push_back, allow_raw_pointers())\n .function(\"resize\", internal::VectorAccess<VecType>::resize, allow_raw_pointers())\n .function(\"size\", internal::VectorAccess<VecType>::size, allow_raw_pointers())\n .function(\"get\", internal::VectorAccess<VecType>::get, allow_raw_pointers())\n .function(\"set\", internal::VectorAccess<VecType>::set, allow_raw_pointers())\n ;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// MAPS\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\ntemplate<typename MapType>\nstruct MapAccess {\n// This nearly duplicated code is used for generating more specific TypeScript\n// types when using more modern C++ versions.\n#if __cplusplus >= 201703L\n static std::optional<typename MapType::mapped_type> get(\n const MapType& m,\n const typename MapType::key_type& k\n ) {\n auto i = m.find(k);\n if (i == m.end()) {\n return {};\n } else {\n return i->second;\n }\n }\n#else\n static val get(\n const MapType& m,\n const typename MapType::key_type& k\n ) {\n auto i = m.find(k);\n if (i == m.end()) {\n return val::undefined();\n } else {\n return val(i->second);\n }\n }\n#endif\n\n static void set(\n MapType& m,\n const typename MapType::key_type& k,\n const typename MapType::mapped_type& v\n ) {\n m[k] = v;\n }\n\n static std::vector<typename MapType::key_type> keys(\n const MapType& m\n ) {\n std::vector<typename MapType::key_type> keys;\n keys.reserve(m.size());\n for (const auto& pair : m) {\n keys.push_back(pair.first);\n }\n return keys;\n }\n\n static unsigned int size(const MapType& m) {\n return m.size();\n }\n};\n\n} // end namespace internal\n\ntemplate<typename K, typename V, class Compare = std::less<K>,\n class Allocator = std::allocator<std::pair<const K, V>>>\nclass_<std::map<K, V, Compare, Allocator>> register_map(const char* name) {\n typedef std::map<K,V, Compare, Allocator> MapType;\n#if __cplusplus >= 201703L\n register_optional<V>();\n#endif\n\n return class_<MapType>(name)\n .template constructor<>()\n .function(\"size\", internal::MapAccess<MapType>::size)\n .function(\"get\", internal::MapAccess<MapType>::get)\n .function(\"set\", internal::MapAccess<MapType>::set)\n .function(\"keys\", internal::MapAccess<MapType>::keys)\n ;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// std::optional\n////////////////////////////////////////////////////////////////////////////////\n\n#if __cplusplus >= 201703L\nnamespace internal {\ntemplate <typename T>\nstruct BindingType<std::optional<T>> {\n using ValBinding = BindingType<val>;\n using WireType = ValBinding::WireType;\n\n template<typename ReturnPolicy = void>\n static WireType toWireType(std::optional<T> value, rvp::default_tag) {\n if (value) {\n return ValBinding::toWireType(val(*value, allow_raw_pointers()), rvp::default_tag{});\n }\n return ValBinding::toWireType(val::undefined(), rvp::default_tag{});\n }\n\n\n static std::optional<T> fromWireType(WireType value) {\n val optional = val::take_ownership(value);\n if (optional.isUndefined()) {\n return {};\n }\n return optional.as<T>();\n }\n};\n} // end namespace internal\n#endif\n\n\n////////////////////////////////////////////////////////////////////////////////\n// ENUMS\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename EnumType>\nclass enum_ {\npublic:\n typedef EnumType enum_type;\n\n enum_(const char* name) {\n using namespace internal;\n _embind_register_enum(\n internal::TypeID<EnumType>::get(),\n name,\n sizeof(EnumType),\n std::is_signed<typename std::underlying_type<EnumType>::type>::value);\n }\n\n enum_& value(const char* name, EnumType value) {\n using namespace internal;\n // TODO: there's still an issue here.\n // if EnumType is an unsigned long, then JS may receive it as a signed long\n static_assert(sizeof(value) <= sizeof(internal::GenericEnumValue), \"enum type must fit in a GenericEnumValue\");\n\n _embind_register_enum_value(\n internal::TypeID<EnumType>::get(),\n name,\n static_cast<internal::GenericEnumValue>(value));\n return *this;\n }\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// CONSTANTS\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\ntemplate<typename T> double asGenericValue(T t) {\n return static_cast<double>(t);\n}\n\ntemplate<typename T> uintptr_t asGenericValue(T* p) {\n return reinterpret_cast<uintptr_t>(p);\n}\n\n}\n\ntemplate<typename ConstantType>\nvoid constant(const char* name, const ConstantType& v) {\n using namespace internal;\n typedef BindingType<const ConstantType&> BT;\n _embind_register_constant(\n name,\n TypeID<const ConstantType&>::get(),\n static_cast<double>(asGenericValue(BT::toWireType(v, rvp::default_tag{}))));\n}\n\ntemplate <typename T>\ninline void register_type(const char* name) {\n using namespace internal;\n _embind_register_user_type(TypeID<T>::get(), name);\n}\n\ntemplate <typename T>\ninline void register_type(const char* name, const char* definition) {\n using namespace internal;\n _embind_register_user_type_definition(TypeID<T>::get(), name, definition);\n}\n\n// EMSCRIPTEN_BINDINGS creates a static struct to initialize the binding which\n// will get included in the program if the translation unit in which it is\n// defined gets linked into the program. Using a C++ constructor here ensures it\n// occurs after any other C++ constructors in this file, which is not true for\n// __attribute__((constructor)) (they run before C++ constructors in the same\n// file).\n#define EMSCRIPTEN_BINDINGS(name) \\\n static void embind_init_##name(); \\\n static struct EmBindInit_##name : emscripten::internal::InitFunc { \\\n EmBindInit_##name() : InitFunc(embind_init_##name) {} \\\n } EmBindInit_##name##_instance; \\\n static void embind_init_##name()\n\n} // end namespace emscripten\n","#include <ds/ds.hh>\n#include <ds/search.hh>\n#include <emscripten/bind.h>\n\nnamespace em = emscripten;\n\n// 由于embind的限制,这里无法使用string_view。\n// 为了保持一致性,一律使用复制。\ntemplate<typename T>\nauto from_string(const std::string& string, int buffer_size) -> std::unique_ptr<T> {\n auto result = reinterpret_cast<T*>(operator new(buffer_size));\n auto scan_result = result->scan(string.data(), reinterpret_cast<std::byte*>(result) + buffer_size);\n if (scan_result == nullptr) [[unlikely]] {\n operator delete(result);\n return std::unique_ptr<T>(nullptr);\n }\n return std::unique_ptr<T>(result);\n}\n\ntemplate<typename T>\nauto to_string(T* value, int buffer_size) -> std::string {\n auto result = reinterpret_cast<char*>(operator new(buffer_size));\n auto print_result = value->print(result, reinterpret_cast<char*>(result) + buffer_size);\n if (print_result == nullptr || print_result - result == buffer_size) [[unlikely]] {\n operator delete(result);\n return std::string();\n }\n *print_result = '\\0';\n auto string = std::string(result);\n operator delete(result);\n return string;\n}\n\ntemplate<typename T>\nauto from_binary(const std::vector<std::uint8_t>& binary) -> std::unique_ptr<T> {\n auto dst = std::unique_ptr<T>(reinterpret_cast<T*>(operator new(binary.size())));\n memcpy(dst.get(), binary.data(), binary.size());\n return dst;\n}\n\ntemplate<typename T>\nauto to_binary(T* value) -> std::vector<std::uint8_t> {\n std::vector<std::uint8_t> result;\n result.resize(value->data_size());\n memcpy(result.data(), value, value->data_size());\n return result;\n}\n\ntemplate<typename T>\nauto clone(T* value) -> std::unique_ptr<T> {\n auto result = std::unique_ptr<T>(reinterpret_cast<T*>(operator new(value->data_size())));\n memcpy(result.get(), value, value->data_size());\n return result;\n}\n\ntemplate<typename T>\nauto data_size(T* value) -> int {\n return value->data_size();\n}\n\ntemplate<typename T>\nauto common_declaration(em::class_<T>& t) {\n t.class_function(\"from_string\", from_string<T>);\n t.class_function(\"to_string\", to_string<T>, em::allow_raw_pointers());\n t.class_function(\"from_binary\", from_binary<T>);\n t.class_function(\"to_binary\", to_binary<T>, em::allow_raw_pointers());\n t.function(\"clone\", clone<T>, em::allow_raw_pointers());\n t.function(\"data_size\", data_size<T>, em::allow_raw_pointers());\n}\n\nauto term_ground(ds::term_t* term, ds::term_t* dictionary, const std::string& scope, int length) -> std::unique_ptr<ds::term_t> {\n const char* scope_ptr = scope.size() != 0 ? scope.data() : nullptr;\n auto result = reinterpret_cast<ds::term_t*>(operator new(length));\n if (result->ground(term, dictionary, scope_ptr, reinterpret_cast<std::byte*>(result) + length) == nullptr) [[unlikely]] {\n operator delete(result);\n return std::unique_ptr<ds::term_t>(nullptr);\n }\n return std::unique_ptr<ds::term_t>(result);\n}\n\nauto rule_ground(ds::rule_t* rule, ds::rule_t* dictionary, const std::string& scope, int length) -> std::unique_ptr<ds::rule_t> {\n const char* scope_ptr = scope.size() != 0 ? scope.data() : nullptr;\n auto result = reinterpret_cast<ds::rule_t*>(operator new(length));\n if (result->ground(rule, dictionary, scope_ptr, reinterpret_cast<std::byte*>(result) + length) == nullptr) [[unlikely]] {\n operator delete(result);\n return std::unique_ptr<ds::rule_t>(nullptr);\n }\n return std::unique_ptr<ds::rule_t>(result);\n}\n\nauto rule_match(ds::rule_t* rule_1, ds::rule_t* rule_2, int length) -> std::unique_ptr<ds::rule_t> {\n auto result = reinterpret_cast<ds::rule_t*>(operator new(length));\n if (result->match(rule_1, rule_2, reinterpret_cast<std::byte*>(result) + length) == nullptr) [[unlikely]] {\n operator delete(result);\n return std::unique_ptr<ds::rule_t>(nullptr);\n }\n return std::unique_ptr<ds::rule_t>(result);\n}\n\nauto term_rename(ds::term_t* term, ds::term_t* prefix_and_suffix, int length) -> std::unique_ptr<ds::term_t> {\n auto result = reinterpret_cast<ds::term_t*>(operator new(length));\n if (result->rename(term, prefix_and_suffix, reinterpret_cast<std::byte*>(result) + length) == nullptr) [[unlikely]] {\n operator delete(result);\n return std::unique_ptr<ds::term_t>(nullptr);\n }\n return std::unique_ptr<ds::term_t>(result);\n}\n\nauto rule_rename(ds::rule_t* rule, ds::rule_t* prefix_and_suffix, int length) -> std::unique_ptr<ds::rule_t> {\n auto result = reinterpret_cast<ds::rule_t*>(operator new(length));\n if (result->rename(rule, prefix_and_suffix, reinterpret_cast<std::byte*>(result) + length) == nullptr) [[unlikely]] {\n operator delete(result);\n return std::unique_ptr<ds::rule_t>(nullptr);\n }\n return std::unique_ptr<ds::rule_t>(result);\n}\n\nauto search_add(ds::search_t* search, const std::string& text) -> bool {\n return search->add(text);\n}\n\nauto search_execute(ds::search_t* search, const em::val& callback) -> ds::length_t {\n return search->execute([&callback](ds::rule_t* candidate) -> bool { return callback(candidate, em::allow_raw_pointers()).as<bool>(); });\n}\n\nEMSCRIPTEN_BINDINGS(ds) {\n em::register_vector<std::uint8_t>(\"Buffer\");\n\n auto string_t = em::class_<ds::string_t>(\"String\");\n auto item_t = em::class_<ds::item_t>(\"Item\");\n auto variable_t = em::class_<ds::variable_t>(\"Variable\");\n auto list_t = em::class_<ds::list_t>(\"List\");\n auto term_t = em::class_<ds::term_t>(\"Term\");\n auto rule_t = em::class_<ds::rule_t>(\"Rule\");\n\n common_declaration(string_t);\n common_declaration(item_t);\n common_declaration(variable_t);\n common_declaration(list_t);\n common_declaration(term_t);\n common_declaration(rule_t);\n\n item_t.function(\"name\", &ds::item_t::name, em::return_value_policy::reference());\n\n variable_t.function(\"name\", &ds::variable_t::name, em::return_value_policy::reference());\n\n list_t.function(\"length\", &ds::list_t::get_list_size);\n list_t.function(\"getitem\", &ds::list_t::term, em::return_value_policy::reference());\n\n em::enum_<ds::term_type_t>(\"TermType\")\n .value(\"Variable\", ds::term_type_t::variable)\n .value(\"Item\", ds::term_type_t::item)\n .value(\"List\", ds::term_type_t::list)\n .value(\"Null\", ds::term_type_t::null);\n term_t.function(\"get_type\", &ds::term_t::get_type);\n term_t.function(\"variable\", &ds::term_t::variable, em::return_value_policy::reference());\n term_t.function(\"item\", &ds::term_t::item, em::return_value_policy::reference());\n term_t.function(\"list\", &ds::term_t::list, em::return_value_policy::reference());\n\n rule_t.function(\"length\", &ds::rule_t::premises_count);\n rule_t.function(\"conclusion\", &ds::rule_t::conclusion, em::return_value_policy::reference());\n rule_t.function(\"getitem\", &ds::rule_t::premises, em::return_value_policy::reference());\n\n term_t.class_function(\"ground\", term_ground, em::return_value_policy::take_ownership());\n rule_t.class_function(\"ground\", rule_ground, em::return_value_policy::take_ownership());\n rule_t.class_function(\"match\", rule_match, em::return_value_policy::take_ownership());\n term_t.class_function(\"rename\", term_rename, em::return_value_policy::take_ownership());\n rule_t.class_function(\"rename\", rule_rename, em::return_value_policy::take_ownership());\n\n auto search_t = em::class_<ds::search_t>(\"Search\");\n search_t.constructor<ds::length_t, ds::length_t>();\n search_t.function(\"set_limit_size\", &ds::search_t::set_limit_size);\n search_t.function(\"set_buffer_size\", &ds::search_t::set_buffer_size);\n search_t.function(\"reset\", &ds::search_t::reset);\n // 因为embind的限制,这里无法使用string_view和function。\n search_t.function(\"add\", &search_add, em::allow_raw_pointers());\n search_t.function(\"execute\", &search_execute, em::allow_raw_pointers());\n}\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___VECTOR_VECTOR_H\n#define _LIBCPP___VECTOR_VECTOR_H\n\n#include <__algorithm/copy.h>\n#include <__algorithm/copy_n.h>\n#include <__algorithm/fill_n.h>\n#include <__algorithm/max.h>\n#include <__algorithm/min.h>\n#include <__algorithm/move.h>\n#include <__algorithm/move_backward.h>\n#include <__algorithm/ranges_copy_n.h>\n#include <__algorithm/rotate.h>\n#include <__assert>\n#include <__config>\n#include <__debug_utils/sanitizers.h>\n#include <__format/enable_insertable.h>\n#include <__fwd/vector.h>\n#include <__iterator/advance.h>\n#include <__iterator/bounded_iter.h>\n#include <__iterator/concepts.h>\n#include <__iterator/distance.h>\n#include <__iterator/iterator_traits.h>\n#include <__iterator/move_iterator.h>\n#include <__iterator/next.h>\n#include <__iterator/reverse_iterator.h>\n#include <__iterator/wrap_iter.h>\n#include <__memory/addressof.h>\n#include <__memory/allocate_at_least.h>\n#include <__memory/allocator.h>\n#include <__memory/allocator_traits.h>\n#include <__memory/compressed_pair.h>\n#include <__memory/noexcept_move_assign_container.h>\n#include <__memory/pointer_traits.h>\n#include <__memory/swap_allocator.h>\n#include <__memory/temp_value.h>\n#include <__memory/uninitialized_algorithms.h>\n#include <__ranges/access.h>\n#include <__ranges/concepts.h>\n#include <__ranges/container_compatible_range.h>\n#include <__ranges/from_range.h>\n#include <__split_buffer>\n#include <__type_traits/conditional.h>\n#include <__type_traits/enable_if.h>\n#include <__type_traits/is_allocator.h>\n#include <__type_traits/is_constant_evaluated.h>\n#include <__type_traits/is_constructible.h>\n#include <__type_traits/is_nothrow_assignable.h>\n#include <__type_traits/is_nothrow_constructible.h>\n#include <__type_traits/is_pointer.h>\n#include <__type_traits/is_same.h>\n#include <__type_traits/is_trivially_relocatable.h>\n#include <__type_traits/type_identity.h>\n#include <__utility/exception_guard.h>\n#include <__utility/forward.h>\n#include <__utility/is_pointer_in_range.h>\n#include <__utility/move.h>\n#include <__utility/pair.h>\n#include <__utility/swap.h>\n#include <initializer_list>\n#include <limits>\n#include <stdexcept>\n\n// These headers define parts of vectors definition, since they define ADL functions or class specializations.\n#include <__vector/comparison.h>\n#include <__vector/container_traits.h>\n#include <__vector/swap.h>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_PUSH_MACROS\n#include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\ntemplate <class _Tp, class _Allocator /* = allocator<_Tp> */>\nclass _LIBCPP_TEMPLATE_VIS vector {\nprivate:\n typedef allocator<_Tp> __default_allocator_type;\n\npublic:\n //\n // Types\n //\n typedef vector __self;\n typedef _Tp value_type;\n typedef _Allocator allocator_type;\n typedef allocator_traits<allocator_type> __alloc_traits;\n typedef value_type& reference;\n typedef const value_type& const_reference;\n typedef typename __alloc_traits::size_type size_type;\n typedef typename __alloc_traits::difference_type difference_type;\n typedef typename __alloc_traits::pointer pointer;\n typedef typename __alloc_traits::const_pointer const_pointer;\n#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR\n // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's\n // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is\n // considered contiguous.\n typedef __bounded_iter<__wrap_iter<pointer> > iterator;\n typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator;\n#else\n typedef __wrap_iter<pointer> iterator;\n typedef __wrap_iter<const_pointer> const_iterator;\n#endif\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n\n // A vector containers the following members which may be trivially relocatable:\n // - pointer: may be trivially relocatable, so it's checked\n // - allocator_type: may be trivially relocatable, so it's checked\n // vector doesn't contain any self-references, so it's trivially relocatable if its members are.\n using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<\n __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,\n vector,\n void>;\n\n static_assert(__check_valid_allocator<allocator_type>::value, \"\");\n static_assert(is_same<typename allocator_type::value_type, value_type>::value,\n \"Allocator::value_type must be same type as value_type\");\n\n //\n // [vector.cons], construct/copy/destroy\n //\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector()\n _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) {}\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)\n#if _LIBCPP_STD_VER <= 14\n _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)\n#else\n noexcept\n#endif\n : __alloc_(__a) {\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n) {\n auto __guard = std::__make_exception_guard(__destroy_vector(*this));\n if (__n > 0) {\n __vallocate(__n);\n __construct_at_end(__n);\n }\n __guard.__complete();\n }\n\n#if _LIBCPP_STD_VER >= 14\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a)\n : __alloc_(__a) {\n auto __guard = std::__make_exception_guard(__destroy_vector(*this));\n if (__n > 0) {\n __vallocate(__n);\n __construct_at_end(__n);\n }\n __guard.__complete();\n }\n#endif\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x) {\n auto __guard = std::__make_exception_guard(__destroy_vector(*this));\n if (__n > 0) {\n __vallocate(__n);\n __construct_at_end(__n, __x);\n }\n __guard.__complete();\n }\n\n template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI\n vector(size_type __n, const value_type& __x, const allocator_type& __a)\n : __alloc_(__a) {\n auto __guard = std::__make_exception_guard(__destroy_vector(*this));\n if (__n > 0) {\n __vallocate(__n);\n __construct_at_end(__n, __x);\n }\n __guard.__complete();\n }\n\n template <class _InputIterator,\n __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&\n is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,\n int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last) {\n __init_with_sentinel(__first, __last);\n }\n\n template <class _InputIterator,\n __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&\n is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,\n int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI\n vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)\n : __alloc_(__a) {\n __init_with_sentinel(__first, __last);\n }\n\n template <\n class _ForwardIterator,\n __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&\n is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,\n int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last) {\n size_type __n = static_cast<size_type>(std::distance(__first, __last));\n __init_with_size(__first, __last, __n);\n }\n\n template <\n class _ForwardIterator,\n __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&\n is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,\n int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI\n vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)\n : __alloc_(__a) {\n size_type __n = static_cast<size_type>(std::distance(__first, __last));\n __init_with_size(__first, __last, __n);\n }\n\n#if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<_Tp> _Range>\n _LIBCPP_HIDE_FROM_ABI constexpr vector(\n from_range_t, _Range&& __range, const allocator_type& __alloc = allocator_type())\n : __alloc_(__alloc) {\n if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {\n auto __n = static_cast<size_type>(ranges::distance(__range));\n __init_with_size(ranges::begin(__range), ranges::end(__range), __n);\n\n } else {\n __init_with_sentinel(ranges::begin(__range), ranges::end(__range));\n }\n }\n#endif\n\nprivate:\n class __destroy_vector {\n public:\n _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {}\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {\n if (__vec_.__begin_ != nullptr) {\n __vec_.clear();\n __vec_.__annotate_delete();\n __alloc_traits::deallocate(__vec_.__alloc_, __vec_.__begin_, __vec_.capacity());\n }\n }\n\n private:\n vector& __vec_;\n };\n\npublic:\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector (*this)(); }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x)\n : __alloc_(__alloc_traits::select_on_container_copy_construction(__x.__alloc_)) {\n __init_with_size(__x.__begin_, __x.__end_, __x.size());\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI\n vector(const vector& __x, const __type_identity_t<allocator_type>& __a)\n : __alloc_(__a) {\n __init_with_size(__x.__begin_, __x.__end_, __x.size());\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(const vector& __x);\n\n#ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(initializer_list<value_type> __il) {\n __init_with_size(__il.begin(), __il.end(), __il.size());\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI\n vector(initializer_list<value_type> __il, const allocator_type& __a)\n : __alloc_(__a) {\n __init_with_size(__il.begin(), __il.end(), __il.size());\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(initializer_list<value_type> __il) {\n assign(__il.begin(), __il.end());\n return *this;\n }\n#endif // !_LIBCPP_CXX03_LANG\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(vector&& __x)\n#if _LIBCPP_STD_VER >= 17\n noexcept;\n#else\n _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);\n#endif\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI\n vector(vector&& __x, const __type_identity_t<allocator_type>& __a);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(vector&& __x)\n _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {\n __move_assign(__x, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());\n return *this;\n }\n\n template <class _InputIterator,\n __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&\n is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,\n int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_InputIterator __first, _InputIterator __last) {\n __assign_with_sentinel(__first, __last);\n }\n template <\n class _ForwardIterator,\n __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&\n is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,\n int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last) {\n __assign_with_size(__first, __last, std::distance(__first, __last));\n }\n\n#if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<_Tp> _Range>\n _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) {\n if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {\n auto __n = static_cast<size_type>(ranges::distance(__range));\n __assign_with_size(ranges::begin(__range), ranges::end(__range), __n);\n\n } else {\n __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));\n }\n }\n#endif\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const_reference __u);\n\n#ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) {\n assign(__il.begin(), __il.end());\n }\n#endif\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {\n return this->__alloc_;\n }\n\n //\n // Iterators\n //\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {\n return __make_iter(__add_alignment_assumption(this->__begin_));\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {\n return __make_iter(__add_alignment_assumption(this->__begin_));\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT {\n return __make_iter(__add_alignment_assumption(this->__end_));\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {\n return __make_iter(__add_alignment_assumption(this->__end_));\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT {\n return reverse_iterator(end());\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {\n return const_reverse_iterator(end());\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT {\n return reverse_iterator(begin());\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {\n return const_reverse_iterator(begin());\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT {\n return rbegin();\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }\n\n //\n // [vector.capacity], capacity\n //\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT {\n return static_cast<size_type>(this->__end_ - this->__begin_);\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT {\n return static_cast<size_type>(this->__cap_ - this->__begin_);\n }\n [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {\n return this->__begin_ == this->__end_;\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {\n return std::min<size_type>(__alloc_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max());\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;\n\n //\n // element access\n //\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), \"vector[] index out of bounds\");\n return this->__begin_[__n];\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), \"vector[] index out of bounds\");\n return this->__begin_[__n];\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n) {\n if (__n >= size())\n this->__throw_out_of_range();\n return this->__begin_[__n];\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const {\n if (__n >= size())\n this->__throw_out_of_range();\n return this->__begin_[__n];\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), \"front() called on an empty vector\");\n return *this->__begin_;\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), \"front() called on an empty vector\");\n return *this->__begin_;\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), \"back() called on an empty vector\");\n return *(this->__end_ - 1);\n }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), \"back() called on an empty vector\");\n return *(this->__end_ - 1);\n }\n\n //\n // [vector.data], data access\n //\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT {\n return std::__to_address(this->__begin_);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT {\n return std::__to_address(this->__begin_);\n }\n\n //\n // [vector.modifiers], modifiers\n //\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x) { emplace_back(__x); }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x) { emplace_back(std::move(__x)); }\n\n template <class... _Args>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI\n#if _LIBCPP_STD_VER >= 17\n reference\n emplace_back(_Args&&... __args);\n#else\n void\n emplace_back(_Args&&... __args);\n#endif\n\n#if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<_Tp> _Range>\n _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) {\n insert_range(end(), std::forward<_Range>(__range));\n }\n#endif\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), \"vector::pop_back called on an empty vector\");\n this->__destruct_at_end(this->__end_ - 1);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x);\n template <class... _Args>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator\n insert(const_iterator __position, size_type __n, const_reference __x);\n\n template <class _InputIterator,\n __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&\n is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value,\n int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator\n insert(const_iterator __position, _InputIterator __first, _InputIterator __last) {\n return __insert_with_sentinel(__position, __first, __last);\n }\n\n template <\n class _ForwardIterator,\n __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&\n is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value,\n int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator\n insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) {\n return __insert_with_size(__position, __first, __last, std::distance(__first, __last));\n }\n\n#if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<_Tp> _Range>\n _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) {\n if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {\n auto __n = static_cast<size_type>(ranges::distance(__range));\n return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);\n\n } else {\n return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));\n }\n }\n#endif\n\n#ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator\n insert(const_iterator __position, initializer_list<value_type> __il) {\n return insert(__position, __il.begin(), __il.end());\n }\n#endif\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT {\n size_type __old_size = size();\n __base_destruct_at_end(this->__begin_);\n __annotate_shrink(__old_size);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz, const_reference __x);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(vector&)\n#if _LIBCPP_STD_VER >= 14\n _NOEXCEPT;\n#else\n _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);\n#endif\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;\n\nprivate:\n pointer __begin_ = nullptr;\n pointer __end_ = nullptr;\n _LIBCPP_COMPRESSED_PAIR(pointer, __cap_ = nullptr, allocator_type, __alloc_);\n\n // Allocate space for __n objects\n // throws length_error if __n > max_size()\n // throws (probably bad_alloc) if memory run out\n // Precondition: __begin_ == __end_ == __cap_ == nullptr\n // Precondition: __n > 0\n // Postcondition: capacity() >= __n\n // Postcondition: size() == 0\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {\n if (__n > max_size())\n __throw_length_error();\n auto __allocation = std::__allocate_at_least(this->__alloc_, __n);\n __begin_ = __allocation.ptr;\n __end_ = __allocation.ptr;\n __cap_ = __begin_ + __allocation.count;\n __annotate_new(0);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vdeallocate() _NOEXCEPT;\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __recommend(size_type __new_size) const;\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);\n\n template <class _InputIterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) {\n auto __guard = std::__make_exception_guard(__destroy_vector(*this));\n\n if (__n > 0) {\n __vallocate(__n);\n __construct_at_end(std::move(__first), std::move(__last), __n);\n }\n\n __guard.__complete();\n }\n\n template <class _InputIterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __init_with_sentinel(_InputIterator __first, _Sentinel __last) {\n auto __guard = std::__make_exception_guard(__destroy_vector(*this));\n\n for (; __first != __last; ++__first)\n emplace_back(*__first);\n\n __guard.__complete();\n }\n\n template <class _Iterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last);\n\n // The `_Iterator` in `*_with_size` functions can be input-only only if called from `*_range` (since C++23).\n // Otherwise, `_Iterator` is a forward iterator.\n\n template <class _Iterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n);\n\n template <class _InputIterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator\n __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last);\n\n template <class _Iterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator\n __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n);\n\n template <class _InputIterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT {\n#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR\n // Bound the iterator according to the capacity, rather than the size.\n //\n // Vector guarantees that iterators stay valid as long as no reallocation occurs even if new elements are inserted\n // into the container; for these cases, we need to make sure that the newly-inserted elements can be accessed\n // through the bounded iterator without failing checks. The downside is that the bounded iterator won't catch\n // access that is logically out-of-bounds, i.e., goes beyond the size, but is still within the capacity. With the\n // current implementation, there is no connection between a bounded iterator and its associated container, so we\n // don't have a way to update existing valid iterators when the container is resized and thus have to go with\n // a laxer approach.\n return std::__make_bounded_iter(\n std::__wrap_iter<pointer>(__p),\n std::__wrap_iter<pointer>(this->__begin_),\n std::__wrap_iter<pointer>(this->__cap_));\n#else\n return iterator(__p);\n#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT {\n#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR\n // Bound the iterator according to the capacity, rather than the size.\n return std::__make_bounded_iter(\n std::__wrap_iter<const_pointer>(__p),\n std::__wrap_iter<const_pointer>(this->__begin_),\n std::__wrap_iter<const_pointer>(this->__cap_));\n#else\n return const_iterator(__p);\n#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer\n __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __move_range(pointer __from_s, pointer __from_e, pointer __to);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type)\n _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, false_type)\n _NOEXCEPT_(__alloc_traits::is_always_equal::value);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last) _NOEXCEPT {\n size_type __old_size = size();\n __base_destruct_at_end(__new_last);\n __annotate_shrink(__old_size);\n }\n\n template <class... _Args>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __emplace_back_slow_path(_Args&&... __args);\n\n // The following functions are no-ops outside of AddressSanitizer mode.\n // We call annotations for every allocator, unless explicitly disabled.\n //\n // To disable annotations for a particular allocator, change value of\n // __asan_annotate_container_with_allocator to false.\n // For more details, see the \"Using libc++\" documentation page or\n // the documentation for __sanitizer_annotate_contiguous_container.\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {\n std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity(), __old_mid, __new_mid);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {\n (void)__current_size;\n#if _LIBCPP_HAS_ASAN\n __annotate_contiguous_container(data() + capacity(), data() + __current_size);\n#endif\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {\n#if _LIBCPP_HAS_ASAN\n __annotate_contiguous_container(data() + size(), data() + capacity());\n#endif\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT {\n (void)__n;\n#if _LIBCPP_HAS_ASAN\n __annotate_contiguous_container(data() + size(), data() + size() + __n);\n#endif\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT {\n (void)__old_size;\n#if _LIBCPP_HAS_ASAN\n __annotate_contiguous_container(data() + __old_size, data() + size());\n#endif\n }\n\n struct _ConstructTransaction {\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n)\n : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {\n#if _LIBCPP_HAS_ASAN\n __v_.__annotate_increase(__n);\n#endif\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {\n __v_.__end_ = __pos_;\n#if _LIBCPP_HAS_ASAN\n if (__pos_ != __new_end_) {\n __v_.__annotate_shrink(__new_end_ - __v_.__begin_);\n }\n#endif\n }\n\n vector& __v_;\n pointer __pos_;\n const_pointer const __new_end_;\n\n _ConstructTransaction(_ConstructTransaction const&) = delete;\n _ConstructTransaction& operator=(_ConstructTransaction const&) = delete;\n };\n\n template <class... _Args>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_one_at_end(_Args&&... __args) {\n _ConstructTransaction __tx(*this, 1);\n __alloc_traits::construct(this->__alloc_, std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...);\n ++__tx.__pos_;\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {\n pointer __soon_to_be_end = this->__end_;\n while (__new_last != __soon_to_be_end)\n __alloc_traits::destroy(this->__alloc_, std::__to_address(--__soon_to_be_end));\n this->__end_ = __new_last;\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c) {\n __copy_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_copy_assignment::value>());\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c)\n _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||\n is_nothrow_move_assignable<allocator_type>::value) {\n __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());\n }\n\n [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_length_error() { std::__throw_length_error(\"vector\"); }\n\n [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_out_of_range() { std::__throw_out_of_range(\"vector\"); }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c, true_type) {\n if (this->__alloc_ != __c.__alloc_) {\n clear();\n __annotate_delete();\n __alloc_traits::deallocate(this->__alloc_, this->__begin_, capacity());\n this->__begin_ = this->__end_ = this->__cap_ = nullptr;\n }\n this->__alloc_ = __c.__alloc_;\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector&, false_type) {}\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c, true_type)\n _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {\n this->__alloc_ = std::move(__c.__alloc_);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}\n\n template <class _Ptr = pointer, __enable_if_t<is_pointer<_Ptr>::value, int> = 0>\n static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI pointer\n __add_alignment_assumption(_Ptr __p) _NOEXCEPT {\n if (!__libcpp_is_constant_evaluated()) {\n return static_cast<pointer>(__builtin_assume_aligned(__p, _LIBCPP_ALIGNOF(decltype(*__p))));\n }\n return __p;\n }\n\n template <class _Ptr = pointer, __enable_if_t<!is_pointer<_Ptr>::value, int> = 0>\n static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI pointer\n __add_alignment_assumption(_Ptr __p) _NOEXCEPT {\n return __p;\n }\n};\n\n#if _LIBCPP_STD_VER >= 17\ntemplate <class _InputIterator,\n class _Alloc = allocator<__iter_value_type<_InputIterator>>,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,\n class = enable_if_t<__is_allocator<_Alloc>::value> >\nvector(_InputIterator, _InputIterator) -> vector<__iter_value_type<_InputIterator>, _Alloc>;\n\ntemplate <class _InputIterator,\n class _Alloc,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,\n class = enable_if_t<__is_allocator<_Alloc>::value> >\nvector(_InputIterator, _InputIterator, _Alloc) -> vector<__iter_value_type<_InputIterator>, _Alloc>;\n#endif\n\n#if _LIBCPP_STD_VER >= 23\ntemplate <ranges::input_range _Range,\n class _Alloc = allocator<ranges::range_value_t<_Range>>,\n class = enable_if_t<__is_allocator<_Alloc>::value> >\nvector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>;\n#endif\n\n// __swap_out_circular_buffer relocates the objects in [__begin_, __end_) into the front of __v and swaps the buffers of\n// *this and __v. It is assumed that __v provides space for exactly (__end_ - __begin_) objects in the front. This\n// function has a strong exception guarantee.\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\nvector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) {\n __annotate_delete();\n auto __new_begin = __v.__begin_ - (__end_ - __begin_);\n std::__uninitialized_allocator_relocate(\n this->__alloc_, std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin));\n __v.__begin_ = __new_begin;\n __end_ = __begin_; // All the objects have been destroyed by relocating them.\n std::swap(this->__begin_, __v.__begin_);\n std::swap(this->__end_, __v.__end_);\n std::swap(this->__cap_, __v.__cap_);\n __v.__first_ = __v.__begin_;\n __annotate_new(size());\n}\n\n// __swap_out_circular_buffer relocates the objects in [__begin_, __p) into the front of __v, the objects in\n// [__p, __end_) into the back of __v and swaps the buffers of *this and __v. It is assumed that __v provides space for\n// exactly (__p - __begin_) objects in the front and space for at least (__end_ - __p) objects in the back. This\n// function has a strong exception guarantee if __begin_ == __p || __end_ == __p.\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer\nvector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) {\n __annotate_delete();\n pointer __ret = __v.__begin_;\n\n // Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_)\n // in case something in [__begin_, __p) throws.\n std::__uninitialized_allocator_relocate(\n this->__alloc_, std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.__end_));\n __v.__end_ += (__end_ - __p);\n __end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them.\n auto __new_begin = __v.__begin_ - (__p - __begin_);\n\n std::__uninitialized_allocator_relocate(\n this->__alloc_, std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin));\n __v.__begin_ = __new_begin;\n __end_ = __begin_; // All the objects have been destroyed by relocating them.\n\n std::swap(this->__begin_, __v.__begin_);\n std::swap(this->__end_, __v.__end_);\n std::swap(this->__cap_, __v.__cap_);\n __v.__first_ = __v.__begin_;\n __annotate_new(size());\n return __ret;\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT {\n if (this->__begin_ != nullptr) {\n clear();\n __annotate_delete();\n __alloc_traits::deallocate(this->__alloc_, this->__begin_, capacity());\n this->__begin_ = this->__end_ = this->__cap_ = nullptr;\n }\n}\n\n// Precondition: __new_size > capacity()\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type\nvector<_Tp, _Allocator>::__recommend(size_type __new_size) const {\n const size_type __ms = max_size();\n if (__new_size > __ms)\n this->__throw_length_error();\n const size_type __cap = capacity();\n if (__cap >= __ms / 2)\n return __ms;\n return std::max<size_type>(2 * __cap, __new_size);\n}\n\n// Default constructs __n objects starting at __end_\n// throws if construction throws\n// Precondition: __n > 0\n// Precondition: size() + __n <= capacity()\n// Postcondition: size() == size() + __n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__construct_at_end(size_type __n) {\n _ConstructTransaction __tx(*this, __n);\n const_pointer __new_end = __tx.__new_end_;\n for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {\n __alloc_traits::construct(this->__alloc_, std::__to_address(__pos));\n }\n}\n\n// Copy constructs __n objects starting at __end_ from __x\n// throws if construction throws\n// Precondition: __n > 0\n// Precondition: size() + __n <= capacity()\n// Postcondition: size() == old size() + __n\n// Postcondition: [i] == __x for all i in [size() - __n, __n)\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void\nvector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {\n _ConstructTransaction __tx(*this, __n);\n const_pointer __new_end = __tx.__new_end_;\n for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {\n __alloc_traits::construct(this->__alloc_, std::__to_address(__pos), __x);\n }\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class _InputIterator, class _Sentinel>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\nvector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) {\n _ConstructTransaction __tx(*this, __n);\n __tx.__pos_ = std::__uninitialized_allocator_copy(this->__alloc_, std::move(__first), std::move(__last), __tx.__pos_);\n}\n\n// Default constructs __n objects starting at __end_\n// throws if construction throws\n// Postcondition: size() == size() + __n\n// Exception safety: strong.\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n) {\n if (static_cast<size_type>(this->__cap_ - this->__end_) >= __n)\n this->__construct_at_end(__n);\n else {\n __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), this->__alloc_);\n __v.__construct_at_end(__n);\n __swap_out_circular_buffer(__v);\n }\n}\n\n// Default constructs __n objects starting at __end_\n// throws if construction throws\n// Postcondition: size() == size() + __n\n// Exception safety: strong.\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) {\n if (static_cast<size_type>(this->__cap_ - this->__end_) >= __n)\n this->__construct_at_end(__n, __x);\n else {\n __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), this->__alloc_);\n __v.__construct_at_end(__n, __x);\n __swap_out_circular_buffer(__v);\n }\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x)\n#if _LIBCPP_STD_VER >= 17\n noexcept\n#else\n _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)\n#endif\n : __alloc_(std::move(__x.__alloc_)) {\n this->__begin_ = __x.__begin_;\n this->__end_ = __x.__end_;\n this->__cap_ = __x.__cap_;\n __x.__begin_ = __x.__end_ = __x.__cap_ = nullptr;\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI\nvector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)\n : __alloc_(__a) {\n if (__a == __x.__alloc_) {\n this->__begin_ = __x.__begin_;\n this->__end_ = __x.__end_;\n this->__cap_ = __x.__cap_;\n __x.__begin_ = __x.__end_ = __x.__cap_ = nullptr;\n } else {\n typedef move_iterator<iterator> _Ip;\n __init_with_size(_Ip(__x.begin()), _Ip(__x.end()), __x.size());\n }\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)\n _NOEXCEPT_(__alloc_traits::is_always_equal::value) {\n if (this->__alloc_ != __c.__alloc_) {\n typedef move_iterator<iterator> _Ip;\n assign(_Ip(__c.begin()), _Ip(__c.end()));\n } else\n __move_assign(__c, true_type());\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)\n _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {\n __vdeallocate();\n __move_assign_alloc(__c); // this can throw\n this->__begin_ = __c.__begin_;\n this->__end_ = __c.__end_;\n this->__cap_ = __c.__cap_;\n __c.__begin_ = __c.__end_ = __c.__cap_ = nullptr;\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>&\nvector<_Tp, _Allocator>::operator=(const vector& __x) {\n if (this != std::addressof(__x)) {\n __copy_assign_alloc(__x);\n assign(__x.__begin_, __x.__end_);\n }\n return *this;\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class _Iterator, class _Sentinel>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\nvector<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) {\n pointer __cur = __begin_;\n for (; __first != __last && __cur != __end_; ++__first, (void)++__cur)\n *__cur = *__first;\n if (__cur != __end_) {\n __destruct_at_end(__cur);\n } else {\n for (; __first != __last; ++__first)\n emplace_back(*__first);\n }\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class _Iterator, class _Sentinel>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\nvector<_Tp, _Allocator>::__assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n) {\n size_type __new_size = static_cast<size_type>(__n);\n if (__new_size <= capacity()) {\n if (__new_size > size()) {\n#if _LIBCPP_STD_VER >= 23\n auto __mid = ranges::copy_n(std::move(__first), size(), this->__begin_).in;\n __construct_at_end(std::move(__mid), std::move(__last), __new_size - size());\n#else\n _Iterator __mid = std::next(__first, size());\n std::copy(__first, __mid, this->__begin_);\n __construct_at_end(__mid, __last, __new_size - size());\n#endif\n } else {\n pointer __m = std::__copy(std::move(__first), __last, this->__begin_).second;\n this->__destruct_at_end(__m);\n }\n } else {\n __vdeallocate();\n __vallocate(__recommend(__new_size));\n __construct_at_end(std::move(__first), std::move(__last), __new_size);\n }\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) {\n if (__n <= capacity()) {\n size_type __s = size();\n std::fill_n(this->__begin_, std::min(__n, __s), __u);\n if (__n > __s)\n __construct_at_end(__n - __s, __u);\n else\n this->__destruct_at_end(this->__begin_ + __n);\n } else {\n __vdeallocate();\n __vallocate(__recommend(static_cast<size_type>(__n)));\n __construct_at_end(__n, __u);\n }\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __n) {\n if (__n > capacity()) {\n if (__n > max_size())\n this->__throw_length_error();\n __split_buffer<value_type, allocator_type&> __v(__n, size(), this->__alloc_);\n __swap_out_circular_buffer(__v);\n }\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {\n if (capacity() > size()) {\n#if _LIBCPP_HAS_EXCEPTIONS\n try {\n#endif // _LIBCPP_HAS_EXCEPTIONS\n __split_buffer<value_type, allocator_type&> __v(size(), size(), this->__alloc_);\n // The Standard mandates shrink_to_fit() does not increase the capacity.\n // With equal capacity keep the existing buffer. This avoids extra work\n // due to swapping the elements.\n if (__v.capacity() < capacity())\n __swap_out_circular_buffer(__v);\n#if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n }\n#endif // _LIBCPP_HAS_EXCEPTIONS\n }\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class... _Args>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer\nvector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) {\n __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), this->__alloc_);\n // __v.emplace_back(std::forward<_Args>(__args)...);\n __alloc_traits::construct(this->__alloc_, std::__to_address(__v.__end_), std::forward<_Args>(__args)...);\n __v.__end_++;\n __swap_out_circular_buffer(__v);\n return this->__end_;\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class... _Args>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline\n#if _LIBCPP_STD_VER >= 17\n typename vector<_Tp, _Allocator>::reference\n#else\n void\n#endif\n vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) {\n pointer __end = this->__end_;\n if (__end < this->__cap_) {\n __construct_one_at_end(std::forward<_Args>(__args)...);\n ++__end;\n } else {\n __end = __emplace_back_slow_path(std::forward<_Args>(__args)...);\n }\n this->__end_ = __end;\n#if _LIBCPP_STD_VER >= 17\n return *(__end - 1);\n#endif\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator\nvector<_Tp, _Allocator>::erase(const_iterator __position) {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(\n __position != end(), \"vector::erase(iterator) called with a non-dereferenceable iterator\");\n difference_type __ps = __position - cbegin();\n pointer __p = this->__begin_ + __ps;\n this->__destruct_at_end(std::move(__p + 1, this->__end_, __p));\n return __make_iter(__p);\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator\nvector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) {\n _LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, \"vector::erase(first, last) called with invalid range\");\n pointer __p = this->__begin_ + (__first - begin());\n if (__first != __last) {\n this->__destruct_at_end(std::move(__p + (__last - __first), this->__end_, __p));\n }\n return __make_iter(__p);\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\nvector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) {\n pointer __old_last = this->__end_;\n difference_type __n = __old_last - __to;\n {\n pointer __i = __from_s + __n;\n _ConstructTransaction __tx(*this, __from_e - __i);\n for (pointer __pos = __tx.__pos_; __i < __from_e; ++__i, (void)++__pos, __tx.__pos_ = __pos) {\n __alloc_traits::construct(this->__alloc_, std::__to_address(__pos), std::move(*__i));\n }\n }\n std::move_backward(__from_s, __from_s + __n, __old_last);\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator\nvector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) {\n pointer __p = this->__begin_ + (__position - begin());\n if (this->__end_ < this->__cap_) {\n if (__p == this->__end_) {\n __construct_one_at_end(__x);\n } else {\n __move_range(__p, this->__end_, __p + 1);\n const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);\n if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x)))\n ++__xr;\n *__p = *__xr;\n }\n } else {\n __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);\n __v.emplace_back(__x);\n __p = __swap_out_circular_buffer(__v, __p);\n }\n return __make_iter(__p);\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator\nvector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) {\n pointer __p = this->__begin_ + (__position - begin());\n if (this->__end_ < this->__cap_) {\n if (__p == this->__end_) {\n __construct_one_at_end(std::move(__x));\n } else {\n __move_range(__p, this->__end_, __p + 1);\n *__p = std::move(__x);\n }\n } else {\n __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);\n __v.emplace_back(std::move(__x));\n __p = __swap_out_circular_buffer(__v, __p);\n }\n return __make_iter(__p);\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class... _Args>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator\nvector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {\n pointer __p = this->__begin_ + (__position - begin());\n if (this->__end_ < this->__cap_) {\n if (__p == this->__end_) {\n __construct_one_at_end(std::forward<_Args>(__args)...);\n } else {\n __temp_value<value_type, _Allocator> __tmp(this->__alloc_, std::forward<_Args>(__args)...);\n __move_range(__p, this->__end_, __p + 1);\n *__p = std::move(__tmp.get());\n }\n } else {\n __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);\n __v.emplace_back(std::forward<_Args>(__args)...);\n __p = __swap_out_circular_buffer(__v, __p);\n }\n return __make_iter(__p);\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator\nvector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) {\n pointer __p = this->__begin_ + (__position - begin());\n if (__n > 0) {\n // We can't compare unrelated pointers inside constant expressions\n if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__cap_ - this->__end_)) {\n size_type __old_n = __n;\n pointer __old_last = this->__end_;\n if (__n > static_cast<size_type>(this->__end_ - __p)) {\n size_type __cx = __n - (this->__end_ - __p);\n __construct_at_end(__cx, __x);\n __n -= __cx;\n }\n if (__n > 0) {\n __move_range(__p, __old_last, __p + __old_n);\n const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);\n if (__p <= __xr && __xr < this->__end_)\n __xr += __old_n;\n std::fill_n(__p, __n, *__xr);\n }\n } else {\n __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);\n __v.__construct_at_end(__n, __x);\n __p = __swap_out_circular_buffer(__v, __p);\n }\n }\n return __make_iter(__p);\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class _InputIterator, class _Sentinel>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator\nvector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) {\n difference_type __off = __position - begin();\n pointer __p = this->__begin_ + __off;\n pointer __old_last = this->__end_;\n for (; this->__end_ != this->__cap_ && __first != __last; ++__first)\n __construct_one_at_end(*__first);\n\n if (__first == __last)\n (void)std::rotate(__p, __old_last, this->__end_);\n else {\n __split_buffer<value_type, allocator_type&> __v(__alloc_);\n auto __guard = std::__make_exception_guard(\n _AllocatorDestroyRangeReverse<allocator_type, pointer>(__alloc_, __old_last, this->__end_));\n __v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last));\n __split_buffer<value_type, allocator_type&> __merged(\n __recommend(size() + __v.size()), __off, __alloc_); // has `__off` positions available at the front\n std::__uninitialized_allocator_relocate(\n __alloc_, std::__to_address(__old_last), std::__to_address(this->__end_), std::__to_address(__merged.__end_));\n __guard.__complete(); // Release the guard once objects in [__old_last_, __end_) have been successfully relocated.\n __merged.__end_ += this->__end_ - __old_last;\n this->__end_ = __old_last;\n std::__uninitialized_allocator_relocate(\n __alloc_, std::__to_address(__v.__begin_), std::__to_address(__v.__end_), std::__to_address(__merged.__end_));\n __merged.__end_ += __v.size();\n __v.__end_ = __v.__begin_;\n __p = __swap_out_circular_buffer(__merged, __p);\n }\n return __make_iter(__p);\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class _Iterator, class _Sentinel>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator\nvector<_Tp, _Allocator>::__insert_with_size(\n const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n) {\n pointer __p = this->__begin_ + (__position - begin());\n if (__n > 0) {\n if (__n <= this->__cap_ - this->__end_) {\n pointer __old_last = this->__end_;\n difference_type __dx = this->__end_ - __p;\n if (__n > __dx) {\n#if _LIBCPP_STD_VER >= 23\n if constexpr (!forward_iterator<_Iterator>) {\n __construct_at_end(std::move(__first), std::move(__last), __n);\n std::rotate(__p, __old_last, this->__end_);\n } else\n#endif\n {\n _Iterator __m = std::next(__first, __dx);\n __construct_at_end(__m, __last, __n - __dx);\n if (__dx > 0) {\n __move_range(__p, __old_last, __p + __n);\n std::copy(__first, __m, __p);\n }\n }\n } else {\n __move_range(__p, __old_last, __p + __n);\n#if _LIBCPP_STD_VER >= 23\n if constexpr (!forward_iterator<_Iterator>) {\n ranges::copy_n(std::move(__first), __n, __p);\n } else\n#endif\n {\n std::copy_n(__first, __n, __p);\n }\n }\n } else {\n __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);\n __v.__construct_at_end_with_size(std::move(__first), __n);\n __p = __swap_out_circular_buffer(__v, __p);\n }\n }\n return __make_iter(__p);\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz) {\n size_type __cs = size();\n if (__cs < __sz)\n this->__append(__sz - __cs);\n else if (__cs > __sz)\n this->__destruct_at_end(this->__begin_ + __sz);\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) {\n size_type __cs = size();\n if (__cs < __sz)\n this->__append(__sz - __cs, __x);\n else if (__cs > __sz)\n this->__destruct_at_end(this->__begin_ + __sz);\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x)\n#if _LIBCPP_STD_VER >= 14\n _NOEXCEPT\n#else\n _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)\n#endif\n{\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __alloc_traits::propagate_on_container_swap::value || this->__alloc_ == __x.__alloc_,\n \"vector::swap: Either propagate_on_container_swap must be true\"\n \" or the allocators must compare equal\");\n std::swap(this->__begin_, __x.__begin_);\n std::swap(this->__end_, __x.__end_);\n std::swap(this->__cap_, __x.__cap_);\n std::__swap_allocator(this->__alloc_, __x.__alloc_);\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<_Tp, _Allocator>::__invariants() const {\n if (this->__begin_ == nullptr) {\n if (this->__end_ != nullptr || this->__cap_ != nullptr)\n return false;\n } else {\n if (this->__begin_ > this->__end_)\n return false;\n if (this->__begin_ == this->__cap_)\n return false;\n if (this->__end_ > this->__cap_)\n return false;\n }\n return true;\n}\n\n#if _LIBCPP_STD_VER >= 20\ntemplate <>\ninline constexpr bool __format::__enable_insertable<vector<char>> = true;\n# if _LIBCPP_HAS_WIDE_CHARACTERS\ntemplate <>\ninline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true;\n# endif\n#endif // _LIBCPP_STD_VER >= 20\n\n_LIBCPP_END_NAMESPACE_STD\n\n_LIBCPP_POP_MACROS\n\n#endif // _LIBCPP___VECTOR_VECTOR_H\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___NEW_ALLOCATE_H\n#define _LIBCPP___NEW_ALLOCATE_H\n\n#include <__config>\n#include <__cstddef/max_align_t.h>\n#include <__cstddef/size_t.h>\n#include <__new/align_val_t.h>\n#include <__new/global_new_delete.h> // for _LIBCPP_HAS_SIZED_DEALLOCATION\n#include <__type_traits/type_identity.h>\n#include <__utility/element_count.h>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\n_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {\n#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__\n return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;\n#else\n return __align > _LIBCPP_ALIGNOF(max_align_t);\n#endif\n}\n\ntemplate <class... _Args>\n_LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) {\n#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)\n return __builtin_operator_new(__args...);\n#else\n return ::operator new(__args...);\n#endif\n}\n\ntemplate <class... _Args>\n_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT {\n#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)\n __builtin_operator_delete(__args...);\n#else\n ::operator delete(__args...);\n#endif\n}\n\ntemplate <class _Tp>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp*\n__libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) {\n size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);\n#if _LIBCPP_HAS_ALIGNED_ALLOCATION\n if (__is_overaligned_for_new(__align)) {\n const align_val_t __align_val = static_cast<align_val_t>(__align);\n return static_cast<_Tp*>(std::__libcpp_operator_new(__size, __align_val));\n }\n#endif\n\n (void)__align;\n return static_cast<_Tp*>(std::__libcpp_operator_new(__size));\n}\n\n#if _LIBCPP_HAS_SIZED_DEALLOCATION\n# define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) __VA_ARGS__\n#else\n# define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) /* nothing */\n#endif\n\ntemplate <class _Tp>\ninline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(\n __type_identity_t<_Tp>* __ptr, __element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {\n size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);\n (void)__size;\n#if !_LIBCPP_HAS_ALIGNED_ALLOCATION\n (void)__align;\n return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size));\n#else\n if (__is_overaligned_for_new(__align)) {\n const align_val_t __align_val = static_cast<align_val_t>(__align);\n return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size), __align_val);\n } else {\n return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size));\n }\n#endif\n}\n\n#undef _LIBCPP_ONLY_IF_SIZED_DEALLOCATION\n\ntemplate <class _Tp>\ninline _LIBCPP_HIDE_FROM_ABI void\n__libcpp_deallocate_unsized(__type_identity_t<_Tp>* __ptr, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {\n#if !_LIBCPP_HAS_ALIGNED_ALLOCATION\n (void)__align;\n return std::__libcpp_operator_delete(__ptr);\n#else\n if (__is_overaligned_for_new(__align)) {\n const align_val_t __align_val = static_cast<align_val_t>(__align);\n return std::__libcpp_operator_delete(__ptr, __align_val);\n } else {\n return std::__libcpp_operator_delete(__ptr);\n }\n#endif\n}\n_LIBCPP_END_NAMESPACE_STD\n\n#endif // _LIBCPP___NEW_ALLOCATE_H\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#include \"include/overridable_function.h\"\n#include <__assert>\n#include <__memory/aligned_alloc.h>\n#include <cstddef>\n#include <cstdlib>\n#include <new>\n\n#if !defined(__GLIBCXX__) && !defined(_LIBCPP_ABI_VCRUNTIME)\n\n// The code below is copied as-is into libc++abi's libcxxabi/src/stdlib_new_delete.cpp\n// file. The version in this file is the canonical one.\n\ninline void __throw_bad_alloc_shim() { std::__throw_bad_alloc(); }\n\n# define _LIBCPP_ASSERT_SHIM(expr, str) _LIBCPP_ASSERT(expr, str)\n\n// ------------------ BEGIN COPY ------------------\n// Implement all new and delete operators as weak definitions\n// in this shared library, so that they can be overridden by programs\n// that define non-weak copies of the functions.\n\nstatic void* operator_new_impl(std::size_t size) {\n if (size == 0)\n size = 1;\n void* p;\n while ((p = std::malloc(size)) == nullptr) {\n // If malloc fails and there is a new_handler,\n // call it to try free up memory.\n std::new_handler nh = std::get_new_handler();\n if (nh)\n nh();\n else\n break;\n }\n return p;\n}\n\n_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std::size_t size) _THROW_BAD_ALLOC {\n void* p = operator_new_impl(size);\n if (p == nullptr)\n __throw_bad_alloc_shim();\n return p;\n}\n\n_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {\n# if !_LIBCPP_HAS_EXCEPTIONS\n# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION\n _LIBCPP_ASSERT_SHIM(\n !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)),\n \"libc++ was configured with exceptions disabled and `operator new(size_t)` has been overridden, \"\n \"but `operator new(size_t, nothrow_t)` has not been overridden. This is problematic because \"\n \"`operator new(size_t, nothrow_t)` must call `operator new(size_t)`, which will terminate in case \"\n \"it fails to allocate, making it impossible for `operator new(size_t, nothrow_t)` to fulfill its \"\n \"contract (since it should return nullptr upon failure). Please make sure you override \"\n \"`operator new(size_t, nothrow_t)` as well.\");\n# endif\n\n return operator_new_impl(size);\n# else\n void* p = nullptr;\n try {\n p = ::operator new(size);\n } catch (...) {\n }\n return p;\n# endif\n}\n\n_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](size_t size) _THROW_BAD_ALLOC {\n return ::operator new(size);\n}\n\n_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {\n# if !_LIBCPP_HAS_EXCEPTIONS\n# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION\n _LIBCPP_ASSERT_SHIM(\n !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new[])),\n \"libc++ was configured with exceptions disabled and `operator new[](size_t)` has been overridden, \"\n \"but `operator new[](size_t, nothrow_t)` has not been overridden. This is problematic because \"\n \"`operator new[](size_t, nothrow_t)` must call `operator new[](size_t)`, which will terminate in case \"\n \"it fails to allocate, making it impossible for `operator new[](size_t, nothrow_t)` to fulfill its \"\n \"contract (since it should return nullptr upon failure). Please make sure you override \"\n \"`operator new[](size_t, nothrow_t)` as well.\");\n# endif\n\n return operator_new_impl(size);\n# else\n void* p = nullptr;\n try {\n p = ::operator new[](size);\n } catch (...) {\n }\n return p;\n# endif\n}\n\n_LIBCPP_WEAK void operator delete(void* ptr) noexcept { std::free(ptr); }\n\n_LIBCPP_WEAK void operator delete(void* ptr, const std::nothrow_t&) noexcept { ::operator delete(ptr); }\n\n_LIBCPP_WEAK void operator delete(void* ptr, size_t) noexcept { ::operator delete(ptr); }\n\n_LIBCPP_WEAK void operator delete[](void* ptr) noexcept { ::operator delete(ptr); }\n\n_LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept { ::operator delete[](ptr); }\n\n_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); }\n\n# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION\n\nstatic void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) {\n if (size == 0)\n size = 1;\n if (static_cast<size_t>(alignment) < sizeof(void*))\n alignment = std::align_val_t(sizeof(void*));\n\n // Try allocating memory. If allocation fails and there is a new_handler,\n // call it to try free up memory, and try again until it succeeds, or until\n // the new_handler decides to terminate.\n void* p;\n while ((p = std::__libcpp_aligned_alloc(static_cast<std::size_t>(alignment), size)) == nullptr) {\n std::new_handler nh = std::get_new_handler();\n if (nh)\n nh();\n else\n break;\n }\n return p;\n}\n\n_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void*\noperator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {\n void* p = operator_new_aligned_impl(size, alignment);\n if (p == nullptr)\n __throw_bad_alloc_shim();\n return p;\n}\n\n_LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {\n# if !_LIBCPP_HAS_EXCEPTIONS\n# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION\n _LIBCPP_ASSERT_SHIM(\n !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new)),\n \"libc++ was configured with exceptions disabled and `operator new(size_t, align_val_t)` has been overridden, \"\n \"but `operator new(size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because \"\n \"`operator new(size_t, align_val_t, nothrow_t)` must call `operator new(size_t, align_val_t)`, which will \"\n \"terminate in case it fails to allocate, making it impossible for `operator new(size_t, align_val_t, nothrow_t)` \"\n \"to fulfill its contract (since it should return nullptr upon failure). Please make sure you override \"\n \"`operator new(size_t, align_val_t, nothrow_t)` as well.\");\n# endif\n\n return operator_new_aligned_impl(size, alignment);\n# else\n void* p = nullptr;\n try {\n p = ::operator new(size, alignment);\n } catch (...) {\n }\n return p;\n# endif\n}\n\n_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void*\noperator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {\n return ::operator new(size, alignment);\n}\n\n_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {\n# if !_LIBCPP_HAS_EXCEPTIONS\n# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION\n _LIBCPP_ASSERT_SHIM(\n !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new[])),\n \"libc++ was configured with exceptions disabled and `operator new[](size_t, align_val_t)` has been overridden, \"\n \"but `operator new[](size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because \"\n \"`operator new[](size_t, align_val_t, nothrow_t)` must call `operator new[](size_t, align_val_t)`, which will \"\n \"terminate in case it fails to allocate, making it impossible for `operator new[](size_t, align_val_t, \"\n \"nothrow_t)` to fulfill its contract (since it should return nullptr upon failure). Please make sure you \"\n \"override \"\n \"`operator new[](size_t, align_val_t, nothrow_t)` as well.\");\n# endif\n\n return operator_new_aligned_impl(size, alignment);\n# else\n void* p = nullptr;\n try {\n p = ::operator new[](size, alignment);\n } catch (...) {\n }\n return p;\n# endif\n}\n\n_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t) noexcept { std::__libcpp_aligned_free(ptr); }\n\n_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept {\n ::operator delete(ptr, alignment);\n}\n\n_LIBCPP_WEAK void operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept {\n ::operator delete(ptr, alignment);\n}\n\n_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment) noexcept {\n ::operator delete(ptr, alignment);\n}\n\n_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept {\n ::operator delete[](ptr, alignment);\n}\n\n_LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignment) noexcept {\n ::operator delete[](ptr, alignment);\n}\n\n# endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION\n// ------------------ END COPY ------------------\n\n#endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___MEMORY_CONSTRUCT_AT_H\n#define _LIBCPP___MEMORY_CONSTRUCT_AT_H\n\n#include <__assert>\n#include <__config>\n#include <__iterator/access.h>\n#include <__memory/addressof.h>\n#include <__new/placement_new_delete.h>\n#include <__type_traits/enable_if.h>\n#include <__type_traits/is_array.h>\n#include <__utility/declval.h>\n#include <__utility/forward.h>\n#include <__utility/move.h>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_PUSH_MACROS\n#include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\n// construct_at\n\n#if _LIBCPP_STD_VER >= 20\n\ntemplate <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>\n_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {\n _LIBCPP_ASSERT_NON_NULL(__location != nullptr, \"null pointer given to construct_at\");\n return ::new (static_cast<void*>(__location)) _Tp(std::forward<_Args>(__args)...);\n}\n\n#endif\n\ntemplate <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __location, _Args&&... __args) {\n#if _LIBCPP_STD_VER >= 20\n return std::construct_at(__location, std::forward<_Args>(__args)...);\n#else\n return _LIBCPP_ASSERT_NON_NULL(__location != nullptr, \"null pointer given to construct_at\"),\n ::new (static_cast<void*>(__location)) _Tp(std::forward<_Args>(__args)...);\n#endif\n}\n\n// destroy_at\n\n// The internal functions are available regardless of the language version (with the exception of the `__destroy_at`\n// taking an array).\n\ntemplate <class _ForwardIterator>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator);\n\ntemplate <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) {\n _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, \"null pointer given to destroy_at\");\n __loc->~_Tp();\n}\n\n#if _LIBCPP_STD_VER >= 20\ntemplate <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) {\n _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, \"null pointer given to destroy_at\");\n std::__destroy(std::begin(*__loc), std::end(*__loc));\n}\n#endif\n\ntemplate <class _ForwardIterator>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator\n__destroy(_ForwardIterator __first, _ForwardIterator __last) {\n for (; __first != __last; ++__first)\n std::__destroy_at(std::addressof(*__first));\n return __first;\n}\n\ntemplate <class _BidirectionalIterator>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator\n__reverse_destroy(_BidirectionalIterator __first, _BidirectionalIterator __last) {\n while (__last != __first) {\n --__last;\n std::__destroy_at(std::addressof(*__last));\n }\n return __last;\n}\n\n#if _LIBCPP_STD_VER >= 17\n\ntemplate <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) {\n std::__destroy_at(__loc);\n}\n\n# if _LIBCPP_STD_VER >= 20\ntemplate <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) {\n std::__destroy_at(__loc);\n}\n# endif\n\ntemplate <class _ForwardIterator>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy(_ForwardIterator __first, _ForwardIterator __last) {\n (void)std::__destroy(std::move(__first), std::move(__last));\n}\n\ntemplate <class _ForwardIterator, class _Size>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {\n for (; __n > 0; (void)++__first, --__n)\n std::__destroy_at(std::addressof(*__first));\n return __first;\n}\n\n#endif // _LIBCPP_STD_VER >= 17\n\n_LIBCPP_END_NAMESPACE_STD\n\n_LIBCPP_POP_MACROS\n\n#endif // _LIBCPP___MEMORY_CONSTRUCT_AT_H\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___SPLIT_BUFFER\n#define _LIBCPP___SPLIT_BUFFER\n\n#include <__algorithm/max.h>\n#include <__algorithm/move.h>\n#include <__algorithm/move_backward.h>\n#include <__config>\n#include <__iterator/distance.h>\n#include <__iterator/iterator_traits.h>\n#include <__iterator/move_iterator.h>\n#include <__memory/allocate_at_least.h>\n#include <__memory/allocator.h>\n#include <__memory/allocator_traits.h>\n#include <__memory/compressed_pair.h>\n#include <__memory/pointer_traits.h>\n#include <__memory/swap_allocator.h>\n#include <__type_traits/conditional.h>\n#include <__type_traits/enable_if.h>\n#include <__type_traits/integral_constant.h>\n#include <__type_traits/is_nothrow_assignable.h>\n#include <__type_traits/is_nothrow_constructible.h>\n#include <__type_traits/is_swappable.h>\n#include <__type_traits/is_trivially_destructible.h>\n#include <__type_traits/is_trivially_relocatable.h>\n#include <__type_traits/remove_reference.h>\n#include <__utility/forward.h>\n#include <__utility/move.h>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_PUSH_MACROS\n#include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\n// __split_buffer allocates a contiguous chunk of memory and stores objects in the range [__begin_, __end_).\n// It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __cap_). That allows\n// it to grow both in the front and back without having to move the data.\n\ntemplate <class _Tp, class _Allocator = allocator<_Tp> >\nstruct __split_buffer {\npublic:\n using value_type = _Tp;\n using allocator_type = _Allocator;\n using __alloc_rr _LIBCPP_NODEBUG = __libcpp_remove_reference_t<allocator_type>;\n using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<__alloc_rr>;\n using reference = value_type&;\n using const_reference = const value_type&;\n using size_type = typename __alloc_traits::size_type;\n using difference_type = typename __alloc_traits::difference_type;\n using pointer = typename __alloc_traits::pointer;\n using const_pointer = typename __alloc_traits::const_pointer;\n using iterator = pointer;\n using const_iterator = const_pointer;\n\n // A __split_buffer contains the following members which may be trivially relocatable:\n // - pointer: may be trivially relocatable, so it's checked\n // - allocator_type: may be trivially relocatable, so it's checked\n // __split_buffer doesn't have any self-references, so it's trivially relocatable if its members are.\n using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<\n __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,\n __split_buffer,\n void>;\n\n pointer __first_;\n pointer __begin_;\n pointer __end_;\n _LIBCPP_COMPRESSED_PAIR(pointer, __cap_, allocator_type, __alloc_);\n\n __split_buffer(const __split_buffer&) = delete;\n __split_buffer& operator=(const __split_buffer&) = delete;\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer()\n _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)\n : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr) {}\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(__alloc_rr& __a)\n : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {}\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(const __alloc_rr& __a)\n : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {}\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI\n __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c)\n _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer& operator=(__split_buffer&& __c)\n _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&\n is_nothrow_move_assignable<allocator_type>::value) ||\n !__alloc_traits::propagate_on_container_move_assignment::value);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer();\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __begin_; }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __begin_; }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __end_; }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __end_; }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __destruct_at_end(__begin_); }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const {\n return static_cast<size_type>(__end_ - __begin_);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { return __end_ == __begin_; }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const {\n return static_cast<size_type>(__cap_ - __first_);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const {\n return static_cast<size_type>(__begin_ - __first_);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const {\n return static_cast<size_type>(__cap_ - __end_);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { return *__begin_; }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const { return *__begin_; }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() { return *(__end_ - 1); }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const { return *(__end_ - 1); }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;\n\n template <class... _Args>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);\n template <class... _Args>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_front() { __destruct_at_begin(__begin_ + 1); }\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() { __destruct_at_end(__end_ - 1); }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);\n\n template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);\n\n template <class _Iterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last);\n\n template <class _Iterator>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __construct_at_end_with_size(_Iterator __first, size_type __n);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin) {\n __destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin, false_type);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin, true_type);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last) _NOEXCEPT {\n __destruct_at_end(__new_last, false_type());\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x)\n _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;\n\nprivate:\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer& __c, true_type)\n _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {\n __alloc_ = std::move(__c.__alloc_);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {}\n\n struct _ConstructTransaction {\n _LIBCPP_CONSTEXPR_SINCE_CXX20\n _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT\n : __pos_(*__p),\n __end_(*__p + __n),\n __dest_(__p) {}\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { *__dest_ = __pos_; }\n\n pointer __pos_;\n const pointer __end_;\n\n private:\n pointer* __dest_;\n };\n};\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants() const {\n if (__first_ == nullptr) {\n if (__begin_ != nullptr)\n return false;\n if (__end_ != nullptr)\n return false;\n if (__cap_ != nullptr)\n return false;\n } else {\n if (__begin_ < __first_)\n return false;\n if (__end_ < __begin_)\n return false;\n if (__cap_ < __end_)\n return false;\n }\n return true;\n}\n\n// Default constructs __n objects starting at __end_\n// throws if construction throws\n// Precondition: __n > 0\n// Precondition: size() + __n <= capacity()\n// Postcondition: size() == size() + __n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) {\n _ConstructTransaction __tx(&this->__end_, __n);\n for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {\n __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_));\n }\n}\n\n// Copy constructs __n objects starting at __end_ from __x\n// throws if construction throws\n// Precondition: __n > 0\n// Precondition: size() + __n <= capacity()\n// Postcondition: size() == old size() + __n\n// Postcondition: [i] == __x for all i in [size() - __n, __n)\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\n__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {\n _ConstructTransaction __tx(&this->__end_, __n);\n for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {\n __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), __x);\n }\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class _Iterator, class _Sentinel>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\n__split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last) {\n __alloc_rr& __a = __alloc_;\n for (; __first != __last; ++__first) {\n if (__end_ == __cap_) {\n size_type __old_cap = __cap_ - __first_;\n size_type __new_cap = std::max<size_type>(2 * __old_cap, 8);\n __split_buffer __buf(__new_cap, 0, __a);\n for (pointer __p = __begin_; __p != __end_; ++__p, (void)++__buf.__end_)\n __alloc_traits::construct(__buf.__alloc_, std::__to_address(__buf.__end_), std::move(*__p));\n swap(__buf);\n }\n __alloc_traits::construct(__a, std::__to_address(this->__end_), *__first);\n ++this->__end_;\n }\n}\ntemplate <class _Tp, class _Allocator>\ntemplate <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\n__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) {\n __construct_at_end_with_size(__first, std::distance(__first, __last));\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class _ForwardIterator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\n__split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) {\n _ConstructTransaction __tx(&this->__end_, __n);\n for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) {\n __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), *__first);\n }\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void\n__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) {\n while (__begin_ != __new_begin)\n __alloc_traits::destroy(__alloc_, std::__to_address(__begin_++));\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void\n__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) {\n __begin_ = __new_begin;\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void\n__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT {\n while (__new_last != __end_)\n __alloc_traits::destroy(__alloc_, std::__to_address(--__end_));\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void\n__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT {\n __end_ = __new_last;\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20\n__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)\n : __cap_(nullptr), __alloc_(__a) {\n if (__cap == 0) {\n __first_ = nullptr;\n } else {\n auto __allocation = std::__allocate_at_least(__alloc_, __cap);\n __first_ = __allocation.ptr;\n __cap = __allocation.count;\n }\n __begin_ = __end_ = __first_ + __start;\n __cap_ = __first_ + __cap;\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::~__split_buffer() {\n clear();\n if (__first_)\n __alloc_traits::deallocate(__alloc_, __first_, capacity());\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)\n _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)\n : __first_(std::move(__c.__first_)),\n __begin_(std::move(__c.__begin_)),\n __end_(std::move(__c.__end_)),\n __cap_(std::move(__c.__cap_)),\n __alloc_(std::move(__c.__alloc_)) {\n __c.__first_ = nullptr;\n __c.__begin_ = nullptr;\n __c.__end_ = nullptr;\n __c.__cap_ = nullptr;\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20\n__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)\n : __cap_(nullptr), __alloc_(__a) {\n if (__a == __c.__alloc_) {\n __first_ = __c.__first_;\n __begin_ = __c.__begin_;\n __end_ = __c.__end_;\n __cap_ = __c.__cap_;\n __c.__first_ = nullptr;\n __c.__begin_ = nullptr;\n __c.__end_ = nullptr;\n __c.__cap_ = nullptr;\n } else {\n auto __allocation = std::__allocate_at_least(__alloc_, __c.size());\n __first_ = __allocation.ptr;\n __begin_ = __end_ = __first_;\n __cap_ = __first_ + __allocation.count;\n typedef move_iterator<iterator> _Ip;\n __construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));\n }\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>&\n__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)\n _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&\n is_nothrow_move_assignable<allocator_type>::value) ||\n !__alloc_traits::propagate_on_container_move_assignment::value) {\n clear();\n shrink_to_fit();\n __first_ = __c.__first_;\n __begin_ = __c.__begin_;\n __end_ = __c.__end_;\n __cap_ = __c.__cap_;\n __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());\n __c.__first_ = __c.__begin_ = __c.__end_ = __c.__cap_ = nullptr;\n return *this;\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)\n _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>) {\n std::swap(__first_, __x.__first_);\n std::swap(__begin_, __x.__begin_);\n std::swap(__end_, __x.__end_);\n std::swap(__cap_, __x.__cap_);\n std::__swap_allocator(__alloc_, __x.__alloc_);\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {\n if (capacity() > size()) {\n#if _LIBCPP_HAS_EXCEPTIONS\n try {\n#endif // _LIBCPP_HAS_EXCEPTIONS\n __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc_);\n if (__t.capacity() < capacity()) {\n __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));\n __t.__end_ = __t.__begin_ + (__end_ - __begin_);\n std::swap(__first_, __t.__first_);\n std::swap(__begin_, __t.__begin_);\n std::swap(__end_, __t.__end_);\n std::swap(__cap_, __t.__cap_);\n }\n#if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n }\n#endif // _LIBCPP_HAS_EXCEPTIONS\n }\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class... _Args>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_front(_Args&&... __args) {\n if (__begin_ == __first_) {\n if (__end_ < __cap_) {\n difference_type __d = __cap_ - __end_;\n __d = (__d + 1) / 2;\n __begin_ = std::move_backward(__begin_, __end_, __end_ + __d);\n __end_ += __d;\n } else {\n size_type __c = std::max<size_type>(2 * static_cast<size_type>(__cap_ - __first_), 1);\n __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc_);\n __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));\n std::swap(__first_, __t.__first_);\n std::swap(__begin_, __t.__begin_);\n std::swap(__end_, __t.__end_);\n std::swap(__cap_, __t.__cap_);\n }\n }\n __alloc_traits::construct(__alloc_, std::__to_address(__begin_ - 1), std::forward<_Args>(__args)...);\n --__begin_;\n}\n\ntemplate <class _Tp, class _Allocator>\ntemplate <class... _Args>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) {\n if (__end_ == __cap_) {\n if (__begin_ > __first_) {\n difference_type __d = __begin_ - __first_;\n __d = (__d + 1) / 2;\n __end_ = std::move(__begin_, __end_, __begin_ - __d);\n __begin_ -= __d;\n } else {\n size_type __c = std::max<size_type>(2 * static_cast<size_type>(__cap_ - __first_), 1);\n __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc_);\n __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));\n std::swap(__first_, __t.__first_);\n std::swap(__begin_, __t.__begin_);\n std::swap(__end_, __t.__end_);\n std::swap(__cap_, __t.__cap_);\n }\n }\n __alloc_traits::construct(__alloc_, std::__to_address(__end_), std::forward<_Args>(__args)...);\n ++__end_;\n}\n\ntemplate <class _Tp, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void\nswap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {\n __x.swap(__y);\n}\n\n_LIBCPP_END_NAMESPACE_STD\n\n_LIBCPP_POP_MACROS\n\n#endif // _LIBCPP___SPLIT_BUFFER\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H\n#define _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H\n\n#include <__algorithm/copy.h>\n#include <__algorithm/move.h>\n#include <__algorithm/unwrap_iter.h>\n#include <__algorithm/unwrap_range.h>\n#include <__config>\n#include <__cstddef/size_t.h>\n#include <__iterator/iterator_traits.h>\n#include <__iterator/reverse_iterator.h>\n#include <__memory/addressof.h>\n#include <__memory/allocator_traits.h>\n#include <__memory/construct_at.h>\n#include <__memory/pointer_traits.h>\n#include <__type_traits/enable_if.h>\n#include <__type_traits/extent.h>\n#include <__type_traits/is_array.h>\n#include <__type_traits/is_constant_evaluated.h>\n#include <__type_traits/is_same.h>\n#include <__type_traits/is_trivially_assignable.h>\n#include <__type_traits/is_trivially_constructible.h>\n#include <__type_traits/is_trivially_relocatable.h>\n#include <__type_traits/is_unbounded_array.h>\n#include <__type_traits/negation.h>\n#include <__type_traits/remove_const.h>\n#include <__type_traits/remove_extent.h>\n#include <__utility/exception_guard.h>\n#include <__utility/move.h>\n#include <__utility/pair.h>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_PUSH_MACROS\n#include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\nstruct __always_false {\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(_Args&&...) const _NOEXCEPT {\n return false;\n }\n};\n\n// uninitialized_copy\n\ntemplate <class _ValueType, class _InputIterator, class _Sentinel1, class _ForwardIterator, class _EndPredicate>\ninline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_copy(\n _InputIterator __ifirst, _Sentinel1 __ilast, _ForwardIterator __ofirst, _EndPredicate __stop_copying) {\n _ForwardIterator __idx = __ofirst;\n#if _LIBCPP_HAS_EXCEPTIONS\n try {\n#endif\n for (; __ifirst != __ilast && !__stop_copying(__idx); ++__ifirst, (void)++__idx)\n ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst);\n#if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n std::__destroy(__ofirst, __idx);\n throw;\n }\n#endif\n\n return pair<_InputIterator, _ForwardIterator>(std::move(__ifirst), std::move(__idx));\n}\n\ntemplate <class _InputIterator, class _ForwardIterator>\n_LIBCPP_HIDE_FROM_ABI _ForwardIterator\nuninitialized_copy(_InputIterator __ifirst, _InputIterator __ilast, _ForwardIterator __ofirst) {\n typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;\n auto __result = std::__uninitialized_copy<_ValueType>(\n std::move(__ifirst), std::move(__ilast), std::move(__ofirst), __always_false());\n return std::move(__result.second);\n}\n\n// uninitialized_copy_n\n\ntemplate <class _ValueType, class _InputIterator, class _Size, class _ForwardIterator, class _EndPredicate>\ninline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>\n__uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_copying) {\n _ForwardIterator __idx = __ofirst;\n#if _LIBCPP_HAS_EXCEPTIONS\n try {\n#endif\n for (; __n > 0 && !__stop_copying(__idx); ++__ifirst, (void)++__idx, (void)--__n)\n ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst);\n#if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n std::__destroy(__ofirst, __idx);\n throw;\n }\n#endif\n\n return pair<_InputIterator, _ForwardIterator>(std::move(__ifirst), std::move(__idx));\n}\n\ntemplate <class _InputIterator, class _Size, class _ForwardIterator>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator\nuninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst) {\n typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;\n auto __result =\n std::__uninitialized_copy_n<_ValueType>(std::move(__ifirst), __n, std::move(__ofirst), __always_false());\n return std::move(__result.second);\n}\n\n// uninitialized_fill\n\ntemplate <class _ValueType, class _ForwardIterator, class _Sentinel, class _Tp>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator\n__uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) {\n _ForwardIterator __idx = __first;\n#if _LIBCPP_HAS_EXCEPTIONS\n try {\n#endif\n for (; __idx != __last; ++__idx)\n ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__x);\n#if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n std::__destroy(__first, __idx);\n throw;\n }\n#endif\n\n return __idx;\n}\n\ntemplate <class _ForwardIterator, class _Tp>\ninline _LIBCPP_HIDE_FROM_ABI void\nuninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __x) {\n typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;\n (void)std::__uninitialized_fill<_ValueType>(__first, __last, __x);\n}\n\n// uninitialized_fill_n\n\ntemplate <class _ValueType, class _ForwardIterator, class _Size, class _Tp>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator\n__uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) {\n _ForwardIterator __idx = __first;\n#if _LIBCPP_HAS_EXCEPTIONS\n try {\n#endif\n for (; __n > 0; ++__idx, (void)--__n)\n ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__x);\n#if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n std::__destroy(__first, __idx);\n throw;\n }\n#endif\n\n return __idx;\n}\n\ntemplate <class _ForwardIterator, class _Size, class _Tp>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator\nuninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) {\n typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;\n return std::__uninitialized_fill_n<_ValueType>(__first, __n, __x);\n}\n\n#if _LIBCPP_STD_VER >= 17\n\n// uninitialized_default_construct\n\ntemplate <class _ValueType, class _ForwardIterator, class _Sentinel>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator\n__uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) {\n auto __idx = __first;\n# if _LIBCPP_HAS_EXCEPTIONS\n try {\n# endif\n for (; __idx != __last; ++__idx)\n ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType;\n# if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n std::__destroy(__first, __idx);\n throw;\n }\n# endif\n\n return __idx;\n}\n\ntemplate <class _ForwardIterator>\ninline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) {\n using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;\n (void)std::__uninitialized_default_construct<_ValueType>(std::move(__first), std::move(__last));\n}\n\n// uninitialized_default_construct_n\n\ntemplate <class _ValueType, class _ForwardIterator, class _Size>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {\n auto __idx = __first;\n# if _LIBCPP_HAS_EXCEPTIONS\n try {\n# endif\n for (; __n > 0; ++__idx, (void)--__n)\n ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType;\n# if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n std::__destroy(__first, __idx);\n throw;\n }\n# endif\n\n return __idx;\n}\n\ntemplate <class _ForwardIterator, class _Size>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {\n using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;\n return std::__uninitialized_default_construct_n<_ValueType>(std::move(__first), __n);\n}\n\n// uninitialized_value_construct\n\ntemplate <class _ValueType, class _ForwardIterator, class _Sentinel>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator\n__uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) {\n auto __idx = __first;\n# if _LIBCPP_HAS_EXCEPTIONS\n try {\n# endif\n for (; __idx != __last; ++__idx)\n ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType();\n# if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n std::__destroy(__first, __idx);\n throw;\n }\n# endif\n\n return __idx;\n}\n\ntemplate <class _ForwardIterator>\ninline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last) {\n using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;\n (void)std::__uninitialized_value_construct<_ValueType>(std::move(__first), std::move(__last));\n}\n\n// uninitialized_value_construct_n\n\ntemplate <class _ValueType, class _ForwardIterator, class _Size>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {\n auto __idx = __first;\n# if _LIBCPP_HAS_EXCEPTIONS\n try {\n# endif\n for (; __n > 0; ++__idx, (void)--__n)\n ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType();\n# if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n std::__destroy(__first, __idx);\n throw;\n }\n# endif\n\n return __idx;\n}\n\ntemplate <class _ForwardIterator, class _Size>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {\n using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;\n return std::__uninitialized_value_construct_n<_ValueType>(std::move(__first), __n);\n}\n\n// uninitialized_move\n\ntemplate <class _ValueType,\n class _InputIterator,\n class _Sentinel1,\n class _ForwardIterator,\n class _EndPredicate,\n class _IterMove>\ninline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move(\n _InputIterator __ifirst,\n _Sentinel1 __ilast,\n _ForwardIterator __ofirst,\n _EndPredicate __stop_moving,\n _IterMove __iter_move) {\n auto __idx = __ofirst;\n# if _LIBCPP_HAS_EXCEPTIONS\n try {\n# endif\n for (; __ifirst != __ilast && !__stop_moving(__idx); ++__idx, (void)++__ifirst) {\n ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst));\n }\n# if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n std::__destroy(__ofirst, __idx);\n throw;\n }\n# endif\n\n return {std::move(__ifirst), std::move(__idx)};\n}\n\ntemplate <class _InputIterator, class _ForwardIterator>\ninline _LIBCPP_HIDE_FROM_ABI _ForwardIterator\nuninitialized_move(_InputIterator __ifirst, _InputIterator __ilast, _ForwardIterator __ofirst) {\n using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;\n auto __iter_move = [](auto&& __iter) -> decltype(auto) { return std::move(*__iter); };\n\n auto __result = std::__uninitialized_move<_ValueType>(\n std::move(__ifirst), std::move(__ilast), std::move(__ofirst), __always_false(), __iter_move);\n return std::move(__result.second);\n}\n\n// uninitialized_move_n\n\ntemplate <class _ValueType,\n class _InputIterator,\n class _Size,\n class _ForwardIterator,\n class _EndPredicate,\n class _IterMove>\ninline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move_n(\n _InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_moving, _IterMove __iter_move) {\n auto __idx = __ofirst;\n# if _LIBCPP_HAS_EXCEPTIONS\n try {\n# endif\n for (; __n > 0 && !__stop_moving(__idx); ++__idx, (void)++__ifirst, --__n)\n ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst));\n# if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n std::__destroy(__ofirst, __idx);\n throw;\n }\n# endif\n\n return {std::move(__ifirst), std::move(__idx)};\n}\n\ntemplate <class _InputIterator, class _Size, class _ForwardIterator>\ninline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>\nuninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst) {\n using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;\n auto __iter_move = [](auto&& __iter) -> decltype(auto) { return std::move(*__iter); };\n\n return std::__uninitialized_move_n<_ValueType>(\n std::move(__ifirst), __n, std::move(__ofirst), __always_false(), __iter_move);\n}\n\n// TODO: Rewrite this to iterate left to right and use reverse_iterators when calling\n// Destroys every element in the range [first, last) FROM RIGHT TO LEFT using allocator\n// destruction. If elements are themselves C-style arrays, they are recursively destroyed\n// in the same manner.\n//\n// This function assumes that destructors do not throw, and that the allocator is bound to\n// the correct type.\ntemplate <class _Alloc,\n class _BidirIter,\n __enable_if_t<__has_bidirectional_iterator_category<_BidirIter>::value, int> = 0>\n_LIBCPP_HIDE_FROM_ABI constexpr void\n__allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _BidirIter __last) noexcept {\n using _ValueType = typename iterator_traits<_BidirIter>::value_type;\n static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _ValueType>,\n \"The allocator should already be rebound to the correct type\");\n\n if (__first == __last)\n return;\n\n if constexpr (is_array_v<_ValueType>) {\n static_assert(!__is_unbounded_array_v<_ValueType>,\n \"arrays of unbounded arrays don't exist, but if they did we would mess up here\");\n\n using _Element = remove_extent_t<_ValueType>;\n __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);\n do {\n --__last;\n decltype(auto) __array = *__last;\n std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + extent_v<_ValueType>);\n } while (__last != __first);\n } else {\n do {\n --__last;\n allocator_traits<_Alloc>::destroy(__alloc, std::addressof(*__last));\n } while (__last != __first);\n }\n}\n\n// Constructs the object at the given location using the allocator's construct method.\n//\n// If the object being constructed is an array, each element of the array is allocator-constructed,\n// recursively. If an exception is thrown during the construction of an array, the initialized\n// elements are destroyed in reverse order of initialization using allocator destruction.\n//\n// This function assumes that the allocator is bound to the correct type.\ntemplate <class _Alloc, class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr void __allocator_construct_at_multidimensional(_Alloc& __alloc, _Tp* __loc) {\n static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>,\n \"The allocator should already be rebound to the correct type\");\n\n if constexpr (is_array_v<_Tp>) {\n using _Element = remove_extent_t<_Tp>;\n __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);\n size_t __i = 0;\n _Tp& __array = *__loc;\n\n // If an exception is thrown, destroy what we have constructed so far in reverse order.\n auto __guard = std::__make_exception_guard([&]() {\n std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);\n });\n\n for (; __i != extent_v<_Tp>; ++__i) {\n std::__allocator_construct_at_multidimensional(__elem_alloc, std::addressof(__array[__i]));\n }\n __guard.__complete();\n } else {\n allocator_traits<_Alloc>::construct(__alloc, __loc);\n }\n}\n\n// Constructs the object at the given location using the allocator's construct method, passing along\n// the provided argument.\n//\n// If the object being constructed is an array, the argument is also assumed to be an array. Each\n// each element of the array being constructed is allocator-constructed from the corresponding\n// element of the argument array. If an exception is thrown during the construction of an array,\n// the initialized elements are destroyed in reverse order of initialization using allocator\n// destruction.\n//\n// This function assumes that the allocator is bound to the correct type.\ntemplate <class _Alloc, class _Tp, class _Arg>\n_LIBCPP_HIDE_FROM_ABI constexpr void\n__allocator_construct_at_multidimensional(_Alloc& __alloc, _Tp* __loc, _Arg const& __arg) {\n static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>,\n \"The allocator should already be rebound to the correct type\");\n\n if constexpr (is_array_v<_Tp>) {\n static_assert(is_array_v<_Arg>,\n \"Provided non-array initialization argument to __allocator_construct_at_multidimensional when \"\n \"trying to construct an array.\");\n\n using _Element = remove_extent_t<_Tp>;\n __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);\n size_t __i = 0;\n _Tp& __array = *__loc;\n\n // If an exception is thrown, destroy what we have constructed so far in reverse order.\n auto __guard = std::__make_exception_guard([&]() {\n std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);\n });\n for (; __i != extent_v<_Tp>; ++__i) {\n std::__allocator_construct_at_multidimensional(__elem_alloc, std::addressof(__array[__i]), __arg[__i]);\n }\n __guard.__complete();\n } else {\n allocator_traits<_Alloc>::construct(__alloc, __loc, __arg);\n }\n}\n\n// Given a range starting at it and containing n elements, initializes each element in the\n// range from left to right using the construct method of the allocator (rebound to the\n// correct type).\n//\n// If an exception is thrown, the initialized elements are destroyed in reverse order of\n// initialization using allocator_traits destruction. If the elements in the range are C-style\n// arrays, they are initialized element-wise using allocator construction, and recursively so.\ntemplate <class _Alloc,\n class _BidirIter,\n class _Tp,\n class _Size = typename iterator_traits<_BidirIter>::difference_type>\n_LIBCPP_HIDE_FROM_ABI constexpr void\n__uninitialized_allocator_fill_n_multidimensional(_Alloc& __alloc, _BidirIter __it, _Size __n, _Tp const& __value) {\n using _ValueType = typename iterator_traits<_BidirIter>::value_type;\n __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc);\n _BidirIter __begin = __it;\n\n // If an exception is thrown, destroy what we have constructed so far in reverse order.\n auto __guard =\n std::__make_exception_guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });\n for (; __n != 0; --__n, ++__it) {\n std::__allocator_construct_at_multidimensional(__value_alloc, std::addressof(*__it), __value);\n }\n __guard.__complete();\n}\n\n// Same as __uninitialized_allocator_fill_n_multidimensional, but doesn't pass any initialization argument\n// to the allocator's construct method, which results in value initialization.\ntemplate <class _Alloc, class _BidirIter, class _Size = typename iterator_traits<_BidirIter>::difference_type>\n_LIBCPP_HIDE_FROM_ABI constexpr void\n__uninitialized_allocator_value_construct_n_multidimensional(_Alloc& __alloc, _BidirIter __it, _Size __n) {\n using _ValueType = typename iterator_traits<_BidirIter>::value_type;\n __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc);\n _BidirIter __begin = __it;\n\n // If an exception is thrown, destroy what we have constructed so far in reverse order.\n auto __guard =\n std::__make_exception_guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });\n for (; __n != 0; --__n, ++__it) {\n std::__allocator_construct_at_multidimensional(__value_alloc, std::addressof(*__it));\n }\n __guard.__complete();\n}\n\n#endif // _LIBCPP_STD_VER >= 17\n\n// Destroy all elements in [__first, __last) from left to right using allocator destruction.\ntemplate <class _Alloc, class _Iter, class _Sent>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\n__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {\n for (; __first != __last; ++__first)\n allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first));\n}\n\ntemplate <class _Alloc, class _Iter>\nclass _AllocatorDestroyRangeReverse {\npublic:\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14\n _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)\n : __alloc_(__alloc), __first_(__first), __last_(__last) {}\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void operator()() const {\n std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_));\n }\n\nprivate:\n _Alloc& __alloc_;\n _Iter& __first_;\n _Iter& __last_;\n};\n\n// Copy-construct [__first1, __last1) in [__first2, __first2 + N), where N is distance(__first1, __last1).\n//\n// The caller has to ensure that __first2 can hold at least N uninitialized elements. If an exception is thrown the\n// already copied elements are destroyed in reverse order of their construction.\ntemplate <class _Alloc, class _Iter1, class _Sent1, class _Iter2>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2\n__uninitialized_allocator_copy_impl(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {\n auto __destruct_first = __first2;\n auto __guard =\n std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2));\n while (__first1 != __last1) {\n allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), *__first1);\n ++__first1;\n ++__first2;\n }\n __guard.__complete();\n return __first2;\n}\n\ntemplate <class _Alloc, class _Type>\nstruct __allocator_has_trivial_copy_construct : _Not<__has_construct<_Alloc, _Type*, const _Type&> > {};\n\ntemplate <class _Type>\nstruct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_type {};\n\ntemplate <class _Alloc,\n class _In,\n class _Out,\n __enable_if_t<is_trivially_copy_constructible<_In>::value && is_trivially_copy_assignable<_In>::value &&\n is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value &&\n __allocator_has_trivial_copy_construct<_Alloc, _In>::value,\n int> = 0>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out*\n__uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) {\n if (__libcpp_is_constant_evaluated()) {\n while (__first1 != __last1) {\n std::__construct_at(std::__to_address(__first2), *__first1);\n ++__first1;\n ++__first2;\n }\n return __first2;\n } else {\n return std::copy(__first1, __last1, __first2);\n }\n}\n\ntemplate <class _Alloc, class _Iter1, class _Sent1, class _Iter2>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2\n__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {\n auto __unwrapped_range = std::__unwrap_range(std::move(__first1), std::move(__last1));\n auto __result = std::__uninitialized_allocator_copy_impl(\n __alloc, std::move(__unwrapped_range.first), std::move(__unwrapped_range.second), std::__unwrap_iter(__first2));\n return std::__rewrap_iter(__first2, __result);\n}\n\ntemplate <class _Alloc, class _Type>\nstruct __allocator_has_trivial_move_construct : _Not<__has_construct<_Alloc, _Type*, _Type&&> > {};\n\ntemplate <class _Type>\nstruct __allocator_has_trivial_move_construct<allocator<_Type>, _Type> : true_type {};\n\ntemplate <class _Alloc, class _Tp>\nstruct __allocator_has_trivial_destroy : _Not<__has_destroy<_Alloc, _Tp*> > {};\n\ntemplate <class _Tp, class _Up>\nstruct __allocator_has_trivial_destroy<allocator<_Tp>, _Up> : true_type {};\n\n// __uninitialized_allocator_relocate relocates the objects in [__first, __last) into __result.\n// Relocation means that the objects in [__first, __last) are placed into __result as-if by move-construct and destroy,\n// except that the move constructor and destructor may never be called if they are known to be equivalent to a memcpy.\n//\n// Preconditions: __result doesn't contain any objects and [__first, __last) contains objects\n// Postconditions: __result contains the objects from [__first, __last) and\n// [__first, __last) doesn't contain any objects\n//\n// The strong exception guarantee is provided if any of the following are true:\n// - is_nothrow_move_constructible<_ValueType>\n// - is_copy_constructible<_ValueType>\n// - __libcpp_is_trivially_relocatable<_ValueType>\ntemplate <class _Alloc, class _ContiguousIterator>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __uninitialized_allocator_relocate(\n _Alloc& __alloc, _ContiguousIterator __first, _ContiguousIterator __last, _ContiguousIterator __result) {\n static_assert(__libcpp_is_contiguous_iterator<_ContiguousIterator>::value, \"\");\n using _ValueType = typename iterator_traits<_ContiguousIterator>::value_type;\n static_assert(__is_cpp17_move_insertable<_Alloc>::value,\n \"The specified type does not meet the requirements of Cpp17MoveInsertable\");\n if (__libcpp_is_constant_evaluated() || !__libcpp_is_trivially_relocatable<_ValueType>::value ||\n !__allocator_has_trivial_move_construct<_Alloc, _ValueType>::value ||\n !__allocator_has_trivial_destroy<_Alloc, _ValueType>::value) {\n auto __destruct_first = __result;\n auto __guard = std::__make_exception_guard(\n _AllocatorDestroyRangeReverse<_Alloc, _ContiguousIterator>(__alloc, __destruct_first, __result));\n auto __iter = __first;\n while (__iter != __last) {\n#if _LIBCPP_HAS_EXCEPTIONS\n allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__result), std::move_if_noexcept(*__iter));\n#else\n allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__result), std::move(*__iter));\n#endif\n ++__iter;\n ++__result;\n }\n __guard.__complete();\n std::__allocator_destroy(__alloc, __first, __last);\n } else {\n // Casting to void* to suppress clang complaining that this is technically UB.\n __builtin_memcpy(static_cast<void*>(std::__to_address(__result)),\n std::__to_address(__first),\n sizeof(_ValueType) * (__last - __first));\n }\n}\n\n_LIBCPP_END_NAMESPACE_STD\n\n_LIBCPP_POP_MACROS\n\n#endif // _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___UTILITY_SWAP_H\n#define _LIBCPP___UTILITY_SWAP_H\n\n#include <__config>\n#include <__cstddef/size_t.h>\n#include <__type_traits/enable_if.h>\n#include <__type_traits/is_assignable.h>\n#include <__type_traits/is_constructible.h>\n#include <__type_traits/is_nothrow_assignable.h>\n#include <__type_traits/is_nothrow_constructible.h>\n#include <__type_traits/is_swappable.h>\n#include <__utility/declval.h>\n#include <__utility/move.h>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_PUSH_MACROS\n#include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\n#ifndef _LIBCPP_CXX03_LANG\ntemplate <class _Tp>\nusing __swap_result_t _LIBCPP_NODEBUG =\n __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>;\n#else\ntemplate <class>\nusing __swap_result_t _LIBCPP_NODEBUG = void;\n#endif\n\ntemplate <class _Tp>\ninline _LIBCPP_HIDE_FROM_ABI __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_SINCE_CXX20 swap(_Tp& __x, _Tp& __y)\n _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value) {\n _Tp __t(std::move(__x));\n __x = std::move(__y);\n __y = std::move(__t);\n}\n\ntemplate <class _Tp, size_t _Np, __enable_if_t<__is_swappable_v<_Tp>, int> >\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np])\n _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) {\n for (size_t __i = 0; __i != _Np; ++__i) {\n swap(__a[__i], __b[__i]);\n }\n}\n\n_LIBCPP_END_NAMESPACE_STD\n\n_LIBCPP_POP_MACROS\n\n#endif // _LIBCPP___UTILITY_SWAP_H\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP_OPTIONAL\n#define _LIBCPP_OPTIONAL\n\n/*\n optional synopsis\n\n// C++1z\n\nnamespace std {\n // [optional.optional], class template optional\n template <class T>\n class optional;\n\n template<class T>\n concept is-derived-from-optional = requires(const T& t) { // exposition only\n []<class U>(const optional<U>&){ }(t);\n };\n\n // [optional.nullopt], no-value state indicator\n struct nullopt_t{see below };\n inline constexpr nullopt_t nullopt(unspecified );\n\n // [optional.bad.access], class bad_optional_access\n class bad_optional_access;\n\n // [optional.relops], relational operators\n template <class T, class U>\n constexpr bool operator==(const optional<T>&, const optional<U>&);\n template <class T, class U>\n constexpr bool operator!=(const optional<T>&, const optional<U>&);\n template <class T, class U>\n constexpr bool operator<(const optional<T>&, const optional<U>&);\n template <class T, class U>\n constexpr bool operator>(const optional<T>&, const optional<U>&);\n template <class T, class U>\n constexpr bool operator<=(const optional<T>&, const optional<U>&);\n template <class T, class U>\n constexpr bool operator>=(const optional<T>&, const optional<U>&);\n template<class T, three_way_comparable_with<T> U>\n constexpr compare_three_way_result_t<T, U>\n operator<=>(const optional<T>&, const optional<U>&); // since C++20\n\n // [optional.nullops], comparison with nullopt\n template<class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept;\n template<class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept; // until C++17\n template<class T> constexpr bool operator!=(const optional<T>&, nullopt_t) noexcept; // until C++17\n template<class T> constexpr bool operator!=(nullopt_t, const optional<T>&) noexcept; // until C++17\n template<class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept; // until C++17\n template<class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept; // until C++17\n template<class T> constexpr bool operator<=(const optional<T>&, nullopt_t) noexcept; // until C++17\n template<class T> constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept; // until C++17\n template<class T> constexpr bool operator>(const optional<T>&, nullopt_t) noexcept; // until C++17\n template<class T> constexpr bool operator>(nullopt_t, const optional<T>&) noexcept; // until C++17\n template<class T> constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept; // until C++17\n template<class T> constexpr bool operator>=(nullopt_t, const optional<T>&) noexcept; // until C++17\n template<class T>\n constexpr strong_ordering operator<=>(const optional<T>&, nullopt_t) noexcept; // since C++20\n\n // [optional.comp.with.t], comparison with T\n template<class T, class U> constexpr bool operator==(const optional<T>&, const U&);\n template<class T, class U> constexpr bool operator==(const T&, const optional<U>&);\n template<class T, class U> constexpr bool operator!=(const optional<T>&, const U&);\n template<class T, class U> constexpr bool operator!=(const T&, const optional<U>&);\n template<class T, class U> constexpr bool operator<(const optional<T>&, const U&);\n template<class T, class U> constexpr bool operator<(const T&, const optional<U>&);\n template<class T, class U> constexpr bool operator<=(const optional<T>&, const U&);\n template<class T, class U> constexpr bool operator<=(const T&, const optional<U>&);\n template<class T, class U> constexpr bool operator>(const optional<T>&, const U&);\n template<class T, class U> constexpr bool operator>(const T&, const optional<U>&);\n template<class T, class U> constexpr bool operator>=(const optional<T>&, const U&);\n template<class T, class U> constexpr bool operator>=(const T&, const optional<U>&);\n template<class T, class U>\n requires (!is-derived-from-optional<U>) && three_way_comparable_with<T, U>\n constexpr compare_three_way_result_t<T, U>\n operator<=>(const optional<T>&, const U&); // since C++20\n\n // [optional.specalg], specialized algorithms\n template<class T>\n void swap(optional<T>&, optional<T>&) noexcept(see below ); // constexpr in C++20\n\n template<class T>\n constexpr optional<see below > make_optional(T&&);\n template<class T, class... Args>\n constexpr optional<T> make_optional(Args&&... args);\n template<class T, class U, class... Args>\n constexpr optional<T> make_optional(initializer_list<U> il, Args&&... args);\n\n // [optional.hash], hash support\n template<class T> struct hash;\n template<class T> struct hash<optional<T>>;\n\n template<class T>\n class optional {\n public:\n using value_type = T;\n\n // [optional.ctor], constructors\n constexpr optional() noexcept;\n constexpr optional(nullopt_t) noexcept;\n constexpr optional(const optional &);\n constexpr optional(optional &&) noexcept(see below);\n template<class... Args>\n constexpr explicit optional(in_place_t, Args &&...);\n template<class U, class... Args>\n constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...);\n template<class U = T>\n constexpr explicit(see-below) optional(U &&);\n template<class U>\n explicit(see-below) optional(const optional<U> &); // constexpr in C++20\n template<class U>\n explicit(see-below) optional(optional<U> &&); // constexpr in C++20\n\n // [optional.dtor], destructor\n ~optional(); // constexpr in C++20\n\n // [optional.assign], assignment\n optional &operator=(nullopt_t) noexcept; // constexpr in C++20\n constexpr optional &operator=(const optional &);\n constexpr optional &operator=(optional &&) noexcept(see below);\n template<class U = T> optional &operator=(U &&); // constexpr in C++20\n template<class U> optional &operator=(const optional<U> &); // constexpr in C++20\n template<class U> optional &operator=(optional<U> &&); // constexpr in C++20\n template<class... Args> T& emplace(Args &&...); // constexpr in C++20\n template<class U, class... Args> T& emplace(initializer_list<U>, Args &&...); // constexpr in C++20\n\n // [optional.swap], swap\n void swap(optional &) noexcept(see below ); // constexpr in C++20\n\n // [optional.observe], observers\n constexpr T const *operator->() const noexcept;\n constexpr T *operator->() noexcept;\n constexpr T const &operator*() const & noexcept;\n constexpr T &operator*() & noexcept;\n constexpr T &&operator*() && noexcept;\n constexpr const T &&operator*() const && noexcept;\n constexpr explicit operator bool() const noexcept;\n constexpr bool has_value() const noexcept;\n constexpr T const &value() const &;\n constexpr T &value() &;\n constexpr T &&value() &&;\n constexpr const T &&value() const &&;\n template<class U> constexpr T value_or(U &&) const &;\n template<class U> constexpr T value_or(U &&) &&;\n\n // [optional.monadic], monadic operations\n template<class F> constexpr auto and_then(F&& f) &; // since C++23\n template<class F> constexpr auto and_then(F&& f) &&; // since C++23\n template<class F> constexpr auto and_then(F&& f) const&; // since C++23\n template<class F> constexpr auto and_then(F&& f) const&&; // since C++23\n template<class F> constexpr auto transform(F&& f) &; // since C++23\n template<class F> constexpr auto transform(F&& f) &&; // since C++23\n template<class F> constexpr auto transform(F&& f) const&; // since C++23\n template<class F> constexpr auto transform(F&& f) const&&; // since C++23\n template<class F> constexpr optional or_else(F&& f) &&; // since C++23\n template<class F> constexpr optional or_else(F&& f) const&; // since C++23\n\n // [optional.mod], modifiers\n void reset() noexcept; // constexpr in C++20\n\n private:\n T *val; // exposition only\n };\n\n template<class T>\n optional(T) -> optional<T>;\n\n} // namespace std\n\n*/\n\n#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n# include <__cxx03/optional>\n#else\n# include <__assert>\n# include <__compare/compare_three_way_result.h>\n# include <__compare/ordering.h>\n# include <__compare/three_way_comparable.h>\n# include <__concepts/invocable.h>\n# include <__config>\n# include <__exception/exception.h>\n# include <__functional/hash.h>\n# include <__functional/invoke.h>\n# include <__functional/unary_function.h>\n# include <__fwd/functional.h>\n# include <__memory/addressof.h>\n# include <__memory/construct_at.h>\n# include <__tuple/sfinae_helpers.h>\n# include <__type_traits/add_pointer.h>\n# include <__type_traits/conditional.h>\n# include <__type_traits/conjunction.h>\n# include <__type_traits/decay.h>\n# include <__type_traits/disjunction.h>\n# include <__type_traits/enable_if.h>\n# include <__type_traits/invoke.h>\n# include <__type_traits/is_array.h>\n# include <__type_traits/is_assignable.h>\n# include <__type_traits/is_constructible.h>\n# include <__type_traits/is_convertible.h>\n# include <__type_traits/is_destructible.h>\n# include <__type_traits/is_nothrow_assignable.h>\n# include <__type_traits/is_nothrow_constructible.h>\n# include <__type_traits/is_object.h>\n# include <__type_traits/is_reference.h>\n# include <__type_traits/is_same.h>\n# include <__type_traits/is_scalar.h>\n# include <__type_traits/is_swappable.h>\n# include <__type_traits/is_trivially_assignable.h>\n# include <__type_traits/is_trivially_constructible.h>\n# include <__type_traits/is_trivially_destructible.h>\n# include <__type_traits/is_trivially_relocatable.h>\n# include <__type_traits/negation.h>\n# include <__type_traits/remove_const.h>\n# include <__type_traits/remove_cv.h>\n# include <__type_traits/remove_cvref.h>\n# include <__type_traits/remove_reference.h>\n# include <__utility/declval.h>\n# include <__utility/forward.h>\n# include <__utility/in_place.h>\n# include <__utility/move.h>\n# include <__utility/swap.h>\n# include <__verbose_abort>\n# include <initializer_list>\n# include <version>\n\n// standard-mandated includes\n\n// [optional.syn]\n# include <compare>\n\n# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n# endif\n\n_LIBCPP_PUSH_MACROS\n# include <__undef_macros>\n\nnamespace std // purposefully not using versioning namespace\n{\n\nclass _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public exception {\npublic:\n _LIBCPP_HIDE_FROM_ABI bad_optional_access() _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI bad_optional_access(const bad_optional_access&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI bad_optional_access& operator=(const bad_optional_access&) _NOEXCEPT = default;\n // Get the key function ~bad_optional_access() into the dylib\n ~bad_optional_access() _NOEXCEPT override;\n const char* what() const _NOEXCEPT override;\n};\n\n} // namespace std\n\n# if _LIBCPP_STD_VER >= 17\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\n[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void\n__throw_bad_optional_access() {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw bad_optional_access();\n# else\n _LIBCPP_VERBOSE_ABORT(\"bad_optional_access was thrown in -fno-exceptions mode\");\n# endif\n}\n\nstruct nullopt_t {\n struct __secret_tag {\n explicit __secret_tag() = default;\n };\n _LIBCPP_HIDE_FROM_ABI constexpr explicit nullopt_t(__secret_tag, __secret_tag) noexcept {}\n};\n\ninline constexpr nullopt_t nullopt{nullopt_t::__secret_tag{}, nullopt_t::__secret_tag{}};\n\nstruct __optional_construct_from_invoke_tag {};\n\ntemplate <class _Tp, bool = is_trivially_destructible<_Tp>::value>\nstruct __optional_destruct_base;\n\ntemplate <class _Tp>\nstruct __optional_destruct_base<_Tp, false> {\n typedef _Tp value_type;\n static_assert(is_object_v<value_type>, \"instantiation of optional with a non-object type is undefined behavior\");\n union {\n char __null_state_;\n remove_cv_t<value_type> __val_;\n };\n bool __engaged_;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__optional_destruct_base() {\n if (__engaged_)\n __val_.~value_type();\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base() noexcept : __null_state_(), __engaged_(false) {}\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args)\n : __val_(std::forward<_Args>(__args)...), __engaged_(true) {}\n\n# if _LIBCPP_STD_VER >= 23\n template <class _Fp, class... _Args>\n _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(\n __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)\n : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept {\n if (__engaged_) {\n __val_.~value_type();\n __engaged_ = false;\n }\n }\n};\n\ntemplate <class _Tp>\nstruct __optional_destruct_base<_Tp, true> {\n typedef _Tp value_type;\n static_assert(is_object_v<value_type>, \"instantiation of optional with a non-object type is undefined behavior\");\n union {\n char __null_state_;\n remove_cv_t<value_type> __val_;\n };\n bool __engaged_;\n\n _LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base() noexcept : __null_state_(), __engaged_(false) {}\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args)\n : __val_(std::forward<_Args>(__args)...), __engaged_(true) {}\n\n# if _LIBCPP_STD_VER >= 23\n template <class _Fp, class... _Args>\n _LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base(\n __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)\n : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept {\n if (__engaged_) {\n __engaged_ = false;\n }\n }\n};\n\ntemplate <class _Tp, bool = is_reference<_Tp>::value>\nstruct __optional_storage_base : __optional_destruct_base<_Tp> {\n using __base _LIBCPP_NODEBUG = __optional_destruct_base<_Tp>;\n using value_type = _Tp;\n using __base::__base;\n\n _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return this->__engaged_; }\n\n _LIBCPP_HIDE_FROM_ABI constexpr value_type& __get() & noexcept { return this->__val_; }\n _LIBCPP_HIDE_FROM_ABI constexpr const value_type& __get() const& noexcept { return this->__val_; }\n _LIBCPP_HIDE_FROM_ABI constexpr value_type&& __get() && noexcept { return std::move(this->__val_); }\n _LIBCPP_HIDE_FROM_ABI constexpr const value_type&& __get() const&& noexcept { return std::move(this->__val_); }\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_Args&&... __args) {\n _LIBCPP_ASSERT_INTERNAL(!has_value(), \"__construct called for engaged __optional_storage\");\n std::__construct_at(std::addressof(this->__val_), std::forward<_Args>(__args)...);\n this->__engaged_ = true;\n }\n\n template <class _That>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_from(_That&& __opt) {\n if (__opt.has_value())\n __construct(std::forward<_That>(__opt).__get());\n }\n\n template <class _That>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt) {\n if (this->__engaged_ == __opt.has_value()) {\n if (this->__engaged_)\n static_cast<_Tp&>(this->__val_) = std::forward<_That>(__opt).__get();\n } else {\n if (this->__engaged_)\n this->reset();\n else\n __construct(std::forward<_That>(__opt).__get());\n }\n }\n};\n\n// optional<T&> is currently required to be ill-formed. However, it may\n// be allowed in the future. For this reason, it has already been implemented\n// to ensure we can make the change in an ABI-compatible manner.\ntemplate <class _Tp>\nstruct __optional_storage_base<_Tp, true> {\n using value_type = _Tp;\n using __raw_type _LIBCPP_NODEBUG = remove_reference_t<_Tp>;\n __raw_type* __value_;\n\n template <class _Up>\n static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() {\n using _RawUp = __libcpp_remove_reference_t<_Up>;\n using _UpPtr = _RawUp*;\n using _RawTp = __libcpp_remove_reference_t<_Tp>;\n using _TpPtr = _RawTp*;\n using _CheckLValueArg =\n integral_constant<bool,\n (is_lvalue_reference<_Up>::value && is_convertible<_UpPtr, _TpPtr>::value) ||\n is_same<_RawUp, reference_wrapper<_RawTp>>::value ||\n is_same<_RawUp, reference_wrapper<__remove_const_t<_RawTp>>>::value >;\n return (is_lvalue_reference<_Tp>::value && _CheckLValueArg::value) ||\n (is_rvalue_reference<_Tp>::value && !is_lvalue_reference<_Up>::value &&\n is_convertible<_UpPtr, _TpPtr>::value);\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr __optional_storage_base() noexcept : __value_(nullptr) {}\n\n template <class _UArg>\n _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_storage_base(in_place_t, _UArg&& __uarg)\n : __value_(std::addressof(__uarg)) {\n static_assert(__can_bind_reference<_UArg>(),\n \"Attempted to construct a reference element in tuple from a \"\n \"possible temporary\");\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { __value_ = nullptr; }\n\n _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return __value_ != nullptr; }\n\n _LIBCPP_HIDE_FROM_ABI constexpr value_type& __get() const& noexcept { return *__value_; }\n\n _LIBCPP_HIDE_FROM_ABI constexpr value_type&& __get() const&& noexcept { return std::forward<value_type>(*__value_); }\n\n template <class _UArg>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_UArg&& __val) {\n _LIBCPP_ASSERT_INTERNAL(!has_value(), \"__construct called for engaged __optional_storage\");\n static_assert(__can_bind_reference<_UArg>(),\n \"Attempted to construct a reference element in tuple from a \"\n \"possible temporary\");\n __value_ = std::addressof(__val);\n }\n\n template <class _That>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_from(_That&& __opt) {\n if (__opt.has_value())\n __construct(std::forward<_That>(__opt).__get());\n }\n\n template <class _That>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt) {\n if (has_value() == __opt.has_value()) {\n if (has_value())\n *__value_ = std::forward<_That>(__opt).__get();\n } else {\n if (has_value())\n reset();\n else\n __construct(std::forward<_That>(__opt).__get());\n }\n }\n};\n\ntemplate <class _Tp, bool = is_trivially_copy_constructible<_Tp>::value>\nstruct __optional_copy_base : __optional_storage_base<_Tp> {\n using __optional_storage_base<_Tp>::__optional_storage_base;\n};\n\ntemplate <class _Tp>\nstruct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp> {\n using __optional_storage_base<_Tp>::__optional_storage_base;\n\n _LIBCPP_HIDE_FROM_ABI __optional_copy_base() = default;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __optional_copy_base(const __optional_copy_base& __opt) {\n this->__construct_from(__opt);\n }\n\n _LIBCPP_HIDE_FROM_ABI __optional_copy_base(__optional_copy_base&&) = default;\n _LIBCPP_HIDE_FROM_ABI __optional_copy_base& operator=(const __optional_copy_base&) = default;\n _LIBCPP_HIDE_FROM_ABI __optional_copy_base& operator=(__optional_copy_base&&) = default;\n};\n\ntemplate <class _Tp, bool = is_trivially_move_constructible<_Tp>::value>\nstruct __optional_move_base : __optional_copy_base<_Tp> {\n using __optional_copy_base<_Tp>::__optional_copy_base;\n};\n\ntemplate <class _Tp>\nstruct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp> {\n using value_type = _Tp;\n using __optional_copy_base<_Tp>::__optional_copy_base;\n\n _LIBCPP_HIDE_FROM_ABI __optional_move_base() = default;\n _LIBCPP_HIDE_FROM_ABI __optional_move_base(const __optional_move_base&) = default;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20\n __optional_move_base(__optional_move_base&& __opt) noexcept(is_nothrow_move_constructible_v<value_type>) {\n this->__construct_from(std::move(__opt));\n }\n\n _LIBCPP_HIDE_FROM_ABI __optional_move_base& operator=(const __optional_move_base&) = default;\n _LIBCPP_HIDE_FROM_ABI __optional_move_base& operator=(__optional_move_base&&) = default;\n};\n\ntemplate <class _Tp,\n bool = is_trivially_destructible<_Tp>::value && is_trivially_copy_constructible<_Tp>::value &&\n is_trivially_copy_assignable<_Tp>::value>\nstruct __optional_copy_assign_base : __optional_move_base<_Tp> {\n using __optional_move_base<_Tp>::__optional_move_base;\n};\n\ntemplate <class _Tp>\nstruct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp> {\n using __optional_move_base<_Tp>::__optional_move_base;\n\n _LIBCPP_HIDE_FROM_ABI __optional_copy_assign_base() = default;\n _LIBCPP_HIDE_FROM_ABI __optional_copy_assign_base(const __optional_copy_assign_base&) = default;\n _LIBCPP_HIDE_FROM_ABI __optional_copy_assign_base(__optional_copy_assign_base&&) = default;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __optional_copy_assign_base&\n operator=(const __optional_copy_assign_base& __opt) {\n this->__assign_from(__opt);\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI __optional_copy_assign_base& operator=(__optional_copy_assign_base&&) = default;\n};\n\ntemplate <class _Tp,\n bool = is_trivially_destructible<_Tp>::value && is_trivially_move_constructible<_Tp>::value &&\n is_trivially_move_assignable<_Tp>::value>\nstruct __optional_move_assign_base : __optional_copy_assign_base<_Tp> {\n using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;\n};\n\ntemplate <class _Tp>\nstruct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp> {\n using value_type = _Tp;\n using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;\n\n _LIBCPP_HIDE_FROM_ABI __optional_move_assign_base() = default;\n _LIBCPP_HIDE_FROM_ABI __optional_move_assign_base(const __optional_move_assign_base& __opt) = default;\n _LIBCPP_HIDE_FROM_ABI __optional_move_assign_base(__optional_move_assign_base&&) = default;\n _LIBCPP_HIDE_FROM_ABI __optional_move_assign_base& operator=(const __optional_move_assign_base&) = default;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __optional_move_assign_base&\n operator=(__optional_move_assign_base&& __opt) noexcept(\n is_nothrow_move_assignable_v<value_type> && is_nothrow_move_constructible_v<value_type>) {\n this->__assign_from(std::move(__opt));\n return *this;\n }\n};\n\ntemplate <class _Tp>\nusing __optional_sfinae_ctor_base_t _LIBCPP_NODEBUG =\n __sfinae_ctor_base< is_copy_constructible<_Tp>::value, is_move_constructible<_Tp>::value >;\n\ntemplate <class _Tp>\nusing __optional_sfinae_assign_base_t _LIBCPP_NODEBUG =\n __sfinae_assign_base< (is_copy_constructible<_Tp>::value && is_copy_assignable<_Tp>::value),\n (is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value) >;\n\ntemplate <class _Tp>\nclass optional;\n\n# if _LIBCPP_STD_VER >= 20\n\ntemplate <class _Tp>\nconcept __is_derived_from_optional = requires(const _Tp& __t) { []<class _Up>(const optional<_Up>&) {}(__t); };\n\n# endif // _LIBCPP_STD_VER >= 20\n\ntemplate <class _Tp>\nstruct __is_std_optional : false_type {};\ntemplate <class _Tp>\nstruct __is_std_optional<optional<_Tp>> : true_type {};\n\ntemplate <class _Tp>\nclass _LIBCPP_DECLSPEC_EMPTY_BASES optional\n : private __optional_move_assign_base<_Tp>,\n private __optional_sfinae_ctor_base_t<_Tp>,\n private __optional_sfinae_assign_base_t<_Tp> {\n using __base _LIBCPP_NODEBUG = __optional_move_assign_base<_Tp>;\n\npublic:\n using value_type = _Tp;\n\n using __trivially_relocatable _LIBCPP_NODEBUG =\n conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>;\n\nprivate:\n // Disable the reference extension using this static assert.\n static_assert(!is_same_v<__remove_cvref_t<value_type>, in_place_t>,\n \"instantiation of optional with in_place_t is ill-formed\");\n static_assert(!is_same_v<__remove_cvref_t<value_type>, nullopt_t>,\n \"instantiation of optional with nullopt_t is ill-formed\");\n static_assert(!is_reference_v<value_type>, \"instantiation of optional with a reference type is ill-formed\");\n static_assert(is_destructible_v<value_type>, \"instantiation of optional with a non-destructible type is ill-formed\");\n static_assert(!is_array_v<value_type>, \"instantiation of optional with an array type is ill-formed\");\n\n // LWG2756: conditionally explicit conversion from _Up\n struct _CheckOptionalArgsConstructor {\n template <class _Up>\n _LIBCPP_HIDE_FROM_ABI static constexpr bool __enable_implicit() {\n return is_constructible_v<_Tp, _Up&&> && is_convertible_v<_Up&&, _Tp>;\n }\n\n template <class _Up>\n _LIBCPP_HIDE_FROM_ABI static constexpr bool __enable_explicit() {\n return is_constructible_v<_Tp, _Up&&> && !is_convertible_v<_Up&&, _Tp>;\n }\n };\n template <class _Up>\n using _CheckOptionalArgsCtor _LIBCPP_NODEBUG =\n _If< _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value && _IsNotSame<__remove_cvref_t<_Up>, optional>::value &&\n (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_optional<__remove_cvref_t<_Up>>::value),\n _CheckOptionalArgsConstructor,\n __check_tuple_constructor_fail >;\n template <class _QualUp>\n struct _CheckOptionalLikeConstructor {\n template <class _Up, class _Opt = optional<_Up>>\n using __check_constructible_from_opt _LIBCPP_NODEBUG =\n _Or< is_constructible<_Tp, _Opt&>,\n is_constructible<_Tp, _Opt const&>,\n is_constructible<_Tp, _Opt&&>,\n is_constructible<_Tp, _Opt const&&>,\n is_convertible<_Opt&, _Tp>,\n is_convertible<_Opt const&, _Tp>,\n is_convertible<_Opt&&, _Tp>,\n is_convertible<_Opt const&&, _Tp> >;\n template <class _Up, class _Opt = optional<_Up>>\n using __check_assignable_from_opt _LIBCPP_NODEBUG =\n _Or< is_assignable<_Tp&, _Opt&>,\n is_assignable<_Tp&, _Opt const&>,\n is_assignable<_Tp&, _Opt&&>,\n is_assignable<_Tp&, _Opt const&&> >;\n template <class _Up, class _QUp = _QualUp>\n _LIBCPP_HIDE_FROM_ABI static constexpr bool __enable_implicit() {\n return is_convertible<_QUp, _Tp>::value &&\n (is_same_v<remove_cv_t<_Tp>, bool> || !__check_constructible_from_opt<_Up>::value);\n }\n template <class _Up, class _QUp = _QualUp>\n _LIBCPP_HIDE_FROM_ABI static constexpr bool __enable_explicit() {\n return !is_convertible<_QUp, _Tp>::value &&\n (is_same_v<remove_cv_t<_Tp>, bool> || !__check_constructible_from_opt<_Up>::value);\n }\n template <class _Up, class _QUp = _QualUp>\n _LIBCPP_HIDE_FROM_ABI static constexpr bool __enable_assign() {\n // Construction and assignability of _QUp to _Tp has already been\n // checked.\n return !__check_constructible_from_opt<_Up>::value && !__check_assignable_from_opt<_Up>::value;\n }\n };\n\n template <class _Up, class _QualUp>\n using _CheckOptionalLikeCtor _LIBCPP_NODEBUG =\n _If< _And< _IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp> >::value,\n _CheckOptionalLikeConstructor<_QualUp>,\n __check_tuple_constructor_fail >;\n template <class _Up, class _QualUp>\n using _CheckOptionalLikeAssign _LIBCPP_NODEBUG =\n _If< _And< _IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp>, is_assignable<_Tp&, _QualUp> >::value,\n _CheckOptionalLikeConstructor<_QualUp>,\n __check_tuple_constructor_fail >;\n\npublic:\n _LIBCPP_HIDE_FROM_ABI constexpr optional() noexcept {}\n _LIBCPP_HIDE_FROM_ABI constexpr optional(const optional&) = default;\n _LIBCPP_HIDE_FROM_ABI constexpr optional(optional&&) = default;\n _LIBCPP_HIDE_FROM_ABI constexpr optional(nullopt_t) noexcept {}\n\n template <\n class _InPlaceT,\n class... _Args,\n class = enable_if_t< _And< _IsSame<_InPlaceT, in_place_t>, is_constructible<value_type, _Args...> >::value > >\n _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_InPlaceT, _Args&&... __args)\n : __base(in_place, std::forward<_Args>(__args)...) {}\n\n template <class _Up,\n class... _Args,\n class = enable_if_t< is_constructible_v<value_type, initializer_list<_Up>&, _Args...>> >\n _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)\n : __base(in_place, __il, std::forward<_Args>(__args)...) {}\n\n template <class _Up = value_type,\n enable_if_t< _CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI constexpr optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {}\n\n template <class _Up, enable_if_t< _CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {}\n\n // LWG2756: conditionally explicit conversion from const optional<_Up>&\n template <class _Up,\n enable_if_t< _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v) {\n this->__construct_from(__v);\n }\n template <class _Up,\n enable_if_t< _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v) {\n this->__construct_from(__v);\n }\n\n // LWG2756: conditionally explicit conversion from optional<_Up>&&\n template <class _Up, enable_if_t< _CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_implicit<_Up>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v) {\n this->__construct_from(std::move(__v));\n }\n template <class _Up, enable_if_t< _CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_explicit<_Up>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v) {\n this->__construct_from(std::move(__v));\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <class _Tag,\n class _Fp,\n class... _Args,\n __enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args)\n : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(nullopt_t) noexcept {\n reset();\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr optional& operator=(const optional&) = default;\n _LIBCPP_HIDE_FROM_ABI constexpr optional& operator=(optional&&) = default;\n\n // LWG2756\n template <\n class _Up = value_type,\n class = enable_if_t< _And< _IsNotSame<__remove_cvref_t<_Up>, optional>,\n _Or< _IsNotSame<__remove_cvref_t<_Up>, value_type>, _Not<is_scalar<value_type>> >,\n is_constructible<value_type, _Up>,\n is_assignable<value_type&, _Up> >::value> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) {\n if (this->has_value())\n this->__get() = std::forward<_Up>(__v);\n else\n this->__construct(std::forward<_Up>(__v));\n return *this;\n }\n\n // LWG2756\n template <class _Up,\n enable_if_t< _CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(const optional<_Up>& __v) {\n this->__assign_from(__v);\n return *this;\n }\n\n // LWG2756\n template <class _Up, enable_if_t< _CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_assign<_Up>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(optional<_Up>&& __v) {\n this->__assign_from(std::move(__v));\n return *this;\n }\n\n template <class... _Args, class = enable_if_t< is_constructible_v<value_type, _Args...> > >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) {\n reset();\n this->__construct(std::forward<_Args>(__args)...);\n return this->__get();\n }\n\n template <class _Up,\n class... _Args,\n class = enable_if_t< is_constructible_v<value_type, initializer_list<_Up>&, _Args...> > >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {\n reset();\n this->__construct(__il, std::forward<_Args>(__args)...);\n return this->__get();\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\n swap(optional& __opt) noexcept(is_nothrow_move_constructible_v<value_type> && is_nothrow_swappable_v<value_type>) {\n if (this->has_value() == __opt.has_value()) {\n using std::swap;\n if (this->has_value())\n swap(this->__get(), __opt.__get());\n } else {\n if (this->has_value()) {\n __opt.__construct(std::move(this->__get()));\n reset();\n } else {\n this->__construct(std::move(__opt.__get()));\n __opt.reset();\n }\n }\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type const> operator->() const noexcept {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), \"optional operator-> called on a disengaged value\");\n return std::addressof(this->__get());\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type> operator->() noexcept {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), \"optional operator-> called on a disengaged value\");\n return std::addressof(this->__get());\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr const value_type& operator*() const& noexcept {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), \"optional operator* called on a disengaged value\");\n return this->__get();\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr value_type& operator*() & noexcept {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), \"optional operator* called on a disengaged value\");\n return this->__get();\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr value_type&& operator*() && noexcept {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), \"optional operator* called on a disengaged value\");\n return std::move(this->__get());\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr const value_type&& operator*() const&& noexcept {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), \"optional operator* called on a disengaged value\");\n return std::move(this->__get());\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return has_value(); }\n\n using __base::__get;\n using __base::has_value;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type const& value() const& {\n if (!this->has_value())\n __throw_bad_optional_access();\n return this->__get();\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type& value() & {\n if (!this->has_value())\n __throw_bad_optional_access();\n return this->__get();\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type&& value() && {\n if (!this->has_value())\n __throw_bad_optional_access();\n return std::move(this->__get());\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type const&& value() const&& {\n if (!this->has_value())\n __throw_bad_optional_access();\n return std::move(this->__get());\n }\n\n template <class _Up>\n _LIBCPP_HIDE_FROM_ABI constexpr value_type value_or(_Up&& __v) const& {\n static_assert(is_copy_constructible_v<value_type>, \"optional<T>::value_or: T must be copy constructible\");\n static_assert(is_convertible_v<_Up, value_type>, \"optional<T>::value_or: U must be convertible to T\");\n return this->has_value() ? this->__get() : static_cast<value_type>(std::forward<_Up>(__v));\n }\n\n template <class _Up>\n _LIBCPP_HIDE_FROM_ABI constexpr value_type value_or(_Up&& __v) && {\n static_assert(is_move_constructible_v<value_type>, \"optional<T>::value_or: T must be move constructible\");\n static_assert(is_convertible_v<_Up, value_type>, \"optional<T>::value_or: U must be convertible to T\");\n return this->has_value() ? std::move(this->__get()) : static_cast<value_type>(std::forward<_Up>(__v));\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <class _Func>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) & {\n using _Up = invoke_result_t<_Func, value_type&>;\n static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,\n \"Result of f(value()) must be a specialization of std::optional\");\n if (*this)\n return std::invoke(std::forward<_Func>(__f), value());\n return remove_cvref_t<_Up>();\n }\n\n template <class _Func>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) const& {\n using _Up = invoke_result_t<_Func, const value_type&>;\n static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,\n \"Result of f(value()) must be a specialization of std::optional\");\n if (*this)\n return std::invoke(std::forward<_Func>(__f), value());\n return remove_cvref_t<_Up>();\n }\n\n template <class _Func>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) && {\n using _Up = invoke_result_t<_Func, value_type&&>;\n static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,\n \"Result of f(std::move(value())) must be a specialization of std::optional\");\n if (*this)\n return std::invoke(std::forward<_Func>(__f), std::move(value()));\n return remove_cvref_t<_Up>();\n }\n\n template <class _Func>\n _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& {\n using _Up = invoke_result_t<_Func, const value_type&&>;\n static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,\n \"Result of f(std::move(value())) must be a specialization of std::optional\");\n if (*this)\n return std::invoke(std::forward<_Func>(__f), std::move(value()));\n return remove_cvref_t<_Up>();\n }\n\n template <class _Func>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) & {\n using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>;\n static_assert(!is_array_v<_Up>, \"Result of f(value()) should not be an Array\");\n static_assert(!is_same_v<_Up, in_place_t>, \"Result of f(value()) should not be std::in_place_t\");\n static_assert(!is_same_v<_Up, nullopt_t>, \"Result of f(value()) should not be std::nullopt_t\");\n static_assert(is_object_v<_Up>, \"Result of f(value()) should be an object type\");\n if (*this)\n return optional<_Up>(__optional_construct_from_invoke_tag{}, std::forward<_Func>(__f), value());\n return optional<_Up>();\n }\n\n template <class _Func>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) const& {\n using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>;\n static_assert(!is_array_v<_Up>, \"Result of f(value()) should not be an Array\");\n static_assert(!is_same_v<_Up, in_place_t>, \"Result of f(value()) should not be std::in_place_t\");\n static_assert(!is_same_v<_Up, nullopt_t>, \"Result of f(value()) should not be std::nullopt_t\");\n static_assert(is_object_v<_Up>, \"Result of f(value()) should be an object type\");\n if (*this)\n return optional<_Up>(__optional_construct_from_invoke_tag{}, std::forward<_Func>(__f), value());\n return optional<_Up>();\n }\n\n template <class _Func>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) && {\n using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>;\n static_assert(!is_array_v<_Up>, \"Result of f(std::move(value())) should not be an Array\");\n static_assert(!is_same_v<_Up, in_place_t>, \"Result of f(std::move(value())) should not be std::in_place_t\");\n static_assert(!is_same_v<_Up, nullopt_t>, \"Result of f(std::move(value())) should not be std::nullopt_t\");\n static_assert(is_object_v<_Up>, \"Result of f(std::move(value())) should be an object type\");\n if (*this)\n return optional<_Up>(__optional_construct_from_invoke_tag{}, std::forward<_Func>(__f), std::move(value()));\n return optional<_Up>();\n }\n\n template <class _Func>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) const&& {\n using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>;\n static_assert(!is_array_v<_Up>, \"Result of f(std::move(value())) should not be an Array\");\n static_assert(!is_same_v<_Up, in_place_t>, \"Result of f(std::move(value())) should not be std::in_place_t\");\n static_assert(!is_same_v<_Up, nullopt_t>, \"Result of f(std::move(value())) should not be std::nullopt_t\");\n static_assert(is_object_v<_Up>, \"Result of f(std::move(value())) should be an object type\");\n if (*this)\n return optional<_Up>(__optional_construct_from_invoke_tag{}, std::forward<_Func>(__f), std::move(value()));\n return optional<_Up>();\n }\n\n template <invocable _Func>\n _LIBCPP_HIDE_FROM_ABI constexpr optional or_else(_Func&& __f) const&\n requires is_copy_constructible_v<value_type>\n {\n static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,\n \"Result of f() should be the same type as this optional\");\n if (*this)\n return *this;\n return std::forward<_Func>(__f)();\n }\n\n template <invocable _Func>\n _LIBCPP_HIDE_FROM_ABI constexpr optional or_else(_Func&& __f) &&\n requires is_move_constructible_v<value_type>\n {\n static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,\n \"Result of f() should be the same type as this optional\");\n if (*this)\n return std::move(*this);\n return std::forward<_Func>(__f)();\n }\n# endif // _LIBCPP_STD_VER >= 23\n\n using __base::reset;\n};\n\n# if _LIBCPP_STD_VER >= 17\ntemplate <class _Tp>\noptional(_Tp) -> optional<_Tp>;\n# endif\n\n// Comparisons between optionals\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,\n bool >\noperator==(const optional<_Tp>& __x, const optional<_Up>& __y) {\n if (static_cast<bool>(__x) != static_cast<bool>(__y))\n return false;\n if (!static_cast<bool>(__x))\n return true;\n return *__x == *__y;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,\n bool >\noperator!=(const optional<_Tp>& __x, const optional<_Up>& __y) {\n if (static_cast<bool>(__x) != static_cast<bool>(__y))\n return true;\n if (!static_cast<bool>(__x))\n return false;\n return *__x != *__y;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,\n bool >\noperator<(const optional<_Tp>& __x, const optional<_Up>& __y) {\n if (!static_cast<bool>(__y))\n return false;\n if (!static_cast<bool>(__x))\n return true;\n return *__x < *__y;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,\n bool >\noperator>(const optional<_Tp>& __x, const optional<_Up>& __y) {\n if (!static_cast<bool>(__x))\n return false;\n if (!static_cast<bool>(__y))\n return true;\n return *__x > *__y;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,\n bool >\noperator<=(const optional<_Tp>& __x, const optional<_Up>& __y) {\n if (!static_cast<bool>(__x))\n return true;\n if (!static_cast<bool>(__y))\n return false;\n return *__x <= *__y;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,\n bool >\noperator>=(const optional<_Tp>& __x, const optional<_Up>& __y) {\n if (!static_cast<bool>(__y))\n return true;\n if (!static_cast<bool>(__x))\n return false;\n return *__x >= *__y;\n}\n\n# if _LIBCPP_STD_VER >= 20\n\ntemplate <class _Tp, three_way_comparable_with<_Tp> _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr compare_three_way_result_t<_Tp, _Up>\noperator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) {\n if (__x && __y)\n return *__x <=> *__y;\n return __x.has_value() <=> __y.has_value();\n}\n\n# endif // _LIBCPP_STD_VER >= 20\n\n// Comparisons with nullopt\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, nullopt_t) noexcept {\n return !static_cast<bool>(__x);\n}\n\n# if _LIBCPP_STD_VER <= 17\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(nullopt_t, const optional<_Tp>& __x) noexcept {\n return !static_cast<bool>(__x);\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const optional<_Tp>& __x, nullopt_t) noexcept {\n return static_cast<bool>(__x);\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(nullopt_t, const optional<_Tp>& __x) noexcept {\n return static_cast<bool>(__x);\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const optional<_Tp>&, nullopt_t) noexcept {\n return false;\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(nullopt_t, const optional<_Tp>& __x) noexcept {\n return static_cast<bool>(__x);\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const optional<_Tp>& __x, nullopt_t) noexcept {\n return !static_cast<bool>(__x);\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(nullopt_t, const optional<_Tp>&) noexcept {\n return true;\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const optional<_Tp>& __x, nullopt_t) noexcept {\n return static_cast<bool>(__x);\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(nullopt_t, const optional<_Tp>&) noexcept {\n return false;\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const optional<_Tp>&, nullopt_t) noexcept {\n return true;\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(nullopt_t, const optional<_Tp>& __x) noexcept {\n return !static_cast<bool>(__x);\n}\n\n# else // _LIBCPP_STD_VER <= 17\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>& __x, nullopt_t) noexcept {\n return __x.has_value() <=> false;\n}\n\n# endif // _LIBCPP_STD_VER <= 17\n\n// Comparisons with T\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,\n bool >\noperator==(const optional<_Tp>& __x, const _Up& __v) {\n return static_cast<bool>(__x) ? *__x == __v : false;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,\n bool >\noperator==(const _Tp& __v, const optional<_Up>& __x) {\n return static_cast<bool>(__x) ? __v == *__x : false;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,\n bool >\noperator!=(const optional<_Tp>& __x, const _Up& __v) {\n return static_cast<bool>(__x) ? *__x != __v : true;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,\n bool >\noperator!=(const _Tp& __v, const optional<_Up>& __x) {\n return static_cast<bool>(__x) ? __v != *__x : true;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,\n bool >\noperator<(const optional<_Tp>& __x, const _Up& __v) {\n return static_cast<bool>(__x) ? *__x < __v : true;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,\n bool >\noperator<(const _Tp& __v, const optional<_Up>& __x) {\n return static_cast<bool>(__x) ? __v < *__x : false;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,\n bool >\noperator<=(const optional<_Tp>& __x, const _Up& __v) {\n return static_cast<bool>(__x) ? *__x <= __v : true;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,\n bool >\noperator<=(const _Tp& __v, const optional<_Up>& __x) {\n return static_cast<bool>(__x) ? __v <= *__x : false;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,\n bool >\noperator>(const optional<_Tp>& __x, const _Up& __v) {\n return static_cast<bool>(__x) ? *__x > __v : false;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,\n bool >\noperator>(const _Tp& __v, const optional<_Up>& __x) {\n return static_cast<bool>(__x) ? __v > *__x : true;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,\n bool >\noperator>=(const optional<_Tp>& __x, const _Up& __v) {\n return static_cast<bool>(__x) ? *__x >= __v : false;\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<\n is_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,\n bool >\noperator>=(const _Tp& __v, const optional<_Up>& __x) {\n return static_cast<bool>(__x) ? __v >= *__x : true;\n}\n\n# if _LIBCPP_STD_VER >= 20\n\ntemplate <class _Tp, class _Up>\n requires(!__is_derived_from_optional<_Up>) && three_way_comparable_with<_Tp, _Up>\n_LIBCPP_HIDE_FROM_ABI constexpr compare_three_way_result_t<_Tp, _Up>\noperator<=>(const optional<_Tp>& __x, const _Up& __v) {\n return __x.has_value() ? *__x <=> __v : strong_ordering::less;\n}\n\n# endif // _LIBCPP_STD_VER >= 20\n\ntemplate <class _Tp>\ninline _LIBCPP_HIDE_FROM_ABI\n_LIBCPP_CONSTEXPR_SINCE_CXX20 enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, void >\nswap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) {\n __x.swap(__y);\n}\n\ntemplate <class _Tp>\n_LIBCPP_HIDE_FROM_ABI constexpr optional<decay_t<_Tp>> make_optional(_Tp&& __v) {\n return optional<decay_t<_Tp>>(std::forward<_Tp>(__v));\n}\n\ntemplate <class _Tp, class... _Args>\n_LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(_Args&&... __args) {\n return optional<_Tp>(in_place, std::forward<_Args>(__args)...);\n}\n\ntemplate <class _Tp, class _Up, class... _Args>\n_LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(initializer_list<_Up> __il, _Args&&... __args) {\n return optional<_Tp>(in_place, __il, std::forward<_Args>(__args)...);\n}\n\ntemplate <class _Tp>\nstruct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>> > {\n# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)\n _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type;\n _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;\n# endif\n\n _LIBCPP_HIDE_FROM_ABI size_t operator()(const optional<_Tp>& __opt) const {\n return static_cast<bool>(__opt) ? hash<remove_const_t<_Tp>>()(*__opt) : 0;\n }\n};\n\n_LIBCPP_END_NAMESPACE_STD\n\n# endif // _LIBCPP_STD_VER >= 17\n\n_LIBCPP_POP_MACROS\n\n# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20\n# include <atomic>\n# include <climits>\n# include <concepts>\n# include <ctime>\n# include <iterator>\n# include <limits>\n# include <memory>\n# include <ratio>\n# include <stdexcept>\n# include <tuple>\n# include <type_traits>\n# include <typeinfo>\n# include <utility>\n# include <variant>\n# endif\n#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n\n#endif // _LIBCPP_OPTIONAL\n","/*\n * Copyright 2012 The Emscripten Authors. All rights reserved.\n * Emscripten is available under two separate licenses, the MIT license and the\n * University of Illinois/NCSA Open Source License. Both these licenses can be\n * found in the LICENSE file.\n */\n\n#pragma once\n\n#include <cassert>\n#include <array>\n#include <climits>\n#include <emscripten/wire.h>\n#include <cstdint> // uintptr_t\n#include <vector>\n#include <type_traits>\n#include <pthread.h>\n#if __cplusplus >= 202002L\n#include <coroutine>\n#include <exception>\n#include <variant>\n#endif\n\nnamespace emscripten {\n\nclass val;\n\ntypedef struct _EM_VAL* EM_VAL;\n\nnamespace internal {\n\ntemplate<typename WrapperType>\nval wrapped_extend(const std::string&, const val&);\n\nenum class EM_INVOKER_KIND {\n FUNCTION,\n METHOD,\n CONSTRUCTOR,\n CAST,\n};\n\n// Implemented in JavaScript. Don't call these directly.\nextern \"C\" {\n\nvoid _emval_register_symbol(const char*);\n\nenum {\n _EMVAL_UNDEFINED = 2,\n _EMVAL_NULL = 4,\n _EMVAL_TRUE = 6,\n _EMVAL_FALSE = 8,\n _EMVAL_LAST_RESERVED_HANDLE = 8,\n};\n\ntypedef struct _EM_DESTRUCTORS* EM_DESTRUCTORS;\ntypedef struct _EM_INVOKER* EM_INVOKER;\ntypedef double EM_GENERIC_WIRE_TYPE;\ntypedef const void* EM_VAR_ARGS;\n\nvoid _emval_incref(EM_VAL value);\nvoid _emval_decref(EM_VAL value);\n\nvoid _emval_run_destructors(EM_DESTRUCTORS handle);\n\nEM_VAL _emval_new_array(void);\nEM_VAL _emval_new_array_from_memory_view(EM_VAL mv);\nvoid _emval_array_to_memory_view(EM_VAL dst, EM_VAL src);\nEM_VAL _emval_new_object(void);\nEM_VAL _emval_new_cstring(const char*);\nEM_VAL _emval_new_u8string(const char*);\nEM_VAL _emval_new_u16string(const char16_t*);\n\nEM_VAL _emval_get_global(const char* name);\nEM_VAL _emval_get_module_property(const char* name);\nEM_VAL _emval_get_property(EM_VAL object, EM_VAL key);\nvoid _emval_set_property(EM_VAL object, EM_VAL key, EM_VAL value);\n\nbool _emval_equals(EM_VAL first, EM_VAL second);\nbool _emval_strictly_equals(EM_VAL first, EM_VAL second);\nbool _emval_greater_than(EM_VAL first, EM_VAL second);\nbool _emval_less_than(EM_VAL first, EM_VAL second);\nbool _emval_not(EM_VAL object);\n\n// DO NOT call this more than once per signature. It will\n// leak generated function objects!\nEM_INVOKER _emval_create_invoker(\n unsigned argCount, // including return value\n const TYPEID argTypes[],\n EM_INVOKER_KIND kind);\nEM_GENERIC_WIRE_TYPE _emval_invoke(\n EM_INVOKER caller,\n EM_VAL handle,\n const char* methodName,\n EM_DESTRUCTORS* destructors,\n EM_VAR_ARGS argv);\nint64_t _emval_invoke_i64(\n EM_INVOKER caller,\n EM_VAL handle,\n const char* methodName,\n EM_DESTRUCTORS* destructors,\n EM_VAR_ARGS argv);\nEM_VAL _emval_typeof(EM_VAL value);\nbool _emval_instanceof(EM_VAL object, EM_VAL constructor);\nbool _emval_is_number(EM_VAL object);\nbool _emval_is_string(EM_VAL object);\nbool _emval_in(EM_VAL item, EM_VAL object);\nbool _emval_delete(EM_VAL object, EM_VAL property);\n[[noreturn]] bool _emval_throw(EM_VAL object);\nEM_VAL _emval_await(EM_VAL promise);\nEM_VAL _emval_iter_begin(EM_VAL iterable);\nEM_VAL _emval_iter_next(EM_VAL iterator);\n\n#if __cplusplus >= 202002L\nvoid _emval_coro_suspend(EM_VAL promise, void* coro_ptr);\nEM_VAL _emval_from_current_cxa_exception();\nEM_VAL _emval_coro_make_promise(EM_VAL *resolve, EM_VAL *reject);\n#endif\n\n} // extern \"C\"\n\ntemplate<const char* address>\nstruct symbol_registrar {\n symbol_registrar() {\n internal::_emval_register_symbol(address);\n }\n};\n\nstruct DestructorsRunner {\npublic:\n explicit DestructorsRunner(EM_DESTRUCTORS d)\n : destructors(d)\n {}\n ~DestructorsRunner() {\n if (destructors) {\n _emval_run_destructors(destructors);\n }\n }\n\n DestructorsRunner(const DestructorsRunner&) = delete;\n void operator=(const DestructorsRunner&) = delete;\n\nprivate:\n EM_DESTRUCTORS destructors;\n};\n\ntemplate<typename WireType>\nstruct GenericWireTypeConverter {\n static WireType from(double wt) {\n return static_cast<WireType>(wt);\n }\n};\n\ntemplate<typename Pointee>\nstruct GenericWireTypeConverter<Pointee*> {\n static Pointee* from(double wt) {\n return reinterpret_cast<Pointee*>(static_cast<uintptr_t>(wt));\n }\n};\n\ntemplate<>\nstruct GenericWireTypeConverter<BindingType<void>::WireType> {\n static BindingType<void>::WireType from(double) {\n return {};\n }\n};\n\ntemplate<typename... Args>\nstruct PackSize;\n\ntemplate<>\nstruct PackSize<> {\n static constexpr size_t value = 0;\n};\n\ntemplate<typename Arg, typename... Args>\nstruct PackSize<Arg, Args...> {\n static constexpr size_t value = (sizeof(typename BindingType<Arg>::WireType) + 7) / 8 + PackSize<Args...>::value;\n};\n\nunion GenericWireType {\n union {\n unsigned u;\n size_t s;\n float f;\n const void* p;\n } w[2];\n double d;\n uint64_t u;\n};\nstatic_assert(sizeof(GenericWireType) == 2*sizeof(void*), \"GenericWireType must be size of 2 pointers\");\nstatic_assert(alignof(GenericWireType) == 8, \"GenericWireType must be 8-byte-aligned\");\n\ninline void writeGenericWireType(GenericWireType*& cursor, float wt) {\n cursor->w[0].f = wt;\n ++cursor;\n}\n\ninline void writeGenericWireType(GenericWireType*& cursor, double wt) {\n cursor->d = wt;\n ++cursor;\n}\n\ninline void writeGenericWireType(GenericWireType*& cursor, int64_t wt) {\n cursor->u = wt;\n ++cursor;\n}\n\ninline void writeGenericWireType(GenericWireType*& cursor, uint64_t wt) {\n cursor->u = wt;\n ++cursor;\n}\n\ntemplate<typename T>\nvoid writeGenericWireType(GenericWireType*& cursor, T* wt) {\n cursor->w[0].p = wt;\n ++cursor;\n}\n\ntemplate<typename ElementType>\ninline void writeGenericWireType(GenericWireType*& cursor, const memory_view<ElementType>& wt) {\n cursor->w[0].s = wt.size;\n cursor->w[1].p = (void*)wt.data;\n ++cursor;\n}\n\ntemplate<typename T>\nvoid writeGenericWireType(GenericWireType*& cursor, T wt) {\n cursor->w[0].u = static_cast<unsigned>(wt);\n ++cursor;\n}\n\ninline void writeGenericWireTypes(GenericWireType*&) {\n}\n\ntemplate<typename First, typename... Rest>\nEMSCRIPTEN_ALWAYS_INLINE void writeGenericWireTypes(GenericWireType*& cursor, First&& first, Rest&&... rest) {\n writeGenericWireType(cursor, BindingType<First>::toWireType(std::forward<First>(first), rvp::default_tag{}));\n writeGenericWireTypes(cursor, std::forward<Rest>(rest)...);\n}\n\ntemplate<typename... Args>\nstruct WireTypePack {\n WireTypePack(Args&&... args) {\n GenericWireType* cursor = elements.data();\n writeGenericWireTypes(cursor, std::forward<Args>(args)...);\n }\n\n operator EM_VAR_ARGS() const {\n return elements.data();\n }\n\nprivate:\n std::array<GenericWireType, PackSize<Args...>::value> elements;\n};\n\n} // end namespace internal\n\n#define EMSCRIPTEN_SYMBOL(name) \\\nstatic const char name##_symbol[] = #name; \\\nstatic const ::emscripten::internal::symbol_registrar<name##_symbol> name##_registrar\n\nclass EMBIND_VISIBILITY_DEFAULT val {\npublic:\n // missing operators:\n // * ~ - + ++ --\n // * * / %\n // * + -\n // * << >> >>>\n // * & ^ | && || ?:\n //\n // exposing void, comma, and conditional is unnecessary\n // same with: = += -= *= /= %= <<= >>= >>>= &= ^= |=\n\n static val array() {\n return val(internal::_emval_new_array());\n }\n\n template<typename Iter>\n static val array(Iter begin, Iter end) {\n#if __cplusplus >= 202002L\n if constexpr (std::contiguous_iterator<Iter> &&\n internal::typeSupportsMemoryView<\n typename std::iterator_traits<Iter>::value_type>()) {\n val view{ typed_memory_view(std::distance(begin, end), std::to_address(begin)) };\n return val(internal::_emval_new_array_from_memory_view(view.as_handle()));\n }\n // For numeric arrays, following codes are unreachable and the compiler\n // will do 'dead code elimination'.\n // Others fallback old way.\n#endif\n val new_array = array();\n for (auto it = begin; it != end; ++it) {\n new_array.call<void>(\"push\", *it);\n }\n return new_array;\n }\n\n template<typename T>\n static val array(const std::vector<T>& vec) {\n if constexpr (internal::typeSupportsMemoryView<T>()) {\n // for numeric types, pass memory view and copy in JS side one-off\n val view{ typed_memory_view(vec.size(), vec.data()) };\n return val(internal::_emval_new_array_from_memory_view(view.as_handle()));\n } else {\n return array(vec.begin(), vec.end());\n }\n }\n\n static val object() {\n return val(internal::_emval_new_object());\n }\n\n static val u8string(const char* s) {\n return val(internal::_emval_new_u8string(s));\n }\n\n static val u16string(const char16_t* s) {\n return val(internal::_emval_new_u16string(s));\n }\n\n static val undefined() {\n return val(EM_VAL(internal::_EMVAL_UNDEFINED));\n }\n\n static val null() {\n return val(EM_VAL(internal::_EMVAL_NULL));\n }\n\n static val take_ownership(EM_VAL e) {\n return val(e);\n }\n\n static val global(const char* name = 0) {\n return val(internal::_emval_get_global(name));\n }\n\n static val module_property(const char* name) {\n return val(internal::_emval_get_module_property(name));\n }\n\n template<typename T, typename... Policies>\n explicit val(T&& value, Policies...) {\n using namespace internal;\n\n new (this) val(internalCallWithPolicy<EM_INVOKER_KIND::CAST, WithPolicies<Policies...>, val>(nullptr, nullptr, std::forward<T>(value)));\n }\n\n val() : val(EM_VAL(internal::_EMVAL_UNDEFINED)) {}\n\n explicit val(const char* v)\n : val(internal::_emval_new_cstring(v))\n {}\n\n // Note: unlike other constructors, this doesn't use as_handle() because\n // it just moves a value and doesn't need to go via incref/decref.\n // This means it's safe to move values across threads - an error will\n // only arise if you access or free it from the wrong thread later.\n val(val&& v) : handle(v.handle), thread(v.thread) {\n v.handle = 0;\n }\n\n val(const val& v) : val(v.as_handle()) {\n if (uses_ref_count()) {\n internal::_emval_incref(handle);\n }\n }\n\n // Add an explicit overload for `val&` as well.\n // Without it, C++ will try to use the `T&&` constructor instead of the more\n // efficient `val(const val&)` when trying to copy a `val` instance.\n val(val& v) : val(static_cast<const val&>(v)) {}\n\n ~val() {\n if (uses_ref_count()) {\n internal::_emval_decref(as_handle());\n handle = 0;\n }\n }\n\n EM_VAL as_handle() const {\n#ifdef _REENTRANT\n assert(pthread_equal(thread, pthread_self()) && \"val accessed from wrong thread\");\n#endif\n return handle;\n }\n\n // Takes ownership of the handle away from, and invalidates, this instance.\n EM_VAL release_ownership() {\n EM_VAL taken = as_handle();\n handle = 0;\n return taken;\n }\n\n val& operator=(val&& v) & {\n val tmp(std::move(v));\n this->~val();\n new (this) val(std::move(tmp));\n return *this;\n }\n\n val& operator=(const val& v) & {\n return *this = val(v);\n }\n\n bool hasOwnProperty(const char* key) const {\n return val::global(\"Object\")[\"prototype\"][\"hasOwnProperty\"].call<bool>(\"call\", *this, val(key));\n }\n\n bool isNull() const {\n return as_handle() == EM_VAL(internal::_EMVAL_NULL);\n }\n\n bool isUndefined() const {\n return as_handle() == EM_VAL(internal::_EMVAL_UNDEFINED);\n }\n\n bool isTrue() const {\n return as_handle() == EM_VAL(internal::_EMVAL_TRUE);\n }\n\n bool isFalse() const {\n return as_handle() == EM_VAL(internal::_EMVAL_FALSE);\n }\n\n bool isNumber() const {\n return internal::_emval_is_number(as_handle());\n }\n\n bool isString() const {\n return internal::_emval_is_string(as_handle());\n }\n\n bool isArray() const {\n return instanceof(global(\"Array\"));\n }\n\n bool equals(const val& v) const {\n return internal::_emval_equals(as_handle(), v.as_handle());\n }\n\n bool operator==(const val& v) const {\n return equals(v);\n }\n\n bool operator!=(const val& v) const {\n return !equals(v);\n }\n\n bool strictlyEquals(const val& v) const {\n return internal::_emval_strictly_equals(as_handle(), v.as_handle());\n }\n\n bool operator>(const val& v) const {\n return internal::_emval_greater_than(as_handle(), v.as_handle());\n }\n\n bool operator>=(const val& v) const {\n return (*this > v) || (*this == v);\n }\n\n bool operator<(const val& v) const {\n return internal::_emval_less_than(as_handle(), v.as_handle());\n }\n\n bool operator<=(const val& v) const {\n return (*this < v) || (*this == v);\n }\n\n bool operator!() const {\n return internal::_emval_not(as_handle());\n }\n\n template<typename T>\n val operator[](const T& key) const {\n return val(internal::_emval_get_property(as_handle(), val_ref(key).as_handle()));\n }\n\n template<typename K, typename V, typename... Policies>\n void set(const K& key, const V& value, Policies... policies) {\n internal::_emval_set_property(as_handle(), val_ref(key).as_handle(), val_ref(value, policies...).as_handle());\n }\n\n template<typename T>\n bool delete_(const T& property) const {\n return internal::_emval_delete(as_handle(), val_ref(property).as_handle());\n }\n\n template<typename... Args>\n val new_(Args&&... args) const {\n using namespace internal;\n\n return internalCall<EM_INVOKER_KIND::CONSTRUCTOR, val>(as_handle(), nullptr, std::forward<Args>(args)...);\n }\n\n template<typename... Args>\n val operator()(Args&&... args) const {\n using namespace internal;\n\n return internalCall<EM_INVOKER_KIND::FUNCTION, val>(as_handle(), nullptr, std::forward<Args>(args)...);\n }\n\n template<typename ReturnValue, typename... Args>\n ReturnValue call(const char* name, Args&&... args) const {\n using namespace internal;\n\n return internalCall<EM_INVOKER_KIND::METHOD, ReturnValue>(as_handle(), name, std::forward<Args>(args)...);\n }\n\n template<typename T, typename ...Policies>\n T as(Policies...) const {\n using namespace internal;\n\n return internalCallWithPolicy<EM_INVOKER_KIND::CAST, WithPolicies<Policies...>, T>(as_handle(), nullptr, *this);\n }\n\n// Prefer calling val::typeOf() over val::typeof(), since this form works in both C++11 and GNU++11 build modes. \"typeof\" is a reserved word in GNU++11 extensions.\n val typeOf() const {\n return val(internal::_emval_typeof(as_handle()));\n }\n\n// If code is not being compiled with GNU extensions enabled, typeof() is a valid identifier, so support that as a member function.\n#if __is_identifier(typeof)\n [[deprecated(\"Use typeOf() instead.\")]]\n val typeof() const {\n return typeOf();\n }\n#endif\n\n bool instanceof(const val& v) const {\n return internal::_emval_instanceof(as_handle(), v.as_handle());\n }\n\n bool in(const val& v) const {\n return internal::_emval_in(as_handle(), v.as_handle());\n }\n\n [[noreturn]] void throw_() const {\n internal::_emval_throw(as_handle());\n }\n\n val await() const {\n return val(internal::_emval_await(as_handle()));\n }\n\n struct iterator;\n\n iterator begin() const;\n // our iterators are sentinel-based range iterators; use nullptr as the end sentinel\n constexpr nullptr_t end() const { return nullptr; }\n\n#if __cplusplus >= 202002L\n class awaiter;\n awaiter operator co_await() const;\n\n class promise_type;\n#endif\n\nprivate:\n // takes ownership, assumes handle already incref'd and lives on the same thread\n explicit val(EM_VAL handle)\n : handle(handle), thread(pthread_self())\n {}\n\n // Whether this value is a uses incref/decref (true) or is a special reserved\n // value (false).\n bool uses_ref_count() const {\n return handle > reinterpret_cast<EM_VAL>(internal::_EMVAL_LAST_RESERVED_HANDLE);\n }\n\n template<typename WrapperType>\n friend val internal::wrapped_extend(const std::string& , const val& );\n\n template<internal::EM_INVOKER_KIND Kind, typename Ret, typename... Args>\n static Ret internalCall(EM_VAL handle, const char *methodName, Args&&... args) {\n using namespace internal;\n#if __cplusplus >= 201703L\n using Policy = WithPolicies<FilterTypes<isPolicy, Args...>>;\n auto filteredArgs = Filter<isNotPolicy>(args...);\n return std::apply(\n [&](auto&&... actualArgs) -> decltype(auto) {\n return internalCallWithPolicy<Kind, Policy, Ret>(handle, methodName, std::forward<decltype(actualArgs)>(actualArgs)...);\n },\n filteredArgs\n );\n#else\n // When std::apply is not available allow pointers by default. std::apply\n // could be polyfilled, but it requires a lot of code.\n static_assert(internal::conjunction<internal::isNotPolicy<Args>...>::value, \"Using pointer policies with val requires C++17 or newer.\");\n return internalCallWithPolicy<Kind, WithPolicies<allow_raw_pointers>, Ret>(handle, methodName, std::forward<decltype(args)>(args)...);\n#endif\n }\n\n template<internal::EM_INVOKER_KIND Kind, typename Policy, typename Ret, typename... Args>\n static Ret internalCallWithPolicy(EM_VAL handle, const char *methodName, Args&&... args) {\n using namespace internal;\n\n using RetWire = BindingType<Ret>::WireType;\n\n static constexpr typename Policy::template ArgTypeList<Ret, Args...> argTypes;\n thread_local EM_INVOKER mc = _emval_create_invoker(argTypes.getCount(), argTypes.getTypes(), Kind);\n\n WireTypePack<Args...> argv(std::forward<Args>(args)...);\n EM_DESTRUCTORS destructors = nullptr;\n\n RetWire result;\n if constexpr (std::is_integral<RetWire>::value && sizeof(RetWire) == 8) {\n // 64-bit integers can't go through \"generic wire type\" because double and int64 have different ABI.\n result = static_cast<RetWire>(_emval_invoke_i64(\n mc,\n handle,\n methodName,\n &destructors,\n argv));\n } else {\n result = GenericWireTypeConverter<RetWire>::from(_emval_invoke(\n mc,\n handle,\n methodName,\n &destructors,\n argv));\n }\n DestructorsRunner rd(destructors);\n return BindingType<Ret>::fromWireType(result);\n }\n\n template<typename T, typename... Policies>\n val val_ref(const T& v, Policies... policies) const {\n return val(v, policies...);\n }\n\n const val& val_ref(const val& v) const {\n return v;\n }\n\n pthread_t thread;\n EM_VAL handle;\n\n template <typename T, typename>\n friend struct ::emscripten::internal::BindingType;\n};\n\nstruct val::iterator {\n iterator() = delete;\n // Make sure iterator is only moveable, not copyable as it represents a mutable state.\n iterator(iterator&&) = default;\n iterator(const val& v) : iter(internal::_emval_iter_begin(v.as_handle())) {\n this->operator++();\n }\n val&& operator*() { return std::move(cur_value); }\n const val& operator*() const { return cur_value; }\n void operator++() { cur_value = val(internal::_emval_iter_next(iter.as_handle())); }\n bool operator!=(nullptr_t) const { return cur_value.as_handle() != nullptr; }\n\nprivate:\n val iter;\n val cur_value;\n};\n\ninline val::iterator val::begin() const {\n return iterator(*this);\n}\n\n#if __cplusplus >= 202002L\n// Awaiter defines a set of well-known methods that compiler uses\n// to drive the argument of the `co_await` operator (regardless\n// of the type of the parent coroutine).\n// This one is used for Promises represented by the `val` type.\nclass val::awaiter {\n // State machine holding awaiter's current state. One of:\n // - initially created with promise\n // - waiting with a given coroutine handle\n // - completed with a result\n std::variant<val, std::coroutine_handle<val::promise_type>, val> state;\n\n constexpr static std::size_t STATE_PROMISE = 0;\n constexpr static std::size_t STATE_CORO = 1;\n constexpr static std::size_t STATE_RESULT = 2;\n\npublic:\n awaiter(const val& promise)\n : state(std::in_place_index<STATE_PROMISE>, promise) {}\n\n // just in case, ensure nobody moves / copies this type around\n awaiter(awaiter&&) = delete;\n\n // Promises don't have a synchronously accessible \"ready\" state.\n bool await_ready() { return false; }\n\n // On suspend, store the coroutine handle and invoke a helper that will do\n // a rough equivalent of\n // `promise.then(value => this.resume_with(value)).catch(error => this.reject_with(error))`.\n void await_suspend(std::coroutine_handle<val::promise_type> handle) {\n internal::_emval_coro_suspend(std::get<STATE_PROMISE>(state).as_handle(), this);\n state.emplace<STATE_CORO>(handle);\n }\n\n // When JS invokes `resume_with` with some value, store that value and resume\n // the coroutine.\n void resume_with(val&& result) {\n auto coro = std::move(std::get<STATE_CORO>(state));\n state.emplace<STATE_RESULT>(std::move(result));\n coro.resume();\n }\n\n // When JS invokes `reject_with` with some error value, reject currently suspended\n // coroutine's promise with the error value and destroy coroutine frame, because\n // in this scenario coroutine never reaches final_suspend point to be destroyed automatically.\n void reject_with(val&& error);\n\n // `await_resume` finalizes the awaiter and should return the result\n // of the `co_await ...` expression - in our case, the stored value.\n val await_resume() {\n return std::move(std::get<STATE_RESULT>(state));\n }\n};\n\ninline val::awaiter val::operator co_await() const {\n return {*this};\n}\n\n// `promise_type` is a well-known subtype with well-known method names\n// that compiler uses to drive the coroutine itself\n// (`T::promise_type` is used for any coroutine with declared return type `T`).\nclass val::promise_type {\n val promise, resolve, reject;\n\npublic:\n // Create a `new Promise` and store it alongside the `resolve` and `reject`\n // callbacks that can be used to fulfill it.\n promise_type() {\n EM_VAL resolve_handle;\n EM_VAL reject_handle;\n promise = val(internal::_emval_coro_make_promise(&resolve_handle, &reject_handle));\n resolve = val(resolve_handle);\n reject = val(reject_handle);\n }\n\n // Return the stored promise as the actual return value of the coroutine.\n val get_return_object() { return promise; }\n\n // For similarity with JS async functions, our coroutines are eagerly evaluated.\n auto initial_suspend() noexcept { return std::suspend_never{}; }\n auto final_suspend() noexcept { return std::suspend_never{}; }\n\n// When exceptions are disabled we don't define unhandled_exception and rely\n// on the default terminate behavior.\n#ifdef __cpp_exceptions\n // On an unhandled exception, reject the stored promise instead of throwing\n // it asynchronously where it can't be handled.\n void unhandled_exception() {\n try {\n std::rethrow_exception(std::current_exception());\n } catch (const val& error) {\n reject(error);\n } catch (...) {\n val error = val(internal::_emval_from_current_cxa_exception());\n reject(error);\n }\n }\n#endif\n\n // Reject the stored promise due to rejection deeper in the call chain\n void reject_with(val&& error) {\n reject(std::move(error));\n }\n\n // Resolve the stored promise on `co_return value`.\n template<typename T>\n void return_value(T&& value) {\n resolve(std::forward<T>(value));\n }\n};\n\ninline void val::awaiter::reject_with(val&& error) {\n auto coro = std::move(std::get<STATE_CORO>(state));\n auto& promise = coro.promise();\n promise.reject_with(std::move(error));\n coro.destroy();\n}\n\n#endif\n\n// Declare a custom type that can be used in conjunction with\n// emscripten::register_type to emit custom TypeScript definitions for val\n// types.\n#define EMSCRIPTEN_DECLARE_VAL_TYPE(name) \\\nstruct name : public ::emscripten::val { \\\n explicit name(val const &other) : val(other) {} \\\n};\n\nnamespace internal {\n\ntemplate<typename T>\nstruct BindingType<T, typename std::enable_if<std::is_base_of<val, T>::value &&\n !std::is_const<T>::value>::type> {\n typedef EM_VAL WireType;\n\n // Marshall to JS with move semantics when we can invalidate the temporary val\n // object.\n static WireType toWireType(val&& v, rvp::default_tag) {\n return v.release_ownership();\n }\n\n // Marshal to JS with copy semantics when we cannot transfer the val objects\n // reference count.\n static WireType toWireType(const val& v, rvp::default_tag) {\n EM_VAL handle = v.as_handle();\n if (v.uses_ref_count()) {\n _emval_incref(handle);\n }\n return handle;\n }\n static T fromWireType(WireType v) {\n return T(val::take_ownership(v));\n }\n};\n\n}\n\ntemplate <typename T, typename... Policies>\nstd::vector<T> vecFromJSArray(const val& v, Policies... policies) {\n const uint32_t l = v[\"length\"].as<uint32_t>();\n\n std::vector<T> rv;\n rv.reserve(l);\n for (uint32_t i = 0; i < l; ++i) {\n rv.push_back(v[i].as<T>(std::forward<Policies>(policies)...));\n }\n\n return rv;\n}\n\ntemplate <typename T>\nstd::vector<T> convertJSArrayToNumberVector(const val& v) {\n const size_t l = v[\"length\"].as<size_t>();\n\n std::vector<T> rv;\n rv.resize(l);\n\n // Copy the array into our vector through the use of typed arrays.\n // It will try to convert each element through Number().\n // See https://www.ecma-international.org/ecma-262/6.0/#sec-%typedarray%.prototype.set-array-offset\n // and https://www.ecma-international.org/ecma-262/6.0/#sec-tonumber\n val memoryView{ typed_memory_view(l, rv.data()) };\n internal::_emval_array_to_memory_view(memoryView.as_handle(), v.as_handle());\n\n return rv;\n}\n\n} // end namespace emscripten\n","/*\n * Copyright 2012 The Emscripten Authors. All rights reserved.\n * Emscripten is available under two separate licenses, the MIT license and the\n * University of Illinois/NCSA Open Source License. Both these licenses can be\n * found in the LICENSE file.\n */\n\n#pragma once\n\n#if __cplusplus < 201103L\n#error \"embind requires -std=c++11 or newer\"\n#endif\n\n#if __cplusplus < 201703L\n#warning \"embind is likely moving to c++17 (https://github.com/emscripten-core/emscripten/issues/24850)\"\n#endif\n\n// A value moving between JavaScript and C++ has three representations:\n// - The original JS value: a String\n// - The native on-the-wire value: a stack-allocated char*, say\n// - The C++ value: std::string\n//\n// We'll call the on-the-wire type WireType.\n\n#include <cstdio>\n#include <cstdlib>\n#include <memory>\n#include <string>\n\n#define EMSCRIPTEN_ALWAYS_INLINE __attribute__((always_inline))\n#define EMBIND_VISIBILITY_DEFAULT __attribute__((visibility(\"default\")))\n\n#ifndef EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES\n#define EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES 1\n#endif\n\nnamespace emscripten {\n\n#if EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES\nconstexpr bool has_unbound_type_names = true;\n#else\nconstexpr bool has_unbound_type_names = false;\n#endif\n\nnamespace internal {\n\ntypedef const void* TYPEID;\n\n// We don't need the full std::type_info implementation. We\n// just need a unique identifier per type and polymorphic type\n// identification.\n\ntemplate<typename T>\nstatic inline constexpr bool IsCanonicalized = std::is_same<T, typename std::decay<T>::type>::value;\n\ntemplate<typename T>\nstruct CanonicalizedID {\n static_assert(IsCanonicalized<T>, \"T should not be a reference or cv-qualified\");\n static char c;\n static constexpr TYPEID get() {\n return &c;\n }\n};\n\ntemplate<typename T>\nchar CanonicalizedID<T>::c;\n\ntemplate<typename T>\nstruct Canonicalized {\n typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type type;\n};\n\ntemplate<typename T>\nstruct LightTypeID {\n static constexpr TYPEID get() {\n static_assert(IsCanonicalized<T>, \"T should not be a reference or cv-qualified\");\n if (has_unbound_type_names) {\n#if __has_feature(cxx_rtti)\n return &typeid(T);\n#else\n static_assert(!has_unbound_type_names,\n \"Unbound type names are illegal with RTTI disabled. \"\n \"Either add -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 to or remove -fno-rtti \"\n \"from the compiler arguments\");\n#endif\n }\n\n typedef typename Canonicalized<T>::type C;\n return CanonicalizedID<C>::get();\n }\n};\n\ntemplate<typename T>\nconstexpr TYPEID getLightTypeID(const T& value) {\n static_assert(IsCanonicalized<T>, \"T should not be a reference or cv-qualified\");\n if (has_unbound_type_names) {\n#if __has_feature(cxx_rtti)\n return &typeid(value);\n#else\n static_assert(!has_unbound_type_names,\n \"Unbound type names are illegal with RTTI disabled. \"\n \"Either add -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 to or remove -fno-rtti \"\n \"from the compiler arguments\");\n#endif\n }\n return LightTypeID<T>::get();\n}\n\n// The second typename is an unused stub so it's possible to\n// specialize groups of classes via SFINAE.\ntemplate<typename T, typename = void>\nstruct TypeID {\n static constexpr TYPEID get() {\n return LightTypeID<T>::get();\n }\n};\n\ntemplate<typename T>\nstruct TypeID<std::unique_ptr<T>> {\n static_assert(std::is_class<T>::value, \"The type for a std::unique_ptr binding must be a class.\");\n static constexpr TYPEID get() {\n return TypeID<T>::get();\n }\n};\n\ntemplate<typename T>\nstruct TypeID<T*> {\n static_assert(!std::is_pointer<T*>::value, \"Implicitly binding raw pointers is illegal. Specify allow_raw_pointer<arg<?>>\");\n};\n\nnamespace rvp {\n\nstruct default_tag {};\nstruct take_ownership : public default_tag {};\nstruct reference : public default_tag {};\n\n} // end namespace rvp\n\ntemplate<typename T>\nstruct AllowedRawPointer {\n};\n\ntemplate<typename T>\nstruct TypeID<AllowedRawPointer<T>> {\n static constexpr TYPEID get() {\n return LightTypeID<T*>::get();\n }\n};\n\ntemplate<typename T>\nstruct TypeID<const T> : TypeID<T> {\n};\n\ntemplate<typename T>\nstruct TypeID<T&> : TypeID<T> {\n};\n\ntemplate<typename T>\nstruct TypeID<T&&> : TypeID<T> {\n};\n\n// ExecutePolicies<>\n\ntemplate<typename... Policies>\nstruct ExecutePolicies;\n\ntemplate<>\nstruct ExecutePolicies<> {\n template<typename T, int Index>\n struct With {\n typedef T type;\n };\n};\n\ntemplate<typename Policy, typename... Remaining>\nstruct ExecutePolicies<Policy, Remaining...> {\n template<typename T, int Index>\n struct With {\n typedef typename Policy::template Transform<\n typename ExecutePolicies<Remaining...>::template With<T, Index>::type,\n Index\n >::type type;\n };\n};\n\n// TypeList<>\n\ntemplate<typename...>\nstruct TypeList {};\n\n// Cons :: T, TypeList<types...> -> Cons<T, types...>\n\ntemplate<typename First, typename TypeList>\nstruct Cons;\n\ntemplate<typename First, typename... Rest>\nstruct Cons<First, TypeList<Rest...>> {\n typedef TypeList<First, Rest...> type;\n};\n\n// Apply :: T, TypeList<types...> -> T<types...>\n\ntemplate<template<typename...> class Output, typename TypeList>\nstruct Apply;\n\ntemplate<template<typename...> class Output, typename... Types>\nstruct Apply<Output, TypeList<Types...>> {\n typedef Output<Types...> type;\n};\n\n// MapWithIndex_\n\ntemplate<template<size_t, typename> class Mapper, size_t CurrentIndex, typename... Args>\nstruct MapWithIndex_;\n\ntemplate<template<size_t, typename> class Mapper, size_t CurrentIndex, typename First, typename... Rest>\nstruct MapWithIndex_<Mapper, CurrentIndex, First, Rest...> {\n typedef typename Cons<\n typename Mapper<CurrentIndex, First>::type,\n typename MapWithIndex_<Mapper, CurrentIndex + 1, Rest...>::type\n >::type type;\n};\n\ntemplate<template<size_t, typename> class Mapper, size_t CurrentIndex>\nstruct MapWithIndex_<Mapper, CurrentIndex> {\n typedef TypeList<> type;\n};\n\ntemplate<template<typename...> class Output, template<size_t, typename> class Mapper, typename... Args>\nstruct MapWithIndex {\n typedef typename internal::Apply<\n Output,\n typename MapWithIndex_<Mapper, 0, Args...>::type\n >::type type;\n};\n\n\ntemplate<typename ArgList>\nstruct ArgArrayGetter;\n\ntemplate<typename... Args>\nstruct ArgArrayGetter<TypeList<Args...>> {\n static const TYPEID* get() {\n static constexpr TYPEID types[] = { TypeID<Args>::get()... };\n return types;\n }\n};\n\n// WithPolicies<...>::ArgTypeList<...>\n\ntemplate<typename... Policies>\nstruct WithPolicies {\n template<size_t Index, typename T>\n struct MapWithPolicies {\n typedef typename ExecutePolicies<Policies...>::template With<T, Index>::type type;\n };\n\n template<typename... Args>\n struct ArgTypeList {\n unsigned getCount() const {\n return sizeof...(Args);\n }\n\n const TYPEID* getTypes() const {\n return ArgArrayGetter<\n typename MapWithIndex<TypeList, MapWithPolicies, Args...>::type\n >::get();\n }\n };\n};\n\ntemplate<typename... Policies>\nstruct WithPolicies<std::tuple<Policies...>> : WithPolicies<Policies...> {};\n\n// BindingType<T>\n\n// The second typename is an unused stub so it's possible to\n// specialize groups of classes via SFINAE.\ntemplate<typename T, typename = void>\nstruct BindingType;\n\n#define EMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(type) \\\ntemplate<> \\\nstruct BindingType<type> { \\\n typedef type WireType; \\\n constexpr static WireType toWireType(const type& v, rvp::default_tag) { \\\n return v; \\\n } \\\n constexpr static type fromWireType(WireType v) { \\\n return v; \\\n } \\\n}\n\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(char);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(signed char);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(unsigned char);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(signed short);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(unsigned short);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(signed int);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(unsigned int);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(signed long);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(unsigned long);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(float);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(double);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(int64_t);\nEMSCRIPTEN_DEFINE_NATIVE_BINDING_TYPE(uint64_t);\n\ntemplate<>\nstruct BindingType<void> {\n // Using empty struct instead of void is ABI-compatible, but makes it easier\n // to work with wire types in a generic template context, as void can't be\n // stored in local variables or passed around but empty struct can.\n // TODO: switch to std::monostate when we require C++17.\n struct WireType {};\n\n static void fromWireType(WireType) {\n // No-op, as void has no value.\n }\n};\n\ntemplate<>\nstruct BindingType<bool> {\n typedef bool WireType;\n static WireType toWireType(bool b, rvp::default_tag) {\n return b;\n }\n static bool fromWireType(WireType wt) {\n return wt;\n }\n};\n\ntemplate<typename T>\nstruct BindingType<std::basic_string<T>> {\n using String = std::basic_string<T>;\n static_assert(std::is_trivially_copyable<T>::value, \"basic_string elements are memcpy'd\");\n typedef struct {\n size_t length;\n T data[1]; // trailing data\n }* WireType;\n static WireType toWireType(const String& v, rvp::default_tag) {\n WireType wt = (WireType)malloc(sizeof(size_t) + v.length() * sizeof(T));\n wt->length = v.length();\n memcpy(wt->data, v.data(), v.length() * sizeof(T));\n return wt;\n }\n static String fromWireType(WireType v) {\n return String(v->data, v->length);\n }\n};\n\ntemplate<typename T>\nstruct BindingType<const T> : public BindingType<T> {\n};\n\ntemplate<typename T>\nstruct BindingType<T&> : public BindingType<T> {\n};\n\ntemplate<typename T>\nstruct BindingType<T&&> {\n typedef typename BindingType<T>::WireType WireType;\n static T fromWireType(WireType wt) {\n return BindingType<T>::fromWireType(wt);\n }\n};\n\ntemplate<typename T>\nstruct BindingType<T*> {\n typedef T* WireType;\n\n static WireType toWireType(T* p, rvp::default_tag) {\n return p;\n }\n\n static WireType toWireType(T* p, rvp::take_ownership) {\n return p;\n }\n\n static WireType toWireType(T* p, rvp::reference) {\n return p;\n }\n\n static T* fromWireType(WireType wt) {\n return wt;\n }\n};\n\ntemplate<typename T>\nstruct GenericBindingType {\n typedef typename std::remove_reference<T>::type ActualT;\n typedef ActualT* WireType;\n\n template<typename R>\n static WireType toWireType(R&& v, rvp::default_tag) {\n return new ActualT(v);\n }\n\n template<typename R>\n static WireType toWireType(R&& v, rvp::take_ownership) {\n return new ActualT(std::move(v));\n }\n\n template<typename R>\n static WireType toWireType(R&& v, rvp::reference) {\n return &v;\n }\n\n static ActualT& fromWireType(WireType p) {\n return *p;\n }\n};\n\ntemplate<typename T>\nstruct GenericBindingType<std::unique_ptr<T>> {\n typedef typename BindingType<T*>::WireType WireType;\n\n static WireType toWireType(std::unique_ptr<T> p, rvp::default_tag) {\n return BindingType<T*>::toWireType(p.release(), rvp::default_tag{});\n }\n\n static std::unique_ptr<T> fromWireType(WireType wt) {\n return std::unique_ptr<T>(BindingType<T*>::fromWireType(wt));\n }\n};\n\ntemplate<typename Enum>\nstruct EnumBindingType {\n typedef Enum WireType;\n\n static WireType toWireType(Enum v, rvp::default_tag) {\n return v;\n }\n static Enum fromWireType(WireType v) {\n return v;\n }\n};\n\n// catch-all generic binding\ntemplate<typename T, typename>\nstruct BindingType : std::conditional<\n std::is_enum<T>::value,\n EnumBindingType<T>,\n GenericBindingType<T> >::type\n{};\n\ntemplate<typename T>\nauto toWireType(T&& v) -> typename BindingType<T>::WireType {\n return BindingType<T>::toWireType(std::forward<T>(v));\n}\n\ntemplate<typename T>\nconstexpr bool typeSupportsMemoryView() {\n return (std::is_floating_point<T>::value &&\n (sizeof(T) == 4 || sizeof(T) == 8)) ||\n (std::is_integral<T>::value &&\n (sizeof(T) == 1 || sizeof(T) == 2 ||\n sizeof(T) == 4 || sizeof(T) == 8));\n}\n\n} // namespace internal\n\ntemplate<typename ElementType>\nstruct EMBIND_VISIBILITY_DEFAULT memory_view {\n memory_view() = delete;\n explicit memory_view(size_t size, const ElementType* data)\n : size(size)\n , data(data)\n {}\n\n const size_t size; // in elements, not bytes\n const void* const data;\n};\n\n// Note that 'data' is marked const just so it can accept both\n// const and nonconst pointers. It is certainly possible for\n// JavaScript to modify the C heap through the typed array given,\n// as it merely aliases the C heap.\ntemplate<typename T>\ninline memory_view<T> typed_memory_view(size_t size, const T* data) {\n static_assert(internal::typeSupportsMemoryView<T>(),\n \"type of typed_memory_view is invalid\");\n return memory_view<T>(size, data);\n}\n\nnamespace internal {\n\ntemplate<typename ElementType>\nstruct BindingType<memory_view<ElementType>> {\n // This non-word-sized WireType only works because I\n // happen to know that clang will pass aggregates as\n // pointers to stack elements and we never support\n // converting JavaScript typed arrays back into\n // memory_view. (That is, fromWireType is not implemented\n // on the C++ side, nor is toWireType implemented in\n // JavaScript.)\n typedef memory_view<ElementType> WireType;\n static WireType toWireType(const memory_view<ElementType>& mv, rvp::default_tag) {\n return mv;\n }\n};\n\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// POLICIES\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<int Index>\nstruct arg {\n static constexpr int index = Index + 1;\n};\n\nstruct ret_val {\n static constexpr int index = 0;\n};\n\n/*\ntemplate<typename Slot>\nstruct allow_raw_pointer {\n template<typename InputType, int Index>\n struct Transform {\n typedef typename std::conditional<\n Index == Slot::index,\n internal::AllowedRawPointer<typename std::remove_pointer<InputType>::type>,\n InputType\n >::type type;\n };\n};\n*/\n\n// allow all raw pointers\nstruct allow_raw_pointers {\n template<typename InputType, int Index>\n struct Transform {\n // Use decay to handle references to pointers e.g.(T*&)->(T*).\n typedef typename std::decay<InputType>::type DecayedType;\n typedef typename std::conditional<\n std::is_pointer<DecayedType>::value,\n internal::AllowedRawPointer<typename std::remove_pointer<DecayedType>::type>,\n InputType\n >::type type;\n };\n};\n\n// this is temporary until arg policies are reworked\ntemplate<typename Slot>\nstruct allow_raw_pointer : public allow_raw_pointers {\n};\n\nstruct async {\n template<typename InputType, int Index>\n struct Transform {\n typedef InputType type;\n };\n};\n\nstruct pure_virtual {\n template<typename InputType, int Index>\n struct Transform {\n typedef InputType type;\n };\n};\n\ntemplate<typename Slot>\nstruct nonnull {\n static_assert(std::is_same<Slot, ret_val>::value, \"Only nonnull return values are currently supported.\");\n template<typename InputType, int Index>\n struct Transform {\n typedef InputType type;\n };\n};\n\nnamespace return_value_policy {\n\nstruct take_ownership : public allow_raw_pointers {};\nstruct reference : public allow_raw_pointers {};\n\n} // end namespace return_value_policy\n\nnamespace internal {\n\n#if __cplusplus >= 201703L\ntemplate <typename... Args> using conjunction = std::conjunction<Args...>;\ntemplate <typename... Args> using disjunction = std::disjunction<Args...>;\n#else\n// Helper available in C++14.\ntemplate <bool _Test, class _T1, class _T2>\nusing conditional_t = typename std::conditional<_Test, _T1, _T2>::type;\n\ntemplate<class...> struct conjunction : std::true_type {};\ntemplate<class B1> struct conjunction<B1> : B1 {};\ntemplate<class B1, class... Bn>\nstruct conjunction<B1, Bn...>\n : conditional_t<bool(B1::value), conjunction<Bn...>, B1> {};\n\ntemplate<class...> struct disjunction : std::false_type {};\ntemplate<class B1> struct disjunction<B1> : B1 {};\ntemplate<class B1, class... Bn>\nstruct disjunction<B1, Bn...>\n : conditional_t<bool(B1::value), disjunction<Bn...>, B1> {};\n#endif\n\ntemplate<typename... Policies>\nstruct isPolicy;\n\ntemplate<typename... Rest>\nstruct isPolicy<return_value_policy::take_ownership, Rest...> {\n static constexpr bool value = true;\n};\n\ntemplate<typename... Rest>\nstruct isPolicy<return_value_policy::reference, Rest...> {\n static constexpr bool value = true;\n};\n\ntemplate<typename... Rest>\nstruct isPolicy<emscripten::async, Rest...> {\n static constexpr bool value = true;\n};\n\ntemplate <typename T, typename... Rest>\nstruct isPolicy<emscripten::allow_raw_pointer<T>, Rest...> {\n static constexpr bool value = true;\n};\n\ntemplate<typename... Rest>\nstruct isPolicy<allow_raw_pointers, Rest...> {\n static constexpr bool value = true;\n};\n\ntemplate<typename... Rest>\nstruct isPolicy<emscripten::pure_virtual, Rest...> {\n static constexpr bool value = true;\n};\n\ntemplate<typename T, typename... Rest>\nstruct isPolicy<emscripten::nonnull<T>, Rest...> {\n static constexpr bool value = true;\n};\n\ntemplate<typename T, typename... Rest>\nstruct isPolicy<T, Rest...> {\n static constexpr bool value = isPolicy<Rest...>::value;\n};\n\ntemplate<>\nstruct isPolicy<> {\n static constexpr bool value = false;\n};\n\ntemplate<typename T>\nstruct isNotPolicy {\n static constexpr bool value = !isPolicy<T>::value;\n};\n\ntemplate<typename ReturnType, typename... Rest>\nstruct GetReturnValuePolicy {\n using tag = rvp::default_tag;\n};\n\ntemplate<typename ReturnType, typename... Rest>\nstruct GetReturnValuePolicy<ReturnType, return_value_policy::take_ownership, Rest...> {\n using tag = rvp::take_ownership;\n};\n\ntemplate<typename ReturnType, typename... Rest>\nstruct GetReturnValuePolicy<ReturnType, return_value_policy::reference, Rest...> {\n using tag = rvp::reference;\n};\n\ntemplate<typename ReturnType, typename T, typename... Rest>\nstruct GetReturnValuePolicy<ReturnType, T, Rest...> {\n using tag = GetReturnValuePolicy<ReturnType, Rest...>::tag;\n};\n\ntemplate<typename... Policies>\nusing isAsync = disjunction<std::is_same<async, Policies>...>;\n\ntemplate<typename... Policies>\nusing isNonnullReturn = disjunction<std::is_same<nonnull<ret_val>, Policies>...>;\n\n// Build a tuple type that contains all the types where the predicate is true.\n// e.g. FilterTypes<std::is_integral, int, char, float> would return std::tuple<int, char>.\ntemplate <template <class> class Predicate, class... T>\nusing FilterTypes = decltype(std::tuple_cat(\n std::declval<\n typename std::conditional<\n Predicate<T>::value,\n std::tuple<T>,\n std::tuple<>\n >::type\n >()...\n ));\n\n#if __cplusplus >= 201402L\n// Build a tuple that contains all the args where the predicate is true.\ntemplate<template <class> class Predicate, typename... Args>\nauto Filter(Args&&... args) {\n return std::tuple_cat(\n std::get<Predicate<typename std::decay_t<Args>>::value ? 0 : 1>(\n std::make_tuple(\n [](auto&& arg) { return std::forward_as_tuple(std::forward<decltype(arg)>(arg)); },\n [](auto&&) { return std::tuple<>(); }\n )\n )(std::forward<Args>(args))...\n );\n}\n#endif\n\n} // namespace internal\n\n} // namespace emscripten\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP_STRING\n#define _LIBCPP_STRING\n\n// clang-format off\n\n/*\n string synopsis\n\n#include <compare>\n#include <initializer_list>\n\nnamespace std\n{\n\ntemplate <class stateT>\nclass fpos\n{\nprivate:\n stateT st;\npublic:\n fpos(streamoff = streamoff());\n\n operator streamoff() const;\n\n stateT state() const;\n void state(stateT);\n\n fpos& operator+=(streamoff);\n fpos operator+ (streamoff) const;\n fpos& operator-=(streamoff);\n fpos operator- (streamoff) const;\n};\n\ntemplate <class stateT> streamoff operator-(const fpos<stateT>& x, const fpos<stateT>& y);\n\ntemplate <class stateT> bool operator==(const fpos<stateT>& x, const fpos<stateT>& y);\ntemplate <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT>& y);\n\ntemplate <class charT>\nstruct char_traits\n{\n using char_type = charT;\n using int_type = ...;\n using off_type = streamoff;\n using pos_type = streampos;\n using state_type = mbstate_t;\n using comparison_category = strong_ordering; // Since C++20 only for the specializations\n // char, wchar_t, char8_t, char16_t, and char32_t.\n\n static void assign(char_type& c1, const char_type& c2) noexcept;\n static constexpr bool eq(char_type c1, char_type c2) noexcept;\n static constexpr bool lt(char_type c1, char_type c2) noexcept;\n\n static int compare(const char_type* s1, const char_type* s2, size_t n);\n static size_t length(const char_type* s);\n static const char_type* find(const char_type* s, size_t n, const char_type& a);\n static char_type* move(char_type* s1, const char_type* s2, size_t n);\n static char_type* copy(char_type* s1, const char_type* s2, size_t n);\n static char_type* assign(char_type* s, size_t n, char_type a);\n\n static constexpr int_type not_eof(int_type c) noexcept;\n static constexpr char_type to_char_type(int_type c) noexcept;\n static constexpr int_type to_int_type(char_type c) noexcept;\n static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;\n static constexpr int_type eof() noexcept;\n};\n\ntemplate <> struct char_traits<char>;\ntemplate <> struct char_traits<wchar_t>;\ntemplate <> struct char_traits<char8_t>; // C++20\ntemplate <> struct char_traits<char16_t>;\ntemplate <> struct char_traits<char32_t>;\n\ntemplate<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >\nclass basic_string\n{\npublic:\n// types:\n typedef traits traits_type;\n typedef typename traits_type::char_type value_type;\n typedef Allocator allocator_type;\n typedef typename allocator_type::size_type size_type;\n typedef typename allocator_type::difference_type difference_type;\n typedef typename allocator_type::reference reference;\n typedef typename allocator_type::const_reference const_reference;\n typedef typename allocator_type::pointer pointer;\n typedef typename allocator_type::const_pointer const_pointer;\n typedef implementation-defined iterator;\n typedef implementation-defined const_iterator;\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n\n static const size_type npos = -1;\n\n basic_string()\n noexcept(is_nothrow_default_constructible<allocator_type>::value); // constexpr since C++20\n explicit basic_string(const allocator_type& a); // constexpr since C++20\n basic_string(const basic_string& str); // constexpr since C++20\n basic_string(basic_string&& str)\n noexcept(is_nothrow_move_constructible<allocator_type>::value); // constexpr since C++20\n basic_string(const basic_string& str, size_type pos,\n const allocator_type& a = allocator_type()); // constexpr since C++20\n basic_string(const basic_string& str, size_type pos, size_type n,\n const Allocator& a = Allocator()); // constexpr since C++20\n constexpr basic_string(\n basic_string&& str, size_type pos, const Allocator& a = Allocator()); // since C++23\n constexpr basic_string(\n basic_string&& str, size_type pos, size_type n, const Allocator& a = Allocator()); // since C++23\n template<class T>\n basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17, constexpr since C++20\n template <class T>\n explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17, constexpr since C++20\n basic_string(const value_type* s, const allocator_type& a = allocator_type()); // constexpr since C++20\n basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); // constexpr since C++20\n basic_string(nullptr_t) = delete; // C++23\n basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); // constexpr since C++20\n template<class InputIterator>\n basic_string(InputIterator begin, InputIterator end,\n const allocator_type& a = allocator_type()); // constexpr since C++20\n template<container-compatible-range<charT> R>\n constexpr basic_string(from_range_t, R&& rg, const Allocator& a = Allocator()); // since C++23\n basic_string(initializer_list<value_type>, const Allocator& = Allocator()); // constexpr since C++20\n basic_string(const basic_string&, const Allocator&); // constexpr since C++20\n basic_string(basic_string&&, const Allocator&); // constexpr since C++20\n\n ~basic_string(); // constexpr since C++20\n\n operator basic_string_view<charT, traits>() const noexcept; // constexpr since C++20\n\n basic_string& operator=(const basic_string& str); // constexpr since C++20\n template <class T>\n basic_string& operator=(const T& t); // C++17, constexpr since C++20\n basic_string& operator=(basic_string&& str)\n noexcept(\n allocator_type::propagate_on_container_move_assignment::value ||\n allocator_type::is_always_equal::value ); // C++17, constexpr since C++20\n basic_string& operator=(const value_type* s); // constexpr since C++20\n basic_string& operator=(nullptr_t) = delete; // C++23\n basic_string& operator=(value_type c); // constexpr since C++20\n basic_string& operator=(initializer_list<value_type>); // constexpr since C++20\n\n iterator begin() noexcept; // constexpr since C++20\n const_iterator begin() const noexcept; // constexpr since C++20\n iterator end() noexcept; // constexpr since C++20\n const_iterator end() const noexcept; // constexpr since C++20\n\n reverse_iterator rbegin() noexcept; // constexpr since C++20\n const_reverse_iterator rbegin() const noexcept; // constexpr since C++20\n reverse_iterator rend() noexcept; // constexpr since C++20\n const_reverse_iterator rend() const noexcept; // constexpr since C++20\n\n const_iterator cbegin() const noexcept; // constexpr since C++20\n const_iterator cend() const noexcept; // constexpr since C++20\n const_reverse_iterator crbegin() const noexcept; // constexpr since C++20\n const_reverse_iterator crend() const noexcept; // constexpr since C++20\n\n size_type size() const noexcept; // constexpr since C++20\n size_type length() const noexcept; // constexpr since C++20\n size_type max_size() const noexcept; // constexpr since C++20\n size_type capacity() const noexcept; // constexpr since C++20\n\n void resize(size_type n, value_type c); // constexpr since C++20\n void resize(size_type n); // constexpr since C++20\n\n template<class Operation>\n constexpr void resize_and_overwrite(size_type n, Operation op); // since C++23\n\n void reserve(size_type res_arg); // constexpr since C++20\n void reserve(); // deprecated in C++20, removed in C++26\n void shrink_to_fit(); // constexpr since C++20\n void clear() noexcept; // constexpr since C++20\n bool empty() const noexcept; // constexpr since C++20\n\n const_reference operator[](size_type pos) const; // constexpr since C++20\n reference operator[](size_type pos); // constexpr since C++20\n\n const_reference at(size_type n) const; // constexpr since C++20\n reference at(size_type n); // constexpr since C++20\n\n basic_string& operator+=(const basic_string& str); // constexpr since C++20\n template <class T>\n basic_string& operator+=(const T& t); // C++17, constexpr since C++20\n basic_string& operator+=(const value_type* s); // constexpr since C++20\n basic_string& operator+=(value_type c); // constexpr since C++20\n basic_string& operator+=(initializer_list<value_type>); // constexpr since C++20\n\n basic_string& append(const basic_string& str); // constexpr since C++20\n template <class T>\n basic_string& append(const T& t); // C++17, constexpr since C++20\n basic_string& append(const basic_string& str, size_type pos, size_type n=npos); // C++14, constexpr since C++20\n template <class T>\n basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20\n basic_string& append(const value_type* s, size_type n); // constexpr since C++20\n basic_string& append(const value_type* s); // constexpr since C++20\n basic_string& append(size_type n, value_type c); // constexpr since C++20\n template<class InputIterator>\n basic_string& append(InputIterator first, InputIterator last); // constexpr since C++20\n template<container-compatible-range<charT> R>\n constexpr basic_string& append_range(R&& rg); // C++23\n basic_string& append(initializer_list<value_type>); // constexpr since C++20\n\n void push_back(value_type c); // constexpr since C++20\n void pop_back(); // constexpr since C++20\n reference front(); // constexpr since C++20\n const_reference front() const; // constexpr since C++20\n reference back(); // constexpr since C++20\n const_reference back() const; // constexpr since C++20\n\n basic_string& assign(const basic_string& str); // constexpr since C++20\n template <class T>\n basic_string& assign(const T& t); // C++17, constexpr since C++20\n basic_string& assign(basic_string&& str); // constexpr since C++20\n basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14, constexpr since C++20\n template <class T>\n basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20\n basic_string& assign(const value_type* s, size_type n); // constexpr since C++20\n basic_string& assign(const value_type* s); // constexpr since C++20\n basic_string& assign(size_type n, value_type c); // constexpr since C++20\n template<class InputIterator>\n basic_string& assign(InputIterator first, InputIterator last); // constexpr since C++20\n template<container-compatible-range<charT> R>\n constexpr basic_string& assign_range(R&& rg); // C++23\n basic_string& assign(initializer_list<value_type>); // constexpr since C++20\n\n basic_string& insert(size_type pos1, const basic_string& str); // constexpr since C++20\n template <class T>\n basic_string& insert(size_type pos1, const T& t); // constexpr since C++20\n basic_string& insert(size_type pos1, const basic_string& str,\n size_type pos2, size_type n); // constexpr since C++20\n template <class T>\n basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17, constexpr since C++20\n basic_string& insert(size_type pos, const value_type* s, size_type n=npos); // C++14, constexpr since C++20\n basic_string& insert(size_type pos, const value_type* s); // constexpr since C++20\n basic_string& insert(size_type pos, size_type n, value_type c); // constexpr since C++20\n iterator insert(const_iterator p, value_type c); // constexpr since C++20\n iterator insert(const_iterator p, size_type n, value_type c); // constexpr since C++20\n template<class InputIterator>\n iterator insert(const_iterator p, InputIterator first, InputIterator last); // constexpr since C++20\n template<container-compatible-range<charT> R>\n constexpr iterator insert_range(const_iterator p, R&& rg); // C++23\n iterator insert(const_iterator p, initializer_list<value_type>); // constexpr since C++20\n\n basic_string& erase(size_type pos = 0, size_type n = npos); // constexpr since C++20\n iterator erase(const_iterator position); // constexpr since C++20\n iterator erase(const_iterator first, const_iterator last); // constexpr since C++20\n\n basic_string& replace(size_type pos1, size_type n1, const basic_string& str); // constexpr since C++20\n template <class T>\n basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17, constexpr since C++20\n basic_string& replace(size_type pos1, size_type n1, const basic_string& str,\n size_type pos2, size_type n2=npos); // C++14, constexpr since C++20\n template <class T>\n basic_string& replace(size_type pos1, size_type n1, const T& t,\n size_type pos2, size_type n); // C++17, constexpr since C++20\n basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); // constexpr since C++20\n basic_string& replace(size_type pos, size_type n1, const value_type* s); // constexpr since C++20\n basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); // constexpr since C++20\n basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); // constexpr since C++20\n template <class T>\n basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17, constexpr since C++20\n basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n); // constexpr since C++20\n basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s); // constexpr since C++20\n basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); // constexpr since C++20\n template<class InputIterator>\n basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); // constexpr since C++20\n template<container-compatible-range<charT> R>\n constexpr basic_string& replace_with_range(const_iterator i1, const_iterator i2, R&& rg); // C++23\n basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); // constexpr since C++20\n\n size_type copy(value_type* s, size_type n, size_type pos = 0) const; // constexpr since C++20\n basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr in C++20, removed in C++23\n basic_string substr(size_type pos = 0, size_type n = npos) const&; // since C++23\n constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&; // since C++23\n void swap(basic_string& str)\n noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||\n allocator_traits<allocator_type>::is_always_equal::value); // C++17, constexpr since C++20\n\n const value_type* c_str() const noexcept; // constexpr since C++20\n const value_type* data() const noexcept; // constexpr since C++20\n value_type* data() noexcept; // C++17, constexpr since C++20\n\n allocator_type get_allocator() const noexcept; // constexpr since C++20\n\n size_type find(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20\n template <class T>\n size_type find(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20\n size_type find(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20\n size_type find(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20\n size_type find(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20\n\n size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20\n template <class T>\n size_type rfind(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension, constexpr since C++20\n size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20\n size_type rfind(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20\n size_type rfind(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20\n\n size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20\n template <class T>\n size_type find_first_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20\n size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20\n size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20\n size_type find_first_of(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20\n\n size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20\n template <class T>\n size_type find_last_of(const T& t, size_type pos = npos) const noexcept noexcept; // C++17, noexcept as an extension, constexpr since C++20\n size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20\n size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20\n size_type find_last_of(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20\n\n size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20\n template <class T>\n size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20\n size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20\n size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20\n size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20\n\n size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20\n template <class T>\n size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension, constexpr since C++20\n size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20\n size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20\n size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20\n\n int compare(const basic_string& str) const noexcept; // constexpr since C++20\n template <class T>\n int compare(const T& t) const noexcept; // C++17, noexcept as an extension, constexpr since C++20\n int compare(size_type pos1, size_type n1, const basic_string& str) const; // constexpr since C++20\n template <class T>\n int compare(size_type pos1, size_type n1, const T& t) const; // C++17, constexpr since C++20\n int compare(size_type pos1, size_type n1, const basic_string& str,\n size_type pos2, size_type n2=npos) const; // C++14, constexpr since C++20\n template <class T>\n int compare(size_type pos1, size_type n1, const T& t,\n size_type pos2, size_type n2=npos) const; // C++17, constexpr since C++20\n int compare(const value_type* s) const noexcept; // constexpr since C++20\n int compare(size_type pos1, size_type n1, const value_type* s) const; // constexpr since C++20\n int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; // constexpr since C++20\n\n constexpr bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++20\n constexpr bool starts_with(charT c) const noexcept; // C++20\n constexpr bool starts_with(const charT* s) const; // C++20\n constexpr bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++20\n constexpr bool ends_with(charT c) const noexcept; // C++20\n constexpr bool ends_with(const charT* s) const; // C++20\n\n constexpr bool contains(basic_string_view<charT, traits> sv) const noexcept; // C++23\n constexpr bool contains(charT c) const noexcept; // C++23\n constexpr bool contains(const charT* s) const; // C++23\n};\n\ntemplate<class InputIterator,\n class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>\nbasic_string(InputIterator, InputIterator, Allocator = Allocator())\n -> basic_string<typename iterator_traits<InputIterator>::value_type,\n char_traits<typename iterator_traits<InputIterator>::value_type>,\n Allocator>; // C++17\n\ntemplate<ranges::input_range R,\n class Allocator = allocator<ranges::range_value_t<R>>>\n basic_string(from_range_t, R&&, Allocator = Allocator())\n -> basic_string<ranges::range_value_t<R>, char_traits<ranges::range_value_t<R>>,\n Allocator>; // C++23\n\ntemplate<class charT,\n class traits,\n class Allocator = allocator<charT>>\n explicit basic_string(basic_string_view<charT, traits>, const Allocator& = Allocator())\n -> basic_string<charT, traits, Allocator>; // C++17\n\ntemplate<class charT,\n class traits,\n class Allocator = allocator<charT>>\n basic_string(basic_string_view<charT, traits>,\n typename see below::size_type, typename see below::size_type,\n const Allocator& = Allocator())\n -> basic_string<charT, traits, Allocator>; // C++17\n\ntemplate<class charT, class traits, class Allocator>\nbasic_string<charT, traits, Allocator>\noperator+(const basic_string<charT, traits, Allocator>& lhs,\n const basic_string<charT, traits, Allocator>& rhs); // constexpr since C++20\n\ntemplate<class charT, class traits, class Allocator>\nbasic_string<charT, traits, Allocator>\noperator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs); // constexpr since C++20\n\ntemplate<class charT, class traits, class Allocator>\nbasic_string<charT, traits, Allocator>\noperator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20\n\ntemplate<class charT, class traits, class Allocator>\nbasic_string<charT, traits, Allocator>\noperator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); // constexpr since C++20\n\ntemplate<class charT, class traits, class Allocator>\nbasic_string<charT, traits, Allocator>\noperator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); // constexpr since C++20\n\ntemplate<class charT, class traits, class Allocator>\n constexpr basic_string<charT, traits, Allocator>\n operator+(const basic_string<charT, traits, Allocator>& lhs,\n type_identity_t<basic_string_view<charT, traits>> rhs); // Since C++26\ntemplate<class charT, class traits, class Allocator>\n constexpr basic_string<charT, traits, Allocator>\n operator+(basic_string<charT, traits, Allocator>&& lhs,\n type_identity_t<basic_string_view<charT, traits>> rhs); // Since C++26\ntemplate<class charT, class traits, class Allocator>\n constexpr basic_string<charT, traits, Allocator>\n operator+(type_identity_t<basic_string_view<charT, traits>> lhs,\n const basic_string<charT, traits, Allocator>& rhs); // Since C++26\ntemplate<class charT, class traits, class Allocator>\n constexpr basic_string<charT, traits, Allocator>\n operator+(type_identity_t<basic_string_view<charT, traits>> lhs,\n basic_string<charT, traits, Allocator>&& rhs); // Since C++26\n\n\ntemplate<class charT, class traits, class Allocator>\nbool operator==(const basic_string<charT, traits, Allocator>& lhs,\n const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator!=(const basic_string<charT,traits,Allocator>& lhs,\n const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator< (const basic_string<charT, traits, Allocator>& lhs,\n const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator> (const basic_string<charT, traits, Allocator>& lhs,\n const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator<=(const basic_string<charT, traits, Allocator>& lhs,\n const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator>=(const basic_string<charT, traits, Allocator>& lhs,\n const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator>\nbool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20\n\ntemplate<class charT, class traits, class Allocator> // since C++20\nconstexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,\n const basic_string<charT, traits, Allocator>& rhs) noexcept;\n\ntemplate<class charT, class traits, class Allocator> // since C++20\nconstexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,\n const charT* rhs) noexcept;\n\ntemplate<class charT, class traits, class Allocator>\nvoid swap(basic_string<charT, traits, Allocator>& lhs,\n basic_string<charT, traits, Allocator>& rhs)\n noexcept(noexcept(lhs.swap(rhs))); // constexpr since C++20\n\ntemplate<class charT, class traits, class Allocator>\nbasic_istream<charT, traits>&\noperator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);\n\ntemplate<class charT, class traits, class Allocator>\nbasic_ostream<charT, traits>&\noperator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str);\n\ntemplate<class charT, class traits, class Allocator>\nbasic_istream<charT, traits>&\ngetline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str,\n charT delim);\n\ntemplate<class charT, class traits, class Allocator>\nbasic_istream<charT, traits>&\ngetline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);\n\ntemplate<class charT, class traits, class Allocator, class U>\ntypename basic_string<charT, traits, Allocator>::size_type\nerase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20\ntemplate<class charT, class traits, class Allocator, class Predicate>\ntypename basic_string<charT, traits, Allocator>::size_type\nerase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20\n\ntypedef basic_string<char> string;\ntypedef basic_string<wchar_t> wstring;\ntypedef basic_string<char8_t> u8string; // C++20\ntypedef basic_string<char16_t> u16string;\ntypedef basic_string<char32_t> u32string;\n\nint stoi (const string& str, size_t* idx = nullptr, int base = 10);\nlong stol (const string& str, size_t* idx = nullptr, int base = 10);\nunsigned long stoul (const string& str, size_t* idx = nullptr, int base = 10);\nlong long stoll (const string& str, size_t* idx = nullptr, int base = 10);\nunsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10);\n\nfloat stof (const string& str, size_t* idx = nullptr);\ndouble stod (const string& str, size_t* idx = nullptr);\nlong double stold(const string& str, size_t* idx = nullptr);\n\nstring to_string(int val);\nstring to_string(unsigned val);\nstring to_string(long val);\nstring to_string(unsigned long val);\nstring to_string(long long val);\nstring to_string(unsigned long long val);\nstring to_string(float val);\nstring to_string(double val);\nstring to_string(long double val);\n\nint stoi (const wstring& str, size_t* idx = nullptr, int base = 10);\nlong stol (const wstring& str, size_t* idx = nullptr, int base = 10);\nunsigned long stoul (const wstring& str, size_t* idx = nullptr, int base = 10);\nlong long stoll (const wstring& str, size_t* idx = nullptr, int base = 10);\nunsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10);\n\nfloat stof (const wstring& str, size_t* idx = nullptr);\ndouble stod (const wstring& str, size_t* idx = nullptr);\nlong double stold(const wstring& str, size_t* idx = nullptr);\n\nwstring to_wstring(int val);\nwstring to_wstring(unsigned val);\nwstring to_wstring(long val);\nwstring to_wstring(unsigned long val);\nwstring to_wstring(long long val);\nwstring to_wstring(unsigned long long val);\nwstring to_wstring(float val);\nwstring to_wstring(double val);\nwstring to_wstring(long double val);\n\ntemplate <> struct hash<string>;\ntemplate <> struct hash<u8string>; // C++20\ntemplate <> struct hash<u16string>;\ntemplate <> struct hash<u32string>;\ntemplate <> struct hash<wstring>;\n\nbasic_string<char> operator\"\"s( const char *str, size_t len ); // C++14, constexpr since C++20\nbasic_string<wchar_t> operator\"\"s( const wchar_t *str, size_t len ); // C++14, constexpr since C++20\nconstexpr basic_string<char8_t> operator\"\"s( const char8_t *str, size_t len ); // C++20\nbasic_string<char16_t> operator\"\"s( const char16_t *str, size_t len ); // C++14, constexpr since C++20\nbasic_string<char32_t> operator\"\"s( const char32_t *str, size_t len ); // C++14, constexpr since C++20\n\n} // std\n\n*/\n\n// clang-format on\n\n#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n# include <__cxx03/string>\n#else\n# include <__algorithm/max.h>\n# include <__algorithm/min.h>\n# include <__algorithm/remove.h>\n# include <__algorithm/remove_if.h>\n# include <__assert>\n# include <__config>\n# include <__debug_utils/sanitizers.h>\n# include <__format/enable_insertable.h>\n# include <__functional/hash.h>\n# include <__functional/unary_function.h>\n# include <__fwd/string.h>\n# include <__ios/fpos.h>\n# include <__iterator/bounded_iter.h>\n# include <__iterator/distance.h>\n# include <__iterator/iterator_traits.h>\n# include <__iterator/reverse_iterator.h>\n# include <__iterator/wrap_iter.h>\n# include <__memory/addressof.h>\n# include <__memory/allocate_at_least.h>\n# include <__memory/allocator.h>\n# include <__memory/allocator_traits.h>\n# include <__memory/compressed_pair.h>\n# include <__memory/construct_at.h>\n# include <__memory/noexcept_move_assign_container.h>\n# include <__memory/pointer_traits.h>\n# include <__memory/swap_allocator.h>\n# include <__memory_resource/polymorphic_allocator.h>\n# include <__ranges/access.h>\n# include <__ranges/concepts.h>\n# include <__ranges/container_compatible_range.h>\n# include <__ranges/from_range.h>\n# include <__ranges/size.h>\n# include <__string/char_traits.h>\n# include <__string/extern_template_lists.h>\n# include <__type_traits/conditional.h>\n# include <__type_traits/enable_if.h>\n# include <__type_traits/is_allocator.h>\n# include <__type_traits/is_array.h>\n# include <__type_traits/is_convertible.h>\n# include <__type_traits/is_nothrow_assignable.h>\n# include <__type_traits/is_nothrow_constructible.h>\n# include <__type_traits/is_same.h>\n# include <__type_traits/is_standard_layout.h>\n# include <__type_traits/is_trivial.h>\n# include <__type_traits/is_trivially_relocatable.h>\n# include <__type_traits/remove_cvref.h>\n# include <__type_traits/void_t.h>\n# include <__utility/auto_cast.h>\n# include <__utility/declval.h>\n# include <__utility/forward.h>\n# include <__utility/is_pointer_in_range.h>\n# include <__utility/move.h>\n# include <__utility/scope_guard.h>\n# include <__utility/swap.h>\n# include <__utility/unreachable.h>\n# include <climits>\n# include <cstdio> // EOF\n# include <cstring>\n# include <limits>\n# include <stdexcept>\n# include <string_view>\n# include <version>\n\n# if _LIBCPP_HAS_WIDE_CHARACTERS\n# include <cwchar>\n# endif\n\n// standard-mandated includes\n\n// [iterator.range]\n# include <__iterator/access.h>\n# include <__iterator/data.h>\n# include <__iterator/empty.h>\n# include <__iterator/reverse_access.h>\n# include <__iterator/size.h>\n\n// [string.syn]\n# include <compare>\n# include <initializer_list>\n\n# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n# endif\n\n_LIBCPP_PUSH_MACROS\n# include <__undef_macros>\n\n# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN\n# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__(\"address\")))\n// This macro disables AddressSanitizer (ASan) instrumentation for a specific function,\n// allowing memory accesses that would normally trigger ASan errors to proceed without crashing.\n// This is useful for accessing parts of objects memory, which should not be accessed,\n// such as unused bytes in short strings, that should never be accessed\n// by other parts of the program.\n# else\n# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS\n# endif\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\n// basic_string\n\ntemplate <class _CharT, class _Traits, class _Allocator>\nbasic_string<_CharT, _Traits, _Allocator> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20\noperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const basic_string<_CharT, _Traits, _Allocator>& __y);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(const _CharT* __x, const basic_string<_CharT, _Traits, _Allocator>& __y);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(_CharT __x, const basic_string<_CharT, _Traits, _Allocator>& __y);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);\n\n# if _LIBCPP_STD_VER >= 26\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>\noperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,\n type_identity_t<basic_string_view<_CharT, _Traits>> __rhs);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>\noperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, type_identity_t<basic_string_view<_CharT, _Traits>> __rhs);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>\noperator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,\n const basic_string<_CharT, _Traits, _Allocator>& __rhs);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>\noperator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs);\n\n# endif\n\nextern template _LIBCPP_EXPORTED_FROM_ABI string operator+\n <char, char_traits<char>, allocator<char> >(char const*, string const&);\n\ntemplate <class _Iter>\nstruct __string_is_trivial_iterator : public false_type {};\n\ntemplate <class _Tp>\nstruct __string_is_trivial_iterator<_Tp*> : public is_arithmetic<_Tp> {};\n\ntemplate <class _Iter>\nstruct __string_is_trivial_iterator<__wrap_iter<_Iter> > : public __string_is_trivial_iterator<_Iter> {};\n\ntemplate <class _CharT, class _Traits, class _Tp>\nstruct __can_be_converted_to_string_view\n : public _BoolConstant< is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value &&\n !is_convertible<const _Tp&, const _CharT*>::value > {};\n\nstruct __uninitialized_size_tag {};\nstruct __init_with_sentinel_tag {};\n\ntemplate <size_t _PaddingSize>\nstruct __padding {\n char __padding_[_PaddingSize];\n};\n\ntemplate <>\nstruct __padding<0> {};\n\ntemplate <class _CharT, class _Traits, class _Allocator>\nclass basic_string {\nprivate:\n using __default_allocator_type _LIBCPP_NODEBUG = allocator<_CharT>;\n\npublic:\n typedef basic_string __self;\n typedef basic_string_view<_CharT, _Traits> __self_view;\n typedef _Traits traits_type;\n typedef _CharT value_type;\n typedef _Allocator allocator_type;\n typedef allocator_traits<allocator_type> __alloc_traits;\n typedef typename __alloc_traits::size_type size_type;\n typedef typename __alloc_traits::difference_type difference_type;\n typedef value_type& reference;\n typedef const value_type& const_reference;\n typedef typename __alloc_traits::pointer pointer;\n typedef typename __alloc_traits::const_pointer const_pointer;\n\n // A basic_string contains the following members which may be trivially relocatable:\n // - pointer: is currently assumed to be trivially relocatable, but is still checked in case that changes\n // - size_type: is always trivially relocatable, since it has to be an integral type\n // - value_type: is always trivially relocatable, since it has to be trivial\n // - unsigned char: is a fundamental type, so it's trivially relocatable\n // - allocator_type: may or may not be trivially relocatable, so it's checked\n //\n // This string implementation doesn't contain any references into itself. It only contains a bit that says whether\n // it is in small or large string mode, so the entire structure is trivially relocatable if its members are.\n# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN\n // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially\n // relocatable. Because the object's memory might be poisoned when its content\n // is kept inside objects memory (short string optimization), instead of in allocated\n // external memory. In such cases, the destructor is responsible for unpoisoning\n // the memory to avoid triggering false positives.\n // Therefore it's crucial to ensure the destructor is called.\n using __trivially_relocatable = void;\n# else\n using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<\n __libcpp_is_trivially_relocatable<allocator_type>::value && __libcpp_is_trivially_relocatable<pointer>::value,\n basic_string,\n void>;\n# endif\n\n# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const {\n if (__libcpp_is_constant_evaluated())\n return __ptr;\n\n pointer volatile __copy_ptr = __ptr;\n\n return const_cast<pointer&>(__copy_ptr);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer\n __asan_volatile_wrapper(const_pointer const& __ptr) const {\n if (__libcpp_is_constant_evaluated())\n return __ptr;\n\n const_pointer volatile __copy_ptr = __ptr;\n\n return const_cast<const_pointer&>(__copy_ptr);\n }\n# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR)\n# else\n# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR\n# endif\n\n static_assert(!is_array<value_type>::value, \"Character type of basic_string must not be an array\");\n static_assert(is_standard_layout<value_type>::value, \"Character type of basic_string must be standard-layout\");\n static_assert(is_trivial<value_type>::value, \"Character type of basic_string must be trivial\");\n static_assert(is_same<_CharT, typename traits_type::char_type>::value,\n \"traits_type::char_type must be the same type as CharT\");\n static_assert(is_same<typename allocator_type::value_type, value_type>::value,\n \"Allocator::value_type must be same type as value_type\");\n static_assert(__check_valid_allocator<allocator_type>::value, \"\");\n\n# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING\n // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's\n // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is\n // considered contiguous.\n typedef __bounded_iter<__wrap_iter<pointer> > iterator;\n typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator;\n# else\n typedef __wrap_iter<pointer> iterator;\n typedef __wrap_iter<const_pointer> const_iterator;\n# endif\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n\nprivate:\n static_assert(CHAR_BIT == 8, \"This implementation assumes that one byte contains 8 bits\");\n\n# ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT\n\n struct __long {\n pointer __data_;\n size_type __size_;\n size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1;\n size_type __is_long_ : 1;\n };\n\n enum { __min_cap = (sizeof(__long) - 1) / sizeof(value_type) > 2 ? (sizeof(__long) - 1) / sizeof(value_type) : 2 };\n\n struct __short {\n value_type __data_[__min_cap];\n _LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;\n unsigned char __size_ : 7;\n unsigned char __is_long_ : 1;\n };\n\n // The __endian_factor is required because the field we use to store the size\n // has one fewer bit than it would if it were not a bitfield.\n //\n // If the LSB is used to store the short-flag in the short string representation,\n // we have to multiply the size by two when it is stored and divide it by two when\n // it is loaded to make sure that we always store an even number. In the long string\n // representation, we can ignore this because we can assume that we always allocate\n // an even amount of value_types.\n //\n // If the MSB is used for the short-flag, the max_size() is numeric_limits<size_type>::max() / 2.\n // This does not impact the short string representation, since we never need the MSB\n // for representing the size of a short string anyway.\n\n# ifdef _LIBCPP_BIG_ENDIAN\n static const size_type __endian_factor = 2;\n# else\n static const size_type __endian_factor = 1;\n# endif\n\n# else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT\n\n# ifdef _LIBCPP_BIG_ENDIAN\n static const size_type __endian_factor = 1;\n# else\n static const size_type __endian_factor = 2;\n# endif\n\n // Attribute 'packed' is used to keep the layout compatible with the\n // previous definition that did not use bit fields. This is because on\n // some platforms bit fields have a default size rather than the actual\n // size used, e.g., it is 4 bytes on AIX. See D128285 for details.\n struct __long {\n struct _LIBCPP_PACKED {\n size_type __is_long_ : 1;\n size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1;\n };\n size_type __size_;\n pointer __data_;\n };\n\n enum { __min_cap = (sizeof(__long) - 1) / sizeof(value_type) > 2 ? (sizeof(__long) - 1) / sizeof(value_type) : 2 };\n\n struct __short {\n struct _LIBCPP_PACKED {\n unsigned char __is_long_ : 1;\n unsigned char __size_ : 7;\n };\n _LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;\n value_type __data_[__min_cap];\n };\n\n# endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT\n\n static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), \"__short has an unexpected size.\");\n\n union __rep {\n __short __s;\n __long __l;\n };\n\n _LIBCPP_COMPRESSED_PAIR(__rep, __rep_, allocator_type, __alloc_);\n\n // annotate the string with its size() at scope exit. The string has to be in a valid state at that point.\n struct __annotate_new_size {\n basic_string& __str_;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __annotate_new_size(basic_string& __str) : __str_(__str) {}\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()() { __str_.__annotate_new(__str_.size()); }\n };\n\n // Construct a string with the given allocator and enough storage to hold `__size` characters, but\n // don't initialize the characters. The contents of the string, including the null terminator, must be\n // initialized separately.\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(\n __uninitialized_size_tag, size_type __size, const allocator_type& __a)\n : __alloc_(__a) {\n if (__size > max_size())\n __throw_length_error();\n if (__fits_in_sso(__size)) {\n __rep_ = __rep();\n __set_short_size(__size);\n } else {\n auto __capacity = __recommend(__size) + 1;\n auto __allocation = __alloc_traits::allocate(__alloc_, __capacity);\n __begin_lifetime(__allocation, __capacity);\n __set_long_cap(__capacity);\n __set_long_pointer(__allocation);\n __set_long_size(__size);\n }\n __annotate_new(__size);\n }\n\n template <class _Iter, class _Sent>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20\n basic_string(__init_with_sentinel_tag, _Iter __first, _Sent __last, const allocator_type& __a)\n : __alloc_(__a) {\n __init_with_sentinel(std::move(__first), std::move(__last));\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) {\n# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING\n // Bound the iterator according to the size (and not the capacity, unlike vector).\n //\n // By the Standard, string iterators are generally not guaranteed to stay valid when the container is modified,\n // regardless of whether reallocation occurs. This allows us to check for out-of-bounds accesses using logical size,\n // a stricter check, since correct code can never rely on being able to access newly-added elements via an existing\n // iterator.\n return std::__make_bounded_iter(\n std::__wrap_iter<pointer>(__p),\n std::__wrap_iter<pointer>(__get_pointer()),\n std::__wrap_iter<pointer>(__get_pointer() + size()));\n# else\n return iterator(__p);\n# endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const {\n# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING\n // Bound the iterator according to the size (and not the capacity, unlike vector).\n return std::__make_bounded_iter(\n std::__wrap_iter<const_pointer>(__p),\n std::__wrap_iter<const_pointer>(__get_pointer()),\n std::__wrap_iter<const_pointer>(__get_pointer() + size()));\n# else\n return const_iterator(__p);\n# endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING\n }\n\npublic:\n _LIBCPP_TEMPLATE_DATA_VIS static const size_type npos = -1;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string()\n _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)\n : __rep_() {\n __annotate_new(0);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const allocator_type& __a)\n# if _LIBCPP_STD_VER <= 14\n _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)\n# else\n _NOEXCEPT\n# endif\n : __rep_(), __alloc_(__a) {\n __annotate_new(0);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& __str)\n : __alloc_(__alloc_traits::select_on_container_copy_construction(__str.__alloc_)) {\n if (!__str.__is_long()) {\n __rep_ = __str.__rep_;\n __annotate_new(__get_short_size());\n } else\n __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS\n basic_string(const basic_string& __str, const allocator_type& __a)\n : __alloc_(__a) {\n if (!__str.__is_long()) {\n __rep_ = __str.__rep_;\n __annotate_new(__get_short_size());\n } else\n __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());\n }\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str)\n# if _LIBCPP_STD_VER <= 14\n _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)\n# else\n _NOEXCEPT\n# endif\n // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS\n // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first.\n // __str's memory needs to be unpoisoned only in the case where it's a short string.\n : __rep_([](basic_string& __s) -> decltype(__s.__rep_)&& {\n if (!__s.__is_long())\n __s.__annotate_delete();\n return std::move(__s.__rep_);\n }(__str)),\n __alloc_(std::move(__str.__alloc_)) {\n __str.__rep_ = __rep();\n __str.__annotate_new(0);\n if (!__is_long())\n __annotate_new(size());\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str, const allocator_type& __a)\n : __alloc_(__a) {\n if (__str.__is_long() && __a != __str.__alloc_) // copy, not move\n __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());\n else {\n if (__libcpp_is_constant_evaluated())\n __rep_ = __rep();\n if (!__str.__is_long())\n __str.__annotate_delete();\n __rep_ = __str.__rep_;\n __str.__rep_ = __rep();\n __str.__annotate_new(0);\n if (!__is_long() && this != std::addressof(__str))\n __annotate_new(size());\n }\n }\n# endif // _LIBCPP_CXX03_LANG\n\n template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"basic_string(const char*) detected nullptr\");\n __init(__s, traits_type::length(__s));\n }\n\n template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a)\n : __alloc_(__a) {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"basic_string(const char*, allocator) detected nullptr\");\n __init(__s, traits_type::length(__s));\n }\n\n# if _LIBCPP_STD_VER >= 23\n basic_string(nullptr_t) = delete;\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"basic_string(const char*, n) detected nullptr\");\n __init(__s, __n);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20\n basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)\n : __alloc_(__a) {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"basic_string(const char*, n, allocator) detected nullptr\");\n __init(__s, __n);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c) { __init(__n, __c); }\n\n# if _LIBCPP_STD_VER >= 23\n _LIBCPP_HIDE_FROM_ABI constexpr basic_string(\n basic_string&& __str, size_type __pos, const _Allocator& __alloc = _Allocator())\n : basic_string(std::move(__str), __pos, npos, __alloc) {}\n\n _LIBCPP_HIDE_FROM_ABI constexpr basic_string(\n basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator())\n : __alloc_(__alloc) {\n if (__pos > __str.size())\n __throw_out_of_range();\n\n auto __len = std::min<size_type>(__n, __str.size() - __pos);\n if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc_) {\n __move_assign(std::move(__str), __pos, __len);\n } else {\n // Perform a copy because the allocators are not compatible.\n __init(__str.data() + __pos, __len);\n }\n }\n# endif\n\n template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a)\n : __alloc_(__a) {\n __init(__n, __c);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20\n basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator())\n : __alloc_(__a) {\n size_type __str_sz = __str.size();\n if (__pos > __str_sz)\n __throw_out_of_range();\n __init(__str.data() + __pos, std::min(__n, __str_sz - __pos));\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20\n basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator())\n : __alloc_(__a) {\n size_type __str_sz = __str.size();\n if (__pos > __str_sz)\n __throw_out_of_range();\n __init(__str.data() + __pos, __str_sz - __pos);\n }\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string>::value,\n int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20\n basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type())\n : __alloc_(__a) {\n __self_view __sv0 = __t;\n __self_view __sv = __sv0.substr(__pos, __n);\n __init(__sv.data(), __sv.size());\n }\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string>::value,\n int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS\n _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) {\n __self_view __sv = __t;\n __init(__sv.data(), __sv.size());\n }\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string>::value,\n int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS\n _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a)\n : __alloc_(__a) {\n __self_view __sv = __t;\n __init(__sv.data(), __sv.size());\n }\n\n template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last) {\n __init(__first, __last);\n }\n\n template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20\n basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a)\n : __alloc_(__a) {\n __init(__first, __last);\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<_CharT> _Range>\n _LIBCPP_HIDE_FROM_ABI constexpr basic_string(\n from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())\n : __alloc_(__a) {\n if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {\n __init_with_size(ranges::begin(__range), ranges::end(__range), ranges::distance(__range));\n } else {\n __init_with_sentinel(ranges::begin(__range), ranges::end(__range));\n }\n }\n# endif\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il) {\n __init(__il.begin(), __il.end());\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il, const _Allocator& __a)\n : __alloc_(__a) {\n __init(__il.begin(), __il.end());\n }\n# endif // _LIBCPP_CXX03_LANG\n\n inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string() {\n __annotate_delete();\n if (__is_long())\n __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator __self_view() const _NOEXCEPT {\n return __self_view(typename __self_view::__assume_valid(), data(), size());\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string&\n operator=(const basic_string& __str);\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string>::value,\n int> = 0>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const _Tp& __t) {\n __self_view __sv = __t;\n return assign(__sv);\n }\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n operator=(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {\n __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(initializer_list<value_type> __il) {\n return assign(__il.begin(), __il.size());\n }\n# endif\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const value_type* __s) {\n return assign(__s);\n }\n# if _LIBCPP_STD_VER >= 23\n basic_string& operator=(nullptr_t) = delete;\n# endif\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c);\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT {\n return __make_iterator(__get_pointer());\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT {\n return __make_const_iterator(__get_pointer());\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT {\n return __make_iterator(__get_pointer() + size());\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT {\n return __make_const_iterator(__get_pointer() + size());\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT {\n return reverse_iterator(end());\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rbegin() const _NOEXCEPT {\n return const_reverse_iterator(end());\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rend() _NOEXCEPT {\n return reverse_iterator(begin());\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rend() const _NOEXCEPT {\n return const_reverse_iterator(begin());\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cbegin() const _NOEXCEPT { return begin(); }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cend() const _NOEXCEPT { return end(); }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crbegin() const _NOEXCEPT {\n return rbegin();\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crend() const _NOEXCEPT { return rend(); }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT {\n return __is_long() ? __get_long_size() : __get_short_size();\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT { return size(); }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT {\n size_type __m = __alloc_traits::max_size(__alloc_);\n if (__m <= std::numeric_limits<size_type>::max() / 2) {\n return __m - __alignment;\n } else {\n bool __uses_lsb = __endian_factor == 2;\n return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment;\n }\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT {\n return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1;\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n, value_type __c);\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__n, value_type()); }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __requested_capacity);\n\n# if _LIBCPP_STD_VER >= 23\n template <class _Op>\n _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) {\n __resize_default_init(__n);\n __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __resize_default_init(size_type __n);\n\n# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE)\n _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); }\n# endif\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT;\n\n [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {\n return size() == 0;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __pos) const _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos <= size(), \"string index out of bounds\");\n if (__builtin_constant_p(__pos) && !__fits_in_sso(__pos)) {\n return *(__get_long_pointer() + __pos);\n }\n return *(data() + __pos);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __pos) _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos <= size(), \"string index out of bounds\");\n if (__builtin_constant_p(__pos) && !__fits_in_sso(__pos)) {\n return *(__get_long_pointer() + __pos);\n }\n return *(__get_pointer() + __pos);\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference at(size_type __n) const;\n _LIBCPP_CONSTEXPR_SINCE_CXX20 reference at(size_type __n);\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const basic_string& __str) {\n return append(__str);\n }\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string >::value,\n int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n operator+=(const _Tp& __t) {\n __self_view __sv = __t;\n return append(__sv);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const value_type* __s) {\n return append(__s);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(value_type __c) {\n push_back(__c);\n return *this;\n }\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(initializer_list<value_type> __il) {\n return append(__il);\n }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str) {\n return append(__str.data(), __str.size());\n }\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string>::value,\n int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n append(const _Tp& __t) {\n __self_view __sv = __t;\n return append(__sv.data(), __sv.size());\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str, size_type __pos, size_type __n = npos);\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string>::value,\n int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20\n\n basic_string&\n append(const _Tp& __t, size_type __pos, size_type __n = npos);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c);\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append_default_init(size_type __n);\n\n template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n append(_InputIterator __first, _InputIterator __last) {\n const basic_string __temp(__first, __last, __alloc_);\n append(__temp.data(), __temp.size());\n return *this;\n }\n\n template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n append(_ForwardIterator __first, _ForwardIterator __last);\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<_CharT> _Range>\n _LIBCPP_HIDE_FROM_ABI constexpr basic_string& append_range(_Range&& __range) {\n insert_range(end(), std::forward<_Range>(__range));\n return *this;\n }\n# endif\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(initializer_list<value_type> __il) {\n return append(__il.begin(), __il.size());\n }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(value_type __c);\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back();\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), \"string::front(): string is empty\");\n return *__get_pointer();\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), \"string::front(): string is empty\");\n return *data();\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), \"string::back(): string is empty\");\n return *(__get_pointer() + size() - 1);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const _NOEXCEPT {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), \"string::back(): string is empty\");\n return *(data() + size() - 1);\n }\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n assign(const _Tp& __t) {\n __self_view __sv = __t;\n return assign(__sv.data(), __sv.size());\n }\n\n# if _LIBCPP_STD_VER >= 20\n _LIBCPP_HIDE_FROM_ABI constexpr void __move_assign(basic_string&& __str, size_type __pos, size_type __len) {\n // Pilfer the allocation from __str.\n _LIBCPP_ASSERT_INTERNAL(__alloc_ == __str.__alloc_, \"__move_assign called with wrong allocator\");\n size_type __old_sz = __str.size();\n if (!__str.__is_long())\n __str.__annotate_delete();\n __rep_ = __str.__rep_;\n __str.__rep_ = __rep();\n __str.__annotate_new(0);\n\n _Traits::move(data(), data() + __pos, __len);\n __set_size(__len);\n _Traits::assign(data()[__len], value_type());\n\n if (!__is_long()) {\n __annotate_new(__len);\n } else if (__old_sz > __len) {\n __annotate_shrink(__old_sz);\n }\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str) {\n return *this = __str;\n }\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n assign(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {\n *this = std::move(__str);\n return *this;\n }\n# endif\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n = npos);\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string>::value,\n int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n assign(const _Tp& __t, size_type __pos, size_type __n = npos);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c);\n template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n assign(_InputIterator __first, _InputIterator __last);\n\n template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n assign(_ForwardIterator __first, _ForwardIterator __last);\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<_CharT> _Range>\n _LIBCPP_HIDE_FROM_ABI constexpr basic_string& assign_range(_Range&& __range) {\n if constexpr (__string_is_trivial_iterator<ranges::iterator_t<_Range>>::value &&\n (ranges::forward_range<_Range> || ranges::sized_range<_Range>)) {\n size_type __n = static_cast<size_type>(ranges::distance(__range));\n __assign_trivial(ranges::begin(__range), ranges::end(__range), __n);\n\n } else {\n __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));\n }\n\n return *this;\n }\n# endif\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(initializer_list<value_type> __il) {\n return assign(__il.begin(), __il.size());\n }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n insert(size_type __pos1, const basic_string& __str) {\n return insert(__pos1, __str.data(), __str.size());\n }\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n insert(size_type __pos1, const _Tp& __t) {\n __self_view __sv = __t;\n return insert(__pos1, __sv.data(), __sv.size());\n }\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string>::value,\n int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n = npos);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n = npos);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s, size_type __n);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c);\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<_CharT> _Range>\n _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) {\n if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {\n auto __n = static_cast<size_type>(ranges::distance(__range));\n return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);\n\n } else {\n basic_string __temp(from_range, std::forward<_Range>(__range), __alloc_);\n return insert(__position, __temp.data(), __temp.data() + __temp.size());\n }\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator\n insert(const_iterator __pos, size_type __n, value_type __c) {\n difference_type __p = __pos - begin();\n insert(static_cast<size_type>(__p), __n, __c);\n return begin() + __p;\n }\n\n template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator\n insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);\n\n template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator\n insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator\n insert(const_iterator __pos, initializer_list<value_type> __il) {\n return insert(__pos, __il.begin(), __il.end());\n }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& erase(size_type __pos = 0, size_type __n = npos);\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __pos);\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __first, const_iterator __last);\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(size_type __pos1, size_type __n1, const basic_string& __str) {\n return replace(__pos1, __n1, __str.data(), __str.size());\n }\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(size_type __pos1, size_type __n1, const _Tp& __t) {\n __self_view __sv = __t;\n return replace(__pos1, __n1, __sv.data(), __sv.size());\n }\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos);\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string>::value,\n int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) {\n return replace(\n static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __str.data(), __str.size());\n }\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) {\n __self_view __sv = __t;\n return replace(__i1 - begin(), __i2 - __i1, __sv);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) {\n return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(const_iterator __i1, const_iterator __i2, const value_type* __s) {\n return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) {\n return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c);\n }\n\n template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<_CharT> _Range>\n _LIBCPP_HIDE_FROM_ABI constexpr basic_string&\n replace_with_range(const_iterator __i1, const_iterator __i2, _Range&& __range) {\n basic_string __temp(from_range, std::forward<_Range>(__range), __alloc_);\n return replace(__i1, __i2, __temp);\n }\n# endif\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il) {\n return replace(__i1, __i2, __il.begin(), __il.end());\n }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;\n\n# if _LIBCPP_STD_VER <= 20\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string\n substr(size_type __pos = 0, size_type __n = npos) const {\n return basic_string(*this, __pos, __n);\n }\n# else\n _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) const& {\n return basic_string(*this, __pos, __n);\n }\n\n _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) && {\n return basic_string(std::move(*this), __pos, __n);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(basic_string& __str)\n# if _LIBCPP_STD_VER >= 14\n _NOEXCEPT;\n# else\n _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT {\n return std::__to_address(__get_pointer());\n }\n# if _LIBCPP_STD_VER >= 17\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 value_type* data() _NOEXCEPT {\n return std::__to_address(__get_pointer());\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT {\n return __alloc_;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;\n _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;\n _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type\n find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const basic_string& __str) const _NOEXCEPT;\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 int\n compare(const _Tp& __t) const _NOEXCEPT;\n\n template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>\n _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 int\n compare(size_type __pos1, size_type __n1, const _Tp& __t) const;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int\n compare(size_type __pos1, size_type __n1, const basic_string& __str) const;\n _LIBCPP_CONSTEXPR_SINCE_CXX20 int\n compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const;\n\n template <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string>::value,\n int> = 0>\n inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int\n compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const;\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* __s) const _NOEXCEPT;\n _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s) const;\n _LIBCPP_CONSTEXPR_SINCE_CXX20 int\n compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;\n\n# if _LIBCPP_STD_VER >= 20\n constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept {\n return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv);\n }\n\n constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept {\n return !empty() && _Traits::eq(front(), __c);\n }\n\n constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(const value_type* __s) const noexcept {\n return starts_with(__self_view(__s));\n }\n\n constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept {\n return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv);\n }\n\n constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept {\n return !empty() && _Traits::eq(back(), __c);\n }\n\n constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept {\n return ends_with(__self_view(__s));\n }\n# endif\n\n# if _LIBCPP_STD_VER >= 23\n constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept {\n return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv);\n }\n\n constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept {\n return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__c);\n }\n\n constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const {\n return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __clear_and_shrink() _NOEXCEPT;\n\nprivate:\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __shrink_or_extend(size_type __target_capacity);\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS bool\n __is_long() const _NOEXCEPT {\n if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__rep_.__l.__is_long_)) {\n return __rep_.__l.__is_long_;\n }\n return __rep_.__s.__is_long_;\n }\n\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __begin_lifetime(pointer __begin, size_type __n) {\n# if _LIBCPP_STD_VER >= 20\n if (__libcpp_is_constant_evaluated()) {\n for (size_type __i = 0; __i != __n; ++__i)\n std::construct_at(std::addressof(__begin[__i]));\n }\n# else\n (void)__begin;\n (void)__n;\n# endif // _LIBCPP_STD_VER >= 20\n }\n\n _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { return __sz < __min_cap; }\n\n template <class _Iterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\n __assign_trivial(_Iterator __first, _Sentinel __last, size_type __n);\n\n template <class _Iterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last);\n\n // Copy [__first, __last) into [__dest, __dest + (__last - __first)). Assumes that the ranges don't overlap.\n template <class _ForwardIter, class _Sent>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static value_type*\n __copy_non_overlapping_range(_ForwardIter __first, _Sent __last, value_type* __dest) {\n# ifndef _LIBCPP_CXX03_LANG\n if constexpr (__libcpp_is_contiguous_iterator<_ForwardIter>::value &&\n is_same<value_type, __remove_cvref_t<decltype(*__first)>>::value &&\n is_same<_ForwardIter, _Sent>::value) {\n _LIBCPP_ASSERT_INTERNAL(\n !std::__is_overlapping_range(std::__to_address(__first), std::__to_address(__last), __dest),\n \"__copy_non_overlapping_range called with an overlapping range!\");\n traits_type::copy(__dest, std::__to_address(__first), __last - __first);\n return __dest + (__last - __first);\n }\n# endif\n\n for (; __first != __last; ++__first)\n traits_type::assign(*__dest++, *__first);\n return __dest;\n }\n\n template <class _ForwardIterator, class _Sentinel>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 iterator\n __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _Sentinel __last) {\n size_type __sz = size();\n size_type __cap = capacity();\n value_type* __p;\n if (__cap - __sz >= __n) {\n __annotate_increase(__n);\n __p = std::__to_address(__get_pointer());\n size_type __n_move = __sz - __ip;\n if (__n_move != 0)\n traits_type::move(__p + __ip + __n, __p + __ip, __n_move);\n } else {\n __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);\n __p = std::__to_address(__get_long_pointer());\n }\n __sz += __n;\n __set_size(__sz);\n traits_type::assign(__p[__sz], value_type());\n __copy_non_overlapping_range(std::move(__first), std::move(__last), __p + __ip);\n\n return begin() + __ip;\n }\n\n template <class _Iterator, class _Sentinel>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator\n __insert_with_size(const_iterator __pos, _Iterator __first, _Sentinel __last, size_type __n);\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void\n __set_short_size(size_type __s) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__s < __min_cap, \"__s should never be greater than or equal to the short string capacity\");\n __rep_.__s.__size_ = __s;\n __rep_.__s.__is_long_ = false;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS size_type\n __get_short_size() const _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(!__rep_.__s.__is_long_, \"String has to be short when trying to get the short size\");\n return __rep_.__s.__size_;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_size(size_type __s) _NOEXCEPT {\n __rep_.__l.__size_ = __s;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_size() const _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, \"String has to be long when trying to get the long size\");\n return __rep_.__l.__size_;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_size(size_type __s) _NOEXCEPT {\n if (__is_long())\n __set_long_size(__s);\n else\n __set_short_size(__s);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_cap(size_type __s) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(!__fits_in_sso(__s), \"Long capacity should always be larger than the SSO\");\n __rep_.__l.__cap_ = __s / __endian_factor;\n __rep_.__l.__is_long_ = true;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_cap() const _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, \"String has to be long when trying to get the long capacity\");\n return __rep_.__l.__cap_ * __endian_factor;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_pointer(pointer __p) _NOEXCEPT {\n __rep_.__l.__data_ = __p;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, \"String has to be long when trying to get the long pointer\");\n return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_long_pointer() const _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, \"String has to be long when trying to get the long pointer\");\n return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS pointer\n __get_short_pointer() _NOEXCEPT {\n return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__rep_.__s.__data_[0]));\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS const_pointer\n __get_short_pointer() const _NOEXCEPT {\n return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__rep_.__s.__data_[0]));\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_pointer() _NOEXCEPT {\n return __is_long() ? __get_long_pointer() : __get_short_pointer();\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_pointer() const _NOEXCEPT {\n return __is_long() ? __get_long_pointer() : __get_short_pointer();\n }\n\n // The following functions are no-ops outside of AddressSanitizer mode.\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\n __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {\n (void)__old_mid;\n (void)__new_mid;\n# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN\n# if defined(__APPLE__)\n // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099)\n if (!__is_long())\n return;\n# endif\n std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid);\n# endif\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT {\n (void)__current_size;\n# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN\n if (!__libcpp_is_constant_evaluated())\n __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);\n# endif\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT {\n# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN\n if (!__libcpp_is_constant_evaluated())\n __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);\n# endif\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT {\n (void)__n;\n# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN\n if (!__libcpp_is_constant_evaluated())\n __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);\n# endif\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT {\n (void)__old_size;\n# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN\n if (!__libcpp_is_constant_evaluated())\n __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);\n# endif\n }\n\n template <size_type __a>\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __align_it(size_type __s) _NOEXCEPT {\n return (__s + (__a - 1)) & ~(__a - 1);\n }\n enum { __alignment = 8 };\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __s) _NOEXCEPT {\n if (__s < __min_cap) {\n return static_cast<size_type>(__min_cap) - 1;\n }\n const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : __endian_factor;\n size_type __guess = __align_it<__boundary>(__s + 1) - 1;\n if (__guess == __min_cap)\n __guess += __endian_factor;\n\n _LIBCPP_ASSERT_INTERNAL(__guess >= __s, \"recommendation is below the requested size\");\n return __guess;\n }\n\n inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(const value_type* __s, size_type __sz, size_type __reserve);\n inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(const value_type* __s, size_type __sz);\n inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(size_type __n, value_type __c);\n\n // Slow path for the (inlined) copy constructor for 'long' strings.\n // Always externally instantiated and not inlined.\n // Requires that __s is zero terminated.\n // The main reason for this function to exist is because for unstable, we\n // want to allow inlining of the copy constructor. However, we don't want\n // to call the __init() functions as those are marked as inline which may\n // result in over-aggressive inlining by the compiler, where our aim is\n // to only inline the fast path code directly in the ctor.\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void __init_copy_ctor_external(const value_type* __s, size_type __sz);\n\n template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>\n inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(_InputIterator __first, _InputIterator __last);\n\n template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>\n inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(_ForwardIterator __first, _ForwardIterator __last);\n\n template <class _InputIterator, class _Sentinel>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\n __init_with_sentinel(_InputIterator __first, _Sentinel __last);\n template <class _InputIterator, class _Sentinel>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\n __init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz);\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20\n# if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1\n _LIBCPP_HIDE_FROM_ABI\n# endif\n _LIBCPP_DEPRECATED_(\"use __grow_by_without_replace\") void __grow_by(\n size_type __old_cap,\n size_type __delta_cap,\n size_type __old_sz,\n size_type __n_copy,\n size_type __n_del,\n size_type __n_add = 0);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __grow_by_without_replace(\n size_type __old_cap,\n size_type __delta_cap,\n size_type __old_sz,\n size_type __n_copy,\n size_type __n_del,\n size_type __n_add = 0);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 void __grow_by_and_replace(\n size_type __old_cap,\n size_type __delta_cap,\n size_type __old_sz,\n size_type __n_copy,\n size_type __n_del,\n size_type __n_add,\n const value_type* __p_new_stuff);\n\n // __assign_no_alias is invoked for assignment operations where we\n // have proof that the input does not alias the current instance.\n // For example, operator=(basic_string) performs a 'self' check.\n template <bool __is_short>\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string& __assign_no_alias(const value_type* __s, size_type __n);\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_to_end(size_type __pos) {\n _LIBCPP_ASSERT_INTERNAL(__pos <= capacity(), \"Trying to erase at position outside the strings capacity!\");\n __null_terminate_at(std::__to_address(__get_pointer()), __pos);\n }\n\n // __erase_external_with_move is invoked for erase() invocations where\n // `n ~= npos`, likely requiring memory moves on the string data.\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void __erase_external_with_move(size_type __pos, size_type __n);\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const basic_string& __str) {\n __copy_assign_alloc(\n __str, integral_constant<bool, __alloc_traits::propagate_on_container_copy_assignment::value>());\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const basic_string& __str, true_type) {\n if (__alloc_ == __str.__alloc_)\n __alloc_ = __str.__alloc_;\n else {\n if (!__str.__is_long()) {\n __clear_and_shrink();\n __alloc_ = __str.__alloc_;\n } else {\n __annotate_delete();\n auto __guard = std::__make_scope_guard(__annotate_new_size(*this));\n allocator_type __a = __str.__alloc_;\n auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap());\n __begin_lifetime(__allocation.ptr, __allocation.count);\n if (__is_long())\n __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());\n __alloc_ = std::move(__a);\n __set_long_pointer(__allocation.ptr);\n __set_long_cap(__allocation.count);\n __set_long_size(__str.size());\n }\n }\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\n __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {}\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\n __move_assign(basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value);\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void\n __move_assign(basic_string& __str, true_type)\n# if _LIBCPP_STD_VER >= 17\n noexcept;\n# else\n noexcept(is_nothrow_move_assignable<allocator_type>::value);\n# endif\n# endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string& __str)\n _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||\n is_nothrow_move_assignable<allocator_type>::value) {\n __move_assign_alloc(\n __str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string& __c, true_type)\n _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {\n __alloc_ = std::move(__c.__alloc_);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string&, false_type) _NOEXCEPT {}\n\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string& __assign_external(const value_type* __s);\n _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string& __assign_external(const value_type* __s, size_type __n);\n\n // Assigns the value in __s, guaranteed to be __n < __min_cap in length.\n inline _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_short(const value_type* __s, size_type __n) {\n size_type __old_size = size();\n if (__n > __old_size)\n __annotate_increase(__n - __old_size);\n pointer __p =\n __is_long() ? (__set_long_size(__n), __get_long_pointer()) : (__set_short_size(__n), __get_short_pointer());\n traits_type::move(std::__to_address(__p), __s, __n);\n traits_type::assign(__p[__n], value_type());\n if (__old_size > __n)\n __annotate_shrink(__old_size);\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&\n __null_terminate_at(value_type* __p, size_type __newsz) {\n size_type __old_size = size();\n if (__newsz > __old_size)\n __annotate_increase(__newsz - __old_size);\n __set_size(__newsz);\n traits_type::assign(__p[__newsz], value_type());\n if (__old_size > __newsz)\n __annotate_shrink(__old_size);\n return *this;\n }\n\n template <class _Tp>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __addr_in_range(const _Tp& __v) const {\n return std::__is_pointer_in_range(data(), data() + size() + 1, std::addressof(__v));\n }\n\n [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_length_error() {\n std::__throw_length_error(\"basic_string\");\n }\n\n [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_out_of_range() {\n std::__throw_out_of_range(\"basic_string\");\n }\n\n friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const basic_string&);\n friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const value_type*, const basic_string&);\n friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&);\n friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*);\n friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type);\n# if _LIBCPP_STD_VER >= 26\n friend constexpr basic_string operator+ <>(const basic_string&, type_identity_t<__self_view>);\n friend constexpr basic_string operator+ <>(type_identity_t<__self_view>, const basic_string&);\n# endif\n\n template <class _CharT2, class _Traits2, class _Allocator2>\n friend inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool\n operator==(const basic_string<_CharT2, _Traits2, _Allocator2>&, const _CharT2*) _NOEXCEPT;\n};\n\n// These declarations must appear before any functions are implicitly used\n// so that they have the correct visibility specifier.\n# define _LIBCPP_DECLARE(...) extern template __VA_ARGS__;\n# ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION\n_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)\n# if _LIBCPP_HAS_WIDE_CHARACTERS\n_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t)\n# endif\n# else\n_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)\n# if _LIBCPP_HAS_WIDE_CHARACTERS\n_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t)\n# endif\n# endif\n# undef _LIBCPP_DECLARE\n\n# if _LIBCPP_STD_VER >= 17\ntemplate <class _InputIterator,\n class _CharT = __iter_value_type<_InputIterator>,\n class _Allocator = allocator<_CharT>,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,\n class = enable_if_t<__is_allocator<_Allocator>::value> >\nbasic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())\n -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;\n\ntemplate <class _CharT,\n class _Traits,\n class _Allocator = allocator<_CharT>,\n class = enable_if_t<__is_allocator<_Allocator>::value> >\nexplicit basic_string(basic_string_view<_CharT, _Traits>,\n const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>;\n\ntemplate <class _CharT,\n class _Traits,\n class _Allocator = allocator<_CharT>,\n class = enable_if_t<__is_allocator<_Allocator>::value>,\n class _Sz = typename allocator_traits<_Allocator>::size_type >\nbasic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator())\n -> basic_string<_CharT, _Traits, _Allocator>;\n# endif\n\n# if _LIBCPP_STD_VER >= 23\ntemplate <ranges::input_range _Range,\n class _Allocator = allocator<ranges::range_value_t<_Range>>,\n class = enable_if_t<__is_allocator<_Allocator>::value> >\nbasic_string(from_range_t, _Range&&, _Allocator = _Allocator())\n -> basic_string<ranges::range_value_t<_Range>, char_traits<ranges::range_value_t<_Range>>, _Allocator>;\n# endif\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\nbasic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) {\n if (__libcpp_is_constant_evaluated())\n __rep_ = __rep();\n if (__reserve > max_size())\n __throw_length_error();\n pointer __p;\n if (__fits_in_sso(__reserve)) {\n __set_short_size(__sz);\n __p = __get_short_pointer();\n } else {\n auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__reserve) + 1);\n __p = __allocation.ptr;\n __begin_lifetime(__p, __allocation.count);\n __set_long_pointer(__p);\n __set_long_cap(__allocation.count);\n __set_long_size(__sz);\n }\n traits_type::copy(std::__to_address(__p), __s, __sz);\n traits_type::assign(__p[__sz], value_type());\n __annotate_new(__sz);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\nbasic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) {\n if (__libcpp_is_constant_evaluated())\n __rep_ = __rep();\n if (__sz > max_size())\n __throw_length_error();\n pointer __p;\n if (__fits_in_sso(__sz)) {\n __set_short_size(__sz);\n __p = __get_short_pointer();\n } else {\n auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1);\n __p = __allocation.ptr;\n __begin_lifetime(__p, __allocation.count);\n __set_long_pointer(__p);\n __set_long_cap(__allocation.count);\n __set_long_size(__sz);\n }\n traits_type::copy(std::__to_address(__p), __s, __sz);\n traits_type::assign(__p[__sz], value_type());\n __annotate_new(__sz);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void\nbasic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value_type* __s, size_type __sz) {\n if (__libcpp_is_constant_evaluated())\n __rep_ = __rep();\n\n pointer __p;\n if (__fits_in_sso(__sz)) {\n __p = __get_short_pointer();\n __set_short_size(__sz);\n } else {\n if (__sz > max_size())\n __throw_length_error();\n auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1);\n __p = __allocation.ptr;\n __begin_lifetime(__p, __allocation.count);\n __set_long_pointer(__p);\n __set_long_cap(__allocation.count);\n __set_long_size(__sz);\n }\n traits_type::copy(std::__to_address(__p), __s, __sz + 1);\n __annotate_new(__sz);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) {\n if (__libcpp_is_constant_evaluated())\n __rep_ = __rep();\n\n if (__n > max_size())\n __throw_length_error();\n pointer __p;\n if (__fits_in_sso(__n)) {\n __set_short_size(__n);\n __p = __get_short_pointer();\n } else {\n auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__n) + 1);\n __p = __allocation.ptr;\n __begin_lifetime(__p, __allocation.count);\n __set_long_pointer(__p);\n __set_long_cap(__allocation.count);\n __set_long_size(__n);\n }\n traits_type::assign(std::__to_address(__p), __n, __c);\n traits_type::assign(__p[__n], value_type());\n __annotate_new(__n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\nbasic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) {\n __init_with_sentinel(std::move(__first), std::move(__last));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _InputIterator, class _Sentinel>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\nbasic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator __first, _Sentinel __last) {\n __rep_ = __rep();\n __annotate_new(0);\n\n# if _LIBCPP_HAS_EXCEPTIONS\n try {\n# endif // _LIBCPP_HAS_EXCEPTIONS\n for (; __first != __last; ++__first)\n push_back(*__first);\n# if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n __annotate_delete();\n if (__is_long())\n __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());\n throw;\n }\n# endif // _LIBCPP_HAS_EXCEPTIONS\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void\nbasic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last) {\n size_type __sz = static_cast<size_type>(std::distance(__first, __last));\n __init_with_size(__first, __last, __sz);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _InputIterator, class _Sentinel>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\nbasic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz) {\n if (__libcpp_is_constant_evaluated())\n __rep_ = __rep();\n\n if (__sz > max_size())\n __throw_length_error();\n\n pointer __p;\n if (__fits_in_sso(__sz)) {\n __set_short_size(__sz);\n __p = __get_short_pointer();\n\n } else {\n auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1);\n __p = __allocation.ptr;\n __begin_lifetime(__p, __allocation.count);\n __set_long_pointer(__p);\n __set_long_cap(__allocation.count);\n __set_long_size(__sz);\n }\n\n# if _LIBCPP_HAS_EXCEPTIONS\n try {\n# endif // _LIBCPP_HAS_EXCEPTIONS\n auto __end = __copy_non_overlapping_range(std::move(__first), std::move(__last), std::__to_address(__p));\n traits_type::assign(*__end, value_type());\n# if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n if (__is_long())\n __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());\n throw;\n }\n# endif // _LIBCPP_HAS_EXCEPTIONS\n __annotate_new(__sz);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace(\n size_type __old_cap,\n size_type __delta_cap,\n size_type __old_sz,\n size_type __n_copy,\n size_type __n_del,\n size_type __n_add,\n const value_type* __p_new_stuff) {\n size_type __ms = max_size();\n if (__delta_cap > __ms - __old_cap - 1)\n __throw_length_error();\n pointer __old_p = __get_pointer();\n size_type __cap =\n __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1;\n __annotate_delete();\n auto __guard = std::__make_scope_guard(__annotate_new_size(*this));\n auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1);\n pointer __p = __allocation.ptr;\n __begin_lifetime(__p, __allocation.count);\n if (__n_copy != 0)\n traits_type::copy(std::__to_address(__p), std::__to_address(__old_p), __n_copy);\n if (__n_add != 0)\n traits_type::copy(std::__to_address(__p) + __n_copy, __p_new_stuff, __n_add);\n size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;\n if (__sec_cp_sz != 0)\n traits_type::copy(\n std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);\n if (__old_cap + 1 != __min_cap)\n __alloc_traits::deallocate(__alloc_, __old_p, __old_cap + 1);\n __set_long_pointer(__p);\n __set_long_cap(__allocation.count);\n __old_sz = __n_copy + __n_add + __sec_cp_sz;\n __set_long_size(__old_sz);\n traits_type::assign(__p[__old_sz], value_type());\n}\n\n// __grow_by is deprecated because it does not set the size. It may not update the size when the size is changed, and it\n// may also not set the size at all when the string was short initially. This leads to unpredictable size value. It is\n// not removed or changed to avoid breaking the ABI.\ntemplate <class _CharT, class _Traits, class _Allocator>\nvoid _LIBCPP_CONSTEXPR_SINCE_CXX20\n# if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1\n_LIBCPP_HIDE_FROM_ABI\n# endif\n_LIBCPP_DEPRECATED_(\"use __grow_by_without_replace\") basic_string<_CharT, _Traits, _Allocator>::__grow_by(\n size_type __old_cap,\n size_type __delta_cap,\n size_type __old_sz,\n size_type __n_copy,\n size_type __n_del,\n size_type __n_add) {\n size_type __ms = max_size();\n if (__delta_cap > __ms - __old_cap)\n __throw_length_error();\n pointer __old_p = __get_pointer();\n size_type __cap =\n __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1;\n auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1);\n pointer __p = __allocation.ptr;\n __begin_lifetime(__p, __allocation.count);\n if (__n_copy != 0)\n traits_type::copy(std::__to_address(__p), std::__to_address(__old_p), __n_copy);\n size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;\n if (__sec_cp_sz != 0)\n traits_type::copy(\n std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);\n if (__old_cap + 1 != __min_cap)\n __alloc_traits::deallocate(__alloc_, __old_p, __old_cap + 1);\n __set_long_pointer(__p);\n __set_long_cap(__allocation.count);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\nvoid _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI\nbasic_string<_CharT, _Traits, _Allocator>::__grow_by_without_replace(\n size_type __old_cap,\n size_type __delta_cap,\n size_type __old_sz,\n size_type __n_copy,\n size_type __n_del,\n size_type __n_add) {\n __annotate_delete();\n auto __guard = std::__make_scope_guard(__annotate_new_size(*this));\n _LIBCPP_SUPPRESS_DEPRECATED_PUSH\n __grow_by(__old_cap, __delta_cap, __old_sz, __n_copy, __n_del, __n_add);\n _LIBCPP_SUPPRESS_DEPRECATED_POP\n __set_long_size(__old_sz - __n_del + __n_add);\n}\n\n// assign\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <bool __is_short>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* __s, size_type __n) {\n size_type __cap = __is_short ? static_cast<size_type>(__min_cap) : __get_long_cap();\n if (__n < __cap) {\n size_type __old_size = __is_short ? __get_short_size() : __get_long_size();\n if (__n > __old_size)\n __annotate_increase(__n - __old_size);\n pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer();\n __is_short ? __set_short_size(__n) : __set_long_size(__n);\n traits_type::copy(std::__to_address(__p), __s, __n);\n traits_type::assign(__p[__n], value_type());\n if (__old_size > __n)\n __annotate_shrink(__old_size);\n } else {\n size_type __sz = __is_short ? __get_short_size() : __get_long_size();\n __grow_by_and_replace(__cap - 1, __n - __cap + 1, __sz, 0, __sz, __n, __s);\n }\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s, size_type __n) {\n size_type __cap = capacity();\n if (__cap >= __n) {\n size_type __old_size = size();\n if (__n > __old_size)\n __annotate_increase(__n - __old_size);\n value_type* __p = std::__to_address(__get_pointer());\n traits_type::move(__p, __s, __n);\n return __null_terminate_at(__p, __n);\n } else {\n size_type __sz = size();\n __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s);\n return *this;\n }\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"string::assign received nullptr\");\n return (__builtin_constant_p(__n) && __fits_in_sso(__n)) ? __assign_short(__s, __n) : __assign_external(__s, __n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) {\n size_type __cap = capacity();\n size_type __old_size = size();\n if (__cap < __n) {\n size_type __sz = size();\n __grow_by_without_replace(__cap, __n - __cap, __sz, 0, __sz);\n __annotate_increase(__n);\n } else if (__n > __old_size)\n __annotate_increase(__n - __old_size);\n value_type* __p = std::__to_address(__get_pointer());\n traits_type::assign(__p, __n, __c);\n return __null_terminate_at(__p, __n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) {\n pointer __p;\n size_type __old_size = size();\n if (__old_size == 0)\n __annotate_increase(1);\n if (__is_long()) {\n __p = __get_long_pointer();\n __set_long_size(1);\n } else {\n __p = __get_short_pointer();\n __set_short_size(1);\n }\n traits_type::assign(*__p, __c);\n traits_type::assign(*++__p, value_type());\n if (__old_size > 1)\n __annotate_shrink(__old_size);\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) {\n if (this != std::addressof(__str)) {\n __copy_assign_alloc(__str);\n if (!__is_long()) {\n if (!__str.__is_long()) {\n size_type __old_size = __get_short_size();\n if (__get_short_size() < __str.__get_short_size())\n __annotate_increase(__str.__get_short_size() - __get_short_size());\n __rep_ = __str.__rep_;\n if (__old_size > __get_short_size())\n __annotate_shrink(__old_size);\n } else {\n return __assign_no_alias<true>(__str.data(), __str.size());\n }\n } else {\n return __assign_no_alias<false>(__str.data(), __str.size());\n }\n }\n return *this;\n}\n\n# ifndef _LIBCPP_CXX03_LANG\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__move_assign(\n basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value) {\n if (__alloc_ != __str.__alloc_)\n assign(__str);\n else\n __move_assign(__str, true_type());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void\nbasic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)\n# if _LIBCPP_STD_VER >= 17\n noexcept\n# else\n noexcept(is_nothrow_move_assignable<allocator_type>::value)\n# endif\n{\n __annotate_delete();\n if (__is_long()) {\n __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());\n# if _LIBCPP_STD_VER <= 14\n if (!is_nothrow_move_assignable<allocator_type>::value) {\n __set_short_size(0);\n traits_type::assign(__get_short_pointer()[0], value_type());\n __annotate_new(0);\n }\n# endif\n }\n size_type __str_old_size = __str.size();\n bool __str_was_short = !__str.__is_long();\n\n __move_assign_alloc(__str);\n __rep_ = __str.__rep_;\n __str.__set_short_size(0);\n traits_type::assign(__str.__get_short_pointer()[0], value_type());\n\n if (__str_was_short && this != std::addressof(__str))\n __str.__annotate_shrink(__str_old_size);\n else\n // ASan annotations: was long, so object memory is unpoisoned as new.\n // Or is same as *this, and __annotate_delete() was called.\n __str.__annotate_new(0);\n\n // ASan annotations: Guard against `std::string s; s = std::move(s);`\n // You can find more here: https://en.cppreference.com/w/cpp/utility/move\n // Quote: \"Unless otherwise specified, all standard library objects that have been moved\n // from are placed in a \"valid but unspecified state\", meaning the object's class\n // invariants hold (so functions without preconditions, such as the assignment operator,\n // can be safely used on the object after it was moved from):\"\n // Quote: \"v = std::move(v); // the value of v is unspecified\"\n if (!__is_long() && std::addressof(__str) != this)\n // If it is long string, delete was never called on original __str's buffer.\n __annotate_new(__get_short_size());\n}\n\n# endif\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) {\n __assign_with_sentinel(__first, __last);\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _InputIterator, class _Sentinel>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\nbasic_string<_CharT, _Traits, _Allocator>::__assign_with_sentinel(_InputIterator __first, _Sentinel __last) {\n const basic_string __temp(__init_with_sentinel_tag(), std::move(__first), std::move(__last), __alloc_);\n assign(__temp.data(), __temp.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) {\n if (__string_is_trivial_iterator<_ForwardIterator>::value) {\n size_type __n = static_cast<size_type>(std::distance(__first, __last));\n __assign_trivial(__first, __last, __n);\n } else {\n __assign_with_sentinel(__first, __last);\n }\n\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Iterator, class _Sentinel>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void\nbasic_string<_CharT, _Traits, _Allocator>::__assign_trivial(_Iterator __first, _Sentinel __last, size_type __n) {\n _LIBCPP_ASSERT_INTERNAL(\n __string_is_trivial_iterator<_Iterator>::value, \"The iterator type given to `__assign_trivial` must be trivial\");\n\n size_type __old_size = size();\n size_type __cap = capacity();\n if (__cap < __n) {\n // Unlike `append` functions, if the input range points into the string itself, there is no case that the input\n // range could get invalidated by reallocation:\n // 1. If the input range is a subset of the string itself, its size cannot exceed the capacity of the string,\n // thus no reallocation would happen.\n // 2. In the exotic case where the input range is the byte representation of the string itself, the string\n // object itself stays valid even if reallocation happens.\n size_type __sz = size();\n __grow_by_without_replace(__cap, __n - __cap, __sz, 0, __sz);\n __annotate_increase(__n);\n } else if (__n > __old_size)\n __annotate_increase(__n - __old_size);\n pointer __p = __get_pointer();\n for (; __first != __last; ++__p, (void)++__first)\n traits_type::assign(*__p, *__first);\n traits_type::assign(*__p, value_type());\n __set_size(__n);\n if (__n < __old_size)\n __annotate_shrink(__old_size);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) {\n size_type __sz = __str.size();\n if (__pos > __sz)\n __throw_out_of_range();\n return assign(__str.data() + __pos, std::min(__n, __sz - __pos));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,\n int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::assign(const _Tp& __t, size_type __pos, size_type __n) {\n __self_view __sv = __t;\n size_type __sz = __sv.size();\n if (__pos > __sz)\n __throw_out_of_range();\n return assign(__sv.data() + __pos, std::min(__n, __sz - __pos));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {\n return __assign_external(__s, traits_type::length(__s));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::assign received nullptr\");\n return __builtin_constant_p(*__s)\n ? (__fits_in_sso(traits_type::length(__s)) ? __assign_short(__s, traits_type::length(__s))\n : __assign_external(__s, traits_type::length(__s)))\n : __assign_external(__s);\n}\n// append\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"string::append received nullptr\");\n size_type __cap = capacity();\n size_type __sz = size();\n if (__cap - __sz >= __n) {\n if (__n) {\n __annotate_increase(__n);\n value_type* __p = std::__to_address(__get_pointer());\n traits_type::copy(__p + __sz, __s, __n);\n __sz += __n;\n __set_size(__sz);\n traits_type::assign(__p[__sz], value_type());\n }\n } else\n __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s);\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) {\n if (__n) {\n size_type __cap = capacity();\n size_type __sz = size();\n if (__cap - __sz < __n)\n __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);\n __annotate_increase(__n);\n pointer __p = __get_pointer();\n traits_type::assign(std::__to_address(__p) + __sz, __n, __c);\n __sz += __n;\n __set_size(__sz);\n traits_type::assign(__p[__sz], value_type());\n }\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void\nbasic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n) {\n if (__n) {\n size_type __cap = capacity();\n size_type __sz = size();\n if (__cap - __sz < __n)\n __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);\n __annotate_increase(__n);\n pointer __p = __get_pointer();\n __sz += __n;\n __set_size(__sz);\n traits_type::assign(__p[__sz], value_type());\n }\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) {\n bool __is_short = !__is_long();\n size_type __cap;\n size_type __sz;\n if (__is_short) {\n __cap = __min_cap - 1;\n __sz = __get_short_size();\n } else {\n __cap = __get_long_cap() - 1;\n __sz = __get_long_size();\n }\n if (__sz == __cap) {\n __grow_by_without_replace(__cap, 1, __sz, __sz, 0);\n __annotate_increase(1);\n __is_short = false; // the string is always long after __grow_by\n } else\n __annotate_increase(1);\n pointer __p = __get_pointer();\n if (__is_short) {\n __p = __get_short_pointer() + __sz;\n __set_short_size(__sz + 1);\n } else {\n __p = __get_long_pointer() + __sz;\n __set_long_size(__sz + 1);\n }\n traits_type::assign(*__p, __c);\n traits_type::assign(*++__p, value_type());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _ForwardIterator __last) {\n size_type __sz = size();\n size_type __cap = capacity();\n size_type __n = static_cast<size_type>(std::distance(__first, __last));\n if (__n) {\n if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) {\n if (__cap - __sz < __n)\n __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);\n __annotate_increase(__n);\n auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz));\n traits_type::assign(*__end, value_type());\n __set_size(__sz + __n);\n } else {\n const basic_string __temp(__first, __last, __alloc_);\n append(__temp.data(), __temp.size());\n }\n }\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) {\n size_type __sz = __str.size();\n if (__pos > __sz)\n __throw_out_of_range();\n return append(__str.data() + __pos, std::min(__n, __sz - __pos));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,\n int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::append(const _Tp& __t, size_type __pos, size_type __n) {\n __self_view __sv = __t;\n size_type __sz = __sv.size();\n if (__pos > __sz)\n __throw_out_of_range();\n return append(__sv.data() + __pos, std::min(__n, __sz - __pos));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::append received nullptr\");\n return append(__s, traits_type::length(__s));\n}\n\n// insert\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"string::insert received nullptr\");\n size_type __sz = size();\n if (__pos > __sz)\n __throw_out_of_range();\n size_type __cap = capacity();\n if (__cap - __sz >= __n) {\n if (__n) {\n __annotate_increase(__n);\n value_type* __p = std::__to_address(__get_pointer());\n size_type __n_move = __sz - __pos;\n if (__n_move != 0) {\n if (std::__is_pointer_in_range(__p + __pos, __p + __sz, __s))\n __s += __n;\n traits_type::move(__p + __pos + __n, __p + __pos, __n_move);\n }\n traits_type::move(__p + __pos, __s, __n);\n __sz += __n;\n __set_size(__sz);\n traits_type::assign(__p[__sz], value_type());\n }\n } else\n __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s);\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) {\n size_type __sz = size();\n if (__pos > __sz)\n __throw_out_of_range();\n if (__n) {\n size_type __cap = capacity();\n value_type* __p;\n if (__cap - __sz >= __n) {\n __annotate_increase(__n);\n __p = std::__to_address(__get_pointer());\n size_type __n_move = __sz - __pos;\n if (__n_move != 0)\n traits_type::move(__p + __pos + __n, __p + __pos, __n_move);\n } else {\n __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n);\n __p = std::__to_address(__get_long_pointer());\n }\n traits_type::assign(__p + __pos, __n, __c);\n __sz += __n;\n __set_size(__sz);\n traits_type::assign(__p[__sz], value_type());\n }\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator\nbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) {\n const basic_string __temp(__first, __last, __alloc_);\n return insert(__pos, __temp.data(), __temp.data() + __temp.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator\nbasic_string<_CharT, _Traits, _Allocator>::insert(\n const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) {\n auto __n = static_cast<size_type>(std::distance(__first, __last));\n return __insert_with_size(__pos, __first, __last, __n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Iterator, class _Sentinel>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator\nbasic_string<_CharT, _Traits, _Allocator>::__insert_with_size(\n const_iterator __pos, _Iterator __first, _Sentinel __last, size_type __n) {\n size_type __ip = static_cast<size_type>(__pos - begin());\n if (__n == 0)\n return begin() + __ip;\n\n if (__string_is_trivial_iterator<_Iterator>::value && !__addr_in_range(*__first)) {\n return __insert_from_safe_copy(__n, __ip, std::move(__first), std::move(__last));\n } else {\n const basic_string __temp(__init_with_sentinel_tag(), std::move(__first), std::move(__last), __alloc_);\n return __insert_from_safe_copy(__n, __ip, __temp.begin(), __temp.end());\n }\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::insert(\n size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n) {\n size_type __str_sz = __str.size();\n if (__pos2 > __str_sz)\n __throw_out_of_range();\n return insert(__pos1, __str.data() + __pos2, std::min(__n, __str_sz - __pos2));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,\n int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n) {\n __self_view __sv = __t;\n size_type __str_sz = __sv.size();\n if (__pos2 > __str_sz)\n __throw_out_of_range();\n return insert(__pos1, __sv.data() + __pos2, std::min(__n, __str_sz - __pos2));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::insert received nullptr\");\n return insert(__pos, __s, traits_type::length(__s));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator\nbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c) {\n size_type __ip = static_cast<size_type>(__pos - begin());\n size_type __sz = size();\n size_type __cap = capacity();\n value_type* __p;\n if (__cap == __sz) {\n __grow_by_without_replace(__cap, 1, __sz, __ip, 0, 1);\n __p = std::__to_address(__get_long_pointer());\n } else {\n __annotate_increase(1);\n __p = std::__to_address(__get_pointer());\n size_type __n_move = __sz - __ip;\n if (__n_move != 0)\n traits_type::move(__p + __ip + 1, __p + __ip, __n_move);\n }\n traits_type::assign(__p[__ip], __c);\n traits_type::assign(__p[++__sz], value_type());\n __set_size(__sz);\n return begin() + static_cast<difference_type>(__ip);\n}\n\n// replace\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::replace(\n size_type __pos, size_type __n1, const value_type* __s, size_type __n2)\n _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK {\n _LIBCPP_ASSERT_NON_NULL(__n2 == 0 || __s != nullptr, \"string::replace received nullptr\");\n size_type __sz = size();\n if (__pos > __sz)\n __throw_out_of_range();\n __n1 = std::min(__n1, __sz - __pos);\n size_type __cap = capacity();\n if (__cap - __sz + __n1 >= __n2) {\n value_type* __p = std::__to_address(__get_pointer());\n if (__n1 != __n2) {\n if (__n2 > __n1)\n __annotate_increase(__n2 - __n1);\n size_type __n_move = __sz - __pos - __n1;\n if (__n_move != 0) {\n if (__n1 > __n2) {\n traits_type::move(__p + __pos, __s, __n2);\n traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);\n return __null_terminate_at(__p, __sz + (__n2 - __n1));\n }\n if (std::__is_pointer_in_range(__p + __pos + 1, __p + __sz, __s)) {\n if (__p + __pos + __n1 <= __s)\n __s += __n2 - __n1;\n else // __p + __pos < __s < __p + __pos + __n1\n {\n traits_type::move(__p + __pos, __s, __n1);\n __pos += __n1;\n __s += __n2;\n __n2 -= __n1;\n __n1 = 0;\n }\n }\n traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);\n }\n }\n traits_type::move(__p + __pos, __s, __n2);\n return __null_terminate_at(__p, __sz + (__n2 - __n1));\n } else\n __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s);\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) {\n size_type __sz = size();\n if (__pos > __sz)\n __throw_out_of_range();\n __n1 = std::min(__n1, __sz - __pos);\n size_type __cap = capacity();\n value_type* __p;\n if (__cap - __sz + __n1 >= __n2) {\n __p = std::__to_address(__get_pointer());\n if (__n1 != __n2) {\n if (__n2 > __n1)\n __annotate_increase(__n2 - __n1);\n size_type __n_move = __sz - __pos - __n1;\n if (__n_move != 0)\n traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);\n }\n } else {\n __grow_by_without_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2);\n __p = std::__to_address(__get_long_pointer());\n }\n traits_type::assign(__p + __pos, __n2, __c);\n return __null_terminate_at(__p, __sz - (__n1 - __n2));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::replace(\n const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) {\n const basic_string __temp(__j1, __j2, __alloc_);\n return replace(__i1, __i2, __temp);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::replace(\n size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) {\n size_type __str_sz = __str.size();\n if (__pos2 > __str_sz)\n __throw_out_of_range();\n return replace(__pos1, __n1, __str.data() + __pos2, std::min(__n2, __str_sz - __pos2));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,\n int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::replace(\n size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) {\n __self_view __sv = __t;\n size_type __str_sz = __sv.size();\n if (__pos2 > __str_sz)\n __throw_out_of_range();\n return replace(__pos1, __n1, __sv.data() + __pos2, std::min(__n2, __str_sz - __pos2));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::replace received nullptr\");\n return replace(__pos, __n1, __s, traits_type::length(__s));\n}\n\n// erase\n\n// 'externally instantiated' erase() implementation, called when __n != npos.\n// Does not check __pos against size()\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void\nbasic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(size_type __pos, size_type __n) {\n if (__n) {\n size_type __sz = size();\n value_type* __p = std::__to_address(__get_pointer());\n __n = std::min(__n, __sz - __pos);\n size_type __n_move = __sz - __pos - __n;\n if (__n_move != 0)\n traits_type::move(__p + __pos, __p + __pos + __n, __n_move);\n __null_terminate_at(__p, __sz - __n);\n }\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&\nbasic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) {\n if (__pos > size())\n __throw_out_of_range();\n if (__n == npos) {\n __erase_to_end(__pos);\n } else {\n __erase_external_with_move(__pos, __n);\n }\n return *this;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator\nbasic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(\n __pos != end(), \"string::erase(iterator) called with a non-dereferenceable iterator\");\n iterator __b = begin();\n size_type __r = static_cast<size_type>(__pos - __b);\n erase(__r, 1);\n return __b + static_cast<difference_type>(__r);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator\nbasic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) {\n _LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, \"string::erase(first, last) called with invalid range\");\n iterator __b = begin();\n size_type __r = static_cast<size_type>(__first - __b);\n erase(__r, static_cast<size_type>(__last - __first));\n return __b + static_cast<difference_type>(__r);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::pop_back() {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), \"string::pop_back(): string is already empty\");\n __erase_to_end(size() - 1);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT {\n size_type __old_size = size();\n if (__is_long()) {\n traits_type::assign(*__get_long_pointer(), value_type());\n __set_long_size(0);\n } else {\n traits_type::assign(*__get_short_pointer(), value_type());\n __set_short_size(0);\n }\n __annotate_shrink(__old_size);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) {\n size_type __sz = size();\n if (__n > __sz)\n append(__n - __sz, __c);\n else\n __erase_to_end(__n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void\nbasic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) {\n size_type __sz = size();\n if (__n > __sz) {\n __append_default_init(__n - __sz);\n } else\n __erase_to_end(__n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) {\n if (__requested_capacity > max_size())\n __throw_length_error();\n\n // Make sure reserve(n) never shrinks. This is technically only required in C++20\n // and later (since P0966R1), however we provide consistent behavior in all Standard\n // modes because this function is instantiated in the shared library.\n if (__requested_capacity <= capacity())\n return;\n\n __shrink_or_extend(__recommend(__requested_capacity));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT {\n size_type __target_capacity = __recommend(size());\n if (__target_capacity == capacity())\n return;\n\n __shrink_or_extend(__target_capacity);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 void\nbasic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) {\n __annotate_delete();\n auto __guard = std::__make_scope_guard(__annotate_new_size(*this));\n size_type __cap = capacity();\n size_type __sz = size();\n\n pointer __new_data, __p;\n bool __was_long, __now_long;\n if (__fits_in_sso(__target_capacity)) {\n __was_long = true;\n __now_long = false;\n __new_data = __get_short_pointer();\n __p = __get_long_pointer();\n } else {\n if (__target_capacity > __cap) {\n // Extend\n // - called from reserve should propagate the exception thrown.\n auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1);\n __new_data = __allocation.ptr;\n __target_capacity = __allocation.count - 1;\n } else {\n // Shrink\n // - called from shrink_to_fit should not throw.\n // - called from reserve may throw but is not required to.\n# if _LIBCPP_HAS_EXCEPTIONS\n try {\n# endif // _LIBCPP_HAS_EXCEPTIONS\n auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1);\n\n // The Standard mandates shrink_to_fit() does not increase the capacity.\n // With equal capacity keep the existing buffer. This avoids extra work\n // due to swapping the elements.\n if (__allocation.count - 1 > capacity()) {\n __alloc_traits::deallocate(__alloc_, __allocation.ptr, __allocation.count);\n return;\n }\n __new_data = __allocation.ptr;\n __target_capacity = __allocation.count - 1;\n# if _LIBCPP_HAS_EXCEPTIONS\n } catch (...) {\n return;\n }\n# endif // _LIBCPP_HAS_EXCEPTIONS\n }\n __begin_lifetime(__new_data, __target_capacity + 1);\n __now_long = true;\n __was_long = __is_long();\n __p = __get_pointer();\n }\n traits_type::copy(std::__to_address(__new_data), std::__to_address(__p), size() + 1);\n if (__was_long)\n __alloc_traits::deallocate(__alloc_, __p, __cap + 1);\n if (__now_long) {\n __set_long_cap(__target_capacity + 1);\n __set_long_size(__sz);\n __set_long_pointer(__new_data);\n } else\n __set_short_size(__sz);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::const_reference\nbasic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const {\n if (__n >= size())\n __throw_out_of_range();\n return (*this)[__n];\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::reference\nbasic_string<_CharT, _Traits, _Allocator>::at(size_type __n) {\n if (__n >= size())\n __throw_out_of_range();\n return (*this)[__n];\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const {\n size_type __sz = size();\n if (__pos > __sz)\n __throw_out_of_range();\n size_type __rlen = std::min(__n, __sz - __pos);\n traits_type::copy(__s, data() + __pos, __rlen);\n return __rlen;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)\n# if _LIBCPP_STD_VER >= 14\n _NOEXCEPT\n# else\n _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)\n# endif\n{\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value ||\n __alloc_ == __str.__alloc_,\n \"swapping non-equal allocators\");\n if (!__is_long())\n __annotate_delete();\n if (this != std::addressof(__str) && !__str.__is_long())\n __str.__annotate_delete();\n std::swap(__rep_, __str.__rep_);\n std::__swap_allocator(__alloc_, __str.__alloc_);\n if (!__is_long())\n __annotate_new(__get_short_size());\n if (this != std::addressof(__str) && !__str.__is_long())\n __str.__annotate_new(__str.__get_short_size());\n}\n\n// find\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"string::find(): received nullptr\");\n return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT {\n return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find(const _Tp& __t, size_type __pos) const _NOEXCEPT {\n __self_view __sv = __t;\n return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::find(): received nullptr\");\n return std::__str_find<value_type, size_type, traits_type, npos>(\n data(), size(), __s, __pos, traits_type::length(__s));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find(value_type __c, size_type __pos) const _NOEXCEPT {\n return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);\n}\n\n// rfind\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::rfind(\n const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"string::rfind(): received nullptr\");\n return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT {\n return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, size_type __pos) const _NOEXCEPT {\n __self_view __sv = __t;\n return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::rfind(): received nullptr\");\n return std::__str_rfind<value_type, size_type, traits_type, npos>(\n data(), size(), __s, __pos, traits_type::length(__s));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, size_type __pos) const _NOEXCEPT {\n return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);\n}\n\n// find_first_of\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_first_of(\n const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"string::find_first_of(): received nullptr\");\n return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT {\n return std::__str_find_first_of<value_type, size_type, traits_type, npos>(\n data(), size(), __str.data(), __pos, __str.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, size_type __pos) const _NOEXCEPT {\n __self_view __sv = __t;\n return std::__str_find_first_of<value_type, size_type, traits_type, npos>(\n data(), size(), __sv.data(), __pos, __sv.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::find_first_of(): received nullptr\");\n return std::__str_find_first_of<value_type, size_type, traits_type, npos>(\n data(), size(), __s, __pos, traits_type::length(__s));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, size_type __pos) const _NOEXCEPT {\n return find(__c, __pos);\n}\n\n// find_last_of\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_last_of(\n const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"string::find_last_of(): received nullptr\");\n return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT {\n return std::__str_find_last_of<value_type, size_type, traits_type, npos>(\n data(), size(), __str.data(), __pos, __str.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, size_type __pos) const _NOEXCEPT {\n __self_view __sv = __t;\n return std::__str_find_last_of<value_type, size_type, traits_type, npos>(\n data(), size(), __sv.data(), __pos, __sv.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::find_last_of(): received nullptr\");\n return std::__str_find_last_of<value_type, size_type, traits_type, npos>(\n data(), size(), __s, __pos, traits_type::length(__s));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, size_type __pos) const _NOEXCEPT {\n return rfind(__c, __pos);\n}\n\n// find_first_not_of\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(\n const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"string::find_first_not_of(): received nullptr\");\n return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(\n const basic_string& __str, size_type __pos) const _NOEXCEPT {\n return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(\n data(), size(), __str.data(), __pos, __str.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT {\n __self_view __sv = __t;\n return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(\n data(), size(), __sv.data(), __pos, __sv.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::find_first_not_of(): received nullptr\");\n return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(\n data(), size(), __s, __pos, traits_type::length(__s));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT {\n return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);\n}\n\n// find_last_not_of\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(\n const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, \"string::find_last_not_of(): received nullptr\");\n return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(\n const basic_string& __str, size_type __pos) const _NOEXCEPT {\n return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(\n data(), size(), __str.data(), __pos, __str.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT {\n __self_view __sv = __t;\n return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(\n data(), size(), __sv.data(), __pos, __sv.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::find_last_not_of(): received nullptr\");\n return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(\n data(), size(), __s, __pos, traits_type::length(__s));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type\nbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT {\n return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);\n}\n\n// compare\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCEPT {\n __self_view __sv = __t;\n size_t __lhs_sz = size();\n size_t __rhs_sz = __sv.size();\n int __result = traits_type::compare(data(), __sv.data(), std::min(__lhs_sz, __rhs_sz));\n if (__result != 0)\n return __result;\n if (__lhs_sz < __rhs_sz)\n return -1;\n if (__lhs_sz > __rhs_sz)\n return 1;\n return 0;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 int\nbasic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT {\n return compare(__self_view(__str));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare(\n size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const {\n _LIBCPP_ASSERT_NON_NULL(__n2 == 0 || __s != nullptr, \"string::compare(): received nullptr\");\n size_type __sz = size();\n if (__pos1 > __sz || __n2 == npos)\n __throw_out_of_range();\n size_type __rlen = std::min(__n1, __sz - __pos1);\n int __r = traits_type::compare(data() + __pos1, __s, std::min(__rlen, __n2));\n if (__r == 0) {\n if (__rlen < __n2)\n __r = -1;\n else if (__rlen > __n2)\n __r = 1;\n }\n return __r;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 int\nbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const _Tp& __t) const {\n __self_view __sv = __t;\n return compare(__pos1, __n1, __sv.data(), __sv.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 int\nbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const basic_string& __str) const {\n return compare(__pos1, __n1, __str.data(), __str.size());\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ntemplate <class _Tp,\n __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&\n !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,\n int> >\n_LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare(\n size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) const {\n __self_view __sv = __t;\n return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare(\n size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const {\n return compare(__pos1, __n1, __self_view(__str), __pos2, __n2);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 int\nbasic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::compare(): received nullptr\");\n return compare(0, npos, __s, traits_type::length(__s));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_CONSTEXPR_SINCE_CXX20 int\nbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const {\n _LIBCPP_ASSERT_NON_NULL(__s != nullptr, \"string::compare(): received nullptr\");\n return compare(__pos1, __n1, __s, traits_type::length(__s));\n}\n\n// __invariants\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 bool basic_string<_CharT, _Traits, _Allocator>::__invariants() const {\n if (size() > capacity())\n return false;\n if (capacity() < __min_cap - 1)\n return false;\n if (data() == nullptr)\n return false;\n if (!_Traits::eq(data()[size()], value_type()))\n return false;\n return true;\n}\n\n// __clear_and_shrink\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT {\n clear();\n if (__is_long()) {\n __annotate_delete();\n __alloc_traits::deallocate(__alloc_, __get_long_pointer(), capacity() + 1);\n __rep_ = __rep();\n }\n}\n\n// operator==\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool\noperator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,\n const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n size_t __lhs_sz = __lhs.size();\n return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), __rhs.data(), __lhs_sz) == 0;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool\noperator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT {\n _LIBCPP_ASSERT_NON_NULL(__rhs != nullptr, \"operator==(basic_string, char*): received nullptr\");\n\n using _String = basic_string<_CharT, _Traits, _Allocator>;\n\n size_t __rhs_len = _Traits::length(__rhs);\n if (__builtin_constant_p(__rhs_len) && !_String::__fits_in_sso(__rhs_len)) {\n if (!__lhs.__is_long())\n return false;\n }\n if (__rhs_len != __lhs.size())\n return false;\n return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0;\n}\n\n# if _LIBCPP_STD_VER <= 17\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return __rhs == __lhs;\n}\n# endif // _LIBCPP_STD_VER <= 17\n\n# if _LIBCPP_STD_VER >= 20\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs,\n const basic_string<_CharT, _Traits, _Allocator>& __rhs) noexcept {\n return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI constexpr auto\noperator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) {\n return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs);\n}\n\n# else // _LIBCPP_STD_VER >= 20\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,\n const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return !(__lhs == __rhs);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator!=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return !(__lhs == __rhs);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT {\n return !(__lhs == __rhs);\n}\n\n// operator<\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool operator<(const basic_string<_CharT, _Traits, _Allocator>& __lhs,\n const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return __lhs.compare(__rhs) < 0;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT {\n return __lhs.compare(__rhs) < 0;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return __rhs.compare(__lhs) > 0;\n}\n\n// operator>\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool operator>(const basic_string<_CharT, _Traits, _Allocator>& __lhs,\n const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return __rhs < __lhs;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT {\n return __rhs < __lhs;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return __rhs < __lhs;\n}\n\n// operator<=\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,\n const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return !(__rhs < __lhs);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT {\n return !(__rhs < __lhs);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return !(__rhs < __lhs);\n}\n\n// operator>=\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,\n const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return !(__lhs < __rhs);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT {\n return !(__lhs < __rhs);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {\n return !(__lhs < __rhs);\n}\n# endif // _LIBCPP_STD_VER >= 20\n\n// operator +\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,\n const basic_string<_CharT, _Traits, _Allocator>& __rhs) {\n using _String = basic_string<_CharT, _Traits, _Allocator>;\n auto __lhs_sz = __lhs.size();\n auto __rhs_sz = __rhs.size();\n _String __r(__uninitialized_size_tag(),\n __lhs_sz + __rhs_sz,\n _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));\n auto __ptr = std::__to_address(__r.__get_pointer());\n _Traits::copy(__ptr, __lhs.data(), __lhs_sz);\n _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);\n _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());\n return __r;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) {\n using _String = basic_string<_CharT, _Traits, _Allocator>;\n auto __lhs_sz = _Traits::length(__lhs);\n auto __rhs_sz = __rhs.size();\n _String __r(__uninitialized_size_tag(),\n __lhs_sz + __rhs_sz,\n _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));\n auto __ptr = std::__to_address(__r.__get_pointer());\n _Traits::copy(__ptr, __lhs, __lhs_sz);\n _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);\n _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());\n return __r;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) {\n using _String = basic_string<_CharT, _Traits, _Allocator>;\n typename _String::size_type __rhs_sz = __rhs.size();\n _String __r(__uninitialized_size_tag(),\n __rhs_sz + 1,\n _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));\n auto __ptr = std::__to_address(__r.__get_pointer());\n _Traits::assign(__ptr, 1, __lhs);\n _Traits::copy(__ptr + 1, __rhs.data(), __rhs_sz);\n _Traits::assign(__ptr + 1 + __rhs_sz, 1, _CharT());\n return __r;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) {\n using _String = basic_string<_CharT, _Traits, _Allocator>;\n typename _String::size_type __lhs_sz = __lhs.size();\n typename _String::size_type __rhs_sz = _Traits::length(__rhs);\n _String __r(__uninitialized_size_tag(),\n __lhs_sz + __rhs_sz,\n _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));\n auto __ptr = std::__to_address(__r.__get_pointer());\n _Traits::copy(__ptr, __lhs.data(), __lhs_sz);\n _Traits::copy(__ptr + __lhs_sz, __rhs, __rhs_sz);\n _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());\n return __r;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) {\n using _String = basic_string<_CharT, _Traits, _Allocator>;\n typename _String::size_type __lhs_sz = __lhs.size();\n _String __r(__uninitialized_size_tag(),\n __lhs_sz + 1,\n _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));\n auto __ptr = std::__to_address(__r.__get_pointer());\n _Traits::copy(__ptr, __lhs.data(), __lhs_sz);\n _Traits::assign(__ptr + __lhs_sz, 1, __rhs);\n _Traits::assign(__ptr + 1 + __lhs_sz, 1, _CharT());\n return __r;\n}\n\n# ifndef _LIBCPP_CXX03_LANG\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) {\n return std::move(__lhs.append(__rhs));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) {\n return std::move(__rhs.insert(0, __lhs));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) {\n return std::move(__lhs.append(__rhs));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(const _CharT* __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) {\n return std::move(__rhs.insert(0, __lhs));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(_CharT __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) {\n __rhs.insert(__rhs.begin(), __lhs);\n return std::move(__rhs);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) {\n return std::move(__lhs.append(__rhs));\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>\noperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) {\n __lhs.push_back(__rhs);\n return std::move(__lhs);\n}\n\n# endif // _LIBCPP_CXX03_LANG\n\n# if _LIBCPP_STD_VER >= 26\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>\noperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,\n type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) {\n using _String = basic_string<_CharT, _Traits, _Allocator>;\n typename _String::size_type __lhs_sz = __lhs.size();\n typename _String::size_type __rhs_sz = __rhs.size();\n _String __r(__uninitialized_size_tag(),\n __lhs_sz + __rhs_sz,\n _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));\n auto __ptr = std::__to_address(__r.__get_pointer());\n _Traits::copy(__ptr, __lhs.data(), __lhs_sz);\n _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);\n _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());\n return __r;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>\noperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs,\n type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) {\n __lhs.append(__rhs);\n return std::move(__lhs);\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>\noperator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,\n const basic_string<_CharT, _Traits, _Allocator>& __rhs) {\n using _String = basic_string<_CharT, _Traits, _Allocator>;\n typename _String::size_type __lhs_sz = __lhs.size();\n typename _String::size_type __rhs_sz = __rhs.size();\n _String __r(__uninitialized_size_tag(),\n __lhs_sz + __rhs_sz,\n _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));\n auto __ptr = std::__to_address(__r.__get_pointer());\n _Traits::copy(__ptr, __lhs.data(), __lhs_sz);\n _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);\n _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());\n return __r;\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>\noperator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,\n basic_string<_CharT, _Traits, _Allocator>&& __rhs) {\n __rhs.insert(0, __lhs);\n return std::move(__rhs);\n}\n\n# endif // _LIBCPP_STD_VER >= 26\n\n// swap\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void\nswap(basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>& __rhs)\n _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs))) {\n __lhs.swap(__rhs);\n}\n\n_LIBCPP_EXPORTED_FROM_ABI int stoi(const string& __str, size_t* __idx = nullptr, int __base = 10);\n_LIBCPP_EXPORTED_FROM_ABI long stol(const string& __str, size_t* __idx = nullptr, int __base = 10);\n_LIBCPP_EXPORTED_FROM_ABI unsigned long stoul(const string& __str, size_t* __idx = nullptr, int __base = 10);\n_LIBCPP_EXPORTED_FROM_ABI long long stoll(const string& __str, size_t* __idx = nullptr, int __base = 10);\n_LIBCPP_EXPORTED_FROM_ABI unsigned long long stoull(const string& __str, size_t* __idx = nullptr, int __base = 10);\n\n_LIBCPP_EXPORTED_FROM_ABI float stof(const string& __str, size_t* __idx = nullptr);\n_LIBCPP_EXPORTED_FROM_ABI double stod(const string& __str, size_t* __idx = nullptr);\n_LIBCPP_EXPORTED_FROM_ABI long double stold(const string& __str, size_t* __idx = nullptr);\n\n_LIBCPP_EXPORTED_FROM_ABI string to_string(int __val);\n_LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned __val);\n_LIBCPP_EXPORTED_FROM_ABI string to_string(long __val);\n_LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned long __val);\n_LIBCPP_EXPORTED_FROM_ABI string to_string(long long __val);\n_LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned long long __val);\n_LIBCPP_EXPORTED_FROM_ABI string to_string(float __val);\n_LIBCPP_EXPORTED_FROM_ABI string to_string(double __val);\n_LIBCPP_EXPORTED_FROM_ABI string to_string(long double __val);\n\n# if _LIBCPP_HAS_WIDE_CHARACTERS\n_LIBCPP_EXPORTED_FROM_ABI int stoi(const wstring& __str, size_t* __idx = nullptr, int __base = 10);\n_LIBCPP_EXPORTED_FROM_ABI long stol(const wstring& __str, size_t* __idx = nullptr, int __base = 10);\n_LIBCPP_EXPORTED_FROM_ABI unsigned long stoul(const wstring& __str, size_t* __idx = nullptr, int __base = 10);\n_LIBCPP_EXPORTED_FROM_ABI long long stoll(const wstring& __str, size_t* __idx = nullptr, int __base = 10);\n_LIBCPP_EXPORTED_FROM_ABI unsigned long long stoull(const wstring& __str, size_t* __idx = nullptr, int __base = 10);\n\n_LIBCPP_EXPORTED_FROM_ABI float stof(const wstring& __str, size_t* __idx = nullptr);\n_LIBCPP_EXPORTED_FROM_ABI double stod(const wstring& __str, size_t* __idx = nullptr);\n_LIBCPP_EXPORTED_FROM_ABI long double stold(const wstring& __str, size_t* __idx = nullptr);\n\n_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(int __val);\n_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned __val);\n_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long __val);\n_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long __val);\n_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long long __val);\n_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long long __val);\n_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(float __val);\n_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(double __val);\n_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long double __val);\n# endif // _LIBCPP_HAS_WIDE_CHARACTERS\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_TEMPLATE_DATA_VIS const typename basic_string<_CharT, _Traits, _Allocator>::size_type\n basic_string<_CharT, _Traits, _Allocator>::npos;\n\ntemplate <class _CharT, class _Allocator>\nstruct __string_hash : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t> {\n _LIBCPP_HIDE_FROM_ABI size_t\n operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT {\n return std::__do_string_hash(__val.data(), __val.data() + __val.size());\n }\n};\n\ntemplate <class _Allocator>\nstruct hash<basic_string<char, char_traits<char>, _Allocator> > : __string_hash<char, _Allocator> {};\n\n# if _LIBCPP_HAS_CHAR8_T\ntemplate <class _Allocator>\nstruct hash<basic_string<char8_t, char_traits<char8_t>, _Allocator> > : __string_hash<char8_t, _Allocator> {};\n# endif\n\ntemplate <class _Allocator>\nstruct hash<basic_string<char16_t, char_traits<char16_t>, _Allocator> > : __string_hash<char16_t, _Allocator> {};\n\ntemplate <class _Allocator>\nstruct hash<basic_string<char32_t, char_traits<char32_t>, _Allocator> > : __string_hash<char32_t, _Allocator> {};\n\n# if _LIBCPP_HAS_WIDE_CHARACTERS\ntemplate <class _Allocator>\nstruct hash<basic_string<wchar_t, char_traits<wchar_t>, _Allocator> > : __string_hash<wchar_t, _Allocator> {};\n# endif\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&\noperator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Allocator>& __str);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&\noperator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&\ngetline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&\ngetline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&\ngetline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);\n\ntemplate <class _CharT, class _Traits, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&\ngetline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str);\n\n# if _LIBCPP_STD_VER >= 20\ntemplate <class _CharT, class _Traits, class _Allocator, class _Up>\ninline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type\nerase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {\n auto __old_size = __str.size();\n __str.erase(std::remove(__str.begin(), __str.end(), __v), __str.end());\n return __old_size - __str.size();\n}\n\ntemplate <class _CharT, class _Traits, class _Allocator, class _Predicate>\ninline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type\nerase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) {\n auto __old_size = __str.size();\n __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), __str.end());\n return __old_size - __str.size();\n}\n# endif\n\n# if _LIBCPP_STD_VER >= 14\n// Literal suffixes for basic_string [basic.string.literals]\ninline namespace literals {\ninline namespace string_literals {\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char>\noperator\"\"s(const char* __str, size_t __len) {\n return basic_string<char>(__str, __len);\n}\n\n# if _LIBCPP_HAS_WIDE_CHARACTERS\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<wchar_t>\noperator\"\"s(const wchar_t* __str, size_t __len) {\n return basic_string<wchar_t>(__str, __len);\n}\n# endif\n\n# if _LIBCPP_HAS_CHAR8_T\ninline _LIBCPP_HIDE_FROM_ABI constexpr basic_string<char8_t> operator\"\"s(const char8_t* __str, size_t __len) {\n return basic_string<char8_t>(__str, __len);\n}\n# endif\n\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char16_t>\noperator\"\"s(const char16_t* __str, size_t __len) {\n return basic_string<char16_t>(__str, __len);\n}\n\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char32_t>\noperator\"\"s(const char32_t* __str, size_t __len) {\n return basic_string<char32_t>(__str, __len);\n}\n} // namespace string_literals\n} // namespace literals\n\n# if _LIBCPP_STD_VER >= 20\ntemplate <>\ninline constexpr bool __format::__enable_insertable<std::basic_string<char>> = true;\n# if _LIBCPP_HAS_WIDE_CHARACTERS\ntemplate <>\ninline constexpr bool __format::__enable_insertable<std::basic_string<wchar_t>> = true;\n# endif\n# endif\n\n# endif\n\n_LIBCPP_END_NAMESPACE_STD\n\n_LIBCPP_POP_MACROS\n\n# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20\n# include <algorithm>\n# include <concepts>\n# include <cstdlib>\n# include <iterator>\n# include <new>\n# include <type_traits>\n# include <typeinfo>\n# include <utility>\n# endif\n#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n\n#endif // _LIBCPP_STRING\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___STRING_CONSTEXPR_C_FUNCTIONS_H\n#define _LIBCPP___STRING_CONSTEXPR_C_FUNCTIONS_H\n\n#include <__config>\n#include <__cstddef/size_t.h>\n#include <__memory/addressof.h>\n#include <__memory/construct_at.h>\n#include <__type_traits/datasizeof.h>\n#include <__type_traits/enable_if.h>\n#include <__type_traits/is_always_bitcastable.h>\n#include <__type_traits/is_assignable.h>\n#include <__type_traits/is_constant_evaluated.h>\n#include <__type_traits/is_constructible.h>\n#include <__type_traits/is_equality_comparable.h>\n#include <__type_traits/is_integral.h>\n#include <__type_traits/is_same.h>\n#include <__type_traits/is_trivially_copyable.h>\n#include <__type_traits/is_trivially_lexicographically_comparable.h>\n#include <__type_traits/remove_cv.h>\n#include <__utility/element_count.h>\n#include <__utility/is_pointer_in_range.h>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\ntemplate <class _Tp>\ninline const bool __is_char_type = false;\n\ntemplate <>\ninline const bool __is_char_type<char> = true;\n\n#if _LIBCPP_HAS_CHAR8_T\ntemplate <>\ninline const bool __is_char_type<char8_t> = true;\n#endif\n\ntemplate <class _Tp>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_strlen(const _Tp* __str) _NOEXCEPT {\n static_assert(__is_char_type<_Tp>, \"__constexpr_strlen only works with char and char8_t\");\n // GCC currently doesn't support __builtin_strlen for heap-allocated memory during constant evaluation.\n // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816\n if (__libcpp_is_constant_evaluated()) {\n#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_COMPILER_CLANG_BASED)\n if constexpr (is_same_v<_Tp, char>)\n return __builtin_strlen(__str);\n#endif\n size_t __i = 0;\n for (; __str[__i] != '\\0'; ++__i)\n ;\n return __i;\n }\n return __builtin_strlen(reinterpret_cast<const char*>(__str));\n}\n\n// Because of __is_trivially_lexicographically_comparable_v we know that comparing the object representations is\n// equivalent to a std::memcmp. Since we have multiple objects contiguously in memory, we can call memcmp once instead\n// of invoking it on every object individually.\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int\n__constexpr_memcmp(const _Tp* __lhs, const _Up* __rhs, __element_count __n) {\n static_assert(__is_trivially_lexicographically_comparable_v<_Tp, _Up>,\n \"_Tp and _Up have to be trivially lexicographically comparable\");\n\n auto __count = static_cast<size_t>(__n);\n\n if (__libcpp_is_constant_evaluated()) {\n#ifdef _LIBCPP_COMPILER_CLANG_BASED\n if (sizeof(_Tp) == 1 && !is_same<_Tp, bool>::value)\n return __builtin_memcmp(__lhs, __rhs, __count * sizeof(_Tp));\n#endif\n\n while (__count != 0) {\n if (*__lhs < *__rhs)\n return -1;\n if (*__rhs < *__lhs)\n return 1;\n\n --__count;\n ++__lhs;\n ++__rhs;\n }\n return 0;\n } else {\n return __builtin_memcmp(__lhs, __rhs, __count * sizeof(_Tp));\n }\n}\n\n// Because of __libcpp_is_trivially_equality_comparable we know that comparing the object representations is equivalent\n// to a std::memcmp(...) == 0. Since we have multiple objects contiguously in memory, we can call memcmp once instead\n// of invoking it on every object individually.\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool\n__constexpr_memcmp_equal(const _Tp* __lhs, const _Up* __rhs, __element_count __n) {\n static_assert(__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,\n \"_Tp and _Up have to be trivially equality comparable\");\n\n auto __count = static_cast<size_t>(__n);\n\n if (__libcpp_is_constant_evaluated()) {\n#ifdef _LIBCPP_COMPILER_CLANG_BASED\n if (sizeof(_Tp) == 1 && is_integral<_Tp>::value && !is_same<_Tp, bool>::value)\n return __builtin_memcmp(__lhs, __rhs, __count * sizeof(_Tp)) == 0;\n#endif\n while (__count != 0) {\n if (*__lhs != *__rhs)\n return false;\n\n --__count;\n ++__lhs;\n ++__rhs;\n }\n return true;\n } else {\n return ::__builtin_memcmp(__lhs, __rhs, __count * sizeof(_Tp)) == 0;\n }\n}\n\ntemplate <class _Tp, class _Up>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_memchr(_Tp* __str, _Up __value, size_t __count) {\n static_assert(sizeof(_Tp) == 1 && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,\n \"Calling memchr on non-trivially equality comparable types is unsafe.\");\n\n if (__libcpp_is_constant_evaluated()) {\n// use __builtin_char_memchr to optimize constexpr evaluation if we can\n#if _LIBCPP_STD_VER >= 17 && __has_builtin(__builtin_char_memchr)\n if constexpr (is_same_v<remove_cv_t<_Tp>, char> && is_same_v<remove_cv_t<_Up>, char>)\n return __builtin_char_memchr(__str, __value, __count);\n#endif\n\n for (; __count; --__count) {\n if (*__str == __value)\n return __str;\n ++__str;\n }\n return nullptr;\n } else {\n char __value_buffer = 0;\n __builtin_memcpy(&__value_buffer, &__value, sizeof(char));\n return static_cast<_Tp*>(__builtin_memchr(__str, __value_buffer, __count));\n }\n}\n\n// This function performs an assignment to an existing, already alive TriviallyCopyable object\n// from another TriviallyCopyable object.\n//\n// It basically works around the fact that TriviallyCopyable objects are not required to be\n// syntactically copy/move constructible or copy/move assignable. Technically, only one of the\n// four operations is required to be syntactically valid -- but at least one definitely has to\n// be valid.\n//\n// This is necessary in order to implement __constexpr_memmove below in a way that mirrors as\n// closely as possible what the compiler's __builtin_memmove is able to do.\ntemplate <class _Tp, class _Up, __enable_if_t<is_assignable<_Tp&, _Up const&>::value, int> = 0>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& __assign_trivially_copyable(_Tp& __dest, _Up const& __src) {\n __dest = __src;\n return __dest;\n}\n\n// clang-format off\ntemplate <class _Tp, class _Up, __enable_if_t<!is_assignable<_Tp&, _Up const&>::value &&\n is_assignable<_Tp&, _Up&&>::value, int> = 0>\n// clang-format on\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& __assign_trivially_copyable(_Tp& __dest, _Up& __src) {\n __dest =\n static_cast<_Up&&>(__src); // this is safe, we're not actually moving anything since the assignment is trivial\n return __dest;\n}\n\n// clang-format off\ntemplate <class _Tp, class _Up, __enable_if_t<!is_assignable<_Tp&, _Up const&>::value &&\n !is_assignable<_Tp&, _Up&&>::value &&\n is_constructible<_Tp, _Up const&>::value, int> = 0>\n// clang-format on\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __assign_trivially_copyable(_Tp& __dest, _Up const& __src) {\n // _Tp is trivially destructible, so we don't need to call its destructor to end the lifetime of the object\n // that was there previously\n std::__construct_at(std::addressof(__dest), __src);\n return __dest;\n}\n\n// clang-format off\ntemplate <class _Tp, class _Up, __enable_if_t<!is_assignable<_Tp&, _Up const&>::value &&\n !is_assignable<_Tp&, _Up&&>::value &&\n !is_constructible<_Tp, _Up const&>::value &&\n is_constructible<_Tp, _Up&&>::value, int> = 0>\n// clang-format on\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __assign_trivially_copyable(_Tp& __dest, _Up& __src) {\n // _Tp is trivially destructible, so we don't need to call its destructor to end the lifetime of the object\n // that was there previously\n std::__construct_at(\n std::addressof(__dest),\n static_cast<_Up&&>(__src)); // this is safe, we're not actually moving anything since the constructor is trivial\n return __dest;\n}\n\ntemplate <class _Tp, class _Up, __enable_if_t<__is_always_bitcastable<_Up, _Tp>::value, int> = 0>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp*\n__constexpr_memmove(_Tp* __dest, _Up* __src, __element_count __n) {\n size_t __count = static_cast<size_t>(__n);\n if (__libcpp_is_constant_evaluated()) {\n#ifdef _LIBCPP_COMPILER_CLANG_BASED\n if (is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value) {\n ::__builtin_memmove(__dest, __src, __count * sizeof(_Tp));\n return __dest;\n }\n#endif\n if (std::__is_pointer_in_range(__src, __src + __count, __dest)) {\n for (; __count > 0; --__count)\n std::__assign_trivially_copyable(__dest[__count - 1], __src[__count - 1]);\n } else {\n for (size_t __i = 0; __i != __count; ++__i)\n std::__assign_trivially_copyable(__dest[__i], __src[__i]);\n }\n } else if (__count > 0) {\n ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __datasizeof_v<_Tp>);\n }\n return __dest;\n}\n\n_LIBCPP_END_NAMESPACE_STD\n\n#endif // _LIBCPP___STRING_CONSTEXPR_C_FUNCTIONS_H\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___STRING_CHAR_TRAITS_H\n#define _LIBCPP___STRING_CHAR_TRAITS_H\n\n#include <__algorithm/fill_n.h>\n#include <__algorithm/find.h>\n#include <__algorithm/find_end.h>\n#include <__algorithm/find_first_of.h>\n#include <__algorithm/min.h>\n#include <__assert>\n#include <__compare/ordering.h>\n#include <__config>\n#include <__cstddef/ptrdiff_t.h>\n#include <__functional/hash.h>\n#include <__functional/identity.h>\n#include <__iterator/iterator_traits.h>\n#include <__std_mbstate_t.h>\n#include <__string/constexpr_c_functions.h>\n#include <__type_traits/is_constant_evaluated.h>\n#include <__utility/is_pointer_in_range.h>\n#include <cstdint>\n#include <cstdio>\n#include <iosfwd>\n\n#if _LIBCPP_HAS_WIDE_CHARACTERS\n# include <cwchar> // for wmemcpy\n#endif\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_PUSH_MACROS\n#include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\ntemplate <class _CharT>\nstruct char_traits;\n/*\nThe Standard does not define the base template for char_traits because it is impossible to provide\na correct definition for arbitrary character types. Instead, it requires implementations to provide\nspecializations for predefined character types like `char`, `wchar_t` and others. We provide this as\nexposition-only to document what members a char_traits specialization should provide:\n{\n using char_type = _CharT;\n using int_type = ...;\n using off_type = ...;\n using pos_type = ...;\n using state_type = ...;\n\n static void assign(char_type&, const char_type&);\n static bool eq(char_type, char_type);\n static bool lt(char_type, char_type);\n\n static int compare(const char_type*, const char_type*, size_t);\n static size_t length(const char_type*);\n static const char_type* find(const char_type*, size_t, const char_type&);\n static char_type* move(char_type*, const char_type*, size_t);\n static char_type* copy(char_type*, const char_type*, size_t);\n static char_type* assign(char_type*, size_t, char_type);\n\n static int_type not_eof(int_type);\n static char_type to_char_type(int_type);\n static int_type to_int_type(char_type);\n static bool eq_int_type(int_type, int_type);\n static int_type eof();\n};\n*/\n\n// char_traits<char>\n\ntemplate <>\nstruct _LIBCPP_TEMPLATE_VIS char_traits<char> {\n using char_type = char;\n using int_type = int;\n using off_type = streamoff;\n using pos_type = streampos;\n using state_type = mbstate_t;\n#if _LIBCPP_STD_VER >= 20\n using comparison_category = strong_ordering;\n#endif\n\n static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void\n assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {\n __c1 = __c2;\n }\n\n // TODO: Make this _LIBCPP_HIDE_FROM_ABI\n static inline _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {\n return __c1 == __c2;\n }\n static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {\n return (unsigned char)__c1 < (unsigned char)__c2;\n }\n\n // __constexpr_memcmp requires a trivially lexicographically comparable type, but char is not when char is a signed\n // type\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int\n compare(const char_type* __lhs, const char_type* __rhs, size_t __count) _NOEXCEPT {\n if (__libcpp_is_constant_evaluated()) {\n#ifdef _LIBCPP_COMPILER_CLANG_BASED\n return __builtin_memcmp(__lhs, __rhs, __count);\n#else\n while (__count != 0) {\n if (lt(*__lhs, *__rhs))\n return -1;\n if (lt(*__rhs, *__lhs))\n return 1;\n\n __count -= sizeof(char_type);\n ++__lhs;\n ++__rhs;\n }\n return 0;\n#endif // _LIBCPP_COMPILER_CLANG_BASED\n } else {\n return __builtin_memcmp(__lhs, __rhs, __count);\n }\n }\n\n static inline _LIBCPP_HIDE_FROM_ABI size_t _LIBCPP_CONSTEXPR_SINCE_CXX17 length(const char_type* __s) _NOEXCEPT {\n return std::__constexpr_strlen(__s);\n }\n\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*\n find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {\n if (__n == 0)\n return nullptr;\n return std::__constexpr_memchr(__s, __a, __n);\n }\n\n static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*\n move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {\n return std::__constexpr_memmove(__s1, __s2, __element_count(__n));\n }\n\n static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*\n copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {\n _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2),\n \"char_traits::copy: source and destination ranges overlap\");\n std::__constexpr_memmove(__s1, __s2, __element_count(__n));\n return __s1;\n }\n\n static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*\n assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {\n std::fill_n(__s, __n, __a);\n return __s;\n }\n\n static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {\n return eq_int_type(__c, eof()) ? ~eof() : __c;\n }\n static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {\n return char_type(__c);\n }\n static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {\n return int_type((unsigned char)__c);\n }\n static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {\n return __c1 == __c2;\n }\n static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(EOF); }\n};\n\ntemplate <class _CharT, class _IntT, _IntT _EOFVal>\nstruct __char_traits_base {\n using char_type = _CharT;\n using int_type = _IntT;\n using off_type = streamoff;\n using state_type = mbstate_t;\n#if _LIBCPP_STD_VER >= 20\n using comparison_category = strong_ordering;\n#endif\n\n // There are different aliases for the different char types, but they are all aliases to this type\n using pos_type = fpos<mbstate_t>;\n\n _LIBCPP_HIDE_FROM_ABI static inline _LIBCPP_CONSTEXPR_SINCE_CXX17 void\n assign(char_type& __lhs, const char_type& __rhs) _NOEXCEPT {\n __lhs = __rhs;\n }\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq(char_type __lhs, char_type __rhs) _NOEXCEPT {\n return __lhs == __rhs;\n }\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool lt(char_type __lhs, char_type __rhs) _NOEXCEPT {\n return __lhs < __rhs;\n }\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*\n move(char_type* __dest, const char_type* __src, size_t __n) _NOEXCEPT {\n return std::__constexpr_memmove(__dest, __src, __element_count(__n));\n }\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*\n copy(char_type* __dest, const char_type* __src, size_t __n) _NOEXCEPT {\n _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__dest, __dest + __n, __src),\n \"char_traits::copy: source and destination ranges overlap\");\n return std::__constexpr_memmove(__dest, __src, __element_count(__n));\n }\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*\n assign(char_type* __str, size_t __n, char_type __fill_char) _NOEXCEPT {\n std::fill_n(__str, __n, __fill_char);\n return __str;\n }\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {\n return char_type(__c);\n }\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { return int_type(__c); }\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __lhs, int_type __rhs) _NOEXCEPT {\n return __lhs == __rhs;\n }\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return _EOFVal; }\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {\n return eq_int_type(__c, eof()) ? static_cast<int_type>(~eof()) : __c;\n }\n};\n\n// char_traits<wchar_t>\n\n#if _LIBCPP_HAS_WIDE_CHARACTERS\ntemplate <>\nstruct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> {\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int\n compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {\n if (__n == 0)\n return 0;\n return std::__constexpr_wmemcmp(__s1, __s2, __n);\n }\n\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT {\n return std::__constexpr_wcslen(__s);\n }\n\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*\n find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {\n if (__n == 0)\n return nullptr;\n return std::__constexpr_wmemchr(__s, __a, __n);\n }\n};\n#endif // _LIBCPP_HAS_WIDE_CHARACTERS\n\n#if _LIBCPP_HAS_CHAR8_T\n\ntemplate <>\nstruct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>\n : __char_traits_base<char8_t, unsigned int, static_cast<unsigned int>(EOF)> {\n static _LIBCPP_HIDE_FROM_ABI constexpr int\n compare(const char_type* __s1, const char_type* __s2, size_t __n) noexcept {\n return std::__constexpr_memcmp(__s1, __s2, __element_count(__n));\n }\n\n static _LIBCPP_HIDE_FROM_ABI constexpr size_t length(const char_type* __str) noexcept {\n return std::__constexpr_strlen(__str);\n }\n\n _LIBCPP_HIDE_FROM_ABI static constexpr const char_type*\n find(const char_type* __s, size_t __n, const char_type& __a) noexcept {\n return std::__constexpr_memchr(__s, __a, __n);\n }\n};\n\n#endif // _LIBCPP_HAS_CHAR8_T\n\ntemplate <>\nstruct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>\n : __char_traits_base<char16_t, uint_least16_t, static_cast<uint_least16_t>(0xFFFF)> {\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int\n compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*\n find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {\n __identity __proj;\n const char_type* __match = std::__find(__s, __s + __n, __a, __proj);\n if (__match == __s + __n)\n return nullptr;\n return __match;\n }\n};\n\ninline _LIBCPP_CONSTEXPR_SINCE_CXX17 int\nchar_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {\n for (; __n; --__n, ++__s1, ++__s2) {\n if (lt(*__s1, *__s2))\n return -1;\n if (lt(*__s2, *__s1))\n return 1;\n }\n return 0;\n}\n\ninline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT {\n size_t __len = 0;\n for (; !eq(*__s, char_type(0)); ++__s)\n ++__len;\n return __len;\n}\n\ntemplate <>\nstruct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>\n : __char_traits_base<char32_t, uint_least32_t, static_cast<uint_least32_t>(0xFFFFFFFF)> {\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int\n compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*\n find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {\n __identity __proj;\n const char_type* __match = std::__find(__s, __s + __n, __a, __proj);\n if (__match == __s + __n)\n return nullptr;\n return __match;\n }\n};\n\ninline _LIBCPP_CONSTEXPR_SINCE_CXX17 int\nchar_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {\n for (; __n; --__n, ++__s1, ++__s2) {\n if (lt(*__s1, *__s2))\n return -1;\n if (lt(*__s2, *__s1))\n return 1;\n }\n return 0;\n}\n\ninline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT {\n size_t __len = 0;\n for (; !eq(*__s, char_type(0)); ++__s)\n ++__len;\n return __len;\n}\n\n// helper fns for basic_string and string_view\n\n// __str_find\ntemplate <class _CharT, class _SizeT, class _Traits, _SizeT __npos>\ninline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n__str_find(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT {\n if (__pos >= __sz)\n return __npos;\n const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);\n if (__r == nullptr)\n return __npos;\n return static_cast<_SizeT>(__r - __p);\n}\n\ntemplate <class _CharT, class _Traits>\n_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 const _CharT* __search_substring(\n const _CharT* __first1, const _CharT* __last1, const _CharT* __first2, const _CharT* __last2) _NOEXCEPT {\n // Take advantage of knowing source and pattern lengths.\n // Stop short when source is smaller than pattern.\n const ptrdiff_t __len2 = __last2 - __first2;\n if (__len2 == 0)\n return __first1;\n\n ptrdiff_t __len1 = __last1 - __first1;\n if (__len1 < __len2)\n return __last1;\n\n // First element of __first2 is loop invariant.\n _CharT __f2 = *__first2;\n while (true) {\n __len1 = __last1 - __first1;\n // Check whether __first1 still has at least __len2 bytes.\n if (__len1 < __len2)\n return __last1;\n\n // Find __f2 the first byte matching in __first1.\n __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);\n if (__first1 == nullptr)\n return __last1;\n\n // It is faster to compare from the first byte of __first1 even if we\n // already know that it matches the first byte of __first2: this is because\n // __first2 is most likely aligned, as it is user's \"pattern\" string, and\n // __first1 + 1 is most likely not aligned, as the match is in the middle of\n // the string.\n if (_Traits::compare(__first1, __first2, __len2) == 0)\n return __first1;\n\n ++__first1;\n }\n}\n\ntemplate <class _CharT, class _SizeT, class _Traits, _SizeT __npos>\ninline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n__str_find(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {\n if (__pos > __sz)\n return __npos;\n\n if (__n == 0) // There is nothing to search, just return __pos.\n return __pos;\n\n const _CharT* __r = std::__search_substring<_CharT, _Traits>(__p + __pos, __p + __sz, __s, __s + __n);\n\n if (__r == __p + __sz)\n return __npos;\n return static_cast<_SizeT>(__r - __p);\n}\n\n// __str_rfind\n\ntemplate <class _CharT, class _SizeT, class _Traits, _SizeT __npos>\ninline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n__str_rfind(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT {\n if (__sz < 1)\n return __npos;\n if (__pos < __sz)\n ++__pos;\n else\n __pos = __sz;\n for (const _CharT* __ps = __p + __pos; __ps != __p;) {\n if (_Traits::eq(*--__ps, __c))\n return static_cast<_SizeT>(__ps - __p);\n }\n return __npos;\n}\n\ntemplate <class _CharT, class _SizeT, class _Traits, _SizeT __npos>\ninline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n__str_rfind(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {\n __pos = std::min(__pos, __sz);\n if (__n < __sz - __pos)\n __pos += __n;\n else\n __pos = __sz;\n const _CharT* __r = std::__find_end_classic(__p, __p + __pos, __s, __s + __n, _Traits::eq);\n if (__n > 0 && __r == __p + __pos)\n return __npos;\n return static_cast<_SizeT>(__r - __p);\n}\n\n// __str_find_first_of\ntemplate <class _CharT, class _SizeT, class _Traits, _SizeT __npos>\ninline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n__str_find_first_of(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {\n if (__pos >= __sz || __n == 0)\n return __npos;\n const _CharT* __r = std::__find_first_of_ce(__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq);\n if (__r == __p + __sz)\n return __npos;\n return static_cast<_SizeT>(__r - __p);\n}\n\n// __str_find_last_of\ntemplate <class _CharT, class _SizeT, class _Traits, _SizeT __npos>\ninline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n__str_find_last_of(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {\n if (__n != 0) {\n if (__pos < __sz)\n ++__pos;\n else\n __pos = __sz;\n for (const _CharT* __ps = __p + __pos; __ps != __p;) {\n const _CharT* __r = _Traits::find(__s, __n, *--__ps);\n if (__r)\n return static_cast<_SizeT>(__ps - __p);\n }\n }\n return __npos;\n}\n\n// __str_find_first_not_of\ntemplate <class _CharT, class _SizeT, class _Traits, _SizeT __npos>\ninline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n__str_find_first_not_of(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {\n if (__pos < __sz) {\n const _CharT* __pe = __p + __sz;\n for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)\n if (_Traits::find(__s, __n, *__ps) == nullptr)\n return static_cast<_SizeT>(__ps - __p);\n }\n return __npos;\n}\n\ntemplate <class _CharT, class _SizeT, class _Traits, _SizeT __npos>\ninline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n__str_find_first_not_of(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT {\n if (__pos < __sz) {\n const _CharT* __pe = __p + __sz;\n for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)\n if (!_Traits::eq(*__ps, __c))\n return static_cast<_SizeT>(__ps - __p);\n }\n return __npos;\n}\n\n// __str_find_last_not_of\ntemplate <class _CharT, class _SizeT, class _Traits, _SizeT __npos>\ninline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n__str_find_last_not_of(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {\n if (__pos < __sz)\n ++__pos;\n else\n __pos = __sz;\n for (const _CharT* __ps = __p + __pos; __ps != __p;)\n if (_Traits::find(__s, __n, *--__ps) == nullptr)\n return static_cast<_SizeT>(__ps - __p);\n return __npos;\n}\n\ntemplate <class _CharT, class _SizeT, class _Traits, _SizeT __npos>\ninline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n__str_find_last_not_of(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT {\n if (__pos < __sz)\n ++__pos;\n else\n __pos = __sz;\n for (const _CharT* __ps = __p + __pos; __ps != __p;)\n if (!_Traits::eq(*--__ps, __c))\n return static_cast<_SizeT>(__ps - __p);\n return __npos;\n}\n\ntemplate <class _Ptr>\ninline _LIBCPP_HIDE_FROM_ABI size_t __do_string_hash(_Ptr __p, _Ptr __e) {\n typedef typename iterator_traits<_Ptr>::value_type value_type;\n return __murmur2_or_cityhash<size_t>()(__p, (__e - __p) * sizeof(value_type));\n}\n\n_LIBCPP_END_NAMESPACE_STD\n\n_LIBCPP_POP_MACROS\n\n#endif // _LIBCPP___STRING_CHAR_TRAITS_H\n","#include <cstring>\n\n#include <ds/helper.hh>\n#include <ds/string.hh>\n\nnamespace ds {\n length_t* string_t::length_pointer() {\n return reinterpret_cast<length_t*>(this);\n }\n\n char* string_t::string_pointer() {\n return reinterpret_cast<char*>(reinterpret_cast<std::byte*>(this) + sizeof(length_t));\n }\n\n length_t string_t::get_length() {\n return *length_pointer();\n }\n\n string_t* string_t::set_length(length_t length, std::byte* check_tail) {\n if (check_before_fail(check_tail, string_pointer(), length)) [[unlikely]] {\n return nullptr;\n }\n *length_pointer() = length;\n return this;\n }\n\n char* string_t::get_string() {\n return string_pointer();\n }\n\n string_t* string_t::set_string(const char* buffer) {\n const char* src = buffer;\n char* dst = get_string();\n bool end = false;\n for (length_t index = 0; index < get_length() - 1; ++index) {\n if (end) {\n dst[index] = 0;\n } else {\n dst[index] = src[index];\n if (src[index] == 0) {\n end = true;\n }\n }\n }\n dst[get_length() - 1] = 0;\n return this;\n }\n\n string_t* string_t::set_null_string(const char* buffer, std::byte* check_tail) {\n length_t length = strlen(buffer) + 1;\n if (check_before_fail(check_tail, string_pointer(), length)) [[unlikely]] {\n return nullptr;\n }\n set_length(length, nullptr);\n set_string(buffer);\n return this;\n }\n\n length_t string_t::data_size() {\n return sizeof(length_t) + sizeof(char) * get_length();\n }\n\n std::byte* string_t::head() {\n return reinterpret_cast<std::byte*>(this);\n }\n\n std::byte* string_t::tail() {\n return head() + data_size();\n }\n\n char* string_t::print(char* buffer, char* check_tail) {\n char* src = get_string();\n char* dst = buffer;\n while (*src) {\n if (check_till_fail(check_tail, dst)) [[unlikely]] {\n return nullptr;\n }\n *(dst++) = *(src++);\n }\n return dst;\n }\n\n const char* string_t::scan(const char* buffer, std::byte* check_tail) {\n const char* src = buffer;\n char* dst = get_string();\n while (true) {\n if (strchr(\"`() \\t\\r\\n\", *src) != nullptr) {\n break;\n }\n if (check_till_fail(check_tail, dst)) [[unlikely]] {\n return nullptr;\n }\n *(dst++) = *(src++);\n }\n if (check_till_fail(check_tail, dst)) [[unlikely]] {\n return nullptr;\n }\n *dst = 0;\n set_length(strlen(get_string()) + 1, nullptr);\n return src;\n }\n} // namespace ds\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP_STRING_H\n#define _LIBCPP_STRING_H\n\n/*\n string.h synopsis\n\nMacros:\n\n NULL\n\nTypes:\n\n size_t\n\nvoid* memcpy(void* restrict s1, const void* restrict s2, size_t n);\nvoid* memmove(void* s1, const void* s2, size_t n);\nchar* strcpy (char* restrict s1, const char* restrict s2);\nchar* strncpy(char* restrict s1, const char* restrict s2, size_t n);\nchar* strcat (char* restrict s1, const char* restrict s2);\nchar* strncat(char* restrict s1, const char* restrict s2, size_t n);\nint memcmp(const void* s1, const void* s2, size_t n);\nint strcmp (const char* s1, const char* s2);\nint strncmp(const char* s1, const char* s2, size_t n);\nint strcoll(const char* s1, const char* s2);\nsize_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);\nconst void* memchr(const void* s, int c, size_t n);\n void* memchr( void* s, int c, size_t n);\nconst char* strchr(const char* s, int c);\n char* strchr( char* s, int c);\nsize_t strcspn(const char* s1, const char* s2);\nconst char* strpbrk(const char* s1, const char* s2);\n char* strpbrk( char* s1, const char* s2);\nconst char* strrchr(const char* s, int c);\n char* strrchr( char* s, int c);\nsize_t strspn(const char* s1, const char* s2);\nconst char* strstr(const char* s1, const char* s2);\n char* strstr( char* s1, const char* s2);\nchar* strtok(char* restrict s1, const char* restrict s2);\nvoid* memset(void* s, int c, size_t n);\nchar* strerror(int errnum);\nsize_t strlen(const char* s);\n\n*/\n\n#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n# include <__cxx03/string.h>\n#else\n# include <__config>\n\n# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n# endif\n\n# if __has_include_next(<string.h>)\n# include_next <string.h>\n# endif\n\n// MSVCRT, GNU libc and its derivates may already have the correct prototype in\n// <string.h>. This macro can be defined by users if their C library provides\n// the right signature.\n# if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \\\n defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)\n# define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS\n# endif\n\n# if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)\nextern \"C++\" {\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strchr(const char* __s, int __c) {\n return __builtin_strchr(__s, __c);\n}\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strchr(char* __s, int __c) {\n return __builtin_strchr(__s, __c);\n}\n\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strpbrk(const char* __s1, const char* __s2) {\n return __builtin_strpbrk(__s1, __s2);\n}\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strpbrk(char* __s1, const char* __s2) {\n return __builtin_strpbrk(__s1, __s2);\n}\n\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strrchr(const char* __s, int __c) {\n return __builtin_strrchr(__s, __c);\n}\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strrchr(char* __s, int __c) {\n return __builtin_strrchr(__s, __c);\n}\n\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const void* memchr(const void* __s, int __c, size_t __n) {\n return __builtin_memchr(__s, __c, __n);\n}\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD void* memchr(void* __s, int __c, size_t __n) {\n return __builtin_memchr(__s, __c, __n);\n}\n\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strstr(const char* __s1, const char* __s2) {\n return __builtin_strstr(__s1, __s2);\n}\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1, const char* __s2) {\n return __builtin_strstr(__s1, __s2);\n}\n} // extern \"C++\"\n# endif\n#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n\n#endif // _LIBCPP_STRING_H\n","#ifndef DS_HELPER_HH\n#define DS_HELPER_HH\n\n#include <cstddef>\n\n#include <ds/config.hh>\n\nnamespace ds {\n template<typename T1, typename T2>\n bool check_before_fail(T1* check_tail, T2* target_tail, length_t offset = 0) {\n if (check_tail != nullptr) {\n if (reinterpret_cast<std::byte*>(check_tail) < reinterpret_cast<std::byte*>(target_tail) + offset) [[unlikely]] {\n return true;\n }\n }\n return false;\n }\n\n template<typename T1, typename T2>\n bool check_till_fail(T1* check_tail, T2* target_tail, length_t offset = 0) {\n if (check_tail != nullptr) {\n if (reinterpret_cast<std::byte*>(check_tail) <= reinterpret_cast<std::byte*>(target_tail) + offset) [[unlikely]] {\n return true;\n }\n }\n return false;\n }\n} // namespace ds\n\n#endif\n","#include <ds/helper.hh>\n#include <ds/variable.hh>\n\nnamespace ds {\n string_t* variable_t::name() {\n return reinterpret_cast<string_t*>(this);\n }\n\n length_t variable_t::data_size() {\n return name()->data_size();\n }\n\n std::byte* variable_t::head() {\n return reinterpret_cast<std::byte*>(this);\n }\n\n std::byte* variable_t::tail() {\n return head() + data_size();\n }\n\n char* variable_t::print(char* buffer, char* check_tail) {\n if (check_till_fail(check_tail, buffer)) [[unlikely]] {\n return nullptr;\n }\n *(buffer++) = '`';\n return name()->print(buffer, check_tail);\n }\n\n const char* variable_t::scan(const char* buffer, std::byte* check_tail) {\n return name()->scan(buffer + 1, check_tail);\n }\n} // namespace ds\n","#include <cstring>\n\n#include <ds/helper.hh>\n#include <ds/list.hh>\n#include <ds/term.hh>\n\nnamespace ds {\n length_t* list_t::list_size_pointer() {\n return reinterpret_cast<length_t*>(this);\n }\n\n length_t* list_t::term_size_pointer(length_t index) {\n if (index < 0 || index > get_list_size()) [[unlikely]] {\n return nullptr;\n }\n return reinterpret_cast<length_t*>(reinterpret_cast<std::byte*>(this) + sizeof(length_t) + sizeof(length_t) * index);\n }\n\n term_t* list_t::term_pointer(length_t index) {\n if (index < 0 || index >= get_list_size()) [[unlikely]] {\n return nullptr;\n }\n return reinterpret_cast<term_t*>(reinterpret_cast<std::byte*>(term_size_pointer(get_list_size())) + term_size(index - 1));\n }\n\n length_t list_t::get_list_size() {\n return *list_size_pointer();\n }\n\n list_t* list_t::set_list_size(length_t list_size, std::byte* check_tail) {\n if (check_before_fail(check_tail, this, sizeof(length_t) + sizeof(length_t) * list_size)) [[unlikely]] {\n return nullptr;\n }\n *list_size_pointer() = list_size;\n for (length_t index = 0; index < get_list_size(); ++index) {\n *term_size_pointer(index) = 0;\n }\n return this;\n }\n\n length_t list_t::term_size(length_t index) {\n if (index == -1) {\n return 0;\n }\n return *term_size_pointer(index);\n }\n\n term_t* list_t::term(length_t index) {\n return term_pointer(index);\n }\n\n void list_t::update_term_size(length_t index) {\n *term_size_pointer(index) = term(index)->data_size() + term_size(index - 1);\n }\n\n length_t list_t::data_size() {\n return sizeof(length_t) + sizeof(length_t) * get_list_size() + term_size(get_list_size() - 1);\n }\n\n std::byte* list_t::head() {\n return reinterpret_cast<std::byte*>(this);\n }\n\n std::byte* list_t::tail() {\n return head() + data_size();\n }\n\n char* list_t::print(char* buffer, char* check_tail) {\n if (check_till_fail(check_tail, buffer)) [[unlikely]] {\n return nullptr;\n }\n *(buffer++) = '(';\n for (length_t index = 0; index < get_list_size(); ++index) {\n if (index != 0) {\n if (check_till_fail(check_tail, buffer)) [[unlikely]] {\n return nullptr;\n }\n *(buffer++) = ' ';\n }\n buffer = term(index)->print(buffer, check_tail);\n if (buffer == nullptr) [[unlikely]] {\n return nullptr;\n }\n }\n if (check_till_fail(check_tail, buffer)) [[unlikely]] {\n return nullptr;\n }\n *(buffer++) = ')';\n return buffer;\n }\n\n const char* list_t::scan(const char* buffer, std::byte* check_tail) {\n // 将当前对象的数据暂时作为buffer,以此读取若干个term\n // 在读取的过程中统计list size\n // 在读取完毕后,将当前对象的数据整体向后移动,留出放置list size和各个term size的空间并填写\n ++buffer;\n term_t* term = reinterpret_cast<term_t*>(this);\n length_t list_size = 0;\n while (true) {\n if (*buffer == ')') {\n ++buffer;\n break;\n }\n if (strchr(\" \\t\\r\\n\", *buffer)) {\n ++buffer;\n continue;\n }\n buffer = term->scan(buffer, check_tail);\n if (buffer == nullptr) [[unlikely]] {\n return nullptr;\n }\n term = reinterpret_cast<term_t*>(term->tail());\n ++list_size;\n }\n length_t offset = sizeof(length_t) + sizeof(length_t) * list_size;\n if (check_before_fail(check_tail, term, offset)) [[unlikely]] {\n return nullptr;\n }\n memmove(\n reinterpret_cast<std::byte*>(this) + offset,\n reinterpret_cast<std::byte*>(this),\n reinterpret_cast<std::byte*>(term) - reinterpret_cast<std::byte*>(this)\n );\n // 向后移动数据后,不需要检查前面的空间是否足够\n set_list_size(list_size, nullptr);\n for (length_t index = 0; index < list_size; ++index) {\n update_term_size(index);\n }\n return buffer;\n }\n} // namespace ds\n","#include <ds/helper.hh>\n#include <ds/item.hh>\n#include <ds/list.hh>\n#include <ds/term.hh>\n#include <ds/variable.hh>\n\nnamespace ds {\n term_type_t* term_t::type_pointer() {\n return reinterpret_cast<term_type_t*>(this);\n }\n\n term_type_t term_t::get_type() {\n return *type_pointer();\n }\n\n term_t* term_t::set_type(term_type_t type, std::byte* check_tail) {\n if (check_before_fail(check_tail, this, sizeof(term_type_t))) [[unlikely]] {\n return nullptr;\n }\n *type_pointer() = type;\n return this;\n }\n\n term_t* term_t::set_null(std::byte* check_tail) {\n return set_type(term_type_t::null, check_tail);\n }\n\n term_t* term_t::set_variable(std::byte* check_tail) {\n return set_type(term_type_t::variable, check_tail);\n }\n\n term_t* term_t::set_item(std::byte* check_tail) {\n return set_type(term_type_t::item, check_tail);\n }\n\n term_t* term_t::set_list(std::byte* check_tail) {\n return set_type(term_type_t::list, check_tail);\n }\n\n bool term_t::is_null() {\n return get_type() == term_type_t::null;\n }\n\n variable_t* term_t::variable() {\n if (get_type() == term_type_t::variable) [[likely]] {\n return reinterpret_cast<variable_t*>(reinterpret_cast<std::byte*>(this) + sizeof(term_type_t));\n } else {\n return nullptr;\n }\n }\n\n item_t* term_t::item() {\n if (get_type() == term_type_t::item) [[likely]] {\n return reinterpret_cast<item_t*>(reinterpret_cast<std::byte*>(this) + sizeof(term_type_t));\n } else {\n return nullptr;\n }\n }\n\n list_t* term_t::list() {\n if (get_type() == term_type_t::list) [[likely]] {\n return reinterpret_cast<list_t*>(reinterpret_cast<std::byte*>(this) + sizeof(term_type_t));\n } else {\n return nullptr;\n }\n }\n\n length_t term_t::data_size() {\n switch (get_type()) {\n case term_type_t::variable:\n return sizeof(term_type_t) + variable()->data_size();\n case term_type_t::item:\n return sizeof(term_type_t) + item()->data_size();\n case term_type_t::list:\n return sizeof(term_type_t) + list()->data_size();\n default:\n return sizeof(term_type_t);\n }\n }\n\n std::byte* term_t::head() {\n return reinterpret_cast<std::byte*>(this);\n }\n\n std::byte* term_t::tail() {\n return head() + data_size();\n }\n\n char* term_t::print(char* buffer, char* check_tail) {\n switch (get_type()) {\n case term_type_t::variable:\n return variable()->print(buffer, check_tail);\n case term_type_t::item:\n return item()->print(buffer, check_tail);\n case term_type_t::list:\n return list()->print(buffer, check_tail);\n default:\n return nullptr;\n }\n }\n\n const char* term_t::scan(const char* buffer, std::byte* check_tail) {\n if (check_before_fail(check_tail, this, sizeof(term_type_t))) [[unlikely]] {\n return nullptr;\n }\n if (*buffer == '`') {\n return set_variable(nullptr)->variable()->scan(buffer, check_tail);\n } else if (*buffer == '(') {\n return set_list(nullptr)->list()->scan(buffer, check_tail);\n } else {\n return set_item(nullptr)->item()->scan(buffer, check_tail);\n }\n }\n} // namespace ds\n","#include <cstring>\n\n#include <ds/helper.hh>\n#include <ds/rule.hh>\n\nnamespace ds {\n term_t* rule_t::conclusion() {\n if (get_list_size() > 0) [[likely]] {\n return term(get_list_size() - 1);\n } else {\n return nullptr;\n }\n }\n\n term_t* rule_t::only_conclusion() {\n if (get_list_size() == 1) [[likely]] {\n return term(0);\n } else {\n return nullptr;\n }\n }\n\n term_t* rule_t::premises(length_t index) {\n if (index < 0 || index >= get_list_size() - 1) [[unlikely]] {\n return nullptr;\n }\n return term(index);\n }\n\n length_t rule_t::premises_count() {\n return get_list_size() - 1;\n }\n\n bool rule_t::valid() {\n return get_list_size() != 0;\n }\n\n rule_t* rule_t::set_null(std::byte* check_tail) {\n if (set_list_size(0, check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n return this;\n }\n\n length_t rule_t::data_size() {\n return list_t::data_size();\n }\n\n std::byte* rule_t::head() {\n return reinterpret_cast<std::byte*>(this);\n }\n\n std::byte* rule_t::tail() {\n return head() + data_size();\n }\n\n char* rule_t::print(char* buffer, char* check_tail) {\n if (!valid()) [[unlikely]] {\n return nullptr;\n }\n // 记录premises的最大长度用于分割符的长度\n length_t max_length = 4;\n // 打印当前term之前的buffer位置\n char* last_buffer = buffer;\n for (length_t index = 0; index < premises_count(); ++index) {\n buffer = premises(index)->print(buffer, check_tail);\n if (buffer == nullptr) [[unlikely]] {\n return nullptr;\n }\n length_t this_length = buffer - last_buffer;\n max_length = this_length > max_length ? this_length : max_length;\n if (check_till_fail(check_tail, buffer)) [[unlikely]] {\n return nullptr;\n }\n *(buffer++) = '\\n';\n last_buffer = buffer;\n }\n if (check_till_fail(check_tail, buffer, max_length)) [[unlikely]] {\n return nullptr;\n }\n for (length_t length = 0; length < max_length; ++length) {\n *(buffer++) = '-';\n }\n *(buffer++) = '\\n';\n buffer = conclusion()->print(buffer, check_tail);\n if (buffer == nullptr) [[unlikely]] {\n return nullptr;\n }\n if (check_till_fail(check_tail, buffer)) [[unlikely]] {\n return nullptr;\n }\n *(buffer++) = '\\n';\n return buffer;\n }\n\n const char* rule_t::scan(const char* buffer, std::byte* check_tail) {\n // 先将当前对象的数据暂时作为buffer,以此读取若干个term\n // 在读取的过程中统计conclusion和premises的总数目\n // 在读取完毕后,将当前对象的数据整体向后移动,留出放置元信息的位置并填写\n term_t* term = reinterpret_cast<term_t*>(this);\n length_t list_size = 0;\n bool last_one = false;\n while (true) {\n if (*buffer == '\\0') {\n break;\n }\n if (strchr(\" \\t\\r\\n\", *buffer)) {\n ++buffer;\n continue;\n }\n if (buffer[0] == '-' && buffer[1] == '-') {\n while (*(buffer++) == '-') {\n }\n last_one = true;\n continue;\n }\n buffer = term->scan(buffer, check_tail);\n if (buffer == nullptr) [[unlikely]] {\n return nullptr;\n }\n term = reinterpret_cast<term_t*>(term->tail());\n ++list_size;\n if (last_one) {\n break;\n }\n }\n length_t offset = sizeof(length_t) + sizeof(length_t) * list_size;\n if (check_before_fail(check_tail, term, offset)) [[unlikely]] {\n return nullptr;\n }\n memmove(\n reinterpret_cast<std::byte*>(this) + offset,\n reinterpret_cast<std::byte*>(this),\n reinterpret_cast<std::byte*>(term) - reinterpret_cast<std::byte*>(this)\n );\n set_list_size(list_size, nullptr);\n for (length_t index = 0; index < list_size; ++index) {\n update_term_size(index);\n }\n return buffer;\n }\n} // namespace ds\n","#include <ds/item.hh>\n\nnamespace ds {\n string_t* item_t::name() {\n return reinterpret_cast<string_t*>(this);\n }\n\n length_t item_t::data_size() {\n return name()->data_size();\n }\n\n std::byte* item_t::head() {\n return reinterpret_cast<std::byte*>(this);\n }\n\n std::byte* item_t::tail() {\n return head() + data_size();\n }\n\n char* item_t::print(char* buffer, char* check_tail) {\n return name()->print(buffer, check_tail);\n }\n\n const char* item_t::scan(const char* buffer, std::byte* check_tail) {\n return name()->scan(buffer, check_tail);\n }\n} // namespace ds\n","#include <cstring>\n\n#include <ds/helper.hh>\n#include <ds/item.hh>\n#include <ds/list.hh>\n#include <ds/rule.hh>\n#include <ds/term.hh>\n#include <ds/variable.hh>\n\nnamespace ds {\n term_t* term_t::ground(term_t* term, term_t* dictionary, const char* scope, std::byte* check_tail) {\n switch (term->get_type()) {\n case term_type_t::variable: {\n char* this_string = term->variable()->name()->get_string();\n list_t* list = dictionary->list();\n for (length_t index = 0; index < list->get_list_size(); ++index) {\n list_t* tuple = list->term(index)->list();\n term_t* key = nullptr;\n term_t* value = nullptr;\n const char* scope_key = nullptr;\n const char* scope_value = nullptr;\n switch (tuple->get_list_size()) {\n case 2:\n scope_key = scope;\n scope_value = scope;\n key = tuple->term(0);\n value = tuple->term(1);\n break;\n case 3:\n scope_key = tuple->term(0)->item()->name()->get_string();\n scope_value = scope_key;\n key = tuple->term(1);\n value = tuple->term(2);\n break;\n case 4:\n scope_key = tuple->term(0)->item()->name()->get_string();\n scope_value = tuple->term(1)->item()->name()->get_string();\n key = tuple->term(2);\n value = tuple->term(3);\n break;\n default:\n return nullptr;\n }\n if (scope != nullptr && strcmp(scope, scope_key) != 0) {\n continue;\n }\n if (strcmp(this_string, key->variable()->name()->get_string()) != 0) {\n continue;\n }\n if (this->ground(value, dictionary, scope_value, check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n return this;\n }\n if (check_before_fail(check_tail, this, term->data_size())) [[unlikely]] {\n return nullptr;\n };\n memcpy(this, term, term->data_size());\n return this;\n }\n case term_type_t::item: {\n if (check_before_fail(check_tail, this, term->data_size())) [[unlikely]] {\n return nullptr;\n };\n memcpy(this, term, term->data_size());\n return this;\n }\n case term_type_t::list: {\n list_t* src = term->list();\n if (set_list(check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n list_t* dst = list();\n if (dst->set_list_size(src->get_list_size(), check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n for (length_t index = 0; index < dst->get_list_size(); ++index) {\n if (dst->term(index)->ground(src->term(index), dictionary, scope, check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n dst->update_term_size(index);\n }\n return this;\n }\n default:\n return nullptr;\n }\n }\n\n rule_t* rule_t::ground(rule_t* rule, term_t* dictionary, const char* scope, std::byte* check_tail) {\n list_t* dst = this;\n list_t* src = rule;\n if (dst->set_list_size(src->get_list_size(), check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n for (length_t index = 0; index < dst->get_list_size(); ++index) {\n if (dst->term(index)->ground(src->term(index), dictionary, scope, check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n dst->update_term_size(index);\n }\n return this;\n }\n\n rule_t* rule_t::ground(rule_t* rule, rule_t* dictionary, const char* scope, std::byte* check_tail) {\n return ground(rule, dictionary->only_conclusion(), scope, check_tail);\n }\n} // namespace ds\n","#include <cstring>\n\n#include <ds/helper.hh>\n#include <ds/item.hh>\n#include <ds/list.hh>\n#include <ds/rule.hh>\n#include <ds/term.hh>\n#include <ds/variable.hh>\n\nnamespace ds {\n namespace {\n /// @brief 存储prefix和suffix字符串信息的结构体。\n struct prefix_suffix_t {\n char* prefix_str; // prefix字符串指针,如果prefix为空则为nullptr\n length_t prefix_len; // prefix字符串长度\n char* suffix_str; // suffix字符串指针,如果suffix为空则为nullptr\n length_t suffix_len; // suffix字符串长度\n };\n\n /// @brief 从prefix_and_suffix中提取prefix和suffix字符串。\n /// @param prefix_and_suffix 格式为((prefix) (suffix))的term,每个内部list包含0或1个item。\n /// @param ps 输出参数,存储提取的prefix和suffix信息。\n /// @return 成功返回true,格式错误返回false。\n bool extract_prefix_suffix(term_t* prefix_and_suffix, prefix_suffix_t* ps) {\n list_t* ps_list = prefix_and_suffix->list();\n if (ps_list == nullptr || ps_list->get_list_size() != 2) [[unlikely]] {\n return false;\n }\n // prefix_and_suffix格式为((prefix) (suffix)),每个元素是包含0或1个item的list\n list_t* prefix_list = ps_list->term(0)->list();\n list_t* suffix_list = ps_list->term(1)->list();\n if (prefix_list == nullptr || suffix_list == nullptr) [[unlikely]] {\n return false;\n }\n // 获取prefix字符串(如果list为空则为nullptr)\n ps->prefix_str = nullptr;\n ps->prefix_len = 0;\n if (prefix_list->get_list_size() == 1) {\n item_t* prefix_item = prefix_list->term(0)->item();\n if (prefix_item == nullptr) [[unlikely]] {\n return false;\n }\n ps->prefix_str = prefix_item->name()->get_string();\n // get_length()返回的是包含末尾\\0的长度,所以需要减1\n ps->prefix_len = prefix_item->name()->get_length() - 1;\n } else if (prefix_list->get_list_size() != 0) [[unlikely]] {\n return false;\n }\n // 获取suffix字符串(如果list为空则为nullptr)\n ps->suffix_str = nullptr;\n ps->suffix_len = 0;\n if (suffix_list->get_list_size() == 1) {\n item_t* suffix_item = suffix_list->term(0)->item();\n if (suffix_item == nullptr) [[unlikely]] {\n return false;\n }\n ps->suffix_str = suffix_item->name()->get_string();\n // get_length()返回的是包含末尾\\0的长度,所以需要减1\n ps->suffix_len = suffix_item->name()->get_length() - 1;\n } else if (suffix_list->get_list_size() != 0) [[unlikely]] {\n return false;\n }\n return true;\n }\n\n /// @brief 内部递归函数,使用已提取的prefix和suffix字符串对term进行重命名。\n /// @param result 存放结果的term指针。\n /// @param term 待被重命名的term。\n /// @param ps 包含prefix和suffix信息的结构体指针。\n /// @param check_tail 可选的尾指针检查。\n /// @return 成功返回result,失败返回nullptr。\n term_t* rename_with_strings(term_t* result, term_t* term, prefix_suffix_t* ps, std::byte* check_tail) {\n switch (term->get_type()) {\n case term_type_t::variable: {\n // get_length()返回的是包含末尾\\0的长度,所以需要减1\n length_t name_len = term->variable()->name()->get_length() - 1;\n length_t new_len = ps->prefix_len + name_len + ps->suffix_len + 1;\n if (result->set_variable(check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n if (result->variable()->name()->set_length(new_len, check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n char* name_str = term->variable()->name()->get_string();\n char* dst = result->variable()->name()->get_string();\n if (ps->prefix_len > 0) {\n memcpy(dst, ps->prefix_str, ps->prefix_len);\n }\n memcpy(dst + ps->prefix_len, name_str, name_len);\n if (ps->suffix_len > 0) {\n memcpy(dst + ps->prefix_len + name_len, ps->suffix_str, ps->suffix_len);\n }\n dst[new_len - 1] = 0;\n return result;\n }\n case term_type_t::item: {\n if (check_before_fail(check_tail, result, term->data_size())) [[unlikely]] {\n return nullptr;\n }\n memcpy(result, term, term->data_size());\n return result;\n }\n case term_type_t::list: {\n list_t* src = term->list();\n if (result->set_list(check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n list_t* dst = result->list();\n if (dst->set_list_size(src->get_list_size(), check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n for (length_t index = 0; index < dst->get_list_size(); ++index) {\n if (rename_with_strings(dst->term(index), src->term(index), ps, check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n dst->update_term_size(index);\n }\n return result;\n }\n default:\n return nullptr;\n }\n }\n } // namespace\n\n term_t* term_t::rename(term_t* term, term_t* prefix_and_suffix, std::byte* check_tail) {\n // 在开头提取prefix和suffix字符串,避免每次递归时重复解析\n prefix_suffix_t ps;\n if (!extract_prefix_suffix(prefix_and_suffix, &ps)) [[unlikely]] {\n return nullptr;\n }\n return rename_with_strings(this, term, &ps, check_tail);\n }\n\n rule_t* rule_t::rename(rule_t* rule, rule_t* prefix_and_suffix, std::byte* check_tail) {\n term_t* ps_term = prefix_and_suffix->only_conclusion();\n if (ps_term == nullptr) [[unlikely]] {\n return nullptr;\n }\n // 在开头提取prefix和suffix字符串,避免每次递归时重复解析\n prefix_suffix_t ps;\n if (!extract_prefix_suffix(ps_term, &ps)) [[unlikely]] {\n return nullptr;\n }\n list_t* dst = this;\n list_t* src = rule;\n if (dst->set_list_size(src->get_list_size(), check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n for (length_t index = 0; index < dst->get_list_size(); ++index) {\n if (rename_with_strings(dst->term(index), src->term(index), &ps, check_tail) == nullptr) [[unlikely]] {\n return nullptr;\n }\n dst->update_term_size(index);\n }\n return this;\n }\n} // namespace ds\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___MEMORY_UNIQUE_PTR_H\n#define _LIBCPP___MEMORY_UNIQUE_PTR_H\n\n#include <__assert>\n#include <__compare/compare_three_way.h>\n#include <__compare/compare_three_way_result.h>\n#include <__compare/three_way_comparable.h>\n#include <__config>\n#include <__cstddef/nullptr_t.h>\n#include <__cstddef/size_t.h>\n#include <__functional/hash.h>\n#include <__functional/operations.h>\n#include <__memory/allocator_traits.h> // __pointer\n#include <__memory/array_cookie.h>\n#include <__memory/auto_ptr.h>\n#include <__memory/compressed_pair.h>\n#include <__memory/pointer_traits.h>\n#include <__type_traits/add_lvalue_reference.h>\n#include <__type_traits/common_type.h>\n#include <__type_traits/conditional.h>\n#include <__type_traits/dependent_type.h>\n#include <__type_traits/enable_if.h>\n#include <__type_traits/integral_constant.h>\n#include <__type_traits/is_array.h>\n#include <__type_traits/is_assignable.h>\n#include <__type_traits/is_bounded_array.h>\n#include <__type_traits/is_constant_evaluated.h>\n#include <__type_traits/is_constructible.h>\n#include <__type_traits/is_convertible.h>\n#include <__type_traits/is_function.h>\n#include <__type_traits/is_pointer.h>\n#include <__type_traits/is_reference.h>\n#include <__type_traits/is_same.h>\n#include <__type_traits/is_swappable.h>\n#include <__type_traits/is_trivially_relocatable.h>\n#include <__type_traits/is_unbounded_array.h>\n#include <__type_traits/is_void.h>\n#include <__type_traits/remove_extent.h>\n#include <__type_traits/type_identity.h>\n#include <__utility/declval.h>\n#include <__utility/forward.h>\n#include <__utility/move.h>\n#include <__utility/private_constructor_tag.h>\n#include <cstdint>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_PUSH_MACROS\n#include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\ntemplate <class _Tp>\nstruct _LIBCPP_TEMPLATE_VIS default_delete {\n static_assert(!is_function<_Tp>::value, \"default_delete cannot be instantiated for function types\");\n#ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI constexpr default_delete() _NOEXCEPT = default;\n#else\n _LIBCPP_HIDE_FROM_ABI default_delete() {}\n#endif\n template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(const default_delete<_Up>&) _NOEXCEPT {}\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) const _NOEXCEPT {\n static_assert(sizeof(_Tp) >= 0, \"cannot delete an incomplete type\");\n static_assert(!is_void<_Tp>::value, \"cannot delete an incomplete type\");\n delete __ptr;\n }\n};\n\ntemplate <class _Tp>\nstruct _LIBCPP_TEMPLATE_VIS default_delete<_Tp[]> {\nprivate:\n template <class _Up>\n struct _EnableIfConvertible : enable_if<is_convertible<_Up (*)[], _Tp (*)[]>::value> {};\n\npublic:\n#ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI constexpr default_delete() _NOEXCEPT = default;\n#else\n _LIBCPP_HIDE_FROM_ABI default_delete() {}\n#endif\n\n template <class _Up>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23\n default_delete(const default_delete<_Up[]>&, typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {}\n\n template <class _Up>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename _EnableIfConvertible<_Up>::type\n operator()(_Up* __ptr) const _NOEXCEPT {\n static_assert(sizeof(_Up) >= 0, \"cannot delete an incomplete type\");\n delete[] __ptr;\n }\n};\n\ntemplate <class _Deleter>\nstruct __is_default_deleter : false_type {};\n\ntemplate <class _Tp>\nstruct __is_default_deleter<default_delete<_Tp> > : true_type {};\n\ntemplate <class _Deleter>\nstruct __unique_ptr_deleter_sfinae {\n static_assert(!is_reference<_Deleter>::value, \"incorrect specialization\");\n typedef const _Deleter& __lval_ref_type;\n typedef _Deleter&& __good_rval_ref_type;\n typedef true_type __enable_rval_overload;\n};\n\ntemplate <class _Deleter>\nstruct __unique_ptr_deleter_sfinae<_Deleter const&> {\n typedef const _Deleter& __lval_ref_type;\n typedef const _Deleter&& __bad_rval_ref_type;\n typedef false_type __enable_rval_overload;\n};\n\ntemplate <class _Deleter>\nstruct __unique_ptr_deleter_sfinae<_Deleter&> {\n typedef _Deleter& __lval_ref_type;\n typedef _Deleter&& __bad_rval_ref_type;\n typedef false_type __enable_rval_overload;\n};\n\n#if defined(_LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI)\n# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__))\n#else\n# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI\n#endif\n\ntemplate <class _Tp, class _Dp = default_delete<_Tp> >\nclass _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {\npublic:\n typedef _Tp element_type;\n typedef _Dp deleter_type;\n using pointer _LIBCPP_NODEBUG = __pointer<_Tp, deleter_type>;\n\n static_assert(!is_rvalue_reference<deleter_type>::value, \"the specified deleter type cannot be an rvalue reference\");\n\n // A unique_ptr contains the following members which may be trivially relocatable:\n // - pointer : this may be trivially relocatable, so it's checked\n // - deleter_type: this may be trivially relocatable, so it's checked\n //\n // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no\n // references to itself. This means that the entire structure is trivially relocatable if its members are.\n using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<\n __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,\n unique_ptr,\n void>;\n\nprivate:\n _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);\n\n using _DeleterSFINAE _LIBCPP_NODEBUG = __unique_ptr_deleter_sfinae<_Dp>;\n\n template <bool _Dummy>\n using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;\n\n template <bool _Dummy>\n using _GoodRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;\n\n template <bool _Dummy>\n using _BadRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;\n\n template <bool _Dummy, class _Deleter = typename __dependent_type< __type_identity<deleter_type>, _Dummy>::type>\n using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =\n __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value>;\n\n template <class _ArgType>\n using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = __enable_if_t<is_constructible<deleter_type, _ArgType>::value>;\n\n template <class _UPtr, class _Up>\n using _EnableIfMoveConvertible _LIBCPP_NODEBUG =\n __enable_if_t< is_convertible<typename _UPtr::pointer, pointer>::value && !is_array<_Up>::value >;\n\n template <class _UDel>\n using _EnableIfDeleterConvertible _LIBCPP_NODEBUG =\n __enable_if_t< (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||\n (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) >;\n\n template <class _UDel>\n using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value >;\n\npublic:\n template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(), __deleter_() {}\n\n template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(), __deleter_() {}\n\n template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT\n : __ptr_(__p),\n __deleter_() {}\n\n template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT\n : __ptr_(__p),\n __deleter_(__d) {}\n\n template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT\n : __ptr_(__p),\n __deleter_(std::move(__d)) {\n static_assert(!is_reference<deleter_type>::value, \"rvalue deleter bound to reference\");\n }\n\n template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> > >\n _LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT\n : __ptr_(__u.release()),\n __deleter_(std::forward<deleter_type>(__u.get_deleter())) {}\n\n template <class _Up,\n class _Ep,\n class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,\n class = _EnableIfDeleterConvertible<_Ep> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT\n : __ptr_(__u.release()),\n __deleter_(std::forward<_Ep>(__u.get_deleter())) {}\n\n#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)\n template <class _Up,\n __enable_if_t<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release()), __deleter_() {}\n#endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {\n reset(__u.release());\n __deleter_ = std::forward<deleter_type>(__u.get_deleter());\n return *this;\n }\n\n template <class _Up,\n class _Ep,\n class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,\n class = _EnableIfDeleterAssignable<_Ep> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {\n reset(__u.release());\n __deleter_ = std::forward<_Ep>(__u.get_deleter());\n return *this;\n }\n\n#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)\n template <class _Up,\n __enable_if_t<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI unique_ptr& operator=(auto_ptr<_Up> __p) {\n reset(__p.release());\n return *this;\n }\n#endif\n\n#ifdef _LIBCPP_CXX03_LANG\n unique_ptr(unique_ptr const&) = delete;\n unique_ptr& operator=(unique_ptr const&) = delete;\n#endif\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(nullptr_t) _NOEXCEPT {\n reset();\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const\n _NOEXCEPT_(_NOEXCEPT_(*std::declval<pointer>())) {\n return *__ptr_;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_; }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {\n return __deleter_;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {\n return __ptr_ != nullptr;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {\n pointer __t = __ptr_;\n __ptr_ = pointer();\n return __t;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(pointer __p = pointer()) _NOEXCEPT {\n pointer __tmp = __ptr_;\n __ptr_ = __p;\n if (__tmp)\n __deleter_(__tmp);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {\n using std::swap;\n swap(__ptr_, __u.__ptr_);\n swap(__deleter_, __u.__deleter_);\n }\n};\n\n// Bounds checking in unique_ptr<T[]>\n// ==================================\n//\n// We provide some helper classes that allow bounds checking when accessing a unique_ptr<T[]>.\n// There are a few cases where bounds checking can be implemented:\n//\n// 1. When an array cookie (see [1]) exists at the beginning of the array allocation, we are\n// able to reuse that cookie to extract the size of the array and perform bounds checking.\n// An array cookie is a size inserted at the beginning of the allocation by the compiler.\n// That size is inserted implicitly when doing `new T[n]` in some cases (as of writing this\n// exactly when the array elements are not trivially destructible), and its main purpose is\n// to allow the runtime to destroy the `n` array elements when doing `delete[] array`.\n// When we are able to use array cookies, we reuse information already available in the\n// current runtime, so bounds checking does not require changing libc++'s ABI.\n//\n// However, note that we cannot assume the presence of an array cookie when a custom deleter\n// is used, because the unique_ptr could have been created from an allocation that wasn't\n// obtained via `new T[n]` (since it may not be deleted with `delete[] arr`).\n//\n// 2. When the \"bounded unique_ptr\" ABI configuration (controlled by `_LIBCPP_ABI_BOUNDED_UNIQUE_PTR`)\n// is enabled, we store the size of the allocation (when it is known) so we can check it when\n// indexing into the `unique_ptr`. That changes the layout of `std::unique_ptr<T[]>`, which is\n// an ABI break from the default configuration.\n//\n// Note that even under this ABI configuration, we can't always know the size of the unique_ptr.\n// Indeed, the size of the allocation can only be known when the unique_ptr is created via\n// make_unique or a similar API. For example, it can't be known when constructed from an arbitrary\n// pointer, in which case we are not able to check the bounds on access:\n//\n// unique_ptr<T[], MyDeleter> ptr(new T[3]);\n//\n// When we don't know the size of the allocation via the API used to create the unique_ptr, we\n// try to fall back to using an array cookie when available.\n//\n// Finally, note that when this ABI configuration is enabled, we have no choice but to always\n// make space for the size to be stored in the unique_ptr. Indeed, while we might want to avoid\n// storing the size when an array cookie is available, knowing whether an array cookie is available\n// requires the type stored in the unique_ptr to be complete, while unique_ptr can normally\n// accommodate incomplete types.\n//\n// (1) Implementation where we rely on the array cookie to know the size of the allocation, if\n// an array cookie exists.\nstruct __unique_ptr_array_bounds_stateless {\n __unique_ptr_array_bounds_stateless() = default;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __unique_ptr_array_bounds_stateless(size_t) {}\n\n template <class _Deleter,\n class _Tp,\n __enable_if_t<__is_default_deleter<_Deleter>::value && __has_array_cookie<_Tp>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const {\n // In constant expressions, we can't check the array cookie so we just pretend that the index\n // is in-bounds. The compiler catches invalid accesses anyway.\n if (__libcpp_is_constant_evaluated())\n return true;\n size_t __cookie = std::__get_array_cookie(__ptr);\n return __index < __cookie;\n }\n\n template <class _Deleter,\n class _Tp,\n __enable_if_t<!__is_default_deleter<_Deleter>::value || !__has_array_cookie<_Tp>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t) const {\n return true; // If we don't have an array cookie, we assume the access is in-bounds\n }\n};\n\n// (2) Implementation where we store the size in the class whenever we have it.\n//\n// Semantically, we'd need to store the size as an optional<size_t>. However, since that\n// is really heavy weight, we instead store a size_t and use SIZE_MAX as a magic value\n// meaning that we don't know the size.\nstruct __unique_ptr_array_bounds_stored {\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __unique_ptr_array_bounds_stored() : __size_(SIZE_MAX) {}\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __unique_ptr_array_bounds_stored(size_t __size) : __size_(__size) {}\n\n // Use the array cookie if there's one\n template <class _Deleter,\n class _Tp,\n __enable_if_t<__is_default_deleter<_Deleter>::value && __has_array_cookie<_Tp>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const {\n if (__libcpp_is_constant_evaluated())\n return true;\n size_t __cookie = std::__get_array_cookie(__ptr);\n return __index < __cookie;\n }\n\n // Otherwise, fall back on the stored size (if any)\n template <class _Deleter,\n class _Tp,\n __enable_if_t<!__is_default_deleter<_Deleter>::value || !__has_array_cookie<_Tp>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t __index) const {\n return __index < __size_;\n }\n\nprivate:\n size_t __size_;\n};\n\ntemplate <class _Tp, class _Dp>\nclass _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> {\npublic:\n typedef _Tp element_type;\n typedef _Dp deleter_type;\n using pointer = __pointer<_Tp, deleter_type>;\n\n // A unique_ptr contains the following members which may be trivially relocatable:\n // - pointer: this may be trivially relocatable, so it's checked\n // - deleter_type: this may be trivially relocatable, so it's checked\n // - (optionally) size: this is trivially relocatable\n //\n // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no\n // references to itself. This means that the entire structure is trivially relocatable if its members are.\n using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<\n __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,\n unique_ptr,\n void>;\n\nprivate:\n template <class _Up, class _OtherDeleter>\n friend class unique_ptr;\n\n _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);\n#ifdef _LIBCPP_ABI_BOUNDED_UNIQUE_PTR\n using _BoundsChecker _LIBCPP_NODEBUG = __unique_ptr_array_bounds_stored;\n#else\n using _BoundsChecker _LIBCPP_NODEBUG = __unique_ptr_array_bounds_stateless;\n#endif\n _LIBCPP_NO_UNIQUE_ADDRESS _BoundsChecker __checker_;\n\n template <class _From>\n struct _CheckArrayPointerConversion : is_same<_From, pointer> {};\n\n template <class _FromElem>\n struct _CheckArrayPointerConversion<_FromElem*>\n : integral_constant<bool,\n is_same<_FromElem*, pointer>::value ||\n (is_same<pointer, element_type*>::value &&\n is_convertible<_FromElem (*)[], element_type (*)[]>::value) > {};\n\n typedef __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;\n\n template <bool _Dummy>\n using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;\n\n template <bool _Dummy>\n using _GoodRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;\n\n template <bool _Dummy>\n using _BadRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;\n\n template <bool _Dummy, class _Deleter = typename __dependent_type< __type_identity<deleter_type>, _Dummy>::type>\n using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =\n __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value>;\n\n template <class _ArgType>\n using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = __enable_if_t<is_constructible<deleter_type, _ArgType>::value>;\n\n template <class _Pp>\n using _EnableIfPointerConvertible _LIBCPP_NODEBUG = __enable_if_t< _CheckArrayPointerConversion<_Pp>::value >;\n\n template <class _UPtr, class _Up, class _ElemT = typename _UPtr::element_type>\n using _EnableIfMoveConvertible _LIBCPP_NODEBUG =\n __enable_if_t< is_array<_Up>::value && is_same<pointer, element_type*>::value &&\n is_same<typename _UPtr::pointer, _ElemT*>::value &&\n is_convertible<_ElemT (*)[], element_type (*)[]>::value >;\n\n template <class _UDel>\n using _EnableIfDeleterConvertible _LIBCPP_NODEBUG =\n __enable_if_t< (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||\n (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) >;\n\n template <class _UDel>\n using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value >;\n\npublic:\n template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(), __deleter_() {}\n\n template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(), __deleter_() {}\n\n template <class _Pp,\n bool _Dummy = true,\n class = _EnableIfDeleterDefaultConstructible<_Dummy>,\n class = _EnableIfPointerConvertible<_Pp> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __ptr) _NOEXCEPT\n : __ptr_(__ptr),\n __deleter_() {}\n\n // Private constructor used by make_unique & friends to pass the size that was allocated\n template <class _Tag, class _Ptr, __enable_if_t<is_same<_Tag, __private_constructor_tag>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Tag, _Ptr __ptr, size_t __size) _NOEXCEPT\n : __ptr_(__ptr),\n __checker_(__size) {}\n\n template <class _Pp,\n bool _Dummy = true,\n class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,\n class = _EnableIfPointerConvertible<_Pp> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __ptr, _LValRefType<_Dummy> __deleter) _NOEXCEPT\n : __ptr_(__ptr),\n __deleter_(__deleter) {}\n\n template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _LValRefType<_Dummy> __deleter) _NOEXCEPT\n : __ptr_(nullptr),\n __deleter_(__deleter) {}\n\n template <class _Pp,\n bool _Dummy = true,\n class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,\n class = _EnableIfPointerConvertible<_Pp> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23\n unique_ptr(_Pp __ptr, _GoodRValRefType<_Dummy> __deleter) _NOEXCEPT\n : __ptr_(__ptr),\n __deleter_(std::move(__deleter)) {\n static_assert(!is_reference<deleter_type>::value, \"rvalue deleter bound to reference\");\n }\n\n template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23\n unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __deleter) _NOEXCEPT\n : __ptr_(nullptr),\n __deleter_(std::move(__deleter)) {\n static_assert(!is_reference<deleter_type>::value, \"rvalue deleter bound to reference\");\n }\n\n template <class _Pp,\n bool _Dummy = true,\n class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >,\n class = _EnableIfPointerConvertible<_Pp> >\n _LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __ptr, _BadRValRefType<_Dummy> __deleter) = delete;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT\n : __ptr_(__u.release()),\n __deleter_(std::forward<deleter_type>(__u.get_deleter())),\n __checker_(std::move(__u.__checker_)) {}\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {\n reset(__u.release());\n __deleter_ = std::forward<deleter_type>(__u.get_deleter());\n __checker_ = std::move(__u.__checker_);\n return *this;\n }\n\n template <class _Up,\n class _Ep,\n class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,\n class = _EnableIfDeleterConvertible<_Ep> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT\n : __ptr_(__u.release()),\n __deleter_(std::forward<_Ep>(__u.get_deleter())),\n __checker_(std::move(__u.__checker_)) {}\n\n template <class _Up,\n class _Ep,\n class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,\n class = _EnableIfDeleterAssignable<_Ep> >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {\n reset(__u.release());\n __deleter_ = std::forward<_Ep>(__u.get_deleter());\n __checker_ = std::move(__u.__checker_);\n return *this;\n }\n\n#ifdef _LIBCPP_CXX03_LANG\n unique_ptr(unique_ptr const&) = delete;\n unique_ptr& operator=(unique_ptr const&) = delete;\n#endif\n\npublic:\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(nullptr_t) _NOEXCEPT {\n reset();\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator[](size_t __i) const {\n _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__checker_.__in_bounds<deleter_type>(std::__to_address(__ptr_), __i),\n \"unique_ptr<T[]>::operator[](index): index out of range\");\n return __ptr_[__i];\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {\n return __deleter_;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {\n return __ptr_ != nullptr;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {\n pointer __t = __ptr_;\n __ptr_ = pointer();\n // The deleter and the optional bounds-checker are left unchanged. The bounds-checker\n // will be reinitialized appropriately when/if the unique_ptr gets assigned-to or reset.\n return __t;\n }\n\n template <class _Pp, __enable_if_t<_CheckArrayPointerConversion<_Pp>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(_Pp __ptr) _NOEXCEPT {\n pointer __tmp = __ptr_;\n __ptr_ = __ptr;\n __checker_ = _BoundsChecker();\n if (__tmp)\n __deleter_(__tmp);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(nullptr_t = nullptr) _NOEXCEPT {\n pointer __tmp = __ptr_;\n __ptr_ = nullptr;\n __checker_ = _BoundsChecker();\n if (__tmp)\n __deleter_(__tmp);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {\n using std::swap;\n swap(__ptr_, __u.__ptr_);\n swap(__deleter_, __u.__deleter_);\n swap(__checker_, __u.__checker_);\n }\n};\n\ntemplate <class _Tp, class _Dp, __enable_if_t<__is_swappable_v<_Dp>, int> = 0>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void\nswap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {\n __x.swap(__y);\n}\n\ntemplate <class _T1, class _D1, class _T2, class _D2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool\noperator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {\n return __x.get() == __y.get();\n}\n\n#if _LIBCPP_STD_VER <= 17\ntemplate <class _T1, class _D1, class _T2, class _D2>\ninline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {\n return !(__x == __y);\n}\n#endif\n\ntemplate <class _T1, class _D1, class _T2, class _D2>\ninline _LIBCPP_HIDE_FROM_ABI bool operator<(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {\n typedef typename unique_ptr<_T1, _D1>::pointer _P1;\n typedef typename unique_ptr<_T2, _D2>::pointer _P2;\n typedef typename common_type<_P1, _P2>::type _Vp;\n return less<_Vp>()(__x.get(), __y.get());\n}\n\ntemplate <class _T1, class _D1, class _T2, class _D2>\ninline _LIBCPP_HIDE_FROM_ABI bool operator>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {\n return __y < __x;\n}\n\ntemplate <class _T1, class _D1, class _T2, class _D2>\ninline _LIBCPP_HIDE_FROM_ABI bool operator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {\n return !(__y < __x);\n}\n\ntemplate <class _T1, class _D1, class _T2, class _D2>\ninline _LIBCPP_HIDE_FROM_ABI bool operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {\n return !(__x < __y);\n}\n\n#if _LIBCPP_STD_VER >= 20\ntemplate <class _T1, class _D1, class _T2, class _D2>\n requires three_way_comparable_with<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer>\n_LIBCPP_HIDE_FROM_ABI\ncompare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer>\noperator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {\n return compare_three_way()(__x.get(), __y.get());\n}\n#endif\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool\noperator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT {\n return !__x;\n}\n\n#if _LIBCPP_STD_VER <= 17\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI bool operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT {\n return !__x;\n}\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT {\n return static_cast<bool>(__x);\n}\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI bool operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT {\n return static_cast<bool>(__x);\n}\n#endif // _LIBCPP_STD_VER <= 17\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t) {\n typedef typename unique_ptr<_T1, _D1>::pointer _P1;\n return less<_P1>()(__x.get(), nullptr);\n}\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x) {\n typedef typename unique_ptr<_T1, _D1>::pointer _P1;\n return less<_P1>()(nullptr, __x.get());\n}\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {\n return nullptr < __x;\n}\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x) {\n return __x < nullptr;\n}\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t) {\n return !(nullptr < __x);\n}\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {\n return !(__x < nullptr);\n}\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t) {\n return !(__x < nullptr);\n}\n\ntemplate <class _T1, class _D1>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {\n return !(nullptr < __x);\n}\n\n#if _LIBCPP_STD_VER >= 20\ntemplate <class _T1, class _D1>\n requires three_way_comparable< typename unique_ptr<_T1, _D1>::pointer>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer>\noperator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {\n return compare_three_way()(__x.get(), static_cast<typename unique_ptr<_T1, _D1>::pointer>(nullptr));\n}\n#endif\n\n#if _LIBCPP_STD_VER >= 14\n\ntemplate <class _Tp, class... _Args, enable_if_t<!is_array<_Tp>::value, int> = 0>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique(_Args&&... __args) {\n return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));\n}\n\ntemplate <class _Tp, enable_if_t<__is_unbounded_array_v<_Tp>, int> = 0>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique(size_t __n) {\n typedef __remove_extent_t<_Tp> _Up;\n return unique_ptr<_Tp>(__private_constructor_tag(), new _Up[__n](), __n);\n}\n\ntemplate <class _Tp, class... _Args, enable_if_t<__is_bounded_array_v<_Tp>, int> = 0>\nvoid make_unique(_Args&&...) = delete;\n\n#endif // _LIBCPP_STD_VER >= 14\n\n#if _LIBCPP_STD_VER >= 20\n\ntemplate <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique_for_overwrite() {\n return unique_ptr<_Tp>(new _Tp);\n}\n\ntemplate <class _Tp, enable_if_t<is_unbounded_array_v<_Tp>, int> = 0>\n_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique_for_overwrite(size_t __n) {\n return unique_ptr<_Tp>(__private_constructor_tag(), new __remove_extent_t<_Tp>[__n], __n);\n}\n\ntemplate <class _Tp, class... _Args, enable_if_t<is_bounded_array_v<_Tp>, int> = 0>\nvoid make_unique_for_overwrite(_Args&&...) = delete;\n\n#endif // _LIBCPP_STD_VER >= 20\n\ntemplate <class _Tp>\nstruct _LIBCPP_TEMPLATE_VIS hash;\n\ntemplate <class _Tp, class _Dp>\n#ifdef _LIBCPP_CXX03_LANG\nstruct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> >\n#else\nstruct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper< unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> >\n#endif\n{\n#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)\n _LIBCPP_DEPRECATED_IN_CXX17 typedef unique_ptr<_Tp, _Dp> argument_type;\n _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;\n#endif\n\n _LIBCPP_HIDE_FROM_ABI size_t operator()(const unique_ptr<_Tp, _Dp>& __ptr) const {\n typedef typename unique_ptr<_Tp, _Dp>::pointer pointer;\n return hash<pointer>()(__ptr.get());\n }\n};\n\n_LIBCPP_END_NAMESPACE_STD\n\n_LIBCPP_POP_MACROS\n\n#endif // _LIBCPP___MEMORY_UNIQUE_PTR_H\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___TREE\n#define _LIBCPP___TREE\n\n#include <__algorithm/min.h>\n#include <__assert>\n#include <__config>\n#include <__iterator/distance.h>\n#include <__iterator/iterator_traits.h>\n#include <__iterator/next.h>\n#include <__memory/addressof.h>\n#include <__memory/allocator_traits.h>\n#include <__memory/compressed_pair.h>\n#include <__memory/pointer_traits.h>\n#include <__memory/swap_allocator.h>\n#include <__memory/unique_ptr.h>\n#include <__type_traits/can_extract_key.h>\n#include <__type_traits/enable_if.h>\n#include <__type_traits/invoke.h>\n#include <__type_traits/is_const.h>\n#include <__type_traits/is_constructible.h>\n#include <__type_traits/is_nothrow_assignable.h>\n#include <__type_traits/is_nothrow_constructible.h>\n#include <__type_traits/is_same.h>\n#include <__type_traits/is_swappable.h>\n#include <__type_traits/remove_const_ref.h>\n#include <__type_traits/remove_cvref.h>\n#include <__utility/forward.h>\n#include <__utility/move.h>\n#include <__utility/pair.h>\n#include <__utility/swap.h>\n#include <limits>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_PUSH_MACROS\n#include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\ntemplate <class, class, class, class>\nclass _LIBCPP_TEMPLATE_VIS map;\ntemplate <class, class, class, class>\nclass _LIBCPP_TEMPLATE_VIS multimap;\ntemplate <class, class, class>\nclass _LIBCPP_TEMPLATE_VIS set;\ntemplate <class, class, class>\nclass _LIBCPP_TEMPLATE_VIS multiset;\n\ntemplate <class _Tp, class _Compare, class _Allocator>\nclass __tree;\ntemplate <class _Tp, class _NodePtr, class _DiffType>\nclass _LIBCPP_TEMPLATE_VIS __tree_iterator;\ntemplate <class _Tp, class _ConstNodePtr, class _DiffType>\nclass _LIBCPP_TEMPLATE_VIS __tree_const_iterator;\n\ntemplate <class _Pointer>\nclass __tree_end_node;\ntemplate <class _VoidPtr>\nclass __tree_node_base;\ntemplate <class _Tp, class _VoidPtr>\nclass __tree_node;\n\ntemplate <class _Key, class _Value>\nstruct __value_type;\n\ntemplate <class _Allocator>\nclass __map_node_destructor;\ntemplate <class _TreeIterator>\nclass _LIBCPP_TEMPLATE_VIS __map_iterator;\ntemplate <class _TreeIterator>\nclass _LIBCPP_TEMPLATE_VIS __map_const_iterator;\n\n/*\n\n_NodePtr algorithms\n\nThe algorithms taking _NodePtr are red black tree algorithms. Those\nalgorithms taking a parameter named __root should assume that __root\npoints to a proper red black tree (unless otherwise specified).\n\nEach algorithm herein assumes that __root->__parent_ points to a non-null\nstructure which has a member __left_ which points back to __root. No other\nmember is read or written to at __root->__parent_.\n\n__root->__parent_ will be referred to below (in comments only) as end_node.\nend_node->__left_ is an externably accessible lvalue for __root, and can be\nchanged by node insertion and removal (without explicit reference to end_node).\n\nAll nodes (with the exception of end_node), even the node referred to as\n__root, have a non-null __parent_ field.\n\n*/\n\n// Returns: true if __x is a left child of its parent, else false\n// Precondition: __x != nullptr.\ntemplate <class _NodePtr>\ninline _LIBCPP_HIDE_FROM_ABI bool __tree_is_left_child(_NodePtr __x) _NOEXCEPT {\n return __x == __x->__parent_->__left_;\n}\n\n// Determines if the subtree rooted at __x is a proper red black subtree. If\n// __x is a proper subtree, returns the black height (null counts as 1). If\n// __x is an improper subtree, returns 0.\ntemplate <class _NodePtr>\nunsigned __tree_sub_invariant(_NodePtr __x) {\n if (__x == nullptr)\n return 1;\n // parent consistency checked by caller\n // check __x->__left_ consistency\n if (__x->__left_ != nullptr && __x->__left_->__parent_ != __x)\n return 0;\n // check __x->__right_ consistency\n if (__x->__right_ != nullptr && __x->__right_->__parent_ != __x)\n return 0;\n // check __x->__left_ != __x->__right_ unless both are nullptr\n if (__x->__left_ == __x->__right_ && __x->__left_ != nullptr)\n return 0;\n // If this is red, neither child can be red\n if (!__x->__is_black_) {\n if (__x->__left_ && !__x->__left_->__is_black_)\n return 0;\n if (__x->__right_ && !__x->__right_->__is_black_)\n return 0;\n }\n unsigned __h = std::__tree_sub_invariant(__x->__left_);\n if (__h == 0)\n return 0; // invalid left subtree\n if (__h != std::__tree_sub_invariant(__x->__right_))\n return 0; // invalid or different height right subtree\n return __h + __x->__is_black_; // return black height of this node\n}\n\n// Determines if the red black tree rooted at __root is a proper red black tree.\n// __root == nullptr is a proper tree. Returns true is __root is a proper\n// red black tree, else returns false.\ntemplate <class _NodePtr>\n_LIBCPP_HIDE_FROM_ABI bool __tree_invariant(_NodePtr __root) {\n if (__root == nullptr)\n return true;\n // check __x->__parent_ consistency\n if (__root->__parent_ == nullptr)\n return false;\n if (!std::__tree_is_left_child(__root))\n return false;\n // root must be black\n if (!__root->__is_black_)\n return false;\n // do normal node checks\n return std::__tree_sub_invariant(__root) != 0;\n}\n\n// Returns: pointer to the left-most node under __x.\ntemplate <class _NodePtr>\ninline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_min(_NodePtr __x) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__x != nullptr, \"Root node shouldn't be null\");\n while (__x->__left_ != nullptr)\n __x = __x->__left_;\n return __x;\n}\n\n// Returns: pointer to the right-most node under __x.\ntemplate <class _NodePtr>\ninline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_max(_NodePtr __x) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__x != nullptr, \"Root node shouldn't be null\");\n while (__x->__right_ != nullptr)\n __x = __x->__right_;\n return __x;\n}\n\n// Returns: pointer to the next in-order node after __x.\ntemplate <class _NodePtr>\n_LIBCPP_HIDE_FROM_ABI _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__x != nullptr, \"node shouldn't be null\");\n if (__x->__right_ != nullptr)\n return std::__tree_min(__x->__right_);\n while (!std::__tree_is_left_child(__x))\n __x = __x->__parent_unsafe();\n return __x->__parent_unsafe();\n}\n\ntemplate <class _EndNodePtr, class _NodePtr>\ninline _LIBCPP_HIDE_FROM_ABI _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__x != nullptr, \"node shouldn't be null\");\n if (__x->__right_ != nullptr)\n return static_cast<_EndNodePtr>(std::__tree_min(__x->__right_));\n while (!std::__tree_is_left_child(__x))\n __x = __x->__parent_unsafe();\n return static_cast<_EndNodePtr>(__x->__parent_);\n}\n\n// Returns: pointer to the previous in-order node before __x.\n// Note: __x may be the end node.\ntemplate <class _NodePtr, class _EndNodePtr>\ninline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__x != nullptr, \"node shouldn't be null\");\n if (__x->__left_ != nullptr)\n return std::__tree_max(__x->__left_);\n _NodePtr __xx = static_cast<_NodePtr>(__x);\n while (std::__tree_is_left_child(__xx))\n __xx = __xx->__parent_unsafe();\n return __xx->__parent_unsafe();\n}\n\n// Returns: pointer to a node which has no children\ntemplate <class _NodePtr>\n_LIBCPP_HIDE_FROM_ABI _NodePtr __tree_leaf(_NodePtr __x) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__x != nullptr, \"node shouldn't be null\");\n while (true) {\n if (__x->__left_ != nullptr) {\n __x = __x->__left_;\n continue;\n }\n if (__x->__right_ != nullptr) {\n __x = __x->__right_;\n continue;\n }\n break;\n }\n return __x;\n}\n\n// Effects: Makes __x->__right_ the subtree root with __x as its left child\n// while preserving in-order order.\ntemplate <class _NodePtr>\n_LIBCPP_HIDE_FROM_ABI void __tree_left_rotate(_NodePtr __x) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__x != nullptr, \"node shouldn't be null\");\n _LIBCPP_ASSERT_INTERNAL(__x->__right_ != nullptr, \"node should have a right child\");\n _NodePtr __y = __x->__right_;\n __x->__right_ = __y->__left_;\n if (__x->__right_ != nullptr)\n __x->__right_->__set_parent(__x);\n __y->__parent_ = __x->__parent_;\n if (std::__tree_is_left_child(__x))\n __x->__parent_->__left_ = __y;\n else\n __x->__parent_unsafe()->__right_ = __y;\n __y->__left_ = __x;\n __x->__set_parent(__y);\n}\n\n// Effects: Makes __x->__left_ the subtree root with __x as its right child\n// while preserving in-order order.\ntemplate <class _NodePtr>\n_LIBCPP_HIDE_FROM_ABI void __tree_right_rotate(_NodePtr __x) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__x != nullptr, \"node shouldn't be null\");\n _LIBCPP_ASSERT_INTERNAL(__x->__left_ != nullptr, \"node should have a left child\");\n _NodePtr __y = __x->__left_;\n __x->__left_ = __y->__right_;\n if (__x->__left_ != nullptr)\n __x->__left_->__set_parent(__x);\n __y->__parent_ = __x->__parent_;\n if (std::__tree_is_left_child(__x))\n __x->__parent_->__left_ = __y;\n else\n __x->__parent_unsafe()->__right_ = __y;\n __y->__right_ = __x;\n __x->__set_parent(__y);\n}\n\n// Effects: Rebalances __root after attaching __x to a leaf.\n// Precondition: __x has no children.\n// __x == __root or == a direct or indirect child of __root.\n// If __x were to be unlinked from __root (setting __root to\n// nullptr if __root == __x), __tree_invariant(__root) == true.\n// Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_\n// may be different than the value passed in as __root.\ntemplate <class _NodePtr>\n_LIBCPP_HIDE_FROM_ABI void __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__root != nullptr, \"Root of the tree shouldn't be null\");\n _LIBCPP_ASSERT_INTERNAL(__x != nullptr, \"Can't attach null node to a leaf\");\n __x->__is_black_ = __x == __root;\n while (__x != __root && !__x->__parent_unsafe()->__is_black_) {\n // __x->__parent_ != __root because __x->__parent_->__is_black == false\n if (std::__tree_is_left_child(__x->__parent_unsafe())) {\n _NodePtr __y = __x->__parent_unsafe()->__parent_unsafe()->__right_;\n if (__y != nullptr && !__y->__is_black_) {\n __x = __x->__parent_unsafe();\n __x->__is_black_ = true;\n __x = __x->__parent_unsafe();\n __x->__is_black_ = __x == __root;\n __y->__is_black_ = true;\n } else {\n if (!std::__tree_is_left_child(__x)) {\n __x = __x->__parent_unsafe();\n std::__tree_left_rotate(__x);\n }\n __x = __x->__parent_unsafe();\n __x->__is_black_ = true;\n __x = __x->__parent_unsafe();\n __x->__is_black_ = false;\n std::__tree_right_rotate(__x);\n break;\n }\n } else {\n _NodePtr __y = __x->__parent_unsafe()->__parent_->__left_;\n if (__y != nullptr && !__y->__is_black_) {\n __x = __x->__parent_unsafe();\n __x->__is_black_ = true;\n __x = __x->__parent_unsafe();\n __x->__is_black_ = __x == __root;\n __y->__is_black_ = true;\n } else {\n if (std::__tree_is_left_child(__x)) {\n __x = __x->__parent_unsafe();\n std::__tree_right_rotate(__x);\n }\n __x = __x->__parent_unsafe();\n __x->__is_black_ = true;\n __x = __x->__parent_unsafe();\n __x->__is_black_ = false;\n std::__tree_left_rotate(__x);\n break;\n }\n }\n }\n}\n\n// Precondition: __z == __root or == a direct or indirect child of __root.\n// Effects: unlinks __z from the tree rooted at __root, rebalancing as needed.\n// Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_\n// nor any of its children refer to __z. end_node->__left_\n// may be different than the value passed in as __root.\ntemplate <class _NodePtr>\n_LIBCPP_HIDE_FROM_ABI void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(__root != nullptr, \"Root node should not be null\");\n _LIBCPP_ASSERT_INTERNAL(__z != nullptr, \"The node to remove should not be null\");\n _LIBCPP_ASSERT_INTERNAL(std::__tree_invariant(__root), \"The tree invariants should hold\");\n // __z will be removed from the tree. Client still needs to destruct/deallocate it\n // __y is either __z, or if __z has two children, __tree_next(__z).\n // __y will have at most one child.\n // __y will be the initial hole in the tree (make the hole at a leaf)\n _NodePtr __y = (__z->__left_ == nullptr || __z->__right_ == nullptr) ? __z : std::__tree_next(__z);\n // __x is __y's possibly null single child\n _NodePtr __x = __y->__left_ != nullptr ? __y->__left_ : __y->__right_;\n // __w is __x's possibly null uncle (will become __x's sibling)\n _NodePtr __w = nullptr;\n // link __x to __y's parent, and find __w\n if (__x != nullptr)\n __x->__parent_ = __y->__parent_;\n if (std::__tree_is_left_child(__y)) {\n __y->__parent_->__left_ = __x;\n if (__y != __root)\n __w = __y->__parent_unsafe()->__right_;\n else\n __root = __x; // __w == nullptr\n } else {\n __y->__parent_unsafe()->__right_ = __x;\n // __y can't be root if it is a right child\n __w = __y->__parent_->__left_;\n }\n bool __removed_black = __y->__is_black_;\n // If we didn't remove __z, do so now by splicing in __y for __z,\n // but copy __z's color. This does not impact __x or __w.\n if (__y != __z) {\n // __z->__left_ != nulptr but __z->__right_ might == __x == nullptr\n __y->__parent_ = __z->__parent_;\n if (std::__tree_is_left_child(__z))\n __y->__parent_->__left_ = __y;\n else\n __y->__parent_unsafe()->__right_ = __y;\n __y->__left_ = __z->__left_;\n __y->__left_->__set_parent(__y);\n __y->__right_ = __z->__right_;\n if (__y->__right_ != nullptr)\n __y->__right_->__set_parent(__y);\n __y->__is_black_ = __z->__is_black_;\n if (__root == __z)\n __root = __y;\n }\n // There is no need to rebalance if we removed a red, or if we removed\n // the last node.\n if (__removed_black && __root != nullptr) {\n // Rebalance:\n // __x has an implicit black color (transferred from the removed __y)\n // associated with it, no matter what its color is.\n // If __x is __root (in which case it can't be null), it is supposed\n // to be black anyway, and if it is doubly black, then the double\n // can just be ignored.\n // If __x is red (in which case it can't be null), then it can absorb\n // the implicit black just by setting its color to black.\n // Since __y was black and only had one child (which __x points to), __x\n // is either red with no children, else null, otherwise __y would have\n // different black heights under left and right pointers.\n // if (__x == __root || __x != nullptr && !__x->__is_black_)\n if (__x != nullptr)\n __x->__is_black_ = true;\n else {\n // Else __x isn't root, and is \"doubly black\", even though it may\n // be null. __w can not be null here, else the parent would\n // see a black height >= 2 on the __x side and a black height\n // of 1 on the __w side (__w must be a non-null black or a red\n // with a non-null black child).\n while (true) {\n if (!std::__tree_is_left_child(__w)) // if x is left child\n {\n if (!__w->__is_black_) {\n __w->__is_black_ = true;\n __w->__parent_unsafe()->__is_black_ = false;\n std::__tree_left_rotate(__w->__parent_unsafe());\n // __x is still valid\n // reset __root only if necessary\n if (__root == __w->__left_)\n __root = __w;\n // reset sibling, and it still can't be null\n __w = __w->__left_->__right_;\n }\n // __w->__is_black_ is now true, __w may have null children\n if ((__w->__left_ == nullptr || __w->__left_->__is_black_) &&\n (__w->__right_ == nullptr || __w->__right_->__is_black_)) {\n __w->__is_black_ = false;\n __x = __w->__parent_unsafe();\n // __x can no longer be null\n if (__x == __root || !__x->__is_black_) {\n __x->__is_black_ = true;\n break;\n }\n // reset sibling, and it still can't be null\n __w = std::__tree_is_left_child(__x) ? __x->__parent_unsafe()->__right_ : __x->__parent_->__left_;\n // continue;\n } else // __w has a red child\n {\n if (__w->__right_ == nullptr || __w->__right_->__is_black_) {\n // __w left child is non-null and red\n __w->__left_->__is_black_ = true;\n __w->__is_black_ = false;\n std::__tree_right_rotate(__w);\n // __w is known not to be root, so root hasn't changed\n // reset sibling, and it still can't be null\n __w = __w->__parent_unsafe();\n }\n // __w has a right red child, left child may be null\n __w->__is_black_ = __w->__parent_unsafe()->__is_black_;\n __w->__parent_unsafe()->__is_black_ = true;\n __w->__right_->__is_black_ = true;\n std::__tree_left_rotate(__w->__parent_unsafe());\n break;\n }\n } else {\n if (!__w->__is_black_) {\n __w->__is_black_ = true;\n __w->__parent_unsafe()->__is_black_ = false;\n std::__tree_right_rotate(__w->__parent_unsafe());\n // __x is still valid\n // reset __root only if necessary\n if (__root == __w->__right_)\n __root = __w;\n // reset sibling, and it still can't be null\n __w = __w->__right_->__left_;\n }\n // __w->__is_black_ is now true, __w may have null children\n if ((__w->__left_ == nullptr || __w->__left_->__is_black_) &&\n (__w->__right_ == nullptr || __w->__right_->__is_black_)) {\n __w->__is_black_ = false;\n __x = __w->__parent_unsafe();\n // __x can no longer be null\n if (!__x->__is_black_ || __x == __root) {\n __x->__is_black_ = true;\n break;\n }\n // reset sibling, and it still can't be null\n __w = std::__tree_is_left_child(__x) ? __x->__parent_unsafe()->__right_ : __x->__parent_->__left_;\n // continue;\n } else // __w has a red child\n {\n if (__w->__left_ == nullptr || __w->__left_->__is_black_) {\n // __w right child is non-null and red\n __w->__right_->__is_black_ = true;\n __w->__is_black_ = false;\n std::__tree_left_rotate(__w);\n // __w is known not to be root, so root hasn't changed\n // reset sibling, and it still can't be null\n __w = __w->__parent_unsafe();\n }\n // __w has a left red child, right child may be null\n __w->__is_black_ = __w->__parent_unsafe()->__is_black_;\n __w->__parent_unsafe()->__is_black_ = true;\n __w->__left_->__is_black_ = true;\n std::__tree_right_rotate(__w->__parent_unsafe());\n break;\n }\n }\n }\n }\n }\n}\n\n// node traits\n\ntemplate <class _Tp>\nstruct __is_tree_value_type_imp : false_type {};\n\ntemplate <class _Key, class _Value>\nstruct __is_tree_value_type_imp<__value_type<_Key, _Value> > : true_type {};\n\ntemplate <class... _Args>\nstruct __is_tree_value_type : false_type {};\n\ntemplate <class _One>\nstruct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {};\n\ntemplate <class _Tp>\nstruct __tree_key_value_types {\n typedef _Tp key_type;\n typedef _Tp __node_value_type;\n typedef _Tp __container_value_type;\n static const bool __is_map = false;\n\n _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(_Tp const& __v) { return __v; }\n _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(__node_value_type const& __v) { return __v; }\n _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) { return std::addressof(__n); }\n _LIBCPP_HIDE_FROM_ABI static __container_value_type&& __move(__node_value_type& __v) { return std::move(__v); }\n};\n\ntemplate <class _Key, class _Tp>\nstruct __tree_key_value_types<__value_type<_Key, _Tp> > {\n typedef _Key key_type;\n typedef _Tp mapped_type;\n typedef __value_type<_Key, _Tp> __node_value_type;\n typedef pair<const _Key, _Tp> __container_value_type;\n typedef __container_value_type __map_value_type;\n static const bool __is_map = true;\n\n _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(__node_value_type const& __t) {\n return __t.__get_value().first;\n }\n\n template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(_Up& __t) {\n return __t.first;\n }\n\n _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(__node_value_type const& __t) {\n return __t.__get_value();\n }\n\n template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) {\n return __t;\n }\n\n _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) {\n return std::addressof(__n.__get_value());\n }\n\n _LIBCPP_HIDE_FROM_ABI static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) { return __v.__move(); }\n};\n\ntemplate <class _VoidPtr>\nstruct __tree_node_base_types {\n typedef _VoidPtr __void_pointer;\n\n typedef __tree_node_base<__void_pointer> __node_base_type;\n typedef __rebind_pointer_t<_VoidPtr, __node_base_type> __node_base_pointer;\n\n typedef __tree_end_node<__node_base_pointer> __end_node_type;\n typedef __rebind_pointer_t<_VoidPtr, __end_node_type> __end_node_pointer;\n typedef __end_node_pointer __parent_pointer;\n\n// TODO(LLVM 22): Remove this check\n#ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB\n static_assert(sizeof(__node_base_pointer) == sizeof(__end_node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) ==\n _LIBCPP_ALIGNOF(__end_node_pointer),\n \"It looks like you are using std::__tree (an implementation detail for (multi)map/set) with a fancy \"\n \"pointer type that thas a different representation depending on whether it points to a __tree base \"\n \"pointer or a __tree node pointer (both of which are implementation details of the standard library). \"\n \"This means that your ABI is being broken between LLVM 19 and LLVM 20. If you don't care about your \"\n \"ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to silence this \"\n \"diagnostic.\");\n#endif\n\nprivate:\n static_assert(is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value,\n \"_VoidPtr does not point to unqualified void type\");\n};\n\ntemplate <class _Tp, class _AllocPtr, class _KVTypes = __tree_key_value_types<_Tp>, bool = _KVTypes::__is_map>\nstruct __tree_map_pointer_types {};\n\ntemplate <class _Tp, class _AllocPtr, class _KVTypes>\nstruct __tree_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {\n typedef typename _KVTypes::__map_value_type _Mv;\n typedef __rebind_pointer_t<_AllocPtr, _Mv> __map_value_type_pointer;\n typedef __rebind_pointer_t<_AllocPtr, const _Mv> __const_map_value_type_pointer;\n};\n\ntemplate <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type>\nstruct __tree_node_types;\n\ntemplate <class _NodePtr, class _Tp, class _VoidPtr>\nstruct __tree_node_types<_NodePtr, __tree_node<_Tp, _VoidPtr> >\n : public __tree_node_base_types<_VoidPtr>, __tree_key_value_types<_Tp>, __tree_map_pointer_types<_Tp, _VoidPtr> {\n typedef __tree_node_base_types<_VoidPtr> __base;\n typedef __tree_key_value_types<_Tp> __key_base;\n typedef __tree_map_pointer_types<_Tp, _VoidPtr> __map_pointer_base;\n\npublic:\n typedef typename pointer_traits<_NodePtr>::element_type __node_type;\n typedef _NodePtr __node_pointer;\n\n typedef _Tp __node_value_type;\n typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer;\n typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer;\n typedef typename __base::__end_node_pointer __iter_pointer;\n\nprivate:\n static_assert(!is_const<__node_type>::value, \"_NodePtr should never be a pointer to const\");\n static_assert(is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value,\n \"_VoidPtr does not rebind to _NodePtr.\");\n};\n\ntemplate <class _ValueTp, class _VoidPtr>\nstruct __make_tree_node_types {\n typedef __rebind_pointer_t<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> > _NodePtr;\n typedef __tree_node_types<_NodePtr> type;\n};\n\n// node\n\ntemplate <class _Pointer>\nclass __tree_end_node {\npublic:\n typedef _Pointer pointer;\n pointer __left_;\n\n _LIBCPP_HIDE_FROM_ABI __tree_end_node() _NOEXCEPT : __left_() {}\n};\n\ntemplate <class _VoidPtr>\nclass _LIBCPP_STANDALONE_DEBUG __tree_node_base : public __tree_node_base_types<_VoidPtr>::__end_node_type {\n typedef __tree_node_base_types<_VoidPtr> _NodeBaseTypes;\n\npublic:\n typedef typename _NodeBaseTypes::__node_base_pointer pointer;\n typedef typename _NodeBaseTypes::__parent_pointer __parent_pointer;\n\n pointer __right_;\n __parent_pointer __parent_;\n bool __is_black_;\n\n _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { return static_cast<pointer>(__parent_); }\n\n _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); }\n\n ~__tree_node_base() = delete;\n __tree_node_base(__tree_node_base const&) = delete;\n __tree_node_base& operator=(__tree_node_base const&) = delete;\n};\n\ntemplate <class _Tp, class _VoidPtr>\nclass _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> {\npublic:\n typedef _Tp __node_value_type;\n\n __node_value_type __value_;\n\n _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }\n\n ~__tree_node() = delete;\n __tree_node(__tree_node const&) = delete;\n __tree_node& operator=(__tree_node const&) = delete;\n};\n\ntemplate <class _Allocator>\nclass __tree_node_destructor {\n typedef _Allocator allocator_type;\n typedef allocator_traits<allocator_type> __alloc_traits;\n\npublic:\n typedef typename __alloc_traits::pointer pointer;\n\nprivate:\n typedef __tree_node_types<pointer> _NodeTypes;\n allocator_type& __na_;\n\npublic:\n bool __value_constructed;\n\n _LIBCPP_HIDE_FROM_ABI __tree_node_destructor(const __tree_node_destructor&) = default;\n __tree_node_destructor& operator=(const __tree_node_destructor&) = delete;\n\n _LIBCPP_HIDE_FROM_ABI explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT\n : __na_(__na),\n __value_constructed(__val) {}\n\n _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {\n if (__value_constructed)\n __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_));\n if (__p)\n __alloc_traits::deallocate(__na_, __p, 1);\n }\n\n template <class>\n friend class __map_node_destructor;\n};\n\n#if _LIBCPP_STD_VER >= 17\ntemplate <class _NodeType, class _Alloc>\nstruct __generic_container_node_destructor;\ntemplate <class _Tp, class _VoidPtr, class _Alloc>\nstruct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc> : __tree_node_destructor<_Alloc> {\n using __tree_node_destructor<_Alloc>::__tree_node_destructor;\n};\n#endif\n\ntemplate <class _Tp, class _NodePtr, class _DiffType>\nclass _LIBCPP_TEMPLATE_VIS __tree_iterator {\n typedef __tree_node_types<_NodePtr> _NodeTypes;\n typedef _NodePtr __node_pointer;\n typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;\n typedef typename _NodeTypes::__end_node_pointer __end_node_pointer;\n typedef typename _NodeTypes::__iter_pointer __iter_pointer;\n typedef pointer_traits<__node_pointer> __pointer_traits;\n\n __iter_pointer __ptr_;\n\npublic:\n typedef bidirectional_iterator_tag iterator_category;\n typedef _Tp value_type;\n typedef _DiffType difference_type;\n typedef value_type& reference;\n typedef typename _NodeTypes::__node_value_type_pointer pointer;\n\n _LIBCPP_HIDE_FROM_ABI __tree_iterator() _NOEXCEPT\n#if _LIBCPP_STD_VER >= 14\n : __ptr_(nullptr)\n#endif\n {\n }\n\n _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__value_; }\n _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); }\n\n _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator++() {\n __ptr_ = static_cast<__iter_pointer>(\n std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)));\n return *this;\n }\n _LIBCPP_HIDE_FROM_ABI __tree_iterator operator++(int) {\n __tree_iterator __t(*this);\n ++(*this);\n return __t;\n }\n\n _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator--() {\n __ptr_ = static_cast<__iter_pointer>(\n std::__tree_prev_iter<__node_base_pointer>(static_cast<__end_node_pointer>(__ptr_)));\n return *this;\n }\n _LIBCPP_HIDE_FROM_ABI __tree_iterator operator--(int) {\n __tree_iterator __t(*this);\n --(*this);\n return __t;\n }\n\n friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __tree_iterator& __x, const __tree_iterator& __y) {\n return __x.__ptr_ == __y.__ptr_;\n }\n friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __tree_iterator& __x, const __tree_iterator& __y) {\n return !(__x == __y);\n }\n\nprivate:\n _LIBCPP_HIDE_FROM_ABI explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}\n _LIBCPP_HIDE_FROM_ABI explicit __tree_iterator(__end_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}\n _LIBCPP_HIDE_FROM_ABI __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); }\n template <class, class, class>\n friend class __tree;\n template <class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;\n template <class>\n friend class _LIBCPP_TEMPLATE_VIS __map_iterator;\n template <class, class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS map;\n template <class, class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS multimap;\n template <class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS set;\n template <class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS multiset;\n};\n\ntemplate <class _Tp, class _NodePtr, class _DiffType>\nclass _LIBCPP_TEMPLATE_VIS __tree_const_iterator {\n typedef __tree_node_types<_NodePtr> _NodeTypes;\n typedef typename _NodeTypes::__node_pointer __node_pointer;\n typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;\n typedef typename _NodeTypes::__end_node_pointer __end_node_pointer;\n typedef typename _NodeTypes::__iter_pointer __iter_pointer;\n typedef pointer_traits<__node_pointer> __pointer_traits;\n\n __iter_pointer __ptr_;\n\npublic:\n typedef bidirectional_iterator_tag iterator_category;\n typedef _Tp value_type;\n typedef _DiffType difference_type;\n typedef const value_type& reference;\n typedef typename _NodeTypes::__const_node_value_type_pointer pointer;\n\n _LIBCPP_HIDE_FROM_ABI __tree_const_iterator() _NOEXCEPT\n#if _LIBCPP_STD_VER >= 14\n : __ptr_(nullptr)\n#endif\n {\n }\n\nprivate:\n typedef __tree_iterator<value_type, __node_pointer, difference_type> __non_const_iterator;\n\npublic:\n _LIBCPP_HIDE_FROM_ABI __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}\n\n _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__value_; }\n _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); }\n\n _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator++() {\n __ptr_ = static_cast<__iter_pointer>(\n std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)));\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI __tree_const_iterator operator++(int) {\n __tree_const_iterator __t(*this);\n ++(*this);\n return __t;\n }\n\n _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator--() {\n __ptr_ = static_cast<__iter_pointer>(\n std::__tree_prev_iter<__node_base_pointer>(static_cast<__end_node_pointer>(__ptr_)));\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI __tree_const_iterator operator--(int) {\n __tree_const_iterator __t(*this);\n --(*this);\n return __t;\n }\n\n friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {\n return __x.__ptr_ == __y.__ptr_;\n }\n friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {\n return !(__x == __y);\n }\n\nprivate:\n _LIBCPP_HIDE_FROM_ABI explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}\n _LIBCPP_HIDE_FROM_ABI explicit __tree_const_iterator(__end_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}\n _LIBCPP_HIDE_FROM_ABI __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); }\n\n template <class, class, class>\n friend class __tree;\n template <class, class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS map;\n template <class, class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS multimap;\n template <class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS set;\n template <class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS multiset;\n template <class>\n friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;\n};\n\ntemplate <class _Tp, class _Compare>\n#ifndef _LIBCPP_CXX03_LANG\n_LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Compare const&, _Tp const&, _Tp const&>,\n \"the specified comparator type does not provide a viable const call operator\")\n#endif\nint __diagnose_non_const_comparator();\n\ntemplate <class _Tp, class _Compare, class _Allocator>\nclass __tree {\npublic:\n typedef _Tp value_type;\n typedef _Compare value_compare;\n typedef _Allocator allocator_type;\n\nprivate:\n typedef allocator_traits<allocator_type> __alloc_traits;\n typedef typename __make_tree_node_types<value_type, typename __alloc_traits::void_pointer>::type _NodeTypes;\n typedef typename _NodeTypes::key_type key_type;\n\npublic:\n typedef typename _NodeTypes::__node_value_type __node_value_type;\n typedef typename _NodeTypes::__container_value_type __container_value_type;\n\n typedef typename __alloc_traits::pointer pointer;\n typedef typename __alloc_traits::const_pointer const_pointer;\n typedef typename __alloc_traits::size_type size_type;\n typedef typename __alloc_traits::difference_type difference_type;\n\npublic:\n typedef typename _NodeTypes::__void_pointer __void_pointer;\n\n typedef typename _NodeTypes::__node_type __node;\n typedef typename _NodeTypes::__node_pointer __node_pointer;\n\n typedef typename _NodeTypes::__node_base_type __node_base;\n typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;\n\n typedef typename _NodeTypes::__end_node_type __end_node_t;\n typedef typename _NodeTypes::__end_node_pointer __end_node_ptr;\n\n typedef typename _NodeTypes::__parent_pointer __parent_pointer;\n typedef typename _NodeTypes::__iter_pointer __iter_pointer;\n\n typedef __rebind_alloc<__alloc_traits, __node> __node_allocator;\n typedef allocator_traits<__node_allocator> __node_traits;\n\nprivate:\n // check for sane allocator pointer rebinding semantics. Rebinding the\n // allocator for a new pointer type should be exactly the same as rebinding\n // the pointer using 'pointer_traits'.\n static_assert(is_same<__node_pointer, typename __node_traits::pointer>::value,\n \"Allocator does not rebind pointers in a sane manner.\");\n typedef __rebind_alloc<__node_traits, __node_base> __node_base_allocator;\n typedef allocator_traits<__node_base_allocator> __node_base_traits;\n static_assert(is_same<__node_base_pointer, typename __node_base_traits::pointer>::value,\n \"Allocator does not rebind pointers in a sane manner.\");\n\nprivate:\n __iter_pointer __begin_node_;\n _LIBCPP_COMPRESSED_PAIR(__end_node_t, __end_node_, __node_allocator, __node_alloc_);\n _LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_);\n\npublic:\n _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() _NOEXCEPT {\n return static_cast<__iter_pointer>(pointer_traits<__end_node_ptr>::pointer_to(__end_node_));\n }\n _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() const _NOEXCEPT {\n return static_cast<__iter_pointer>(\n pointer_traits<__end_node_ptr>::pointer_to(const_cast<__end_node_t&>(__end_node_)));\n }\n _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; }\n\nprivate:\n _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; }\n _LIBCPP_HIDE_FROM_ABI __iter_pointer& __begin_node() _NOEXCEPT { return __begin_node_; }\n _LIBCPP_HIDE_FROM_ABI const __iter_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; }\n\npublic:\n _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); }\n\nprivate:\n _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; }\n\npublic:\n _LIBCPP_HIDE_FROM_ABI const size_type& size() const _NOEXCEPT { return __size_; }\n _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __value_comp_; }\n _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __value_comp_; }\n\npublic:\n _LIBCPP_HIDE_FROM_ABI __node_pointer __root() const _NOEXCEPT {\n return static_cast<__node_pointer>(__end_node()->__left_);\n }\n\n _LIBCPP_HIDE_FROM_ABI __node_base_pointer* __root_ptr() const _NOEXCEPT {\n return std::addressof(__end_node()->__left_);\n }\n\n typedef __tree_iterator<value_type, __node_pointer, difference_type> iterator;\n typedef __tree_const_iterator<value_type, __node_pointer, difference_type> const_iterator;\n\n _LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_(\n is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value);\n _LIBCPP_HIDE_FROM_ABI explicit __tree(const allocator_type& __a);\n _LIBCPP_HIDE_FROM_ABI __tree(const value_compare& __comp, const allocator_type& __a);\n _LIBCPP_HIDE_FROM_ABI __tree(const __tree& __t);\n _LIBCPP_HIDE_FROM_ABI __tree& operator=(const __tree& __t);\n template <class _ForwardIterator>\n _LIBCPP_HIDE_FROM_ABI void __assign_unique(_ForwardIterator __first, _ForwardIterator __last);\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI void __assign_multi(_InputIterator __first, _InputIterator __last);\n _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_(\n is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value);\n _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a);\n _LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t) _NOEXCEPT_(\n __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<value_compare>::value&&\n is_nothrow_move_assignable<__node_allocator>::value);\n _LIBCPP_HIDE_FROM_ABI ~__tree();\n\n _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node()); }\n _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__begin_node()); }\n _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_node()); }\n _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_node()); }\n\n _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {\n return std::min<size_type>(__node_traits::max_size(__node_alloc()), numeric_limits<difference_type >::max());\n }\n\n _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI void swap(__tree& __t)\n#if _LIBCPP_STD_VER <= 11\n _NOEXCEPT_(__is_nothrow_swappable_v<value_compare> &&\n (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>));\n#else\n _NOEXCEPT_(__is_nothrow_swappable_v<value_compare>);\n#endif\n\n template <class _Key, class... _Args>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_key_args(_Key const&, _Args&&... __args);\n template <class _Key, class... _Args>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...);\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_impl(_Args&&... __args);\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique_impl(const_iterator __p, _Args&&... __args);\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator __emplace_multi(_Args&&... __args);\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);\n\n template <class _Pp>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_Pp&& __x) {\n return __emplace_unique_extract_key(std::forward<_Pp>(__x), __can_extract_key<_Pp, key_type>());\n }\n\n template <class _First,\n class _Second,\n __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_First&& __f, _Second&& __s) {\n return __emplace_unique_key_args(__f, std::forward<_First>(__f), std::forward<_Second>(__s));\n }\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_Args&&... __args) {\n return __emplace_unique_impl(std::forward<_Args>(__args)...);\n }\n\n template <class _Pp>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) {\n return __emplace_unique_impl(std::forward<_Pp>(__x));\n }\n\n template <class _Pp>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) {\n return __emplace_unique_key_args(__x, std::forward<_Pp>(__x));\n }\n\n template <class _Pp>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) {\n return __emplace_unique_key_args(__x.first, std::forward<_Pp>(__x));\n }\n\n template <class _Pp>\n _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _Pp&& __x) {\n return __emplace_hint_unique_extract_key(__p, std::forward<_Pp>(__x), __can_extract_key<_Pp, key_type>());\n }\n\n template <class _First,\n class _Second,\n __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {\n return __emplace_hint_unique_key_args(__p, __f, std::forward<_First>(__f), std::forward<_Second>(__s)).first;\n }\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _Args&&... __args) {\n return __emplace_hint_unique_impl(__p, std::forward<_Args>(__args)...);\n }\n\n template <class _Pp>\n _LIBCPP_HIDE_FROM_ABI iterator\n __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_fail_tag) {\n return __emplace_hint_unique_impl(__p, std::forward<_Pp>(__x));\n }\n\n template <class _Pp>\n _LIBCPP_HIDE_FROM_ABI iterator\n __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_self_tag) {\n return __emplace_hint_unique_key_args(__p, __x, std::forward<_Pp>(__x)).first;\n }\n\n template <class _Pp>\n _LIBCPP_HIDE_FROM_ABI iterator\n __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_first_tag) {\n return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first;\n }\n\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(const __container_value_type& __v) {\n return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v);\n }\n\n _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, const __container_value_type& __v) {\n return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v).first;\n }\n\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(__container_value_type&& __v) {\n return __emplace_unique_key_args(_NodeTypes::__get_key(__v), std::move(__v));\n }\n\n _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, __container_value_type&& __v) {\n return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), std::move(__v)).first;\n }\n\n template <class _Vp, __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Vp&& __v) {\n return __emplace_unique(std::forward<_Vp>(__v));\n }\n\n template <class _Vp, __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, _Vp&& __v) {\n return __emplace_hint_unique(__p, std::forward<_Vp>(__v));\n }\n\n _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(__container_value_type&& __v) {\n return __emplace_multi(std::move(__v));\n }\n\n _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(const_iterator __p, __container_value_type&& __v) {\n return __emplace_hint_multi(__p, std::move(__v));\n }\n\n template <class _Vp>\n _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(_Vp&& __v) {\n return __emplace_multi(std::forward<_Vp>(__v));\n }\n\n template <class _Vp>\n _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(const_iterator __p, _Vp&& __v) {\n return __emplace_hint_multi(__p, std::forward<_Vp>(__v));\n }\n\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool>\n __node_assign_unique(const __container_value_type& __v, __node_pointer __dest);\n\n _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd);\n _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(const_iterator __p, __node_pointer __nd);\n\n _LIBCPP_HIDE_FROM_ABI iterator __remove_node_pointer(__node_pointer) _NOEXCEPT;\n\n#if _LIBCPP_STD_VER >= 17\n template <class _NodeHandle, class _InsertReturnType>\n _LIBCPP_HIDE_FROM_ABI _InsertReturnType __node_handle_insert_unique(_NodeHandle&&);\n template <class _NodeHandle>\n _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_unique(const_iterator, _NodeHandle&&);\n template <class _Tree>\n _LIBCPP_HIDE_FROM_ABI void __node_handle_merge_unique(_Tree& __source);\n\n template <class _NodeHandle>\n _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(_NodeHandle&&);\n template <class _NodeHandle>\n _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(const_iterator, _NodeHandle&&);\n template <class _Tree>\n _LIBCPP_HIDE_FROM_ABI void __node_handle_merge_multi(_Tree& __source);\n\n template <class _NodeHandle>\n _LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(key_type const&);\n template <class _NodeHandle>\n _LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(const_iterator);\n#endif\n\n _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);\n _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI size_type __erase_unique(const _Key& __k);\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI size_type __erase_multi(const _Key& __k);\n\n _LIBCPP_HIDE_FROM_ABI void\n __insert_node_at(__parent_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT;\n\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __v);\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Key& __v) const;\n\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI size_type __count_unique(const _Key& __k) const;\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI size_type __count_multi(const _Key& __k) const;\n\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Key& __v) {\n return __lower_bound(__v, __root(), __end_node());\n }\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI iterator __lower_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result);\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Key& __v) const {\n return __lower_bound(__v, __root(), __end_node());\n }\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI const_iterator\n __lower_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) const;\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Key& __v) {\n return __upper_bound(__v, __root(), __end_node());\n }\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI iterator __upper_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result);\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Key& __v) const {\n return __upper_bound(__v, __root(), __end_node());\n }\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI const_iterator\n __upper_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) const;\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_unique(const _Key& __k);\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_unique(const _Key& __k) const;\n\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_multi(const _Key& __k);\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_multi(const _Key& __k) const;\n\n typedef __tree_node_destructor<__node_allocator> _Dp;\n typedef unique_ptr<__node, _Dp> __node_holder;\n\n _LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT;\n\nprivate:\n _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_low(__parent_pointer& __parent, const key_type& __v);\n _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_high(__parent_pointer& __parent, const key_type& __v);\n _LIBCPP_HIDE_FROM_ABI __node_base_pointer&\n __find_leaf(const_iterator __hint, __parent_pointer& __parent, const key_type& __v);\n // FIXME: Make this function const qualified. Unfortunately doing so\n // breaks existing code which uses non-const callable comparators.\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__parent_pointer& __parent, const _Key& __v);\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__parent_pointer& __parent, const _Key& __v) const {\n return const_cast<__tree*>(this)->__find_equal(__parent, __v);\n }\n template <class _Key>\n _LIBCPP_HIDE_FROM_ABI __node_base_pointer&\n __find_equal(const_iterator __hint, __parent_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v);\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args);\n\n // TODO: Make this _LIBCPP_HIDE_FROM_ABI\n _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) {\n __copy_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>());\n }\n\n _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t, true_type) {\n if (__node_alloc() != __t.__node_alloc())\n clear();\n __node_alloc() = __t.__node_alloc();\n }\n _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree&, false_type) {}\n\n _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type);\n _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_(\n is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value);\n\n _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree& __t)\n _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||\n is_nothrow_move_assignable<__node_allocator>::value) {\n __move_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());\n }\n\n _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree& __t, true_type)\n _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {\n __node_alloc() = std::move(__t.__node_alloc());\n }\n _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}\n\n struct _DetachedTreeCache {\n _LIBCPP_HIDE_FROM_ABI explicit _DetachedTreeCache(__tree* __t) _NOEXCEPT\n : __t_(__t),\n __cache_root_(__detach_from_tree(__t)) {\n __advance();\n }\n\n _LIBCPP_HIDE_FROM_ABI __node_pointer __get() const _NOEXCEPT { return __cache_elem_; }\n\n _LIBCPP_HIDE_FROM_ABI void __advance() _NOEXCEPT {\n __cache_elem_ = __cache_root_;\n if (__cache_root_) {\n __cache_root_ = __detach_next(__cache_root_);\n }\n }\n\n _LIBCPP_HIDE_FROM_ABI ~_DetachedTreeCache() {\n __t_->destroy(__cache_elem_);\n if (__cache_root_) {\n while (__cache_root_->__parent_ != nullptr)\n __cache_root_ = static_cast<__node_pointer>(__cache_root_->__parent_);\n __t_->destroy(__cache_root_);\n }\n }\n\n _DetachedTreeCache(_DetachedTreeCache const&) = delete;\n _DetachedTreeCache& operator=(_DetachedTreeCache const&) = delete;\n\n private:\n _LIBCPP_HIDE_FROM_ABI static __node_pointer __detach_from_tree(__tree* __t) _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI static __node_pointer __detach_next(__node_pointer) _NOEXCEPT;\n\n __tree* __t_;\n __node_pointer __cache_root_;\n __node_pointer __cache_elem_;\n };\n\n template <class, class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS map;\n template <class, class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS multimap;\n};\n\ntemplate <class _Tp, class _Compare, class _Allocator>\n__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_(\n is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value)\n : __size_(0), __value_comp_(__comp) {\n __begin_node() = __end_node();\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\n__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)\n : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0) {\n __begin_node() = __end_node();\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\n__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a)\n : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) {\n __begin_node() = __end_node();\n}\n\n// Precondition: size() != 0\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::__node_pointer\n__tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_from_tree(__tree* __t) _NOEXCEPT {\n __node_pointer __cache = static_cast<__node_pointer>(__t->__begin_node());\n __t->__begin_node() = __t->__end_node();\n __t->__end_node()->__left_->__parent_ = nullptr;\n __t->__end_node()->__left_ = nullptr;\n __t->size() = 0;\n // __cache->__left_ == nullptr\n if (__cache->__right_ != nullptr)\n __cache = static_cast<__node_pointer>(__cache->__right_);\n // __cache->__left_ == nullptr\n // __cache->__right_ == nullptr\n return __cache;\n}\n\n// Precondition: __cache != nullptr\n// __cache->left_ == nullptr\n// __cache->right_ == nullptr\n// This is no longer a red-black tree\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::__node_pointer\n__tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_next(__node_pointer __cache) _NOEXCEPT {\n if (__cache->__parent_ == nullptr)\n return nullptr;\n if (std::__tree_is_left_child(static_cast<__node_base_pointer>(__cache))) {\n __cache->__parent_->__left_ = nullptr;\n __cache = static_cast<__node_pointer>(__cache->__parent_);\n if (__cache->__right_ == nullptr)\n return __cache;\n return static_cast<__node_pointer>(std::__tree_leaf(__cache->__right_));\n }\n // __cache is right child\n __cache->__parent_unsafe()->__right_ = nullptr;\n __cache = static_cast<__node_pointer>(__cache->__parent_);\n if (__cache->__left_ == nullptr)\n return __cache;\n return static_cast<__node_pointer>(std::__tree_leaf(__cache->__left_));\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\n__tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) {\n if (this != std::addressof(__t)) {\n value_comp() = __t.value_comp();\n __copy_assign_alloc(__t);\n __assign_multi(__t.begin(), __t.end());\n }\n return *this;\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _ForwardIterator>\nvoid __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) {\n typedef iterator_traits<_ForwardIterator> _ITraits;\n typedef typename _ITraits::value_type _ItValueType;\n static_assert(is_same<_ItValueType, __container_value_type>::value,\n \"__assign_unique may only be called with the containers value type\");\n static_assert(\n __has_forward_iterator_category<_ForwardIterator>::value, \"__assign_unique requires a forward iterator\");\n if (size() != 0) {\n _DetachedTreeCache __cache(this);\n for (; __cache.__get() != nullptr && __first != __last; ++__first) {\n if (__node_assign_unique(*__first, __cache.__get()).second)\n __cache.__advance();\n }\n }\n for (; __first != __last; ++__first)\n __insert_unique(*__first);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _InputIterator>\nvoid __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last) {\n typedef iterator_traits<_InputIterator> _ITraits;\n typedef typename _ITraits::value_type _ItValueType;\n static_assert(\n (is_same<_ItValueType, __container_value_type>::value || is_same<_ItValueType, __node_value_type>::value),\n \"__assign_multi may only be called with the containers value type\"\n \" or the nodes value type\");\n if (size() != 0) {\n _DetachedTreeCache __cache(this);\n for (; __cache.__get() && __first != __last; ++__first) {\n __cache.__get()->__value_ = *__first;\n __node_insert_multi(__cache.__get());\n __cache.__advance();\n }\n }\n for (; __first != __last; ++__first)\n __insert_multi(_NodeTypes::__get_value(*__first));\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\n__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)\n : __begin_node_(__iter_pointer()),\n __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())),\n __size_(0),\n __value_comp_(__t.value_comp()) {\n __begin_node() = __end_node();\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\n__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(\n is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value)\n : __begin_node_(std::move(__t.__begin_node_)),\n __end_node_(std::move(__t.__end_node_)),\n __node_alloc_(std::move(__t.__node_alloc_)),\n __size_(__t.__size_),\n __value_comp_(std::move(__t.__value_comp_)) {\n if (size() == 0)\n __begin_node() = __end_node();\n else {\n __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());\n __t.__begin_node() = __t.__end_node();\n __t.__end_node()->__left_ = nullptr;\n __t.size() = 0;\n }\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\n__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a)\n : __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(std::move(__t.value_comp())) {\n if (__a == __t.__alloc()) {\n if (__t.size() == 0)\n __begin_node() = __end_node();\n else {\n __begin_node() = __t.__begin_node();\n __end_node()->__left_ = __t.__end_node()->__left_;\n __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());\n size() = __t.size();\n __t.__begin_node() = __t.__end_node();\n __t.__end_node()->__left_ = nullptr;\n __t.size() = 0;\n }\n } else {\n __begin_node() = __end_node();\n }\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\nvoid __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)\n _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value) {\n destroy(static_cast<__node_pointer>(__end_node()->__left_));\n __begin_node_ = __t.__begin_node_;\n __end_node_ = __t.__end_node_;\n __move_assign_alloc(__t);\n __size_ = __t.__size_;\n __value_comp_ = std::move(__t.__value_comp_);\n if (size() == 0)\n __begin_node() = __end_node();\n else {\n __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());\n __t.__begin_node() = __t.__end_node();\n __t.__end_node()->__left_ = nullptr;\n __t.size() = 0;\n }\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\nvoid __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) {\n if (__node_alloc() == __t.__node_alloc())\n __move_assign(__t, true_type());\n else {\n value_comp() = std::move(__t.value_comp());\n const_iterator __e = end();\n if (size() != 0) {\n _DetachedTreeCache __cache(this);\n while (__cache.__get() != nullptr && __t.size() != 0) {\n __cache.__get()->__value_ = std::move(__t.remove(__t.begin())->__value_);\n __node_insert_multi(__cache.__get());\n __cache.__advance();\n }\n }\n while (__t.size() != 0)\n __insert_multi(__e, _NodeTypes::__move(__t.remove(__t.begin())->__value_));\n }\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\n__tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) _NOEXCEPT_(\n __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<value_compare>::value&&\n is_nothrow_move_assignable<__node_allocator>::value)\n\n{\n __move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());\n return *this;\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\n__tree<_Tp, _Compare, _Allocator>::~__tree() {\n static_assert(is_copy_constructible<value_compare>::value, \"Comparator must be copy-constructible.\");\n destroy(__root());\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\nvoid __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT {\n if (__nd != nullptr) {\n destroy(static_cast<__node_pointer>(__nd->__left_));\n destroy(static_cast<__node_pointer>(__nd->__right_));\n __node_allocator& __na = __node_alloc();\n __node_traits::destroy(__na, _NodeTypes::__get_ptr(__nd->__value_));\n __node_traits::deallocate(__na, __nd, 1);\n }\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\nvoid __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)\n#if _LIBCPP_STD_VER <= 11\n _NOEXCEPT_(__is_nothrow_swappable_v<value_compare> &&\n (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>))\n#else\n _NOEXCEPT_(__is_nothrow_swappable_v<value_compare>)\n#endif\n{\n using std::swap;\n swap(__begin_node_, __t.__begin_node_);\n swap(__end_node_, __t.__end_node_);\n std::__swap_allocator(__node_alloc(), __t.__node_alloc());\n swap(__size_, __t.__size_);\n swap(__value_comp_, __t.__value_comp_);\n if (size() == 0)\n __begin_node() = __end_node();\n else\n __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());\n if (__t.size() == 0)\n __t.__begin_node() = __t.__end_node();\n else\n __t.__end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__t.__end_node());\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\nvoid __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT {\n destroy(__root());\n size() = 0;\n __begin_node() = __end_node();\n __end_node()->__left_ = nullptr;\n}\n\n// Find lower_bound place to insert\n// Set __parent to parent of null leaf\n// Return reference to null leaf\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&\n__tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, const key_type& __v) {\n __node_pointer __nd = __root();\n if (__nd != nullptr) {\n while (true) {\n if (value_comp()(__nd->__value_, __v)) {\n if (__nd->__right_ != nullptr)\n __nd = static_cast<__node_pointer>(__nd->__right_);\n else {\n __parent = static_cast<__parent_pointer>(__nd);\n return __nd->__right_;\n }\n } else {\n if (__nd->__left_ != nullptr)\n __nd = static_cast<__node_pointer>(__nd->__left_);\n else {\n __parent = static_cast<__parent_pointer>(__nd);\n return __parent->__left_;\n }\n }\n }\n }\n __parent = static_cast<__parent_pointer>(__end_node());\n return __parent->__left_;\n}\n\n// Find upper_bound place to insert\n// Set __parent to parent of null leaf\n// Return reference to null leaf\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&\n__tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent, const key_type& __v) {\n __node_pointer __nd = __root();\n if (__nd != nullptr) {\n while (true) {\n if (value_comp()(__v, __nd->__value_)) {\n if (__nd->__left_ != nullptr)\n __nd = static_cast<__node_pointer>(__nd->__left_);\n else {\n __parent = static_cast<__parent_pointer>(__nd);\n return __parent->__left_;\n }\n } else {\n if (__nd->__right_ != nullptr)\n __nd = static_cast<__node_pointer>(__nd->__right_);\n else {\n __parent = static_cast<__parent_pointer>(__nd);\n return __nd->__right_;\n }\n }\n }\n }\n __parent = static_cast<__parent_pointer>(__end_node());\n return __parent->__left_;\n}\n\n// Find leaf place to insert closest to __hint\n// First check prior to __hint.\n// Next check after __hint.\n// Next do O(log N) search.\n// Set __parent to parent of null leaf\n// Return reference to null leaf\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&\n__tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_pointer& __parent, const key_type& __v) {\n if (__hint == end() || !value_comp()(*__hint, __v)) // check before\n {\n // __v <= *__hint\n const_iterator __prior = __hint;\n if (__prior == begin() || !value_comp()(__v, *--__prior)) {\n // *prev(__hint) <= __v <= *__hint\n if (__hint.__ptr_->__left_ == nullptr) {\n __parent = static_cast<__parent_pointer>(__hint.__ptr_);\n return __parent->__left_;\n } else {\n __parent = static_cast<__parent_pointer>(__prior.__ptr_);\n return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_;\n }\n }\n // __v < *prev(__hint)\n return __find_leaf_high(__parent, __v);\n }\n // else __v > *__hint\n return __find_leaf_low(__parent, __v);\n}\n\n// Find place to insert if __v doesn't exist\n// Set __parent to parent of null leaf\n// Return reference to null leaf\n// If __v exists, set parent to node of __v and return reference to node of __v\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&\n__tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, const _Key& __v) {\n __node_pointer __nd = __root();\n __node_base_pointer* __nd_ptr = __root_ptr();\n if (__nd != nullptr) {\n while (true) {\n if (value_comp()(__v, __nd->__value_)) {\n if (__nd->__left_ != nullptr) {\n __nd_ptr = std::addressof(__nd->__left_);\n __nd = static_cast<__node_pointer>(__nd->__left_);\n } else {\n __parent = static_cast<__parent_pointer>(__nd);\n return __parent->__left_;\n }\n } else if (value_comp()(__nd->__value_, __v)) {\n if (__nd->__right_ != nullptr) {\n __nd_ptr = std::addressof(__nd->__right_);\n __nd = static_cast<__node_pointer>(__nd->__right_);\n } else {\n __parent = static_cast<__parent_pointer>(__nd);\n return __nd->__right_;\n }\n } else {\n __parent = static_cast<__parent_pointer>(__nd);\n return *__nd_ptr;\n }\n }\n }\n __parent = static_cast<__parent_pointer>(__end_node());\n return __parent->__left_;\n}\n\n// Find place to insert if __v doesn't exist\n// First check prior to __hint.\n// Next check after __hint.\n// Next do O(log N) search.\n// Set __parent to parent of null leaf\n// Return reference to null leaf\n// If __v exists, set parent to node of __v and return reference to node of __v\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_equal(\n const_iterator __hint, __parent_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v) {\n if (__hint == end() || value_comp()(__v, *__hint)) // check before\n {\n // __v < *__hint\n const_iterator __prior = __hint;\n if (__prior == begin() || value_comp()(*--__prior, __v)) {\n // *prev(__hint) < __v < *__hint\n if (__hint.__ptr_->__left_ == nullptr) {\n __parent = static_cast<__parent_pointer>(__hint.__ptr_);\n return __parent->__left_;\n } else {\n __parent = static_cast<__parent_pointer>(__prior.__ptr_);\n return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_;\n }\n }\n // __v <= *prev(__hint)\n return __find_equal(__parent, __v);\n } else if (value_comp()(*__hint, __v)) // check after\n {\n // *__hint < __v\n const_iterator __next = std::next(__hint);\n if (__next == end() || value_comp()(__v, *__next)) {\n // *__hint < __v < *std::next(__hint)\n if (__hint.__get_np()->__right_ == nullptr) {\n __parent = static_cast<__parent_pointer>(__hint.__ptr_);\n return static_cast<__node_base_pointer>(__hint.__ptr_)->__right_;\n } else {\n __parent = static_cast<__parent_pointer>(__next.__ptr_);\n return __parent->__left_;\n }\n }\n // *next(__hint) <= __v\n return __find_equal(__parent, __v);\n }\n // else __v == *__hint\n __parent = static_cast<__parent_pointer>(__hint.__ptr_);\n __dummy = static_cast<__node_base_pointer>(__hint.__ptr_);\n return __dummy;\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\nvoid __tree<_Tp, _Compare, _Allocator>::__insert_node_at(\n __parent_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT {\n __new_node->__left_ = nullptr;\n __new_node->__right_ = nullptr;\n __new_node->__parent_ = __parent;\n // __new_node->__is_black_ is initialized in __tree_balance_after_insert\n __child = __new_node;\n if (__begin_node()->__left_ != nullptr)\n __begin_node() = static_cast<__iter_pointer>(__begin_node()->__left_);\n std::__tree_balance_after_insert(__end_node()->__left_, __child);\n ++size();\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key, class... _Args>\npair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>\n__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) {\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_equal(__parent, __k);\n __node_pointer __r = static_cast<__node_pointer>(__child);\n bool __inserted = false;\n if (__child == nullptr) {\n __node_holder __h = __construct_node(std::forward<_Args>(__args)...);\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));\n __r = __h.release();\n __inserted = true;\n }\n return pair<iterator, bool>(iterator(__r), __inserted);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key, class... _Args>\npair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>\n__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(\n const_iterator __p, _Key const& __k, _Args&&... __args) {\n __parent_pointer __parent;\n __node_base_pointer __dummy;\n __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k);\n __node_pointer __r = static_cast<__node_pointer>(__child);\n bool __inserted = false;\n if (__child == nullptr) {\n __node_holder __h = __construct_node(std::forward<_Args>(__args)...);\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));\n __r = __h.release();\n __inserted = true;\n }\n return pair<iterator, bool>(iterator(__r), __inserted);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class... _Args>\ntypename __tree<_Tp, _Compare, _Allocator>::__node_holder\n__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {\n static_assert(!__is_tree_value_type<_Args...>::value, \"Cannot construct from __value_type\");\n __node_allocator& __na = __node_alloc();\n __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));\n __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), std::forward<_Args>(__args)...);\n __h.get_deleter().__value_constructed = true;\n return __h;\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class... _Args>\npair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>\n__tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) {\n __node_holder __h = __construct_node(std::forward<_Args>(__args)...);\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_equal(__parent, __h->__value_);\n __node_pointer __r = static_cast<__node_pointer>(__child);\n bool __inserted = false;\n if (__child == nullptr) {\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));\n __r = __h.release();\n __inserted = true;\n }\n return pair<iterator, bool>(iterator(__r), __inserted);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class... _Args>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args) {\n __node_holder __h = __construct_node(std::forward<_Args>(__args)...);\n __parent_pointer __parent;\n __node_base_pointer __dummy;\n __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __h->__value_);\n __node_pointer __r = static_cast<__node_pointer>(__child);\n if (__child == nullptr) {\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));\n __r = __h.release();\n }\n return iterator(__r);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class... _Args>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) {\n __node_holder __h = __construct_node(std::forward<_Args>(__args)...);\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__h->__value_));\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));\n return iterator(static_cast<__node_pointer>(__h.release()));\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class... _Args>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) {\n __node_holder __h = __construct_node(std::forward<_Args>(__args)...);\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__h->__value_));\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));\n return iterator(static_cast<__node_pointer>(__h.release()));\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\npair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>\n__tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_type& __v, __node_pointer __nd) {\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_equal(__parent, _NodeTypes::__get_key(__v));\n __node_pointer __r = static_cast<__node_pointer>(__child);\n bool __inserted = false;\n if (__child == nullptr) {\n __nd->__value_ = __v;\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));\n __r = __nd;\n __inserted = true;\n }\n return pair<iterator, bool>(iterator(__r), __inserted);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) {\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__nd->__value_));\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));\n return iterator(__nd);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, __node_pointer __nd) {\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__nd->__value_));\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));\n return iterator(__nd);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr) _NOEXCEPT {\n iterator __r(__ptr);\n ++__r;\n if (__begin_node() == __ptr)\n __begin_node() = __r.__ptr_;\n --size();\n std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__ptr));\n return __r;\n}\n\n#if _LIBCPP_STD_VER >= 17\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _NodeHandle, class _InsertReturnType>\n_LIBCPP_HIDE_FROM_ABI _InsertReturnType\n__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __nh) {\n if (__nh.empty())\n return _InsertReturnType{end(), false, _NodeHandle()};\n\n __node_pointer __ptr = __nh.__ptr_;\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_equal(__parent, __ptr->__value_);\n if (__child != nullptr)\n return _InsertReturnType{iterator(static_cast<__node_pointer>(__child)), false, std::move(__nh)};\n\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));\n __nh.__release_ptr();\n return _InsertReturnType{iterator(__ptr), true, _NodeHandle()};\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _NodeHandle>\n_LIBCPP_HIDE_FROM_ABI typename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __hint, _NodeHandle&& __nh) {\n if (__nh.empty())\n return end();\n\n __node_pointer __ptr = __nh.__ptr_;\n __parent_pointer __parent;\n __node_base_pointer __dummy;\n __node_base_pointer& __child = __find_equal(__hint, __parent, __dummy, __ptr->__value_);\n __node_pointer __r = static_cast<__node_pointer>(__child);\n if (__child == nullptr) {\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));\n __r = __ptr;\n __nh.__release_ptr();\n }\n return iterator(__r);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _NodeHandle>\n_LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_handle_extract(key_type const& __key) {\n iterator __it = find(__key);\n if (__it == end())\n return _NodeHandle();\n return __node_handle_extract<_NodeHandle>(__it);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _NodeHandle>\n_LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_handle_extract(const_iterator __p) {\n __node_pointer __np = __p.__get_np();\n __remove_node_pointer(__np);\n return _NodeHandle(__np, __alloc());\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Tree>\n_LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(_Tree& __source) {\n static_assert(is_same<typename _Tree::__node_pointer, __node_pointer>::value, \"\");\n\n for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) {\n __node_pointer __src_ptr = __i.__get_np();\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_equal(__parent, _NodeTypes::__get_key(__src_ptr->__value_));\n ++__i;\n if (__child != nullptr)\n continue;\n __source.__remove_node_pointer(__src_ptr);\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr));\n }\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _NodeHandle>\n_LIBCPP_HIDE_FROM_ABI typename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh) {\n if (__nh.empty())\n return end();\n __node_pointer __ptr = __nh.__ptr_;\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__ptr->__value_));\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));\n __nh.__release_ptr();\n return iterator(__ptr);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _NodeHandle>\n_LIBCPP_HIDE_FROM_ABI typename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh) {\n if (__nh.empty())\n return end();\n\n __node_pointer __ptr = __nh.__ptr_;\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_leaf(__hint, __parent, _NodeTypes::__get_key(__ptr->__value_));\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));\n __nh.__release_ptr();\n return iterator(__ptr);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Tree>\n_LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(_Tree& __source) {\n static_assert(is_same<typename _Tree::__node_pointer, __node_pointer>::value, \"\");\n\n for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) {\n __node_pointer __src_ptr = __i.__get_np();\n __parent_pointer __parent;\n __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__src_ptr->__value_));\n ++__i;\n __source.__remove_node_pointer(__src_ptr);\n __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr));\n }\n}\n\n#endif // _LIBCPP_STD_VER >= 17\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p) {\n __node_pointer __np = __p.__get_np();\n iterator __r = __remove_node_pointer(__np);\n __node_allocator& __na = __node_alloc();\n __node_traits::destroy(__na, _NodeTypes::__get_ptr(const_cast<__node_value_type&>(*__p)));\n __node_traits::deallocate(__na, __np, 1);\n return __r;\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l) {\n while (__f != __l)\n __f = erase(__f);\n return iterator(__l.__ptr_);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::size_type\n__tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k) {\n iterator __i = find(__k);\n if (__i == end())\n return 0;\n erase(__i);\n return 1;\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::size_type\n__tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) {\n pair<iterator, iterator> __p = __equal_range_multi(__k);\n size_type __r = 0;\n for (; __p.first != __p.second; ++__r)\n __p.first = erase(__p.first);\n return __r;\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) {\n iterator __p = __lower_bound(__v, __root(), __end_node());\n if (__p != end() && !value_comp()(__v, *__p))\n return __p;\n return end();\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::const_iterator\n__tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) const {\n const_iterator __p = __lower_bound(__v, __root(), __end_node());\n if (__p != end() && !value_comp()(__v, *__p))\n return __p;\n return end();\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::size_type\n__tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const {\n __node_pointer __rt = __root();\n while (__rt != nullptr) {\n if (value_comp()(__k, __rt->__value_)) {\n __rt = static_cast<__node_pointer>(__rt->__left_);\n } else if (value_comp()(__rt->__value_, __k))\n __rt = static_cast<__node_pointer>(__rt->__right_);\n else\n return 1;\n }\n return 0;\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::size_type\n__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const {\n __iter_pointer __result = __end_node();\n __node_pointer __rt = __root();\n while (__rt != nullptr) {\n if (value_comp()(__k, __rt->__value_)) {\n __result = static_cast<__iter_pointer>(__rt);\n __rt = static_cast<__node_pointer>(__rt->__left_);\n } else if (value_comp()(__rt->__value_, __k))\n __rt = static_cast<__node_pointer>(__rt->__right_);\n else\n return std::distance(\n __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)),\n __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));\n }\n return 0;\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) {\n while (__root != nullptr) {\n if (!value_comp()(__root->__value_, __v)) {\n __result = static_cast<__iter_pointer>(__root);\n __root = static_cast<__node_pointer>(__root->__left_);\n } else\n __root = static_cast<__node_pointer>(__root->__right_);\n }\n return iterator(__result);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound(\n const _Key& __v, __node_pointer __root, __iter_pointer __result) const {\n while (__root != nullptr) {\n if (!value_comp()(__root->__value_, __v)) {\n __result = static_cast<__iter_pointer>(__root);\n __root = static_cast<__node_pointer>(__root->__left_);\n } else\n __root = static_cast<__node_pointer>(__root->__right_);\n }\n return const_iterator(__result);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::iterator\n__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) {\n while (__root != nullptr) {\n if (value_comp()(__v, __root->__value_)) {\n __result = static_cast<__iter_pointer>(__root);\n __root = static_cast<__node_pointer>(__root->__left_);\n } else\n __root = static_cast<__node_pointer>(__root->__right_);\n }\n return iterator(__result);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\ntypename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound(\n const _Key& __v, __node_pointer __root, __iter_pointer __result) const {\n while (__root != nullptr) {\n if (value_comp()(__v, __root->__value_)) {\n __result = static_cast<__iter_pointer>(__root);\n __root = static_cast<__node_pointer>(__root->__left_);\n } else\n __root = static_cast<__node_pointer>(__root->__right_);\n }\n return const_iterator(__result);\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\npair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>\n__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {\n typedef pair<iterator, iterator> _Pp;\n __iter_pointer __result = __end_node();\n __node_pointer __rt = __root();\n while (__rt != nullptr) {\n if (value_comp()(__k, __rt->__value_)) {\n __result = static_cast<__iter_pointer>(__rt);\n __rt = static_cast<__node_pointer>(__rt->__left_);\n } else if (value_comp()(__rt->__value_, __k))\n __rt = static_cast<__node_pointer>(__rt->__right_);\n else\n return _Pp(iterator(__rt),\n iterator(__rt->__right_ != nullptr ? static_cast<__iter_pointer>(std::__tree_min(__rt->__right_))\n : __result));\n }\n return _Pp(iterator(__result), iterator(__result));\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\npair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,\n typename __tree<_Tp, _Compare, _Allocator>::const_iterator>\n__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {\n typedef pair<const_iterator, const_iterator> _Pp;\n __iter_pointer __result = __end_node();\n __node_pointer __rt = __root();\n while (__rt != nullptr) {\n if (value_comp()(__k, __rt->__value_)) {\n __result = static_cast<__iter_pointer>(__rt);\n __rt = static_cast<__node_pointer>(__rt->__left_);\n } else if (value_comp()(__rt->__value_, __k))\n __rt = static_cast<__node_pointer>(__rt->__right_);\n else\n return _Pp(\n const_iterator(__rt),\n const_iterator(\n __rt->__right_ != nullptr ? static_cast<__iter_pointer>(std::__tree_min(__rt->__right_)) : __result));\n }\n return _Pp(const_iterator(__result), const_iterator(__result));\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\npair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>\n__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {\n typedef pair<iterator, iterator> _Pp;\n __iter_pointer __result = __end_node();\n __node_pointer __rt = __root();\n while (__rt != nullptr) {\n if (value_comp()(__k, __rt->__value_)) {\n __result = static_cast<__iter_pointer>(__rt);\n __rt = static_cast<__node_pointer>(__rt->__left_);\n } else if (value_comp()(__rt->__value_, __k))\n __rt = static_cast<__node_pointer>(__rt->__right_);\n else\n return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)),\n __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));\n }\n return _Pp(iterator(__result), iterator(__result));\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntemplate <class _Key>\npair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,\n typename __tree<_Tp, _Compare, _Allocator>::const_iterator>\n__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const {\n typedef pair<const_iterator, const_iterator> _Pp;\n __iter_pointer __result = __end_node();\n __node_pointer __rt = __root();\n while (__rt != nullptr) {\n if (value_comp()(__k, __rt->__value_)) {\n __result = static_cast<__iter_pointer>(__rt);\n __rt = static_cast<__node_pointer>(__rt->__left_);\n } else if (value_comp()(__rt->__value_, __k))\n __rt = static_cast<__node_pointer>(__rt->__right_);\n else\n return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)),\n __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));\n }\n return _Pp(const_iterator(__result), const_iterator(__result));\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ntypename __tree<_Tp, _Compare, _Allocator>::__node_holder\n__tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT {\n __node_pointer __np = __p.__get_np();\n if (__begin_node() == __p.__ptr_) {\n if (__np->__right_ != nullptr)\n __begin_node() = static_cast<__iter_pointer>(__np->__right_);\n else\n __begin_node() = static_cast<__iter_pointer>(__np->__parent_);\n }\n --size();\n std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np));\n return __node_holder(__np, _Dp(__node_alloc(), true));\n}\n\ntemplate <class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI void swap(__tree<_Tp, _Compare, _Allocator>& __x, __tree<_Tp, _Compare, _Allocator>& __y)\n _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {\n __x.swap(__y);\n}\n\n_LIBCPP_END_NAMESPACE_STD\n\n_LIBCPP_POP_MACROS\n\n#endif // _LIBCPP___TREE\n","#include <cstring>\n#include <set>\n\n#include <ds/search.hh>\n#include <ds/utility.hh>\n\nnamespace ds {\n bool search_t::less_t::operator()(const std::unique_ptr<rule_t>& lhs, const std::unique_ptr<rule_t>& rhs) const {\n const length_t lhs_size = lhs->data_size();\n const length_t rhs_size = rhs->data_size();\n if (lhs_size < rhs_size) {\n return true;\n }\n if (lhs_size > rhs_size) {\n return false;\n }\n if (std::memcmp(lhs->head(), rhs->head(), lhs_size) < 0) {\n return true;\n }\n return false;\n }\n\n search_t::search_t(length_t _limit_size, length_t _buffer_size) {\n set_limit_size(_limit_size);\n set_buffer_size(_buffer_size);\n reset();\n }\n\n void search_t::set_limit_size(length_t _limit_size) {\n limit_size = _limit_size;\n done_cycle = 0;\n }\n\n void search_t::set_buffer_size(length_t _buffer_size) {\n buffer_size = _buffer_size;\n buffer = std::unique_ptr<rule_t>(reinterpret_cast<rule_t*>(operator new(buffer_size)));\n done_cycle = 0;\n }\n\n void search_t::reset() {\n done_cycle = 0;\n current_cycle = 0;\n rules.clear();\n facts.clear();\n }\n\n bool search_t::add(std::string_view text) {\n auto candidate = text_to_rule(text.data(), limit_size);\n if (candidate) {\n if (done_cycle == current_cycle) {\n ++current_cycle;\n }\n if (candidate->premises_count() != 0) {\n rules.emplace(std::move(candidate), current_cycle);\n } else {\n facts.emplace(std::move(candidate), current_cycle);\n }\n return true;\n } else {\n return false;\n }\n }\n\n length_t search_t::execute(const std::function<bool(rule_t*)>& callback) {\n std::set<std::unique_ptr<rule_t>, less_t> temp_rules;\n std::set<std::unique_ptr<rule_t>, less_t> temp_facts;\n\n bool break_all = false;\n for (auto& [rule, rules_cycle] : rules) {\n for (auto& [fact, facts_cycle] : facts) {\n if (rules_cycle <= done_cycle && facts_cycle <= done_cycle) {\n continue;\n }\n buffer->match(rule.get(), fact.get(), reinterpret_cast<std::byte*>(buffer.get()) + buffer_size);\n if (!buffer->valid()) {\n continue;\n }\n if (buffer->data_size() > limit_size) {\n continue;\n }\n if (buffer->premises_count() != 0) {\n // rule\n if (rules.find(buffer) != rules.end() || temp_rules.find(buffer) != temp_rules.end()) {\n continue;\n }\n auto new_rule = std::unique_ptr<rule_t>(reinterpret_cast<rule_t*>(operator new(buffer->data_size())));\n memcpy(new_rule.get(), buffer.get(), buffer->data_size());\n temp_rules.emplace(std::move(new_rule));\n } else {\n // fact\n if (facts.find(buffer) != facts.end() || temp_facts.find(buffer) != temp_facts.end()) {\n continue;\n }\n auto new_fact = std::unique_ptr<rule_t>(reinterpret_cast<rule_t*>(operator new(buffer->data_size())));\n memcpy(new_fact.get(), buffer.get(), buffer->data_size());\n temp_facts.emplace(std::move(new_fact));\n }\n if (callback(buffer.get())) {\n break_all = true;\n break;\n }\n }\n if (break_all) {\n break;\n }\n }\n\n if (!break_all) {\n done_cycle = current_cycle;\n }\n ++current_cycle;\n length_t count = temp_rules.size() + temp_facts.size();\n for (auto it = temp_rules.begin(); it != temp_rules.end();) {\n auto node = temp_rules.extract(it++);\n rules.emplace(std::move(node.value()), current_cycle);\n }\n for (auto it = temp_facts.begin(); it != temp_facts.end();) {\n auto node = temp_facts.extract(it++);\n facts.emplace(std::move(node.value()), current_cycle);\n }\n return count;\n }\n} // namespace ds\n","#include <ds/utility.hh>\n\nnamespace ds {\n std::unique_ptr<term_t> text_to_term(const char* text, length_t length) {\n auto result = reinterpret_cast<term_t*>(operator new(length));\n auto scan_result = result->scan(text, reinterpret_cast<std::byte*>(result) + length);\n if (scan_result == nullptr) [[unlikely]] {\n operator delete(result);\n return std::unique_ptr<term_t>(nullptr);\n }\n return std::unique_ptr<term_t>(result);\n }\n\n std::unique_ptr<char> term_to_text(term_t* term, length_t length) {\n auto result = reinterpret_cast<char*>(operator new(length));\n auto print_result = term->print(result, reinterpret_cast<char*>(result) + length);\n if (print_result == nullptr || print_result - result == length) [[unlikely]] {\n operator delete(result);\n return std::unique_ptr<char>(nullptr);\n }\n *print_result = '\\0';\n return std::unique_ptr<char>(result);\n }\n\n std::unique_ptr<rule_t> text_to_rule(const char* text, length_t length) {\n auto result = reinterpret_cast<rule_t*>(operator new(length));\n auto scan_result = result->scan(text, reinterpret_cast<std::byte*>(result) + length);\n if (scan_result == nullptr) [[unlikely]] {\n operator delete(result);\n return std::unique_ptr<rule_t>(nullptr);\n }\n return std::unique_ptr<rule_t>(result);\n }\n\n std::unique_ptr<char> rule_to_text(rule_t* rule, length_t length) {\n auto result = reinterpret_cast<char*>(operator new(length));\n auto print_result = rule->print(result, reinterpret_cast<char*>(result) + length);\n if (print_result == nullptr || print_result - result == length) [[unlikely]] {\n operator delete(result);\n return std::unique_ptr<char>(nullptr);\n }\n *print_result = '\\0';\n return std::unique_ptr<char>(result);\n }\n} // namespace ds\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___UTILITY_PAIR_H\n#define _LIBCPP___UTILITY_PAIR_H\n\n#include <__compare/common_comparison_category.h>\n#include <__compare/synth_three_way.h>\n#include <__concepts/different_from.h>\n#include <__config>\n#include <__cstddef/size_t.h>\n#include <__fwd/array.h>\n#include <__fwd/pair.h>\n#include <__fwd/tuple.h>\n#include <__tuple/tuple_indices.h>\n#include <__tuple/tuple_like_no_subrange.h>\n#include <__tuple/tuple_size.h>\n#include <__type_traits/common_reference.h>\n#include <__type_traits/common_type.h>\n#include <__type_traits/conditional.h>\n#include <__type_traits/decay.h>\n#include <__type_traits/enable_if.h>\n#include <__type_traits/integral_constant.h>\n#include <__type_traits/is_assignable.h>\n#include <__type_traits/is_constructible.h>\n#include <__type_traits/is_convertible.h>\n#include <__type_traits/is_implicitly_default_constructible.h>\n#include <__type_traits/is_nothrow_assignable.h>\n#include <__type_traits/is_nothrow_constructible.h>\n#include <__type_traits/is_same.h>\n#include <__type_traits/is_swappable.h>\n#include <__type_traits/is_trivially_relocatable.h>\n#include <__type_traits/nat.h>\n#include <__type_traits/remove_cvref.h>\n#include <__type_traits/unwrap_ref.h>\n#include <__utility/declval.h>\n#include <__utility/forward.h>\n#include <__utility/move.h>\n#include <__utility/piecewise_construct.h>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_PUSH_MACROS\n#include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\ntemplate <class, class>\nstruct __non_trivially_copyable_base {\n _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __non_trivially_copyable_base() _NOEXCEPT {}\n _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI\n __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}\n};\n\ntemplate <class _T1, class _T2>\nstruct _LIBCPP_TEMPLATE_VIS pair\n#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)\n : private __non_trivially_copyable_base<_T1, _T2>\n#endif\n{\n using first_type = _T1;\n using second_type = _T2;\n\n _T1 first;\n _T2 second;\n\n using __trivially_relocatable _LIBCPP_NODEBUG =\n __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value,\n pair,\n void>;\n\n _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;\n _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default;\n\n#ifdef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI pair() : first(), second() {}\n\n _LIBCPP_HIDE_FROM_ABI pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {}\n\n template <class _U1, class _U2>\n _LIBCPP_HIDE_FROM_ABI pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}\n\n _LIBCPP_HIDE_FROM_ABI pair& operator=(pair const& __p) {\n first = __p.first;\n second = __p.second;\n return *this;\n }\n\n // Extension: This is provided in C++03 because it allows properly handling the\n // assignment to a pair containing references, which would be a hard\n // error otherwise.\n template <\n class _U1,\n class _U2,\n __enable_if_t<is_assignable<first_type&, _U1 const&>::value && is_assignable<second_type&, _U2 const&>::value,\n int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair& operator=(pair<_U1, _U2> const& __p) {\n first = __p.first;\n second = __p.second;\n return *this;\n }\n#else\n struct _CheckArgs {\n template <int&...>\n static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() {\n return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value;\n }\n\n template <int&...>\n static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_default() {\n return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value;\n }\n\n template <class _U1, class _U2>\n static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_pair_constructible() {\n return is_constructible<first_type, _U1>::value && is_constructible<second_type, _U2>::value;\n }\n\n template <class _U1, class _U2>\n static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit() {\n return is_convertible<_U1, first_type>::value && is_convertible<_U2, second_type>::value;\n }\n };\n\n template <bool _MaybeEnable>\n using _CheckArgsDep _LIBCPP_NODEBUG = __conditional_t<_MaybeEnable, _CheckArgs, void>;\n\n template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_default(), int> = 0>\n explicit(!_CheckArgsDep<_Dummy>::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept(\n is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value)\n : first(), second() {}\n\n template <bool _Dummy = true,\n __enable_if_t<_CheckArgsDep<_Dummy>::template __is_pair_constructible<_T1 const&, _T2 const&>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI\n _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgsDep<_Dummy>::template __is_implicit<_T1 const&, _T2 const&>())\n pair(_T1 const& __t1, _T2 const& __t2) noexcept(is_nothrow_copy_constructible<first_type>::value &&\n is_nothrow_copy_constructible<second_type>::value)\n : first(__t1), second(__t2) {}\n\n template <\n# if _LIBCPP_STD_VER >= 23 // http://wg21.link/P1951\n class _U1 = _T1,\n class _U2 = _T2,\n# else\n class _U1,\n class _U2,\n# endif\n __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int> = 0 >\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1, _U2>())\n pair(_U1&& __u1, _U2&& __u2) noexcept(is_nothrow_constructible<first_type, _U1>::value &&\n is_nothrow_constructible<second_type, _U2>::value)\n : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) {\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1&, _U2&>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<_U1&, _U2&>())\n pair(pair<_U1, _U2>& __p) noexcept((is_nothrow_constructible<first_type, _U1&>::value &&\n is_nothrow_constructible<second_type, _U2&>::value))\n : first(__p.first), second(__p.second) {}\n# endif\n\n template <class _U1,\n class _U2,\n __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1 const&, _U2 const&>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI\n _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1 const&, _U2 const&>())\n pair(pair<_U1, _U2> const& __p) noexcept(is_nothrow_constructible<first_type, _U1 const&>::value &&\n is_nothrow_constructible<second_type, _U2 const&>::value)\n : first(__p.first), second(__p.second) {}\n\n template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1, _U2>())\n pair(pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, _U1&&>::value &&\n is_nothrow_constructible<second_type, _U2&&>::value)\n : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {}\n\n# if _LIBCPP_STD_VER >= 23\n template <class _U1,\n class _U2,\n __enable_if_t<_CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>(), int> = 0>\n _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<const _U1&&, const _U2&&>())\n pair(const pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, const _U1&&>::value &&\n is_nothrow_constructible<second_type, const _U2&&>::value)\n : first(std::move(__p.first)), second(std::move(__p.second)) {}\n# endif\n\n# if _LIBCPP_STD_VER >= 23\n // TODO: Remove this workaround in LLVM 20. The bug got fixed in Clang 18.\n // This is a workaround for http://llvm.org/PR60710. We should be able to remove it once Clang is fixed.\n template <class _PairLike>\n _LIBCPP_HIDE_FROM_ABI static constexpr bool __pair_like_explicit_wknd() {\n if constexpr (__pair_like_no_subrange<_PairLike>) {\n return !is_convertible_v<decltype(std::get<0>(std::declval<_PairLike&&>())), first_type> ||\n !is_convertible_v<decltype(std::get<1>(std::declval<_PairLike&&>())), second_type>;\n }\n return false;\n }\n\n template <__pair_like_no_subrange _PairLike>\n requires(is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike &&>()))> &&\n is_constructible_v<second_type, decltype(std::get<1>(std::declval<_PairLike &&>()))>)\n _LIBCPP_HIDE_FROM_ABI constexpr explicit(__pair_like_explicit_wknd<_PairLike>()) pair(_PairLike&& __p)\n : first(std::get<0>(std::forward<_PairLike>(__p))), second(std::get<1>(std::forward<_PairLike>(__p))) {}\n# endif\n\n template <class... _Args1, class... _Args2>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20\n pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) noexcept(\n is_nothrow_constructible<first_type, _Args1...>::value && is_nothrow_constructible<second_type, _Args2...>::value)\n : pair(__pc,\n __first_args,\n __second_args,\n typename __make_tuple_indices<sizeof...(_Args1)>::type(),\n typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&\n operator=(__conditional_t<is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value,\n pair,\n __nat> const& __p) noexcept(is_nothrow_copy_assignable<first_type>::value &&\n is_nothrow_copy_assignable<second_type>::value) {\n first = __p.first;\n second = __p.second;\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(\n __conditional_t<is_move_assignable<first_type>::value && is_move_assignable<second_type>::value, pair, __nat>&&\n __p) noexcept(is_nothrow_move_assignable<first_type>::value &&\n is_nothrow_move_assignable<second_type>::value) {\n first = std::forward<first_type>(__p.first);\n second = std::forward<second_type>(__p.second);\n return *this;\n }\n\n template <\n class _U1,\n class _U2,\n __enable_if_t<is_assignable<first_type&, _U1 const&>::value && is_assignable<second_type&, _U2 const&>::value,\n int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2> const& __p) {\n first = __p.first;\n second = __p.second;\n return *this;\n }\n\n template <class _U1,\n class _U2,\n __enable_if_t<is_assignable<first_type&, _U1>::value && is_assignable<second_type&, _U2>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2>&& __p) {\n first = std::forward<_U1>(__p.first);\n second = std::forward<_U2>(__p.second);\n return *this;\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <class = void>\n _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair const& __p) const\n noexcept(is_nothrow_copy_assignable_v<const first_type> && is_nothrow_copy_assignable_v<const second_type>)\n requires(is_copy_assignable_v<const first_type> && is_copy_assignable_v<const second_type>)\n {\n first = __p.first;\n second = __p.second;\n return *this;\n }\n\n template <class = void>\n _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair&& __p) const\n noexcept(is_nothrow_assignable_v<const first_type&, first_type> &&\n is_nothrow_assignable_v<const second_type&, second_type>)\n requires(is_assignable_v<const first_type&, first_type> && is_assignable_v<const second_type&, second_type>)\n {\n first = std::forward<first_type>(__p.first);\n second = std::forward<second_type>(__p.second);\n return *this;\n }\n\n template <class _U1, class _U2>\n _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(const pair<_U1, _U2>& __p) const\n requires(is_assignable_v<const first_type&, const _U1&> && is_assignable_v<const second_type&, const _U2&>)\n {\n first = __p.first;\n second = __p.second;\n return *this;\n }\n\n template <class _U1, class _U2>\n _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair<_U1, _U2>&& __p) const\n requires(is_assignable_v<const first_type&, _U1> && is_assignable_v<const second_type&, _U2>)\n {\n first = std::forward<_U1>(__p.first);\n second = std::forward<_U2>(__p.second);\n return *this;\n }\n\n template <__pair_like_no_subrange _PairLike>\n requires(__different_from<_PairLike, pair> &&\n is_assignable_v<first_type&, decltype(std::get<0>(std::declval<_PairLike>()))> &&\n is_assignable_v<second_type&, decltype(std::get<1>(std::declval<_PairLike>()))>)\n _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(_PairLike&& __p) {\n first = std::get<0>(std::forward<_PairLike>(__p));\n second = std::get<1>(std::forward<_PairLike>(__p));\n return *this;\n }\n\n template <__pair_like_no_subrange _PairLike>\n requires(__different_from<_PairLike, pair> &&\n is_assignable_v<first_type const&, decltype(std::get<0>(std::declval<_PairLike>()))> &&\n is_assignable_v<second_type const&, decltype(std::get<1>(std::declval<_PairLike>()))>)\n _LIBCPP_HIDE_FROM_ABI constexpr pair const& operator=(_PairLike&& __p) const {\n first = std::get<0>(std::forward<_PairLike>(__p));\n second = std::get<1>(std::forward<_PairLike>(__p));\n return *this;\n }\n# endif // _LIBCPP_STD_VER >= 23\n\n // Prior to C++23, we provide an approximation of constructors and assignment operators from\n // pair-like types. This was historically provided as an extension.\n# if _LIBCPP_STD_VER < 23\n // from std::tuple\n template <class _U1,\n class _U2,\n __enable_if_t<is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2> const& __p)\n : first(std::get<0>(__p)), second(std::get<1>(__p)) {}\n\n template < class _U1,\n class _U2,\n __enable_if_t<is_constructible<_T1, _U1 const&>::value && is_constructible<_T2, _U2 const&>::value &&\n !(is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value),\n int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2> const& __p)\n : first(std::get<0>(__p)), second(std::get<1>(__p)) {}\n\n template <class _U1,\n class _U2,\n __enable_if_t<is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2>&& __p)\n : first(std::get<0>(std::move(__p))), second(std::get<1>(std::move(__p))) {}\n\n template <class _U1,\n class _U2,\n __enable_if_t<is_constructible<_T1, _U1>::value && is_constructible<_T2, _U2>::value &&\n !(is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value) > = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2>&& __p)\n : first(std::get<0>(std::move(__p))), second(std::get<1>(std::move(__p))) {}\n\n template <class _U1,\n class _U2,\n __enable_if_t<is_assignable<_T1&, _U1 const&>::value && is_assignable<_T2&, _U2 const&>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2> const& __p) {\n first = std::get<0>(__p);\n second = std::get<1>(__p);\n return *this;\n }\n\n template <class _U1,\n class _U2,\n __enable_if_t<is_assignable<_T1&, _U1&&>::value && is_assignable<_T2&, _U2&&>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2>&& __p) {\n first = std::get<0>(std::move(__p));\n second = std::get<1>(std::move(__p));\n return *this;\n }\n\n // from std::array\n template <class _Up,\n __enable_if_t<is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2> const& __p) : first(__p[0]), second(__p[1]) {}\n\n template <class _Up,\n __enable_if_t<is_constructible<_T1, _Up const&>::value && is_constructible<_T2, _Up const&>::value &&\n !(is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value),\n int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2> const& __p)\n : first(__p[0]), second(__p[1]) {}\n\n template <class _Up, __enable_if_t< is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2>&& __p)\n : first(std::move(__p)[0]), second(std::move(__p)[1]) {}\n\n template <class _Up,\n __enable_if_t<is_constructible<_T1, _Up>::value && is_constructible<_T2, _Up>::value &&\n !(is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value),\n int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2>&& __p)\n : first(std::move(__p)[0]), second(std::move(__p)[1]) {}\n\n template <class _Up,\n __enable_if_t<is_assignable<_T1&, _Up const&>::value && is_assignable<_T2&, _Up const&>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2> const& __p) {\n first = std::get<0>(__p);\n second = std::get<1>(__p);\n return *this;\n }\n\n template <class _Up, __enable_if_t<is_assignable<_T1&, _Up>::value && is_assignable<_T2&, _Up>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2>&& __p) {\n first = std::get<0>(std::move(__p));\n second = std::get<1>(std::move(__p));\n return *this;\n }\n# endif // _LIBCPP_STD_VER < 23\n#endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair& __p)\n _NOEXCEPT_(__is_nothrow_swappable_v<first_type>&& __is_nothrow_swappable_v<second_type>) {\n using std::swap;\n swap(first, __p.first);\n swap(second, __p.second);\n }\n\n#if _LIBCPP_STD_VER >= 23\n _LIBCPP_HIDE_FROM_ABI constexpr void swap(const pair& __p) const\n noexcept(__is_nothrow_swappable_v<const first_type> && __is_nothrow_swappable_v<const second_type>) {\n using std::swap;\n swap(first, __p.first);\n swap(second, __p.second);\n }\n#endif\n\nprivate:\n#ifndef _LIBCPP_CXX03_LANG\n template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20\n pair(piecewise_construct_t,\n tuple<_Args1...>& __first_args,\n tuple<_Args2...>& __second_args,\n __tuple_indices<_I1...>,\n __tuple_indices<_I2...>)\n : first(std::forward<_Args1>(std::get<_I1>(__first_args))...),\n second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {}\n#endif\n};\n\n#if _LIBCPP_STD_VER >= 17\ntemplate <class _T1, class _T2>\npair(_T1, _T2) -> pair<_T1, _T2>;\n#endif\n\n// [pairs.spec], specialized algorithms\n\ntemplate <class _T1, class _T2, class _U1, class _U2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool\noperator==(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {\n return __x.first == __y.first && __x.second == __y.second;\n}\n\n#if _LIBCPP_STD_VER >= 20\n\ntemplate <class _T1, class _T2, class _U1, class _U2>\n_LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t< __synth_three_way_result<_T1, _U1>,\n __synth_three_way_result<_T2, _U2> >\noperator<=>(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {\n if (auto __c = std::__synth_three_way(__x.first, __y.first); __c != 0) {\n return __c;\n }\n return std::__synth_three_way(__x.second, __y.second);\n}\n\n#else // _LIBCPP_STD_VER >= 20\n\ntemplate <class _T1, class _T2, class _U1, class _U2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool\noperator!=(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {\n return !(__x == __y);\n}\n\ntemplate <class _T1, class _T2, class _U1, class _U2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool\noperator<(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {\n return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second);\n}\n\ntemplate <class _T1, class _T2, class _U1, class _U2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool\noperator>(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {\n return __y < __x;\n}\n\ntemplate <class _T1, class _T2, class _U1, class _U2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool\noperator>=(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {\n return !(__x < __y);\n}\n\ntemplate <class _T1, class _T2, class _U1, class _U2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool\noperator<=(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {\n return !(__y < __x);\n}\n\n#endif // _LIBCPP_STD_VER >= 20\n\n#if _LIBCPP_STD_VER >= 23\ntemplate <class _T1, class _T2, class _U1, class _U2, template <class> class _TQual, template <class> class _UQual>\n requires requires {\n typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>;\n }\nstruct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> {\n using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>;\n};\n\ntemplate <class _T1, class _T2, class _U1, class _U2>\n requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; }\nstruct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {\n using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>;\n};\n#endif // _LIBCPP_STD_VER >= 23\n\ntemplate <class _T1, class _T2, __enable_if_t<__is_swappable_v<_T1> && __is_swappable_v<_T2>, int> = 0>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)\n _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) {\n __x.swap(__y);\n}\n\n#if _LIBCPP_STD_VER >= 23\ntemplate <class _T1, class _T2>\n requires(__is_swappable_v<const _T1> && __is_swappable_v<const _T2>)\n_LIBCPP_HIDE_FROM_ABI constexpr void\nswap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x.swap(__y))) {\n __x.swap(__y);\n}\n#endif\n\ntemplate <class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >\nmake_pair(_T1&& __t1, _T2&& __t2) {\n return pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >(std::forward<_T1>(__t1), std::forward<_T2>(__t2));\n}\n\ntemplate <class _T1, class _T2>\nstruct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> > : public integral_constant<size_t, 2> {};\n\ntemplate <size_t _Ip, class _T1, class _T2>\nstruct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> > {\n static_assert(_Ip < 2, \"Index out of bounds in std::tuple_element<std::pair<T1, T2>>\");\n};\n\ntemplate <class _T1, class _T2>\nstruct _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> > {\n using type _LIBCPP_NODEBUG = _T1;\n};\n\ntemplate <class _T1, class _T2>\nstruct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> > {\n using type _LIBCPP_NODEBUG = _T2;\n};\n\ntemplate <size_t _Ip>\nstruct __get_pair;\n\ntemplate <>\nstruct __get_pair<0> {\n template <class _T1, class _T2>\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {\n return __p.first;\n }\n\n template <class _T1, class _T2>\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T1& get(const pair<_T1, _T2>& __p) _NOEXCEPT {\n return __p.first;\n }\n\n template <class _T1, class _T2>\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {\n return std::forward<_T1>(__p.first);\n }\n\n template <class _T1, class _T2>\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T1&& get(const pair<_T1, _T2>&& __p) _NOEXCEPT {\n return std::forward<const _T1>(__p.first);\n }\n};\n\ntemplate <>\nstruct __get_pair<1> {\n template <class _T1, class _T2>\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT {\n return __p.second;\n }\n\n template <class _T1, class _T2>\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T2& get(const pair<_T1, _T2>& __p) _NOEXCEPT {\n return __p.second;\n }\n\n template <class _T1, class _T2>\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {\n return std::forward<_T2>(__p.second);\n }\n\n template <class _T1, class _T2>\n static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T2&& get(const pair<_T1, _T2>&& __p) _NOEXCEPT {\n return std::forward<const _T2>(__p.second);\n }\n};\n\ntemplate <size_t _Ip, class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&\nget(pair<_T1, _T2>& __p) _NOEXCEPT {\n return __get_pair<_Ip>::get(__p);\n}\n\ntemplate <size_t _Ip, class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&\nget(const pair<_T1, _T2>& __p) _NOEXCEPT {\n return __get_pair<_Ip>::get(__p);\n}\n\ntemplate <size_t _Ip, class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&&\nget(pair<_T1, _T2>&& __p) _NOEXCEPT {\n return __get_pair<_Ip>::get(std::move(__p));\n}\n\ntemplate <size_t _Ip, class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&\nget(const pair<_T1, _T2>&& __p) _NOEXCEPT {\n return __get_pair<_Ip>::get(std::move(__p));\n}\n\n#if _LIBCPP_STD_VER >= 14\ntemplate <class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {\n return __get_pair<0>::get(__p);\n}\n\ntemplate <class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT {\n return __get_pair<0>::get(__p);\n}\n\ntemplate <class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {\n return __get_pair<0>::get(std::move(__p));\n}\n\ntemplate <class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT {\n return __get_pair<0>::get(std::move(__p));\n}\n\ntemplate <class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T2, _T1>& __p) _NOEXCEPT {\n return __get_pair<1>::get(__p);\n}\n\ntemplate <class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T2, _T1> const& __p) _NOEXCEPT {\n return __get_pair<1>::get(__p);\n}\n\ntemplate <class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T2, _T1>&& __p) _NOEXCEPT {\n return __get_pair<1>::get(std::move(__p));\n}\n\ntemplate <class _T1, class _T2>\ninline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T2, _T1> const&& __p) _NOEXCEPT {\n return __get_pair<1>::get(std::move(__p));\n}\n\n#endif // _LIBCPP_STD_VER >= 14\n\n_LIBCPP_END_NAMESPACE_STD\n\n_LIBCPP_POP_MACROS\n\n#endif // _LIBCPP___UTILITY_PAIR_H\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___FUNCTIONAL_FUNCTION_H\n#define _LIBCPP___FUNCTIONAL_FUNCTION_H\n\n#include <__assert>\n#include <__config>\n#include <__cstddef/nullptr_t.h>\n#include <__exception/exception.h>\n#include <__functional/binary_function.h>\n#include <__functional/invoke.h>\n#include <__functional/unary_function.h>\n#include <__iterator/iterator_traits.h>\n#include <__memory/addressof.h>\n#include <__memory/allocator.h>\n#include <__memory/allocator_destructor.h>\n#include <__memory/allocator_traits.h>\n#include <__memory/compressed_pair.h>\n#include <__memory/unique_ptr.h>\n#include <__type_traits/aligned_storage.h>\n#include <__type_traits/decay.h>\n#include <__type_traits/is_core_convertible.h>\n#include <__type_traits/is_scalar.h>\n#include <__type_traits/is_trivially_constructible.h>\n#include <__type_traits/is_trivially_destructible.h>\n#include <__type_traits/is_void.h>\n#include <__type_traits/strip_signature.h>\n#include <__utility/forward.h>\n#include <__utility/move.h>\n#include <__utility/piecewise_construct.h>\n#include <__utility/swap.h>\n#include <__verbose_abort>\n#include <tuple>\n#include <typeinfo>\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\n_LIBCPP_PUSH_MACROS\n#include <__undef_macros>\n\n#ifndef _LIBCPP_CXX03_LANG\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\n// bad_function_call\n\n_LIBCPP_DIAGNOSTIC_PUSH\n# if !_LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION\n_LIBCPP_CLANG_DIAGNOSTIC_IGNORED(\"-Wweak-vtables\")\n# endif\nclass _LIBCPP_EXPORTED_FROM_ABI bad_function_call : public exception {\npublic:\n _LIBCPP_HIDE_FROM_ABI bad_function_call() _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI bad_function_call(const bad_function_call&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI bad_function_call& operator=(const bad_function_call&) _NOEXCEPT = default;\n// Note that when a key function is not used, every translation unit that uses\n// bad_function_call will end up containing a weak definition of the vtable and\n// typeinfo.\n# if _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION\n ~bad_function_call() _NOEXCEPT override;\n# else\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {}\n# endif\n\n# ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE\n const char* what() const _NOEXCEPT override;\n# endif\n};\n_LIBCPP_DIAGNOSTIC_POP\n\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_function_call() {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw bad_function_call();\n# else\n _LIBCPP_VERBOSE_ABORT(\"bad_function_call was thrown in -fno-exceptions mode\");\n# endif\n}\n\ntemplate <class _Fp>\nclass _LIBCPP_TEMPLATE_VIS function; // undefined\n\nnamespace __function {\n\ntemplate <class _Rp>\nstruct __maybe_derive_from_unary_function {};\n\ntemplate <class _Rp, class _A1>\nstruct __maybe_derive_from_unary_function<_Rp(_A1)> : public __unary_function<_A1, _Rp> {};\n\ntemplate <class _Rp>\nstruct __maybe_derive_from_binary_function {};\n\ntemplate <class _Rp, class _A1, class _A2>\nstruct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> : public __binary_function<_A1, _A2, _Rp> {};\n\ntemplate <class _Fp>\n_LIBCPP_HIDE_FROM_ABI bool __not_null(_Fp const&) {\n return true;\n}\n\ntemplate <class _Fp>\n_LIBCPP_HIDE_FROM_ABI bool __not_null(_Fp* __ptr) {\n return __ptr;\n}\n\ntemplate <class _Ret, class _Class>\n_LIBCPP_HIDE_FROM_ABI bool __not_null(_Ret _Class::*__ptr) {\n return __ptr;\n}\n\ntemplate <class _Fp>\n_LIBCPP_HIDE_FROM_ABI bool __not_null(function<_Fp> const& __f) {\n return !!__f;\n}\n\n# if _LIBCPP_HAS_EXTENSION_BLOCKS\ntemplate <class _Rp, class... _Args>\n_LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) {\n return __p;\n}\n# endif\n\n} // namespace __function\n\nnamespace __function {\n\n// __alloc_func holds a functor and an allocator.\n\ntemplate <class _Fp, class _Ap, class _FB>\nclass __alloc_func;\ntemplate <class _Fp, class _FB>\nclass __default_alloc_func;\n\ntemplate <class _Fp, class _Ap, class _Rp, class... _ArgTypes>\nclass __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> {\n _LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Ap, __alloc_);\n\npublic:\n using _Target _LIBCPP_NODEBUG = _Fp;\n using _Alloc _LIBCPP_NODEBUG = _Ap;\n\n _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __func_; }\n\n // WIN32 APIs may define __allocator, so use __get_allocator instead.\n _LIBCPP_HIDE_FROM_ABI const _Alloc& __get_allocator() const { return __alloc_; }\n\n _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f) : __func_(std::move(__f)), __alloc_() {}\n\n _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, const _Alloc& __a) : __func_(__f), __alloc_(__a) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, _Alloc&& __a)\n : __func_(__f), __alloc_(std::move(__a)) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f, _Alloc&& __a)\n : __func_(std::move(__f)), __alloc_(std::move(__a)) {}\n\n _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) {\n return std::__invoke_r<_Rp>(__func_, std::forward<_ArgTypes>(__arg)...);\n }\n\n _LIBCPP_HIDE_FROM_ABI __alloc_func* __clone() const {\n typedef allocator_traits<_Alloc> __alloc_traits;\n typedef __rebind_alloc<__alloc_traits, __alloc_func> _AA;\n _AA __a(__alloc_);\n typedef __allocator_destructor<_AA> _Dp;\n unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));\n ::new ((void*)__hold.get()) __alloc_func(__func_, _Alloc(__a));\n return __hold.release();\n }\n\n _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT {\n __func_.~_Fp();\n __alloc_.~_Alloc();\n }\n\n _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__alloc_func* __f) {\n typedef allocator_traits<_Alloc> __alloc_traits;\n typedef __rebind_alloc<__alloc_traits, __alloc_func> _FunAlloc;\n _FunAlloc __a(__f->__get_allocator());\n __f->destroy();\n __a.deallocate(__f, 1);\n }\n};\n\ntemplate <class _Tp>\nstruct __deallocating_deleter {\n _LIBCPP_HIDE_FROM_ABI void operator()(void* __p) const {\n std::__libcpp_deallocate<_Tp>(static_cast<_Tp*>(__p), __element_count(1));\n }\n};\n\ntemplate <class _Fp, class _Rp, class... _ArgTypes>\nclass __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {\n _Fp __f_;\n\npublic:\n using _Target _LIBCPP_NODEBUG = _Fp;\n\n _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __f_; }\n\n _LIBCPP_HIDE_FROM_ABI explicit __default_alloc_func(_Target&& __f) : __f_(std::move(__f)) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}\n\n _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) {\n return std::__invoke_r<_Rp>(__f_, std::forward<_ArgTypes>(__arg)...);\n }\n\n _LIBCPP_HIDE_FROM_ABI __default_alloc_func* __clone() const {\n using _Self = __default_alloc_func;\n unique_ptr<_Self, __deallocating_deleter<_Self>> __hold(std::__libcpp_allocate<_Self>(__element_count(1)));\n _Self* __res = ::new ((void*)__hold.get()) _Self(__f_);\n (void)__hold.release();\n return __res;\n }\n\n _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT { __f_.~_Target(); }\n\n _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__default_alloc_func* __f) {\n __f->destroy();\n std::__libcpp_deallocate<__default_alloc_func>(__f, __element_count(1));\n }\n};\n\n// __base provides an abstract interface for copyable functors.\n\ntemplate <class _Fp>\nclass _LIBCPP_TEMPLATE_VIS __base;\n\ntemplate <class _Rp, class... _ArgTypes>\nclass __base<_Rp(_ArgTypes...)> {\npublic:\n __base(const __base&) = delete;\n __base& operator=(const __base&) = delete;\n\n _LIBCPP_HIDE_FROM_ABI __base() {}\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {}\n virtual __base* __clone() const = 0;\n virtual void __clone(__base*) const = 0;\n virtual void destroy() _NOEXCEPT = 0;\n virtual void destroy_deallocate() _NOEXCEPT = 0;\n virtual _Rp operator()(_ArgTypes&&...) = 0;\n# if _LIBCPP_HAS_RTTI\n virtual const void* target(const type_info&) const _NOEXCEPT = 0;\n virtual const std::type_info& target_type() const _NOEXCEPT = 0;\n# endif // _LIBCPP_HAS_RTTI\n};\n\n// __func implements __base for a given functor type.\n\ntemplate <class _FD, class _Alloc, class _FB>\nclass __func;\n\ntemplate <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>\nclass __func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {\n __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> __f_;\n\npublic:\n _LIBCPP_HIDE_FROM_ABI explicit __func(_Fp&& __f) : __f_(std::move(__f)) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit __func(const _Fp& __f, const _Alloc& __a) : __f_(__f, __a) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit __func(const _Fp& __f, _Alloc&& __a) : __f_(__f, std::move(__a)) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit __func(_Fp&& __f, _Alloc&& __a) : __f_(std::move(__f), std::move(__a)) {}\n\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const;\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg);\n# if _LIBCPP_HAS_RTTI\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(const type_info&) const _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT;\n# endif // _LIBCPP_HAS_RTTI\n};\n\ntemplate <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>\n__base<_Rp(_ArgTypes...)>* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const {\n typedef allocator_traits<_Alloc> __alloc_traits;\n typedef __rebind_alloc<__alloc_traits, __func> _Ap;\n _Ap __a(__f_.__get_allocator());\n typedef __allocator_destructor<_Ap> _Dp;\n unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));\n ::new ((void*)__hold.get()) __func(__f_.__target(), _Alloc(__a));\n return __hold.release();\n}\n\ntemplate <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>\nvoid __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const {\n ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator());\n}\n\ntemplate <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>\nvoid __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT {\n __f_.destroy();\n}\n\ntemplate <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>\nvoid __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT {\n typedef allocator_traits<_Alloc> __alloc_traits;\n typedef __rebind_alloc<__alloc_traits, __func> _Ap;\n _Ap __a(__f_.__get_allocator());\n __f_.destroy();\n __a.deallocate(this, 1);\n}\n\ntemplate <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>\n_Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) {\n return __f_(std::forward<_ArgTypes>(__arg)...);\n}\n\n# if _LIBCPP_HAS_RTTI\n\ntemplate <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>\nconst void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT {\n if (__ti == typeid(_Fp))\n return std::addressof(__f_.__target());\n return nullptr;\n}\n\ntemplate <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>\nconst std::type_info& __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT {\n return typeid(_Fp);\n}\n\n# endif // _LIBCPP_HAS_RTTI\n\n// __value_func creates a value-type from a __func.\n\ntemplate <class _Fp>\nclass __value_func;\n\ntemplate <class _Rp, class... _ArgTypes>\nclass __value_func<_Rp(_ArgTypes...)> {\n _LIBCPP_SUPPRESS_DEPRECATED_PUSH\n typename aligned_storage<3 * sizeof(void*)>::type __buf_;\n _LIBCPP_SUPPRESS_DEPRECATED_POP\n\n typedef __base<_Rp(_ArgTypes...)> __func;\n __func* __f_;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI static __func* __as_base(void* __p) { return reinterpret_cast<__func*>(__p); }\n\npublic:\n _LIBCPP_HIDE_FROM_ABI __value_func() _NOEXCEPT : __f_(nullptr) {}\n\n template <class _Fp, class _Alloc>\n _LIBCPP_HIDE_FROM_ABI __value_func(_Fp&& __f, const _Alloc& __a) : __f_(nullptr) {\n typedef allocator_traits<_Alloc> __alloc_traits;\n typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;\n typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc;\n\n if (__function::__not_null(__f)) {\n _FunAlloc __af(__a);\n if (sizeof(_Fun) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value &&\n is_nothrow_copy_constructible<_FunAlloc>::value) {\n __f_ = ::new ((void*)&__buf_) _Fun(std::move(__f), _Alloc(__af));\n } else {\n typedef __allocator_destructor<_FunAlloc> _Dp;\n unique_ptr<__func, _Dp> __hold(__af.allocate(1), _Dp(__af, 1));\n ::new ((void*)__hold.get()) _Fun(std::move(__f), _Alloc(__a));\n __f_ = __hold.release();\n }\n }\n }\n\n template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __value_func>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI explicit __value_func(_Fp&& __f) : __value_func(std::forward<_Fp>(__f), allocator<_Fp>()) {}\n\n _LIBCPP_HIDE_FROM_ABI __value_func(const __value_func& __f) {\n if (__f.__f_ == nullptr)\n __f_ = nullptr;\n else if ((void*)__f.__f_ == &__f.__buf_) {\n __f_ = __as_base(&__buf_);\n __f.__f_->__clone(__f_);\n } else\n __f_ = __f.__f_->__clone();\n }\n\n _LIBCPP_HIDE_FROM_ABI __value_func(__value_func&& __f) _NOEXCEPT {\n if (__f.__f_ == nullptr)\n __f_ = nullptr;\n else if ((void*)__f.__f_ == &__f.__buf_) {\n __f_ = __as_base(&__buf_);\n __f.__f_->__clone(__f_);\n } else {\n __f_ = __f.__f_;\n __f.__f_ = nullptr;\n }\n }\n\n _LIBCPP_HIDE_FROM_ABI ~__value_func() {\n if ((void*)__f_ == &__buf_)\n __f_->destroy();\n else if (__f_)\n __f_->destroy_deallocate();\n }\n\n _LIBCPP_HIDE_FROM_ABI __value_func& operator=(__value_func&& __f) {\n *this = nullptr;\n if (__f.__f_ == nullptr)\n __f_ = nullptr;\n else if ((void*)__f.__f_ == &__f.__buf_) {\n __f_ = __as_base(&__buf_);\n __f.__f_->__clone(__f_);\n } else {\n __f_ = __f.__f_;\n __f.__f_ = nullptr;\n }\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI __value_func& operator=(nullptr_t) {\n __func* __f = __f_;\n __f_ = nullptr;\n if ((void*)__f == &__buf_)\n __f->destroy();\n else if (__f)\n __f->destroy_deallocate();\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const {\n if (__f_ == nullptr)\n __throw_bad_function_call();\n return (*__f_)(std::forward<_ArgTypes>(__args)...);\n }\n\n _LIBCPP_HIDE_FROM_ABI void swap(__value_func& __f) _NOEXCEPT {\n if (&__f == this)\n return;\n if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) {\n _LIBCPP_SUPPRESS_DEPRECATED_PUSH\n typename aligned_storage<sizeof(__buf_)>::type __tempbuf;\n _LIBCPP_SUPPRESS_DEPRECATED_POP\n __func* __t = __as_base(&__tempbuf);\n __f_->__clone(__t);\n __f_->destroy();\n __f_ = nullptr;\n __f.__f_->__clone(__as_base(&__buf_));\n __f.__f_->destroy();\n __f.__f_ = nullptr;\n __f_ = __as_base(&__buf_);\n __t->__clone(__as_base(&__f.__buf_));\n __t->destroy();\n __f.__f_ = __as_base(&__f.__buf_);\n } else if ((void*)__f_ == &__buf_) {\n __f_->__clone(__as_base(&__f.__buf_));\n __f_->destroy();\n __f_ = __f.__f_;\n __f.__f_ = __as_base(&__f.__buf_);\n } else if ((void*)__f.__f_ == &__f.__buf_) {\n __f.__f_->__clone(__as_base(&__buf_));\n __f.__f_->destroy();\n __f.__f_ = __f_;\n __f_ = __as_base(&__buf_);\n } else\n std::swap(__f_, __f.__f_);\n }\n\n _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __f_ != nullptr; }\n\n# if _LIBCPP_HAS_RTTI\n _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT {\n if (__f_ == nullptr)\n return typeid(void);\n return __f_->target_type();\n }\n\n template <typename _Tp>\n _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT {\n if (__f_ == nullptr)\n return nullptr;\n return (const _Tp*)__f_->target(typeid(_Tp));\n }\n# endif // _LIBCPP_HAS_RTTI\n};\n\n// Storage for a functor object, to be used with __policy to manage copy and\n// destruction.\nunion __policy_storage {\n mutable char __small[sizeof(void*) * 2];\n void* __large;\n};\n\n// True if _Fun can safely be held in __policy_storage.__small.\ntemplate <typename _Fun>\nstruct __use_small_storage\n : public integral_constant<\n bool,\n sizeof(_Fun) <= sizeof(__policy_storage)&& _LIBCPP_ALIGNOF(_Fun) <= _LIBCPP_ALIGNOF(__policy_storage) &&\n is_trivially_copy_constructible<_Fun>::value && is_trivially_destructible<_Fun>::value> {};\n\n// Policy contains information about how to copy, destroy, and move the\n// underlying functor. You can think of it as a vtable of sorts.\nstruct __policy {\n // Used to copy or destroy __large values. null for trivial objects.\n void* (*const __clone)(const void*);\n void (*const __destroy)(void*);\n\n // True if this is the null policy (no value).\n const bool __is_null;\n\n // The target type. May be null if RTTI is disabled.\n const std::type_info* const __type_info;\n\n // Returns a pointer to a static policy object suitable for the functor\n // type.\n template <typename _Fun>\n _LIBCPP_HIDE_FROM_ABI static const __policy* __create() {\n return __choose_policy<_Fun>(__use_small_storage<_Fun>());\n }\n\n _LIBCPP_HIDE_FROM_ABI static const __policy* __create_empty() {\n static constexpr __policy __policy = {\n nullptr,\n nullptr,\n true,\n# if _LIBCPP_HAS_RTTI\n &typeid(void)\n# else\n nullptr\n# endif\n };\n return &__policy;\n }\n\nprivate:\n template <typename _Fun>\n _LIBCPP_HIDE_FROM_ABI static void* __large_clone(const void* __s) {\n const _Fun* __f = static_cast<const _Fun*>(__s);\n return __f->__clone();\n }\n\n template <typename _Fun>\n _LIBCPP_HIDE_FROM_ABI static void __large_destroy(void* __s) {\n _Fun::__destroy_and_delete(static_cast<_Fun*>(__s));\n }\n\n template <typename _Fun>\n _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ false_type) {\n static constexpr __policy __policy = {\n &__large_clone<_Fun>,\n &__large_destroy<_Fun>,\n false,\n# if _LIBCPP_HAS_RTTI\n &typeid(typename _Fun::_Target)\n# else\n nullptr\n# endif\n };\n return &__policy;\n }\n\n template <typename _Fun>\n _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ true_type) {\n static constexpr __policy __policy = {\n nullptr,\n nullptr,\n false,\n# if _LIBCPP_HAS_RTTI\n &typeid(typename _Fun::_Target)\n# else\n nullptr\n# endif\n };\n return &__policy;\n }\n};\n\n// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is\n// faster for types that can be passed in registers.\ntemplate <typename _Tp>\nusing __fast_forward _LIBCPP_NODEBUG = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>;\n\n// __policy_invoker calls an instance of __alloc_func held in __policy_storage.\n\ntemplate <class _Fp>\nstruct __policy_invoker;\n\ntemplate <class _Rp, class... _ArgTypes>\nstruct __policy_invoker<_Rp(_ArgTypes...)> {\n typedef _Rp (*__Call)(const __policy_storage*, __fast_forward<_ArgTypes>...);\n\n __Call __call_;\n\n // Creates an invoker that throws bad_function_call.\n _LIBCPP_HIDE_FROM_ABI __policy_invoker() : __call_(&__call_empty) {}\n\n // Creates an invoker that calls the given instance of __func.\n template <typename _Fun>\n _LIBCPP_HIDE_FROM_ABI static __policy_invoker __create() {\n return __policy_invoker(&__call_impl<_Fun>);\n }\n\nprivate:\n _LIBCPP_HIDE_FROM_ABI explicit __policy_invoker(__Call __c) : __call_(__c) {}\n\n _LIBCPP_HIDE_FROM_ABI static _Rp __call_empty(const __policy_storage*, __fast_forward<_ArgTypes>...) {\n __throw_bad_function_call();\n }\n\n template <typename _Fun>\n _LIBCPP_HIDE_FROM_ABI static _Rp __call_impl(const __policy_storage* __buf, __fast_forward<_ArgTypes>... __args) {\n _Fun* __f = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value ? &__buf->__small : __buf->__large);\n return (*__f)(std::forward<_ArgTypes>(__args)...);\n }\n};\n\n// __policy_func uses a __policy and __policy_invoker to create a type-erased,\n// copyable functor.\n\ntemplate <class _Fp>\nclass __policy_func;\n\ntemplate <class _Rp, class... _ArgTypes>\nclass __policy_func<_Rp(_ArgTypes...)> {\n // Inline storage for small objects.\n __policy_storage __buf_;\n\n // Calls the value stored in __buf_. This could technically be part of\n // policy, but storing it here eliminates a level of indirection inside\n // operator().\n typedef __function::__policy_invoker<_Rp(_ArgTypes...)> __invoker;\n __invoker __invoker_;\n\n // The policy that describes how to move / copy / destroy __buf_. Never\n // null, even if the function is empty.\n const __policy* __policy_;\n\npublic:\n _LIBCPP_HIDE_FROM_ABI __policy_func() : __policy_(__policy::__create_empty()) {}\n\n template <class _Fp, class _Alloc>\n _LIBCPP_HIDE_FROM_ABI __policy_func(_Fp&& __f, const _Alloc& __a) : __policy_(__policy::__create_empty()) {\n typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;\n typedef allocator_traits<_Alloc> __alloc_traits;\n typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc;\n\n if (__function::__not_null(__f)) {\n __invoker_ = __invoker::template __create<_Fun>();\n __policy_ = __policy::__create<_Fun>();\n\n _FunAlloc __af(__a);\n if (__use_small_storage<_Fun>()) {\n ::new ((void*)&__buf_.__small) _Fun(std::move(__f), _Alloc(__af));\n } else {\n typedef __allocator_destructor<_FunAlloc> _Dp;\n unique_ptr<_Fun, _Dp> __hold(__af.allocate(1), _Dp(__af, 1));\n ::new ((void*)__hold.get()) _Fun(std::move(__f), _Alloc(__af));\n __buf_.__large = __hold.release();\n }\n }\n }\n\n template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __policy_func>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI explicit __policy_func(_Fp&& __f) : __policy_(__policy::__create_empty()) {\n typedef __default_alloc_func<_Fp, _Rp(_ArgTypes...)> _Fun;\n\n if (__function::__not_null(__f)) {\n __invoker_ = __invoker::template __create<_Fun>();\n __policy_ = __policy::__create<_Fun>();\n if (__use_small_storage<_Fun>()) {\n ::new ((void*)&__buf_.__small) _Fun(std::move(__f));\n } else {\n unique_ptr<_Fun, __deallocating_deleter<_Fun>> __hold(std::__libcpp_allocate<_Fun>(__element_count(1)));\n __buf_.__large = ::new ((void*)__hold.get()) _Fun(std::move(__f));\n (void)__hold.release();\n }\n }\n }\n\n _LIBCPP_HIDE_FROM_ABI __policy_func(const __policy_func& __f)\n : __buf_(__f.__buf_), __invoker_(__f.__invoker_), __policy_(__f.__policy_) {\n if (__policy_->__clone)\n __buf_.__large = __policy_->__clone(__f.__buf_.__large);\n }\n\n _LIBCPP_HIDE_FROM_ABI __policy_func(__policy_func&& __f)\n : __buf_(__f.__buf_), __invoker_(__f.__invoker_), __policy_(__f.__policy_) {\n if (__policy_->__destroy) {\n __f.__policy_ = __policy::__create_empty();\n __f.__invoker_ = __invoker();\n }\n }\n\n _LIBCPP_HIDE_FROM_ABI ~__policy_func() {\n if (__policy_->__destroy)\n __policy_->__destroy(__buf_.__large);\n }\n\n _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(__policy_func&& __f) {\n *this = nullptr;\n __buf_ = __f.__buf_;\n __invoker_ = __f.__invoker_;\n __policy_ = __f.__policy_;\n __f.__policy_ = __policy::__create_empty();\n __f.__invoker_ = __invoker();\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(nullptr_t) {\n const __policy* __p = __policy_;\n __policy_ = __policy::__create_empty();\n __invoker_ = __invoker();\n if (__p->__destroy)\n __p->__destroy(__buf_.__large);\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const {\n return __invoker_.__call_(std::addressof(__buf_), std::forward<_ArgTypes>(__args)...);\n }\n\n _LIBCPP_HIDE_FROM_ABI void swap(__policy_func& __f) {\n std::swap(__invoker_, __f.__invoker_);\n std::swap(__policy_, __f.__policy_);\n std::swap(__buf_, __f.__buf_);\n }\n\n _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return !__policy_->__is_null; }\n\n# if _LIBCPP_HAS_RTTI\n _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT { return *__policy_->__type_info; }\n\n template <typename _Tp>\n _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT {\n if (__policy_->__is_null || typeid(_Tp) != *__policy_->__type_info)\n return nullptr;\n if (__policy_->__clone) // Out of line storage.\n return reinterpret_cast<const _Tp*>(__buf_.__large);\n else\n return reinterpret_cast<const _Tp*>(&__buf_.__small);\n }\n# endif // _LIBCPP_HAS_RTTI\n};\n\n# if _LIBCPP_HAS_BLOCKS_RUNTIME\n\nextern \"C\" void* _Block_copy(const void*);\nextern \"C\" void _Block_release(const void*);\n\ntemplate <class _Rp1, class... _ArgTypes1, class _Alloc, class _Rp, class... _ArgTypes>\nclass __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {\n typedef _Rp1 (^__block_type)(_ArgTypes1...);\n __block_type __f_;\n\npublic:\n _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type const& __f)\n# if _LIBCPP_HAS_OBJC_ARC\n : __f_(__f)\n# else\n : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))\n# endif\n {\n }\n\n // [TODO] add && to save on a retain\n\n _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type __f, const _Alloc& /* unused */)\n# if _LIBCPP_HAS_OBJC_ARC\n : __f_(__f)\n# else\n : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))\n# endif\n {\n }\n\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const {\n _LIBCPP_ASSERT_INTERNAL(\n false,\n \"Block pointers are just pointers, so they should always fit into \"\n \"std::function's small buffer optimization. This function should \"\n \"never be invoked.\");\n return nullptr;\n }\n\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {\n ::new ((void*)__p) __func(__f_);\n }\n\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT {\n# if !_LIBCPP_HAS_OBJC_ARC\n if (__f_)\n _Block_release(__f_);\n# endif\n __f_ = 0;\n }\n\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT {\n _LIBCPP_ASSERT_INTERNAL(\n false,\n \"Block pointers are just pointers, so they should always fit into \"\n \"std::function's small buffer optimization. This function should \"\n \"never be invoked.\");\n }\n\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg) {\n return std::__invoke(__f_, std::forward<_ArgTypes>(__arg)...);\n }\n\n# if _LIBCPP_HAS_RTTI\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(type_info const& __ti) const _NOEXCEPT {\n if (__ti == typeid(__func::__block_type))\n return &__f_;\n return (const void*)nullptr;\n }\n\n _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT {\n return typeid(__func::__block_type);\n }\n# endif // _LIBCPP_HAS_RTTI\n};\n\n# endif // _LIBCPP_HAS_EXTENSION_BLOCKS\n\n} // namespace __function\n\ntemplate <class _Rp, class... _ArgTypes>\nclass _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>\n : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,\n public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> {\n# ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION\n typedef __function::__value_func<_Rp(_ArgTypes...)> __func;\n# else\n typedef __function::__policy_func<_Rp(_ArgTypes...)> __func;\n# endif\n\n __func __f_;\n\n template <class _Fp,\n bool = _And<_IsNotSame<__remove_cvref_t<_Fp>, function>, __is_invocable<_Fp, _ArgTypes...> >::value>\n struct __callable;\n template <class _Fp>\n struct __callable<_Fp, true> {\n static const bool value =\n is_void<_Rp>::value || __is_core_convertible<__invoke_result_t<_Fp, _ArgTypes...>, _Rp>::value;\n };\n template <class _Fp>\n struct __callable<_Fp, false> {\n static const bool value = false;\n };\n\n template <class _Fp>\n using _EnableIfLValueCallable _LIBCPP_NODEBUG = __enable_if_t<__callable<_Fp&>::value>;\n\npublic:\n typedef _Rp result_type;\n\n // construct/copy/destroy:\n _LIBCPP_HIDE_FROM_ABI function() _NOEXCEPT {}\n _LIBCPP_HIDE_FROM_ABI function(nullptr_t) _NOEXCEPT {}\n _LIBCPP_HIDE_FROM_ABI function(const function&);\n _LIBCPP_HIDE_FROM_ABI function(function&&) _NOEXCEPT;\n template <class _Fp, class = _EnableIfLValueCallable<_Fp>>\n _LIBCPP_HIDE_FROM_ABI function(_Fp);\n\n# if _LIBCPP_STD_VER <= 14\n template <class _Alloc>\n _LIBCPP_HIDE_FROM_ABI function(allocator_arg_t, const _Alloc&) _NOEXCEPT {}\n template <class _Alloc>\n _LIBCPP_HIDE_FROM_ABI function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT {}\n template <class _Alloc>\n _LIBCPP_HIDE_FROM_ABI function(allocator_arg_t, const _Alloc&, const function&);\n template <class _Alloc>\n _LIBCPP_HIDE_FROM_ABI function(allocator_arg_t, const _Alloc&, function&&);\n template <class _Fp, class _Alloc, class = _EnableIfLValueCallable<_Fp>>\n _LIBCPP_HIDE_FROM_ABI function(allocator_arg_t, const _Alloc& __a, _Fp __f);\n# endif\n\n _LIBCPP_HIDE_FROM_ABI function& operator=(const function&);\n _LIBCPP_HIDE_FROM_ABI function& operator=(function&&) _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI function& operator=(nullptr_t) _NOEXCEPT;\n template <class _Fp, class = _EnableIfLValueCallable<__decay_t<_Fp>>>\n _LIBCPP_HIDE_FROM_ABI function& operator=(_Fp&&);\n\n _LIBCPP_HIDE_FROM_ABI ~function();\n\n // function modifiers:\n _LIBCPP_HIDE_FROM_ABI void swap(function&) _NOEXCEPT;\n\n# if _LIBCPP_STD_VER <= 14\n template <class _Fp, class _Alloc>\n _LIBCPP_HIDE_FROM_ABI void assign(_Fp&& __f, const _Alloc& __a) {\n function(allocator_arg, __a, std::forward<_Fp>(__f)).swap(*this);\n }\n# endif\n\n // function capacity:\n _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return static_cast<bool>(__f_); }\n\n // deleted overloads close possible hole in the type system\n template <class _R2, class... _ArgTypes2>\n bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;\n# if _LIBCPP_STD_VER <= 17\n template <class _R2, class... _ArgTypes2>\n bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;\n# endif\n\npublic:\n // function invocation:\n _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes...) const;\n\n# if _LIBCPP_HAS_RTTI\n // function target access:\n _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT;\n template <typename _Tp>\n _LIBCPP_HIDE_FROM_ABI _Tp* target() _NOEXCEPT;\n template <typename _Tp>\n _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT;\n# endif // _LIBCPP_HAS_RTTI\n};\n\n# if _LIBCPP_STD_VER >= 17\ntemplate <class _Rp, class... _Ap>\nfunction(_Rp (*)(_Ap...)) -> function<_Rp(_Ap...)>;\n\ntemplate <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>\nfunction(_Fp) -> function<_Stripped>;\n# endif // _LIBCPP_STD_VER >= 17\n\ntemplate <class _Rp, class... _ArgTypes>\nfunction<_Rp(_ArgTypes...)>::function(const function& __f) : __f_(__f.__f_) {}\n\n# if _LIBCPP_STD_VER <= 14\ntemplate <class _Rp, class... _ArgTypes>\ntemplate <class _Alloc>\nfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, const function& __f) : __f_(__f.__f_) {}\n# endif\n\ntemplate <class _Rp, class... _ArgTypes>\nfunction<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT : __f_(std::move(__f.__f_)) {}\n\n# if _LIBCPP_STD_VER <= 14\ntemplate <class _Rp, class... _ArgTypes>\ntemplate <class _Alloc>\nfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, function&& __f) : __f_(std::move(__f.__f_)) {}\n# endif\n\ntemplate <class _Rp, class... _ArgTypes>\ntemplate <class _Fp, class>\nfunction<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(std::move(__f)) {}\n\n# if _LIBCPP_STD_VER <= 14\ntemplate <class _Rp, class... _ArgTypes>\ntemplate <class _Fp, class _Alloc, class>\nfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a, _Fp __f) : __f_(std::move(__f), __a) {}\n# endif\n\ntemplate <class _Rp, class... _ArgTypes>\nfunction<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(const function& __f) {\n function(__f).swap(*this);\n return *this;\n}\n\ntemplate <class _Rp, class... _ArgTypes>\nfunction<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT {\n __f_ = std::move(__f.__f_);\n return *this;\n}\n\ntemplate <class _Rp, class... _ArgTypes>\nfunction<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT {\n __f_ = nullptr;\n return *this;\n}\n\ntemplate <class _Rp, class... _ArgTypes>\ntemplate <class _Fp, class>\nfunction<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) {\n function(std::forward<_Fp>(__f)).swap(*this);\n return *this;\n}\n\ntemplate <class _Rp, class... _ArgTypes>\nfunction<_Rp(_ArgTypes...)>::~function() {}\n\ntemplate <class _Rp, class... _ArgTypes>\nvoid function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT {\n __f_.swap(__f.__f_);\n}\n\ntemplate <class _Rp, class... _ArgTypes>\n_Rp function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const {\n return __f_(std::forward<_ArgTypes>(__arg)...);\n}\n\n# if _LIBCPP_HAS_RTTI\n\ntemplate <class _Rp, class... _ArgTypes>\nconst std::type_info& function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT {\n return __f_.target_type();\n}\n\ntemplate <class _Rp, class... _ArgTypes>\ntemplate <typename _Tp>\n_Tp* function<_Rp(_ArgTypes...)>::target() _NOEXCEPT {\n return (_Tp*)(__f_.template target<_Tp>());\n}\n\ntemplate <class _Rp, class... _ArgTypes>\ntemplate <typename _Tp>\nconst _Tp* function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT {\n return __f_.template target<_Tp>();\n}\n\n# endif // _LIBCPP_HAS_RTTI\n\ntemplate <class _Rp, class... _ArgTypes>\ninline _LIBCPP_HIDE_FROM_ABI bool operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {\n return !__f;\n}\n\n# if _LIBCPP_STD_VER <= 17\n\ntemplate <class _Rp, class... _ArgTypes>\ninline _LIBCPP_HIDE_FROM_ABI bool operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {\n return !__f;\n}\n\ntemplate <class _Rp, class... _ArgTypes>\ninline _LIBCPP_HIDE_FROM_ABI bool operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {\n return (bool)__f;\n}\n\ntemplate <class _Rp, class... _ArgTypes>\ninline _LIBCPP_HIDE_FROM_ABI bool operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {\n return (bool)__f;\n}\n\n# endif // _LIBCPP_STD_VER <= 17\n\ntemplate <class _Rp, class... _ArgTypes>\ninline _LIBCPP_HIDE_FROM_ABI void swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT {\n return __x.swap(__y);\n}\n\n_LIBCPP_END_NAMESPACE_STD\n\n#endif // _LIBCPP_CXX03_LANG\n\n_LIBCPP_POP_MACROS\n\n#endif // _LIBCPP___FUNCTIONAL_FUNCTION_H\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP_MAP\n#define _LIBCPP_MAP\n\n/*\n\n map synopsis\n\nnamespace std\n{\n\ntemplate <class Key, class T, class Compare = less<Key>,\n class Allocator = allocator<pair<const Key, T>>>\nclass map\n{\npublic:\n // types:\n typedef Key key_type;\n typedef T mapped_type;\n typedef pair<const key_type, mapped_type> value_type;\n typedef Compare key_compare;\n typedef Allocator allocator_type;\n typedef typename allocator_type::reference reference;\n typedef typename allocator_type::const_reference const_reference;\n typedef typename allocator_type::pointer pointer;\n typedef typename allocator_type::const_pointer const_pointer;\n typedef typename allocator_type::size_type size_type;\n typedef typename allocator_type::difference_type difference_type;\n\n typedef implementation-defined iterator;\n typedef implementation-defined const_iterator;\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n typedef unspecified node_type; // C++17\n typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17\n\n class value_compare\n {\n friend class map;\n protected:\n key_compare comp;\n\n value_compare(key_compare c);\n public:\n typedef bool result_type; // deprecated in C++17, removed in C++20\n typedef value_type first_argument_type; // deprecated in C++17, removed in C++20\n typedef value_type second_argument_type; // deprecated in C++17, removed in C++20\n bool operator()(const value_type& x, const value_type& y) const;\n };\n\n // construct/copy/destroy:\n map()\n noexcept(\n is_nothrow_default_constructible<allocator_type>::value &&\n is_nothrow_default_constructible<key_compare>::value &&\n is_nothrow_copy_constructible<key_compare>::value);\n explicit map(const key_compare& comp);\n map(const key_compare& comp, const allocator_type& a);\n template <class InputIterator>\n map(InputIterator first, InputIterator last,\n const key_compare& comp = key_compare());\n template <class InputIterator>\n map(InputIterator first, InputIterator last,\n const key_compare& comp, const allocator_type& a);\n template<container-compatible-range<value_type> R>\n map(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23\n map(const map& m);\n map(map&& m)\n noexcept(\n is_nothrow_move_constructible<allocator_type>::value &&\n is_nothrow_move_constructible<key_compare>::value);\n explicit map(const allocator_type& a);\n map(const map& m, const allocator_type& a);\n map(map&& m, const allocator_type& a);\n map(initializer_list<value_type> il, const key_compare& comp = key_compare());\n map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);\n template <class InputIterator>\n map(InputIterator first, InputIterator last, const allocator_type& a)\n : map(first, last, Compare(), a) {} // C++14\n template<container-compatible-range<value_type> R>\n map(from_range_t, R&& rg, const Allocator& a))\n : map(from_range, std::forward<R>(rg), Compare(), a) { } // C++23\n map(initializer_list<value_type> il, const allocator_type& a)\n : map(il, Compare(), a) {} // C++14\n ~map();\n\n map& operator=(const map& m);\n map& operator=(map&& m)\n noexcept(\n allocator_type::propagate_on_container_move_assignment::value &&\n is_nothrow_move_assignable<allocator_type>::value &&\n is_nothrow_move_assignable<key_compare>::value);\n map& operator=(initializer_list<value_type> il);\n\n // iterators:\n iterator begin() noexcept;\n const_iterator begin() const noexcept;\n iterator end() noexcept;\n const_iterator end() const noexcept;\n\n reverse_iterator rbegin() noexcept;\n const_reverse_iterator rbegin() const noexcept;\n reverse_iterator rend() noexcept;\n const_reverse_iterator rend() const noexcept;\n\n const_iterator cbegin() const noexcept;\n const_iterator cend() const noexcept;\n const_reverse_iterator crbegin() const noexcept;\n const_reverse_iterator crend() const noexcept;\n\n // capacity:\n bool empty() const noexcept;\n size_type size() const noexcept;\n size_type max_size() const noexcept;\n\n // element access:\n mapped_type& operator[](const key_type& k);\n mapped_type& operator[](key_type&& k);\n\n mapped_type& at(const key_type& k);\n const mapped_type& at(const key_type& k) const;\n\n // modifiers:\n template <class... Args>\n pair<iterator, bool> emplace(Args&&... args);\n template <class... Args>\n iterator emplace_hint(const_iterator position, Args&&... args);\n pair<iterator, bool> insert(const value_type& v);\n pair<iterator, bool> insert( value_type&& v); // C++17\n template <class P>\n pair<iterator, bool> insert(P&& p);\n iterator insert(const_iterator position, const value_type& v);\n iterator insert(const_iterator position, value_type&& v); // C++17\n template <class P>\n iterator insert(const_iterator position, P&& p);\n template <class InputIterator>\n void insert(InputIterator first, InputIterator last);\n template<container-compatible-range<value_type> R>\n void insert_range(R&& rg); // C++23\n void insert(initializer_list<value_type> il);\n\n node_type extract(const_iterator position); // C++17\n node_type extract(const key_type& x); // C++17\n insert_return_type insert(node_type&& nh); // C++17\n iterator insert(const_iterator hint, node_type&& nh); // C++17\n\n template <class... Args>\n pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17\n template <class... Args>\n pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17\n template <class... Args>\n iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17\n template <class... Args>\n iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17\n template <class M>\n pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17\n template <class M>\n pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17\n template <class M>\n iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17\n template <class M>\n iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17\n\n iterator erase(const_iterator position);\n iterator erase(iterator position); // C++14\n size_type erase(const key_type& k);\n iterator erase(const_iterator first, const_iterator last);\n void clear() noexcept;\n\n template<class C2>\n void merge(map<Key, T, C2, Allocator>& source); // C++17\n template<class C2>\n void merge(map<Key, T, C2, Allocator>&& source); // C++17\n template<class C2>\n void merge(multimap<Key, T, C2, Allocator>& source); // C++17\n template<class C2>\n void merge(multimap<Key, T, C2, Allocator>&& source); // C++17\n\n void swap(map& m)\n noexcept(allocator_traits<allocator_type>::is_always_equal::value &&\n is_nothrow_swappable<key_compare>::value); // C++17\n\n // observers:\n allocator_type get_allocator() const noexcept;\n key_compare key_comp() const;\n value_compare value_comp() const;\n\n // map operations:\n iterator find(const key_type& k);\n const_iterator find(const key_type& k) const;\n template<typename K>\n iterator find(const K& x); // C++14\n template<typename K>\n const_iterator find(const K& x) const; // C++14\n\n template<typename K>\n size_type count(const K& x) const; // C++14\n size_type count(const key_type& k) const;\n\n bool contains(const key_type& x) const; // C++20\n template<class K> bool contains(const K& x) const; // C++20\n\n iterator lower_bound(const key_type& k);\n const_iterator lower_bound(const key_type& k) const;\n template<typename K>\n iterator lower_bound(const K& x); // C++14\n template<typename K>\n const_iterator lower_bound(const K& x) const; // C++14\n\n iterator upper_bound(const key_type& k);\n const_iterator upper_bound(const key_type& k) const;\n template<typename K>\n iterator upper_bound(const K& x); // C++14\n template<typename K>\n const_iterator upper_bound(const K& x) const; // C++14\n\n pair<iterator,iterator> equal_range(const key_type& k);\n pair<const_iterator,const_iterator> equal_range(const key_type& k) const;\n template<typename K>\n pair<iterator,iterator> equal_range(const K& x); // C++14\n template<typename K>\n pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14\n};\n\ntemplate <class InputIterator,\n class Compare = less<iter_key_t<InputIterator>>,\n class Allocator = allocator<iter_to_alloc_t<InputIterator>>>\nmap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())\n -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17\n\ntemplate<ranges::input_range R, class Compare = less<range-key-type<R>,\n class Allocator = allocator<range-to-alloc-type<R>>>\n map(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())\n -> map<range-key-type<R>, range-mapped-type<R>, Compare, Allocator>; // C++23\n\ntemplate<class Key, class T, class Compare = less<Key>,\n class Allocator = allocator<pair<const Key, T>>>\nmap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())\n -> map<Key, T, Compare, Allocator>; // C++17\n\ntemplate <class InputIterator, class Allocator>\nmap(InputIterator, InputIterator, Allocator)\n -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, less<iter_key_t<InputIterator>>,\n Allocator>; // C++17\n\ntemplate<ranges::input_range R, class Allocator>\n map(from_range_t, R&&, Allocator)\n -> map<range-key-type<R>, range-mapped-type<R>, less<range-key-type<R>>, Allocator>; // C++23\n\ntemplate<class Key, class T, class Allocator>\nmap(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>; // C++17\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator==(const map<Key, T, Compare, Allocator>& x,\n const map<Key, T, Compare, Allocator>& y);\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator< (const map<Key, T, Compare, Allocator>& x,\n const map<Key, T, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator!=(const map<Key, T, Compare, Allocator>& x,\n const map<Key, T, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator> (const map<Key, T, Compare, Allocator>& x,\n const map<Key, T, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator>=(const map<Key, T, Compare, Allocator>& x,\n const map<Key, T, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator<=(const map<Key, T, Compare, Allocator>& x,\n const map<Key, T, Compare, Allocator>& y); // removed in C++20\n\ntemplate<class Key, class T, class Compare, class Allocator>\n synth-three-way-result<pair<const Key, T>>\n operator<=>(const map<Key, T, Compare, Allocator>& x,\n const map<Key, T, Compare, Allocator>& y); // since C++20\n\n// specialized algorithms:\ntemplate <class Key, class T, class Compare, class Allocator>\nvoid\nswap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y)\n noexcept(noexcept(x.swap(y)));\n\ntemplate <class Key, class T, class Compare, class Allocator, class Predicate>\ntypename map<Key, T, Compare, Allocator>::size_type\nerase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); // C++20\n\n\ntemplate <class Key, class T, class Compare = less<Key>,\n class Allocator = allocator<pair<const Key, T>>>\nclass multimap\n{\npublic:\n // types:\n typedef Key key_type;\n typedef T mapped_type;\n typedef pair<const key_type,mapped_type> value_type;\n typedef Compare key_compare;\n typedef Allocator allocator_type;\n typedef typename allocator_type::reference reference;\n typedef typename allocator_type::const_reference const_reference;\n typedef typename allocator_type::size_type size_type;\n typedef typename allocator_type::difference_type difference_type;\n typedef typename allocator_type::pointer pointer;\n typedef typename allocator_type::const_pointer const_pointer;\n\n typedef implementation-defined iterator;\n typedef implementation-defined const_iterator;\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n typedef unspecified node_type; // C++17\n\n class value_compare\n {\n friend class multimap;\n protected:\n key_compare comp;\n value_compare(key_compare c);\n public:\n typedef bool result_type; // deprecated in C++17, removed in C++20\n typedef value_type first_argument_type; // deprecated in C++17, removed in C++20\n typedef value_type second_argument_type; // deprecated in C++17, removed in C++20\n bool operator()(const value_type& x, const value_type& y) const;\n };\n\n // construct/copy/destroy:\n multimap()\n noexcept(\n is_nothrow_default_constructible<allocator_type>::value &&\n is_nothrow_default_constructible<key_compare>::value &&\n is_nothrow_copy_constructible<key_compare>::value);\n explicit multimap(const key_compare& comp);\n multimap(const key_compare& comp, const allocator_type& a);\n template <class InputIterator>\n multimap(InputIterator first, InputIterator last, const key_compare& comp);\n template <class InputIterator>\n multimap(InputIterator first, InputIterator last, const key_compare& comp,\n const allocator_type& a);\n template<container-compatible-range<value_type> R>\n multimap(from_range_t, R&& rg,\n const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23\n multimap(const multimap& m);\n multimap(multimap&& m)\n noexcept(\n is_nothrow_move_constructible<allocator_type>::value &&\n is_nothrow_move_constructible<key_compare>::value);\n explicit multimap(const allocator_type& a);\n multimap(const multimap& m, const allocator_type& a);\n multimap(multimap&& m, const allocator_type& a);\n multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());\n multimap(initializer_list<value_type> il, const key_compare& comp,\n const allocator_type& a);\n template <class InputIterator>\n multimap(InputIterator first, InputIterator last, const allocator_type& a)\n : multimap(first, last, Compare(), a) {} // C++14\n template<container-compatible-range<value_type> R>\n multimap(from_range_t, R&& rg, const Allocator& a))\n : multimap(from_range, std::forward<R>(rg), Compare(), a) { } // C++23\n multimap(initializer_list<value_type> il, const allocator_type& a)\n : multimap(il, Compare(), a) {} // C++14\n ~multimap();\n\n multimap& operator=(const multimap& m);\n multimap& operator=(multimap&& m)\n noexcept(\n allocator_type::propagate_on_container_move_assignment::value &&\n is_nothrow_move_assignable<allocator_type>::value &&\n is_nothrow_move_assignable<key_compare>::value);\n multimap& operator=(initializer_list<value_type> il);\n\n // iterators:\n iterator begin() noexcept;\n const_iterator begin() const noexcept;\n iterator end() noexcept;\n const_iterator end() const noexcept;\n\n reverse_iterator rbegin() noexcept;\n const_reverse_iterator rbegin() const noexcept;\n reverse_iterator rend() noexcept;\n const_reverse_iterator rend() const noexcept;\n\n const_iterator cbegin() const noexcept;\n const_iterator cend() const noexcept;\n const_reverse_iterator crbegin() const noexcept;\n const_reverse_iterator crend() const noexcept;\n\n // capacity:\n bool empty() const noexcept;\n size_type size() const noexcept;\n size_type max_size() const noexcept;\n\n // modifiers:\n template <class... Args>\n iterator emplace(Args&&... args);\n template <class... Args>\n iterator emplace_hint(const_iterator position, Args&&... args);\n iterator insert(const value_type& v);\n iterator insert( value_type&& v); // C++17\n template <class P>\n iterator insert(P&& p);\n iterator insert(const_iterator position, const value_type& v);\n iterator insert(const_iterator position, value_type&& v); // C++17\n template <class P>\n iterator insert(const_iterator position, P&& p);\n template <class InputIterator>\n void insert(InputIterator first, InputIterator last);\n template<container-compatible-range<value_type> R>\n void insert_range(R&& rg); // C++23\n void insert(initializer_list<value_type> il);\n\n node_type extract(const_iterator position); // C++17\n node_type extract(const key_type& x); // C++17\n iterator insert(node_type&& nh); // C++17\n iterator insert(const_iterator hint, node_type&& nh); // C++17\n\n iterator erase(const_iterator position);\n iterator erase(iterator position); // C++14\n size_type erase(const key_type& k);\n iterator erase(const_iterator first, const_iterator last);\n void clear() noexcept;\n\n template<class C2>\n void merge(multimap<Key, T, C2, Allocator>& source); // C++17\n template<class C2>\n void merge(multimap<Key, T, C2, Allocator>&& source); // C++17\n template<class C2>\n void merge(map<Key, T, C2, Allocator>& source); // C++17\n template<class C2>\n void merge(map<Key, T, C2, Allocator>&& source); // C++17\n\n void swap(multimap& m)\n noexcept(allocator_traits<allocator_type>::is_always_equal::value &&\n is_nothrow_swappable<key_compare>::value); // C++17\n\n // observers:\n allocator_type get_allocator() const noexcept;\n key_compare key_comp() const;\n value_compare value_comp() const;\n\n // map operations:\n iterator find(const key_type& k);\n const_iterator find(const key_type& k) const;\n template<typename K>\n iterator find(const K& x); // C++14\n template<typename K>\n const_iterator find(const K& x) const; // C++14\n\n template<typename K>\n size_type count(const K& x) const; // C++14\n size_type count(const key_type& k) const;\n\n bool contains(const key_type& x) const; // C++20\n template<class K> bool contains(const K& x) const; // C++20\n\n iterator lower_bound(const key_type& k);\n const_iterator lower_bound(const key_type& k) const;\n template<typename K>\n iterator lower_bound(const K& x); // C++14\n template<typename K>\n const_iterator lower_bound(const K& x) const; // C++14\n\n iterator upper_bound(const key_type& k);\n const_iterator upper_bound(const key_type& k) const;\n template<typename K>\n iterator upper_bound(const K& x); // C++14\n template<typename K>\n const_iterator upper_bound(const K& x) const; // C++14\n\n pair<iterator,iterator> equal_range(const key_type& k);\n pair<const_iterator,const_iterator> equal_range(const key_type& k) const;\n template<typename K>\n pair<iterator,iterator> equal_range(const K& x); // C++14\n template<typename K>\n pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14\n};\n\ntemplate <class InputIterator,\n class Compare = less<iter_key_t<InputIterator>>,\n class Allocator = allocator<iter_to_alloc_t<InputIterator>>>\nmultimap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())\n -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17\n\ntemplate<ranges::input_range R, class Compare = less<range-key-type<R>>,\n class Allocator = allocator<range-to-alloc-type<R>>>\n multimap(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())\n -> multimap<range-key-type<R>, range-mapped-type<R>, Compare, Allocator>; // C++23\n\ntemplate<class Key, class T, class Compare = less<Key>,\n class Allocator = allocator<pair<const Key, T>>>\nmultimap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())\n -> multimap<Key, T, Compare, Allocator>; // C++17\n\ntemplate <class InputIterator, class Allocator>\nmultimap(InputIterator, InputIterator, Allocator)\n -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,\n less<iter_key_t<InputIterator>>, Allocator>; // C++17\n\ntemplate<ranges::input_range R, class Allocator>\n multimap(from_range_t, R&&, Allocator)\n -> multimap<range-key-type<R>, range-mapped-type<R>, less<range-key-type<R>>, Allocator>; // C++23\n\ntemplate<class Key, class T, class Allocator>\nmultimap(initializer_list<pair<const Key, T>>, Allocator)\n -> multimap<Key, T, less<Key>, Allocator>; // C++17\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator==(const multimap<Key, T, Compare, Allocator>& x,\n const multimap<Key, T, Compare, Allocator>& y);\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator< (const multimap<Key, T, Compare, Allocator>& x,\n const multimap<Key, T, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator!=(const multimap<Key, T, Compare, Allocator>& x,\n const multimap<Key, T, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator> (const multimap<Key, T, Compare, Allocator>& x,\n const multimap<Key, T, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator>=(const multimap<Key, T, Compare, Allocator>& x,\n const multimap<Key, T, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class T, class Compare, class Allocator>\nbool\noperator<=(const multimap<Key, T, Compare, Allocator>& x,\n const multimap<Key, T, Compare, Allocator>& y); // removed in C++20\n\ntemplate<class Key, class T, class Compare, class Allocator>\n synth-three-way-result<pair<const Key, T>>\n operator<=>(const multimap<Key, T, Compare, Allocator>& x,\n const multimap<Key, T, Compare, Allocator>& y); // since c++20\n\n// specialized algorithms:\ntemplate <class Key, class T, class Compare, class Allocator>\nvoid\nswap(multimap<Key, T, Compare, Allocator>& x,\n multimap<Key, T, Compare, Allocator>& y)\n noexcept(noexcept(x.swap(y)));\n\ntemplate <class Key, class T, class Compare, class Allocator, class Predicate>\ntypename multimap<Key, T, Compare, Allocator>::size_type\nerase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20\n\n} // std\n\n*/\n\n#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n# include <__cxx03/map>\n#else\n# include <__algorithm/equal.h>\n# include <__algorithm/lexicographical_compare.h>\n# include <__algorithm/lexicographical_compare_three_way.h>\n# include <__assert>\n# include <__config>\n# include <__functional/binary_function.h>\n# include <__functional/is_transparent.h>\n# include <__functional/operations.h>\n# include <__iterator/erase_if_container.h>\n# include <__iterator/iterator_traits.h>\n# include <__iterator/ranges_iterator_traits.h>\n# include <__iterator/reverse_iterator.h>\n# include <__memory/addressof.h>\n# include <__memory/allocator.h>\n# include <__memory/allocator_traits.h>\n# include <__memory/pointer_traits.h>\n# include <__memory/unique_ptr.h>\n# include <__memory_resource/polymorphic_allocator.h>\n# include <__new/launder.h>\n# include <__node_handle>\n# include <__ranges/concepts.h>\n# include <__ranges/container_compatible_range.h>\n# include <__ranges/from_range.h>\n# include <__tree>\n# include <__type_traits/container_traits.h>\n# include <__type_traits/is_allocator.h>\n# include <__type_traits/remove_const.h>\n# include <__type_traits/type_identity.h>\n# include <__utility/forward.h>\n# include <__utility/pair.h>\n# include <__utility/piecewise_construct.h>\n# include <__utility/swap.h>\n# include <stdexcept>\n# include <tuple>\n# include <version>\n\n// standard-mandated includes\n\n// [iterator.range]\n# include <__iterator/access.h>\n# include <__iterator/data.h>\n# include <__iterator/empty.h>\n# include <__iterator/reverse_access.h>\n# include <__iterator/size.h>\n\n// [associative.map.syn]\n# include <compare>\n# include <initializer_list>\n\n# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n# endif\n\n_LIBCPP_PUSH_MACROS\n# include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\ntemplate <class _Key,\n class _CP,\n class _Compare,\n bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>\nclass __map_value_compare : private _Compare {\npublic:\n _LIBCPP_HIDE_FROM_ABI __map_value_compare() _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)\n : _Compare() {}\n _LIBCPP_HIDE_FROM_ABI __map_value_compare(_Compare __c) _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)\n : _Compare(__c) {}\n _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return *this; }\n _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const {\n return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first);\n }\n _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const {\n return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);\n }\n _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const {\n return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);\n }\n _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) {\n using std::swap;\n swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y));\n }\n\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2>\n _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {\n return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);\n }\n\n template <typename _K2>\n _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {\n return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);\n }\n# endif\n};\n\ntemplate <class _Key, class _CP, class _Compare>\nclass __map_value_compare<_Key, _CP, _Compare, false> {\n _Compare __comp_;\n\npublic:\n _LIBCPP_HIDE_FROM_ABI __map_value_compare() _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)\n : __comp_() {}\n _LIBCPP_HIDE_FROM_ABI __map_value_compare(_Compare __c) _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)\n : __comp_(__c) {}\n _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return __comp_; }\n\n _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const {\n return __comp_(__x.__get_value().first, __y.__get_value().first);\n }\n _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const {\n return __comp_(__x.__get_value().first, __y);\n }\n _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const {\n return __comp_(__x, __y.__get_value().first);\n }\n void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) {\n using std::swap;\n swap(__comp_, __y.__comp_);\n }\n\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2>\n _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {\n return __comp_(__x, __y.__get_value().first);\n }\n\n template <typename _K2>\n _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {\n return __comp_(__x.__get_value().first, __y);\n }\n# endif\n};\n\ntemplate <class _Key, class _CP, class _Compare, bool __b>\ninline _LIBCPP_HIDE_FROM_ABI void\nswap(__map_value_compare<_Key, _CP, _Compare, __b>& __x, __map_value_compare<_Key, _CP, _Compare, __b>& __y)\n _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {\n __x.swap(__y);\n}\n\ntemplate <class _Allocator>\nclass __map_node_destructor {\n typedef _Allocator allocator_type;\n typedef allocator_traits<allocator_type> __alloc_traits;\n\npublic:\n typedef typename __alloc_traits::pointer pointer;\n\nprivate:\n allocator_type& __na_;\n\npublic:\n bool __first_constructed;\n bool __second_constructed;\n\n _LIBCPP_HIDE_FROM_ABI explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT\n : __na_(__na),\n __first_constructed(false),\n __second_constructed(false) {}\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT\n : __na_(__x.__na_),\n __first_constructed(__x.__value_constructed),\n __second_constructed(__x.__value_constructed) {\n __x.__value_constructed = false;\n }\n# endif // _LIBCPP_CXX03_LANG\n\n __map_node_destructor& operator=(const __map_node_destructor&) = delete;\n\n _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {\n if (__second_constructed)\n __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().second));\n if (__first_constructed)\n __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().first));\n if (__p)\n __alloc_traits::deallocate(__na_, __p, 1);\n }\n};\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\nclass map;\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\nclass multimap;\ntemplate <class _TreeIterator>\nclass __map_const_iterator;\n\n# ifndef _LIBCPP_CXX03_LANG\n\ntemplate <class _Key, class _Tp>\nstruct _LIBCPP_STANDALONE_DEBUG __value_type {\n typedef _Key key_type;\n typedef _Tp mapped_type;\n typedef pair<const key_type, mapped_type> value_type;\n typedef pair<key_type&, mapped_type&> __nc_ref_pair_type;\n typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;\n\nprivate:\n value_type __cc_;\n\npublic:\n _LIBCPP_HIDE_FROM_ABI value_type& __get_value() {\n# if _LIBCPP_STD_VER >= 17\n return *std::launder(std::addressof(__cc_));\n# else\n return __cc_;\n# endif\n }\n\n _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const {\n# if _LIBCPP_STD_VER >= 17\n return *std::launder(std::addressof(__cc_));\n# else\n return __cc_;\n# endif\n }\n\n _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() {\n value_type& __v = __get_value();\n return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);\n }\n\n _LIBCPP_HIDE_FROM_ABI __nc_rref_pair_type __move() {\n value_type& __v = __get_value();\n return __nc_rref_pair_type(std::move(const_cast<key_type&>(__v.first)), std::move(__v.second));\n }\n\n _LIBCPP_HIDE_FROM_ABI __value_type& operator=(const __value_type& __v) {\n __ref() = __v.__get_value();\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI __value_type& operator=(__value_type&& __v) {\n __ref() = __v.__move();\n return *this;\n }\n\n template <class _ValueTp, __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI __value_type& operator=(_ValueTp&& __v) {\n __ref() = std::forward<_ValueTp>(__v);\n return *this;\n }\n\n __value_type() = delete;\n ~__value_type() = delete;\n __value_type(const __value_type&) = delete;\n __value_type(__value_type&&) = delete;\n};\n\n# else\n\ntemplate <class _Key, class _Tp>\nstruct __value_type {\n typedef _Key key_type;\n typedef _Tp mapped_type;\n typedef pair<const key_type, mapped_type> value_type;\n\nprivate:\n value_type __cc_;\n\npublic:\n _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; }\n _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; }\n\n __value_type() = delete;\n __value_type(__value_type const&) = delete;\n __value_type& operator=(__value_type const&) = delete;\n ~__value_type() = delete;\n};\n\n# endif // _LIBCPP_CXX03_LANG\n\ntemplate <class _Tp>\nstruct __extract_key_value_types;\n\ntemplate <class _Key, class _Tp>\nstruct __extract_key_value_types<__value_type<_Key, _Tp> > {\n typedef _Key const __key_type;\n typedef _Tp __mapped_type;\n};\n\ntemplate <class _TreeIterator>\nclass _LIBCPP_TEMPLATE_VIS __map_iterator {\n typedef typename _TreeIterator::_NodeTypes _NodeTypes;\n typedef typename _TreeIterator::__pointer_traits __pointer_traits;\n\n _TreeIterator __i_;\n\npublic:\n typedef bidirectional_iterator_tag iterator_category;\n typedef typename _NodeTypes::__map_value_type value_type;\n typedef typename _TreeIterator::difference_type difference_type;\n typedef value_type& reference;\n typedef typename _NodeTypes::__map_value_type_pointer pointer;\n\n _LIBCPP_HIDE_FROM_ABI __map_iterator() _NOEXCEPT {}\n\n _LIBCPP_HIDE_FROM_ABI __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}\n\n _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); }\n _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); }\n\n _LIBCPP_HIDE_FROM_ABI __map_iterator& operator++() {\n ++__i_;\n return *this;\n }\n _LIBCPP_HIDE_FROM_ABI __map_iterator operator++(int) {\n __map_iterator __t(*this);\n ++(*this);\n return __t;\n }\n\n _LIBCPP_HIDE_FROM_ABI __map_iterator& operator--() {\n --__i_;\n return *this;\n }\n _LIBCPP_HIDE_FROM_ABI __map_iterator operator--(int) {\n __map_iterator __t(*this);\n --(*this);\n return __t;\n }\n\n friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __map_iterator& __x, const __map_iterator& __y) {\n return __x.__i_ == __y.__i_;\n }\n friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __map_iterator& __x, const __map_iterator& __y) {\n return __x.__i_ != __y.__i_;\n }\n\n template <class, class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS map;\n template <class, class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS multimap;\n template <class>\n friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;\n};\n\ntemplate <class _TreeIterator>\nclass _LIBCPP_TEMPLATE_VIS __map_const_iterator {\n typedef typename _TreeIterator::_NodeTypes _NodeTypes;\n typedef typename _TreeIterator::__pointer_traits __pointer_traits;\n\n _TreeIterator __i_;\n\npublic:\n typedef bidirectional_iterator_tag iterator_category;\n typedef typename _NodeTypes::__map_value_type value_type;\n typedef typename _TreeIterator::difference_type difference_type;\n typedef const value_type& reference;\n typedef typename _NodeTypes::__const_map_value_type_pointer pointer;\n\n _LIBCPP_HIDE_FROM_ABI __map_const_iterator() _NOEXCEPT {}\n\n _LIBCPP_HIDE_FROM_ABI __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}\n _LIBCPP_HIDE_FROM_ABI\n __map_const_iterator(__map_iterator< typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT : __i_(__i.__i_) {}\n\n _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); }\n _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); }\n\n _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator++() {\n ++__i_;\n return *this;\n }\n _LIBCPP_HIDE_FROM_ABI __map_const_iterator operator++(int) {\n __map_const_iterator __t(*this);\n ++(*this);\n return __t;\n }\n\n _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator--() {\n --__i_;\n return *this;\n }\n _LIBCPP_HIDE_FROM_ABI __map_const_iterator operator--(int) {\n __map_const_iterator __t(*this);\n --(*this);\n return __t;\n }\n\n friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y) {\n return __x.__i_ == __y.__i_;\n }\n friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) {\n return __x.__i_ != __y.__i_;\n }\n\n template <class, class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS map;\n template <class, class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS multimap;\n template <class, class, class>\n friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;\n};\n\ntemplate <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > >\nclass _LIBCPP_TEMPLATE_VIS map {\npublic:\n // types:\n typedef _Key key_type;\n typedef _Tp mapped_type;\n typedef pair<const key_type, mapped_type> value_type;\n typedef __type_identity_t<_Compare> key_compare;\n typedef __type_identity_t<_Allocator> allocator_type;\n typedef value_type& reference;\n typedef const value_type& const_reference;\n\n static_assert(is_same<typename allocator_type::value_type, value_type>::value,\n \"Allocator::value_type must be same type as value_type\");\n\n class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> {\n friend class map;\n\n protected:\n key_compare comp;\n\n _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : comp(__c) {}\n\n public:\n _LIBCPP_HIDE_FROM_ABI bool operator()(const value_type& __x, const value_type& __y) const {\n return comp(__x.first, __y.first);\n }\n };\n\nprivate:\n typedef std::__value_type<key_type, mapped_type> __value_type;\n typedef __map_value_compare<key_type, __value_type, key_compare> __vc;\n typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;\n typedef __tree<__value_type, __vc, __allocator_type> __base;\n typedef typename __base::__node_traits __node_traits;\n typedef allocator_traits<allocator_type> __alloc_traits;\n\n static_assert(__check_valid_allocator<allocator_type>::value, \"\");\n\n __base __tree_;\n\npublic:\n typedef typename __alloc_traits::pointer pointer;\n typedef typename __alloc_traits::const_pointer const_pointer;\n typedef typename __alloc_traits::size_type size_type;\n typedef typename __alloc_traits::difference_type difference_type;\n typedef __map_iterator<typename __base::iterator> iterator;\n typedef __map_const_iterator<typename __base::const_iterator> const_iterator;\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n\n# if _LIBCPP_STD_VER >= 17\n typedef __map_node_handle<typename __base::__node, allocator_type> node_type;\n typedef __insert_return_type<iterator, node_type> insert_return_type;\n# endif\n\n template <class _Key2, class _Value2, class _Comp2, class _Alloc2>\n friend class _LIBCPP_TEMPLATE_VIS map;\n template <class _Key2, class _Value2, class _Comp2, class _Alloc2>\n friend class _LIBCPP_TEMPLATE_VIS multimap;\n\n _LIBCPP_HIDE_FROM_ABI map() _NOEXCEPT_(\n is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&\n is_nothrow_copy_constructible<key_compare>::value)\n : __tree_(__vc(key_compare())) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit map(const key_compare& __comp) _NOEXCEPT_(\n is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_copy_constructible<key_compare>::value)\n : __tree_(__vc(__comp)) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit map(const key_compare& __comp, const allocator_type& __a)\n : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}\n\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const key_compare& __comp = key_compare())\n : __tree_(__vc(__comp)) {\n insert(__f, __l);\n }\n\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI\n map(_InputIterator __f, _InputIterator __l, const key_compare& __comp, const allocator_type& __a)\n : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {\n insert(__f, __l);\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI\n map(from_range_t,\n _Range&& __range,\n const key_compare& __comp = key_compare(),\n const allocator_type& __a = allocator_type())\n : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {\n insert_range(std::forward<_Range>(__range));\n }\n# endif\n\n# if _LIBCPP_STD_VER >= 14\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)\n : map(__f, __l, key_compare(), __a) {}\n# endif\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI map(from_range_t, _Range&& __range, const allocator_type& __a)\n : map(from_range, std::forward<_Range>(__range), key_compare(), __a) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); }\n\n _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) {\n# ifndef _LIBCPP_CXX03_LANG\n __tree_ = __m.__tree_;\n# else\n if (this != std::addressof(__m)) {\n __tree_.clear();\n __tree_.value_comp() = __m.__tree_.value_comp();\n __tree_.__copy_assign_alloc(__m.__tree_);\n insert(__m.begin(), __m.end());\n }\n# endif\n return *this;\n }\n\n# ifndef _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value)\n : __tree_(std::move(__m.__tree_)) {}\n\n _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a);\n\n _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) noexcept(is_nothrow_move_assignable<__base>::value) {\n __tree_ = std::move(__m.__tree_);\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())\n : __tree_(__vc(__comp)) {\n insert(__il.begin(), __il.end());\n }\n\n _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)\n : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {\n insert(__il.begin(), __il.end());\n }\n\n# if _LIBCPP_STD_VER >= 14\n _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const allocator_type& __a)\n : map(__il, key_compare(), __a) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI map& operator=(initializer_list<value_type> __il) {\n __tree_.__assign_unique(__il.begin(), __il.end());\n return *this;\n }\n\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {}\n\n _LIBCPP_HIDE_FROM_ABI map(const map& __m, const allocator_type& __a)\n : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) {\n insert(__m.begin(), __m.end());\n }\n\n _LIBCPP_HIDE_FROM_ABI ~map() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), \"\"); }\n\n _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }\n _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }\n\n _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }\n _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); }\n\n _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }\n\n [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }\n _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }\n _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }\n\n _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k);\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k);\n# endif\n\n _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k);\n _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const;\n\n _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(__tree_.__alloc()); }\n _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); }\n _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); }\n\n# ifndef _LIBCPP_CXX03_LANG\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {\n return __tree_.__emplace_unique(std::forward<_Args>(__args)...);\n }\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {\n return __tree_.__emplace_hint_unique(__p.__i_, std::forward<_Args>(__args)...);\n }\n\n template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __p) {\n return __tree_.__insert_unique(std::forward<_Pp>(__p));\n }\n\n template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) {\n return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p));\n }\n\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); }\n\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {\n return __tree_.__insert_unique(__p.__i_, __v);\n }\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {\n return __tree_.__insert_unique(std::move(__v));\n }\n\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {\n return __tree_.__insert_unique(__p.__i_, std::move(__v));\n }\n\n _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }\n# endif\n\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {\n for (const_iterator __e = cend(); __f != __l; ++__f)\n insert(__e.__i_, *__f);\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {\n const_iterator __end = cend();\n for (auto&& __element : __range) {\n insert(__end.__i_, std::forward<decltype(__element)>(__element));\n }\n }\n# endif\n\n# if _LIBCPP_STD_VER >= 17\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) {\n return __tree_.__emplace_unique_key_args(\n __k,\n std::piecewise_construct,\n std::forward_as_tuple(__k),\n std::forward_as_tuple(std::forward<_Args>(__args)...));\n }\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) {\n return __tree_.__emplace_unique_key_args(\n __k,\n std::piecewise_construct,\n std::forward_as_tuple(std::move(__k)),\n std::forward_as_tuple(std::forward<_Args>(__args)...));\n }\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) {\n return __tree_\n .__emplace_hint_unique_key_args(\n __h.__i_,\n __k,\n std::piecewise_construct,\n std::forward_as_tuple(__k),\n std::forward_as_tuple(std::forward<_Args>(__args)...))\n .first;\n }\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) {\n return __tree_\n .__emplace_hint_unique_key_args(\n __h.__i_,\n __k,\n std::piecewise_construct,\n std::forward_as_tuple(std::move(__k)),\n std::forward_as_tuple(std::forward<_Args>(__args)...))\n .first;\n }\n\n template <class _Vp>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) {\n iterator __p = lower_bound(__k);\n if (__p != end() && !key_comp()(__k, __p->first)) {\n __p->second = std::forward<_Vp>(__v);\n return std::make_pair(__p, false);\n }\n return std::make_pair(emplace_hint(__p, __k, std::forward<_Vp>(__v)), true);\n }\n\n template <class _Vp>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) {\n iterator __p = lower_bound(__k);\n if (__p != end() && !key_comp()(__k, __p->first)) {\n __p->second = std::forward<_Vp>(__v);\n return std::make_pair(__p, false);\n }\n return std::make_pair(emplace_hint(__p, std::move(__k), std::forward<_Vp>(__v)), true);\n }\n\n template <class _Vp>\n _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) {\n auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, __k, std::forward<_Vp>(__v));\n\n if (!__inserted)\n __r->__get_value().second = std::forward<_Vp>(__v);\n\n return __r;\n }\n\n template <class _Vp>\n _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) {\n auto [__r, __inserted] =\n __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, std::move(__k), std::forward<_Vp>(__v));\n\n if (!__inserted)\n __r->__get_value().second = std::forward<_Vp>(__v);\n\n return __r;\n }\n\n# endif // _LIBCPP_STD_VER >= 17\n\n _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); }\n _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); }\n _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); }\n _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) {\n return __tree_.erase(__f.__i_, __l.__i_);\n }\n _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }\n\n# if _LIBCPP_STD_VER >= 17\n _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),\n \"node_type with incompatible allocator passed to map::insert()\");\n return __tree_.template __node_handle_insert_unique< node_type, insert_return_type>(std::move(__nh));\n }\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),\n \"node_type with incompatible allocator passed to map::insert()\");\n return __tree_.template __node_handle_insert_unique<node_type>(__hint.__i_, std::move(__nh));\n }\n _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {\n return __tree_.template __node_handle_extract<node_type>(__key);\n }\n _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {\n return __tree_.template __node_handle_extract<node_type>(__it.__i_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_unique(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_unique(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_unique(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_unique(__source.__tree_);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); }\n\n _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {\n return __tree_.find(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {\n return __tree_.find(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {\n return __tree_.__count_multi(__k);\n }\n# endif\n\n# if _LIBCPP_STD_VER >= 20\n _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {\n return find(__k) != end();\n }\n# endif // _LIBCPP_STD_VER >= 20\n\n _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {\n return __tree_.lower_bound(__k);\n }\n\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {\n return __tree_.lower_bound(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {\n return __tree_.upper_bound(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {\n return __tree_.upper_bound(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {\n return __tree_.__equal_range_unique(__k);\n }\n _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {\n return __tree_.__equal_range_unique(__k);\n }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {\n return __tree_.__equal_range_multi(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {\n return __tree_.__equal_range_multi(__k);\n }\n# endif\n\nprivate:\n typedef typename __base::__node __node;\n typedef typename __base::__node_allocator __node_allocator;\n typedef typename __base::__node_pointer __node_pointer;\n typedef typename __base::__node_base_pointer __node_base_pointer;\n typedef typename __base::__parent_pointer __parent_pointer;\n\n typedef __map_node_destructor<__node_allocator> _Dp;\n typedef unique_ptr<__node, _Dp> __node_holder;\n\n# ifdef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k);\n# endif\n};\n\n# if _LIBCPP_STD_VER >= 17\ntemplate <class _InputIterator,\n class _Compare = less<__iter_key_type<_InputIterator>>,\n class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())\n -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;\n\n# if _LIBCPP_STD_VER >= 23\ntemplate <ranges::input_range _Range,\n class _Compare = less<__range_key_type<_Range>>,\n class _Allocator = allocator<__range_to_alloc_type<_Range>>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())\n -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>;\n# endif\n\ntemplate <class _Key,\n class _Tp,\n class _Compare = less<remove_const_t<_Key>>,\n class _Allocator = allocator<pair<const _Key, _Tp>>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmap(initializer_list<pair<_Key, _Tp>>,\n _Compare = _Compare(),\n _Allocator = _Allocator()) -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;\n\ntemplate <class _InputIterator,\n class _Allocator,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmap(_InputIterator, _InputIterator, _Allocator)\n -> map<__iter_key_type<_InputIterator>,\n __iter_mapped_type<_InputIterator>,\n less<__iter_key_type<_InputIterator>>,\n _Allocator>;\n\n# if _LIBCPP_STD_VER >= 23\ntemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmap(from_range_t, _Range&&, _Allocator)\n -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>;\n# endif\n\ntemplate <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmap(initializer_list<pair<_Key, _Tp>>,\n _Allocator) -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;\n# endif\n\n# ifndef _LIBCPP_CXX03_LANG\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\nmap<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)\n : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) {\n if (__a != __m.get_allocator()) {\n const_iterator __e = cend();\n while (!__m.empty())\n __tree_.__insert_unique(__e.__i_, __m.__tree_.remove(__m.begin().__i_)->__value_.__move());\n }\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\n_Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {\n return __tree_\n .__emplace_unique_key_args(__k, std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple())\n .first->__get_value()\n .second;\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\n_Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) {\n // TODO investigate this clang-tidy warning.\n // NOLINTBEGIN(bugprone-use-after-move)\n return __tree_\n .__emplace_unique_key_args(\n __k, std::piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple())\n .first->__get_value()\n .second;\n // NOLINTEND(bugprone-use-after-move)\n}\n\n# else // _LIBCPP_CXX03_LANG\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ntypename map<_Key, _Tp, _Compare, _Allocator>::__node_holder\nmap<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) {\n __node_allocator& __na = __tree_.__node_alloc();\n __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));\n __node_traits::construct(__na, std::addressof(__h->__value_.__get_value().first), __k);\n __h.get_deleter().__first_constructed = true;\n __node_traits::construct(__na, std::addressof(__h->__value_.__get_value().second));\n __h.get_deleter().__second_constructed = true;\n return __h;\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\n_Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {\n __parent_pointer __parent;\n __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);\n __node_pointer __r = static_cast<__node_pointer>(__child);\n if (__child == nullptr) {\n __node_holder __h = __construct_node_with_key(__k);\n __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));\n __r = __h.release();\n }\n return __r->__value_.__get_value().second;\n}\n\n# endif // _LIBCPP_CXX03_LANG\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\n_Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) {\n __parent_pointer __parent;\n __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);\n if (__child == nullptr)\n __throw_out_of_range(\"map::at: key not found\");\n return static_cast<__node_pointer>(__child)->__value_.__get_value().second;\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\nconst _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const {\n __parent_pointer __parent;\n __node_base_pointer __child = __tree_.__find_equal(__parent, __k);\n if (__child == nullptr)\n __throw_out_of_range(\"map::at: key not found\");\n return static_cast<__node_pointer>(__child)->__value_.__get_value().second;\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {\n return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());\n}\n\n# if _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {\n return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {\n return !(__x == __y);\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {\n return __y < __x;\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {\n return !(__x < __y);\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {\n return !(__y < __x);\n}\n\n# else // #if _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>\noperator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {\n return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);\n}\n\n# endif // #if _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI void\nswap(map<_Key, _Tp, _Compare, _Allocator>& __x, map<_Key, _Tp, _Compare, _Allocator>& __y)\n _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {\n __x.swap(__y);\n}\n\n# if _LIBCPP_STD_VER >= 20\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>\ninline _LIBCPP_HIDE_FROM_ABI typename map<_Key, _Tp, _Compare, _Allocator>::size_type\nerase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {\n return std::__libcpp_erase_if_container(__c, __pred);\n}\n# endif\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\nstruct __container_traits<map<_Key, _Tp, _Compare, _Allocator> > {\n // http://eel.is/c++draft/associative.reqmts.except#2\n // For associative containers, if an exception is thrown by any operation from within\n // an insert or emplace function inserting a single element, the insertion has no effect.\n static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;\n};\n\ntemplate <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > >\nclass _LIBCPP_TEMPLATE_VIS multimap {\npublic:\n // types:\n typedef _Key key_type;\n typedef _Tp mapped_type;\n typedef pair<const key_type, mapped_type> value_type;\n typedef __type_identity_t<_Compare> key_compare;\n typedef __type_identity_t<_Allocator> allocator_type;\n typedef value_type& reference;\n typedef const value_type& const_reference;\n\n static_assert(__check_valid_allocator<allocator_type>::value, \"\");\n static_assert(is_same<typename allocator_type::value_type, value_type>::value,\n \"Allocator::value_type must be same type as value_type\");\n\n class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> {\n friend class multimap;\n\n protected:\n key_compare comp;\n\n _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : comp(__c) {}\n\n public:\n _LIBCPP_HIDE_FROM_ABI bool operator()(const value_type& __x, const value_type& __y) const {\n return comp(__x.first, __y.first);\n }\n };\n\nprivate:\n typedef std::__value_type<key_type, mapped_type> __value_type;\n typedef __map_value_compare<key_type, __value_type, key_compare> __vc;\n typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;\n typedef __tree<__value_type, __vc, __allocator_type> __base;\n typedef typename __base::__node_traits __node_traits;\n typedef allocator_traits<allocator_type> __alloc_traits;\n\n __base __tree_;\n\npublic:\n typedef typename __alloc_traits::pointer pointer;\n typedef typename __alloc_traits::const_pointer const_pointer;\n typedef typename __alloc_traits::size_type size_type;\n typedef typename __alloc_traits::difference_type difference_type;\n typedef __map_iterator<typename __base::iterator> iterator;\n typedef __map_const_iterator<typename __base::const_iterator> const_iterator;\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n\n# if _LIBCPP_STD_VER >= 17\n typedef __map_node_handle<typename __base::__node, allocator_type> node_type;\n# endif\n\n template <class _Key2, class _Value2, class _Comp2, class _Alloc2>\n friend class _LIBCPP_TEMPLATE_VIS map;\n template <class _Key2, class _Value2, class _Comp2, class _Alloc2>\n friend class _LIBCPP_TEMPLATE_VIS multimap;\n\n _LIBCPP_HIDE_FROM_ABI multimap() _NOEXCEPT_(\n is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&\n is_nothrow_copy_constructible<key_compare>::value)\n : __tree_(__vc(key_compare())) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit multimap(const key_compare& __comp) _NOEXCEPT_(\n is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_copy_constructible<key_compare>::value)\n : __tree_(__vc(__comp)) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit multimap(const key_compare& __comp, const allocator_type& __a)\n : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}\n\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI multimap(_InputIterator __f, _InputIterator __l, const key_compare& __comp = key_compare())\n : __tree_(__vc(__comp)) {\n insert(__f, __l);\n }\n\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI\n multimap(_InputIterator __f, _InputIterator __l, const key_compare& __comp, const allocator_type& __a)\n : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {\n insert(__f, __l);\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI\n multimap(from_range_t,\n _Range&& __range,\n const key_compare& __comp = key_compare(),\n const allocator_type& __a = allocator_type())\n : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {\n insert_range(std::forward<_Range>(__range));\n }\n# endif\n\n# if _LIBCPP_STD_VER >= 14\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)\n : multimap(__f, __l, key_compare(), __a) {}\n# endif\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI multimap(from_range_t, _Range&& __range, const allocator_type& __a)\n : multimap(from_range, std::forward<_Range>(__range), key_compare(), __a) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m)\n : __tree_(__m.__tree_.value_comp(),\n __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc())) {\n insert(__m.begin(), __m.end());\n }\n\n _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) {\n# ifndef _LIBCPP_CXX03_LANG\n __tree_ = __m.__tree_;\n# else\n if (this != std::addressof(__m)) {\n __tree_.clear();\n __tree_.value_comp() = __m.__tree_.value_comp();\n __tree_.__copy_assign_alloc(__m.__tree_);\n insert(__m.begin(), __m.end());\n }\n# endif\n return *this;\n }\n\n# ifndef _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value)\n : __tree_(std::move(__m.__tree_)) {}\n\n _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a);\n\n _LIBCPP_HIDE_FROM_ABI multimap& operator=(multimap&& __m) noexcept(is_nothrow_move_assignable<__base>::value) {\n __tree_ = std::move(__m.__tree_);\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())\n : __tree_(__vc(__comp)) {\n insert(__il.begin(), __il.end());\n }\n\n _LIBCPP_HIDE_FROM_ABI\n multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)\n : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {\n insert(__il.begin(), __il.end());\n }\n\n# if _LIBCPP_STD_VER >= 14\n _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const allocator_type& __a)\n : multimap(__il, key_compare(), __a) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI multimap& operator=(initializer_list<value_type> __il) {\n __tree_.__assign_multi(__il.begin(), __il.end());\n return *this;\n }\n\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI explicit multimap(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {}\n\n _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m, const allocator_type& __a)\n : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) {\n insert(__m.begin(), __m.end());\n }\n\n _LIBCPP_HIDE_FROM_ABI ~multimap() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), \"\"); }\n\n _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }\n _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }\n\n _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }\n _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); }\n\n _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }\n\n [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }\n _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }\n _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }\n\n _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(__tree_.__alloc()); }\n _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); }\n _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); }\n\n# ifndef _LIBCPP_CXX03_LANG\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {\n return __tree_.__emplace_multi(std::forward<_Args>(__args)...);\n }\n\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {\n return __tree_.__emplace_hint_multi(__p.__i_, std::forward<_Args>(__args)...);\n }\n\n template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __p) {\n return __tree_.__insert_multi(std::forward<_Pp>(__p));\n }\n\n template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) {\n return __tree_.__insert_multi(__pos.__i_, std::forward<_Pp>(__p));\n }\n\n _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); }\n\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {\n return __tree_.__insert_multi(__p.__i_, std::move(__v));\n }\n\n _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }\n\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); }\n\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {\n return __tree_.__insert_multi(__p.__i_, __v);\n }\n\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {\n for (const_iterator __e = cend(); __f != __l; ++__f)\n __tree_.__insert_multi(__e.__i_, *__f);\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {\n const_iterator __end = cend();\n for (auto&& __element : __range) {\n __tree_.__insert_multi(__end.__i_, std::forward<decltype(__element)>(__element));\n }\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); }\n _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); }\n _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); }\n _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) {\n return __tree_.erase(__f.__i_, __l.__i_);\n }\n\n# if _LIBCPP_STD_VER >= 17\n _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),\n \"node_type with incompatible allocator passed to multimap::insert()\");\n return __tree_.template __node_handle_insert_multi<node_type>(std::move(__nh));\n }\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),\n \"node_type with incompatible allocator passed to multimap::insert()\");\n return __tree_.template __node_handle_insert_multi<node_type>(__hint.__i_, std::move(__nh));\n }\n _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {\n return __tree_.template __node_handle_extract<node_type>(__key);\n }\n _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {\n return __tree_.template __node_handle_extract<node_type>(__it.__i_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n return __tree_.__node_handle_merge_multi(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n return __tree_.__node_handle_merge_multi(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n return __tree_.__node_handle_merge_multi(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n return __tree_.__node_handle_merge_multi(__source.__tree_);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }\n\n _LIBCPP_HIDE_FROM_ABI void swap(multimap& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {\n __tree_.swap(__m.__tree_);\n }\n\n _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {\n return __tree_.find(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {\n return __tree_.find(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {\n return __tree_.__count_multi(__k);\n }\n# endif\n\n# if _LIBCPP_STD_VER >= 20\n _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {\n return find(__k) != end();\n }\n# endif // _LIBCPP_STD_VER >= 20\n\n _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {\n return __tree_.lower_bound(__k);\n }\n\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {\n return __tree_.lower_bound(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {\n return __tree_.upper_bound(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {\n return __tree_.upper_bound(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {\n return __tree_.__equal_range_multi(__k);\n }\n _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {\n return __tree_.__equal_range_multi(__k);\n }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {\n return __tree_.__equal_range_multi(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {\n return __tree_.__equal_range_multi(__k);\n }\n# endif\n\nprivate:\n typedef typename __base::__node __node;\n typedef typename __base::__node_allocator __node_allocator;\n typedef typename __base::__node_pointer __node_pointer;\n\n typedef __map_node_destructor<__node_allocator> _Dp;\n typedef unique_ptr<__node, _Dp> __node_holder;\n};\n\n# if _LIBCPP_STD_VER >= 17\ntemplate <class _InputIterator,\n class _Compare = less<__iter_key_type<_InputIterator>>,\n class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmultimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())\n -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;\n\n# if _LIBCPP_STD_VER >= 23\ntemplate <ranges::input_range _Range,\n class _Compare = less<__range_key_type<_Range>>,\n class _Allocator = allocator<__range_to_alloc_type<_Range>>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmultimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())\n -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>;\n# endif\n\ntemplate <class _Key,\n class _Tp,\n class _Compare = less<remove_const_t<_Key>>,\n class _Allocator = allocator<pair<const _Key, _Tp>>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmultimap(initializer_list<pair<_Key, _Tp>>,\n _Compare = _Compare(),\n _Allocator = _Allocator()) -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;\n\ntemplate <class _InputIterator,\n class _Allocator,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmultimap(_InputIterator, _InputIterator, _Allocator)\n -> multimap<__iter_key_type<_InputIterator>,\n __iter_mapped_type<_InputIterator>,\n less<__iter_key_type<_InputIterator>>,\n _Allocator>;\n\n# if _LIBCPP_STD_VER >= 23\ntemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmultimap(from_range_t, _Range&&, _Allocator)\n -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>;\n# endif\n\ntemplate <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmultimap(initializer_list<pair<_Key, _Tp>>,\n _Allocator) -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;\n# endif\n\n# ifndef _LIBCPP_CXX03_LANG\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\nmultimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)\n : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) {\n if (__a != __m.get_allocator()) {\n const_iterator __e = cend();\n while (!__m.empty())\n __tree_.__insert_multi(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move()));\n }\n}\n# endif\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {\n return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());\n}\n\n# if _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {\n return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {\n return !(__x == __y);\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {\n return __y < __x;\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {\n return !(__x < __y);\n}\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {\n return !(__y < __x);\n}\n\n# else // #if _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>\noperator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,\n const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {\n return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);\n}\n\n# endif // #if _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI void\nswap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, multimap<_Key, _Tp, _Compare, _Allocator>& __y)\n _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {\n __x.swap(__y);\n}\n\n# if _LIBCPP_STD_VER >= 20\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>\ninline _LIBCPP_HIDE_FROM_ABI typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type\nerase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {\n return std::__libcpp_erase_if_container(__c, __pred);\n}\n# endif\n\ntemplate <class _Key, class _Tp, class _Compare, class _Allocator>\nstruct __container_traits<multimap<_Key, _Tp, _Compare, _Allocator> > {\n // http://eel.is/c++draft/associative.reqmts.except#2\n // For associative containers, if an exception is thrown by any operation from within\n // an insert or emplace function inserting a single element, the insertion has no effect.\n static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;\n};\n\n_LIBCPP_END_NAMESPACE_STD\n\n# if _LIBCPP_STD_VER >= 17\n_LIBCPP_BEGIN_NAMESPACE_STD\nnamespace pmr {\ntemplate <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>>\nusing map _LIBCPP_AVAILABILITY_PMR =\n std::map<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;\n\ntemplate <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>>\nusing multimap _LIBCPP_AVAILABILITY_PMR =\n std::multimap<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;\n} // namespace pmr\n_LIBCPP_END_NAMESPACE_STD\n# endif\n\n_LIBCPP_POP_MACROS\n\n# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20\n# include <concepts>\n# include <cstdlib>\n# include <functional>\n# include <iterator>\n# include <type_traits>\n# include <utility>\n# endif\n#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n\n#endif // _LIBCPP_MAP\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP_SET\n#define _LIBCPP_SET\n\n/*\n\n set synopsis\n\nnamespace std\n{\n\ntemplate <class Key, class Compare = less<Key>,\n class Allocator = allocator<Key>>\nclass set\n{\npublic:\n // types:\n typedef Key key_type;\n typedef key_type value_type;\n typedef Compare key_compare;\n typedef key_compare value_compare;\n typedef Allocator allocator_type;\n typedef typename allocator_type::reference reference;\n typedef typename allocator_type::const_reference const_reference;\n typedef typename allocator_type::size_type size_type;\n typedef typename allocator_type::difference_type difference_type;\n typedef typename allocator_type::pointer pointer;\n typedef typename allocator_type::const_pointer const_pointer;\n\n typedef implementation-defined iterator;\n typedef implementation-defined const_iterator;\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n typedef unspecified node_type; // C++17\n typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17\n\n // construct/copy/destroy:\n set()\n noexcept(\n is_nothrow_default_constructible<allocator_type>::value &&\n is_nothrow_default_constructible<key_compare>::value &&\n is_nothrow_copy_constructible<key_compare>::value);\n explicit set(const value_compare& comp);\n set(const value_compare& comp, const allocator_type& a);\n template <class InputIterator>\n set(InputIterator first, InputIterator last,\n const value_compare& comp = value_compare());\n template <class InputIterator>\n set(InputIterator first, InputIterator last, const value_compare& comp,\n const allocator_type& a);\n template<container-compatible-range<value_type> R>\n set(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23\n set(const set& s);\n set(set&& s)\n noexcept(\n is_nothrow_move_constructible<allocator_type>::value &&\n is_nothrow_move_constructible<key_compare>::value);\n explicit set(const allocator_type& a);\n set(const set& s, const allocator_type& a);\n set(set&& s, const allocator_type& a);\n set(initializer_list<value_type> il, const value_compare& comp = value_compare());\n set(initializer_list<value_type> il, const value_compare& comp,\n const allocator_type& a);\n template <class InputIterator>\n set(InputIterator first, InputIterator last, const allocator_type& a)\n : set(first, last, Compare(), a) {} // C++14\n template<container-compatible-range<value_type> R>\n set(from_range_t, R&& rg, const Allocator& a))\n : set(from_range, std::forward<R>(rg), Compare(), a) { } // C++23\n set(initializer_list<value_type> il, const allocator_type& a)\n : set(il, Compare(), a) {} // C++14\n ~set();\n\n set& operator=(const set& s);\n set& operator=(set&& s)\n noexcept(\n allocator_type::propagate_on_container_move_assignment::value &&\n is_nothrow_move_assignable<allocator_type>::value &&\n is_nothrow_move_assignable<key_compare>::value);\n set& operator=(initializer_list<value_type> il);\n\n // iterators:\n iterator begin() noexcept;\n const_iterator begin() const noexcept;\n iterator end() noexcept;\n const_iterator end() const noexcept;\n\n reverse_iterator rbegin() noexcept;\n const_reverse_iterator rbegin() const noexcept;\n reverse_iterator rend() noexcept;\n const_reverse_iterator rend() const noexcept;\n\n const_iterator cbegin() const noexcept;\n const_iterator cend() const noexcept;\n const_reverse_iterator crbegin() const noexcept;\n const_reverse_iterator crend() const noexcept;\n\n // capacity:\n bool empty() const noexcept;\n size_type size() const noexcept;\n size_type max_size() const noexcept;\n\n // modifiers:\n template <class... Args>\n pair<iterator, bool> emplace(Args&&... args);\n template <class... Args>\n iterator emplace_hint(const_iterator position, Args&&... args);\n pair<iterator,bool> insert(const value_type& v);\n pair<iterator,bool> insert(value_type&& v);\n iterator insert(const_iterator position, const value_type& v);\n iterator insert(const_iterator position, value_type&& v);\n template <class InputIterator>\n void insert(InputIterator first, InputIterator last);\n template<container-compatible-range<value_type> R>\n void insert_range(R&& rg); // C++23\n void insert(initializer_list<value_type> il);\n\n node_type extract(const_iterator position); // C++17\n node_type extract(const key_type& x); // C++17\n insert_return_type insert(node_type&& nh); // C++17\n iterator insert(const_iterator hint, node_type&& nh); // C++17\n\n iterator erase(const_iterator position);\n iterator erase(iterator position); // C++14\n size_type erase(const key_type& k);\n iterator erase(const_iterator first, const_iterator last);\n void clear() noexcept;\n\n template<class C2>\n void merge(set<Key, C2, Allocator>& source); // C++17\n template<class C2>\n void merge(set<Key, C2, Allocator>&& source); // C++17\n template<class C2>\n void merge(multiset<Key, C2, Allocator>& source); // C++17\n template<class C2>\n void merge(multiset<Key, C2, Allocator>&& source); // C++17\n\n void swap(set& s)\n noexcept(\n __is_nothrow_swappable<key_compare>::value &&\n (!allocator_type::propagate_on_container_swap::value ||\n __is_nothrow_swappable<allocator_type>::value));\n\n // observers:\n allocator_type get_allocator() const noexcept;\n key_compare key_comp() const;\n value_compare value_comp() const;\n\n // set operations:\n iterator find(const key_type& k);\n const_iterator find(const key_type& k) const;\n template<typename K>\n iterator find(const K& x);\n template<typename K>\n const_iterator find(const K& x) const; // C++14\n\n template<typename K>\n size_type count(const K& x) const; // C++14\n size_type count(const key_type& k) const;\n\n bool contains(const key_type& x) const; // C++20\n template<class K> bool contains(const K& x) const; // C++20\n\n iterator lower_bound(const key_type& k);\n const_iterator lower_bound(const key_type& k) const;\n template<typename K>\n iterator lower_bound(const K& x); // C++14\n template<typename K>\n const_iterator lower_bound(const K& x) const; // C++14\n\n iterator upper_bound(const key_type& k);\n const_iterator upper_bound(const key_type& k) const;\n template<typename K>\n iterator upper_bound(const K& x); // C++14\n template<typename K>\n const_iterator upper_bound(const K& x) const; // C++14\n pair<iterator,iterator> equal_range(const key_type& k);\n pair<const_iterator,const_iterator> equal_range(const key_type& k) const;\n template<typename K>\n pair<iterator,iterator> equal_range(const K& x); // C++14\n template<typename K>\n pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14\n};\n\ntemplate <class InputIterator,\n class Compare = less<typename iterator_traits<InputIterator>::value_type>,\n class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>\nset(InputIterator, InputIterator,\n Compare = Compare(), Allocator = Allocator())\n -> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17\n\ntemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,\n class Allocator = allocator<ranges::range_value_t<R>>>\n set(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())\n -> set<ranges::range_value_t<R>, Compare, Allocator>; // C++23\n\ntemplate<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>\nset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())\n -> set<Key, Compare, Allocator>; // C++17\n\ntemplate<class InputIterator, class Allocator>\nset(InputIterator, InputIterator, Allocator)\n -> set<typename iterator_traits<InputIterator>::value_type,\n less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17\n\ntemplate<ranges::input_range R, class Allocator>\n set(from_range_t, R&&, Allocator)\n -> set<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, Allocator>; // C++23\n\ntemplate<class Key, class Allocator>\nset(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>; // C++17\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator==(const set<Key, Compare, Allocator>& x,\n const set<Key, Compare, Allocator>& y);\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator< (const set<Key, Compare, Allocator>& x,\n const set<Key, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator!=(const set<Key, Compare, Allocator>& x,\n const set<Key, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator> (const set<Key, Compare, Allocator>& x,\n const set<Key, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator>=(const set<Key, Compare, Allocator>& x,\n const set<Key, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator<=(const set<Key, Compare, Allocator>& x,\n const set<Key, Compare, Allocator>& y); // removed in C++20\n\ntemplate<class Key, class Compare, class Allocator>\n synth-three-way-result<Key> operator<=>(const set<Key, Compare, Allocator>& x,\n const set<Key, Compare, Allocator>& y); // since C++20\n\n// specialized algorithms:\ntemplate <class Key, class Compare, class Allocator>\nvoid\nswap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)\n noexcept(noexcept(x.swap(y)));\n\ntemplate <class Key, class Compare, class Allocator, class Predicate>\ntypename set<Key, Compare, Allocator>::size_type\nerase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20\n\ntemplate <class Key, class Compare = less<Key>,\n class Allocator = allocator<Key>>\nclass multiset\n{\npublic:\n // types:\n typedef Key key_type;\n typedef key_type value_type;\n typedef Compare key_compare;\n typedef key_compare value_compare;\n typedef Allocator allocator_type;\n typedef typename allocator_type::reference reference;\n typedef typename allocator_type::const_reference const_reference;\n typedef typename allocator_type::size_type size_type;\n typedef typename allocator_type::difference_type difference_type;\n typedef typename allocator_type::pointer pointer;\n typedef typename allocator_type::const_pointer const_pointer;\n\n typedef implementation-defined iterator;\n typedef implementation-defined const_iterator;\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n typedef unspecified node_type; // C++17\n\n // construct/copy/destroy:\n multiset()\n noexcept(\n is_nothrow_default_constructible<allocator_type>::value &&\n is_nothrow_default_constructible<key_compare>::value &&\n is_nothrow_copy_constructible<key_compare>::value);\n explicit multiset(const value_compare& comp);\n multiset(const value_compare& comp, const allocator_type& a);\n template <class InputIterator>\n multiset(InputIterator first, InputIterator last,\n const value_compare& comp = value_compare());\n template <class InputIterator>\n multiset(InputIterator first, InputIterator last,\n const value_compare& comp, const allocator_type& a);\n template<container-compatible-range<value_type> R>\n multiset(from_range_t, R&& rg,\n const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23\n multiset(const multiset& s);\n multiset(multiset&& s)\n noexcept(\n is_nothrow_move_constructible<allocator_type>::value &&\n is_nothrow_move_constructible<key_compare>::value);\n explicit multiset(const allocator_type& a);\n multiset(const multiset& s, const allocator_type& a);\n multiset(multiset&& s, const allocator_type& a);\n multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());\n multiset(initializer_list<value_type> il, const value_compare& comp,\n const allocator_type& a);\n template <class InputIterator>\n multiset(InputIterator first, InputIterator last, const allocator_type& a)\n : set(first, last, Compare(), a) {} // C++14\n template<container-compatible-range<value_type> R>\n multiset(from_range_t, R&& rg, const Allocator& a))\n : multiset(from_range, std::forward<R>(rg), Compare(), a) { } // C++23\n multiset(initializer_list<value_type> il, const allocator_type& a)\n : set(il, Compare(), a) {} // C++14\n ~multiset();\n\n multiset& operator=(const multiset& s);\n multiset& operator=(multiset&& s)\n noexcept(\n allocator_type::propagate_on_container_move_assignment::value &&\n is_nothrow_move_assignable<allocator_type>::value &&\n is_nothrow_move_assignable<key_compare>::value);\n multiset& operator=(initializer_list<value_type> il);\n\n // iterators:\n iterator begin() noexcept;\n const_iterator begin() const noexcept;\n iterator end() noexcept;\n const_iterator end() const noexcept;\n\n reverse_iterator rbegin() noexcept;\n const_reverse_iterator rbegin() const noexcept;\n reverse_iterator rend() noexcept;\n const_reverse_iterator rend() const noexcept;\n\n const_iterator cbegin() const noexcept;\n const_iterator cend() const noexcept;\n const_reverse_iterator crbegin() const noexcept;\n const_reverse_iterator crend() const noexcept;\n\n // capacity:\n bool empty() const noexcept;\n size_type size() const noexcept;\n size_type max_size() const noexcept;\n\n // modifiers:\n template <class... Args>\n iterator emplace(Args&&... args);\n template <class... Args>\n iterator emplace_hint(const_iterator position, Args&&... args);\n iterator insert(const value_type& v);\n iterator insert(value_type&& v);\n iterator insert(const_iterator position, const value_type& v);\n iterator insert(const_iterator position, value_type&& v);\n template <class InputIterator>\n void insert(InputIterator first, InputIterator last);\n template<container-compatible-range<value_type> R>\n void insert_range(R&& rg); // C++23\n void insert(initializer_list<value_type> il);\n\n node_type extract(const_iterator position); // C++17\n node_type extract(const key_type& x); // C++17\n iterator insert(node_type&& nh); // C++17\n iterator insert(const_iterator hint, node_type&& nh); // C++17\n\n iterator erase(const_iterator position);\n iterator erase(iterator position); // C++14\n size_type erase(const key_type& k);\n iterator erase(const_iterator first, const_iterator last);\n void clear() noexcept;\n\n template<class C2>\n void merge(multiset<Key, C2, Allocator>& source); // C++17\n template<class C2>\n void merge(multiset<Key, C2, Allocator>&& source); // C++17\n template<class C2>\n void merge(set<Key, C2, Allocator>& source); // C++17\n template<class C2>\n void merge(set<Key, C2, Allocator>&& source); // C++17\n\n void swap(multiset& s)\n noexcept(\n __is_nothrow_swappable<key_compare>::value &&\n (!allocator_type::propagate_on_container_swap::value ||\n __is_nothrow_swappable<allocator_type>::value));\n\n // observers:\n allocator_type get_allocator() const noexcept;\n key_compare key_comp() const;\n value_compare value_comp() const;\n\n // set operations:\n iterator find(const key_type& k);\n const_iterator find(const key_type& k) const;\n template<typename K>\n iterator find(const K& x);\n template<typename K>\n const_iterator find(const K& x) const; // C++14\n\n template<typename K>\n size_type count(const K& x) const; // C++14\n size_type count(const key_type& k) const;\n\n bool contains(const key_type& x) const; // C++20\n template<class K> bool contains(const K& x) const; // C++20\n\n iterator lower_bound(const key_type& k);\n const_iterator lower_bound(const key_type& k) const;\n template<typename K>\n iterator lower_bound(const K& x); // C++14\n template<typename K>\n const_iterator lower_bound(const K& x) const; // C++14\n\n iterator upper_bound(const key_type& k);\n const_iterator upper_bound(const key_type& k) const;\n template<typename K>\n iterator upper_bound(const K& x); // C++14\n template<typename K>\n const_iterator upper_bound(const K& x) const; // C++14\n\n pair<iterator,iterator> equal_range(const key_type& k);\n pair<const_iterator,const_iterator> equal_range(const key_type& k) const;\n template<typename K>\n pair<iterator,iterator> equal_range(const K& x); // C++14\n template<typename K>\n pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14\n};\n\ntemplate <class InputIterator,\n class Compare = less<typename iterator_traits<InputIterator>::value_type>,\n class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>\nmultiset(InputIterator, InputIterator,\n Compare = Compare(), Allocator = Allocator())\n -> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17\n\ntemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,\n class Allocator = allocator<ranges::range_value_t<R>>>\n multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())\n -> multiset<ranges::range_value_t<R>, Compare, Allocator>;\n\ntemplate<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>\nmultiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())\n -> multiset<Key, Compare, Allocator>; // C++17\n\ntemplate<class InputIterator, class Allocator>\nmultiset(InputIterator, InputIterator, Allocator)\n -> multiset<typename iterator_traits<InputIterator>::value_type,\n less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17\n\ntemplate<ranges::input_range R, class Allocator>\n multiset(from_range_t, R&&, Allocator)\n -> multiset<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, Allocator>;\n\ntemplate<class Key, class Allocator>\nmultiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>; // C++17\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator==(const multiset<Key, Compare, Allocator>& x,\n const multiset<Key, Compare, Allocator>& y);\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator< (const multiset<Key, Compare, Allocator>& x,\n const multiset<Key, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator!=(const multiset<Key, Compare, Allocator>& x,\n const multiset<Key, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator> (const multiset<Key, Compare, Allocator>& x,\n const multiset<Key, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator>=(const multiset<Key, Compare, Allocator>& x,\n const multiset<Key, Compare, Allocator>& y); // removed in C++20\n\ntemplate <class Key, class Compare, class Allocator>\nbool\noperator<=(const multiset<Key, Compare, Allocator>& x,\n const multiset<Key, Compare, Allocator>& y); // removed in C++20\n\ntemplate<class Key, class Compare, class Allocator>\n synth-three-way-result<Key> operator<=>(const multiset<Key, Compare, Allocator>& x,\n const multiset<Key, Compare, Allocator>& y); // since C++20\n\n// specialized algorithms:\ntemplate <class Key, class Compare, class Allocator>\nvoid\nswap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)\n noexcept(noexcept(x.swap(y)));\n\ntemplate <class Key, class Compare, class Allocator, class Predicate>\ntypename multiset<Key, Compare, Allocator>::size_type\nerase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20\n\n} // std\n\n*/\n\n#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n# include <__cxx03/set>\n#else\n# include <__algorithm/equal.h>\n# include <__algorithm/lexicographical_compare.h>\n# include <__algorithm/lexicographical_compare_three_way.h>\n# include <__assert>\n# include <__config>\n# include <__functional/is_transparent.h>\n# include <__functional/operations.h>\n# include <__iterator/erase_if_container.h>\n# include <__iterator/iterator_traits.h>\n# include <__iterator/ranges_iterator_traits.h>\n# include <__iterator/reverse_iterator.h>\n# include <__memory/allocator.h>\n# include <__memory/allocator_traits.h>\n# include <__memory_resource/polymorphic_allocator.h>\n# include <__node_handle>\n# include <__ranges/concepts.h>\n# include <__ranges/container_compatible_range.h>\n# include <__ranges/from_range.h>\n# include <__tree>\n# include <__type_traits/container_traits.h>\n# include <__type_traits/enable_if.h>\n# include <__type_traits/is_allocator.h>\n# include <__type_traits/is_nothrow_assignable.h>\n# include <__type_traits/is_nothrow_constructible.h>\n# include <__type_traits/is_same.h>\n# include <__type_traits/is_swappable.h>\n# include <__type_traits/type_identity.h>\n# include <__utility/forward.h>\n# include <__utility/move.h>\n# include <__utility/pair.h>\n# include <version>\n\n// standard-mandated includes\n\n// [iterator.range]\n# include <__iterator/access.h>\n# include <__iterator/data.h>\n# include <__iterator/empty.h>\n# include <__iterator/reverse_access.h>\n# include <__iterator/size.h>\n\n// [associative.set.syn]\n# include <compare>\n# include <initializer_list>\n\n# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n# endif\n\n_LIBCPP_PUSH_MACROS\n# include <__undef_macros>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\ntemplate <class _Key, class _Compare, class _Allocator>\nclass multiset;\n\ntemplate <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >\nclass _LIBCPP_TEMPLATE_VIS set {\npublic:\n // types:\n typedef _Key key_type;\n typedef key_type value_type;\n typedef __type_identity_t<_Compare> key_compare;\n typedef key_compare value_compare;\n typedef __type_identity_t<_Allocator> allocator_type;\n typedef value_type& reference;\n typedef const value_type& const_reference;\n\n static_assert(is_same<typename allocator_type::value_type, value_type>::value,\n \"Allocator::value_type must be same type as value_type\");\n\nprivate:\n typedef __tree<value_type, value_compare, allocator_type> __base;\n typedef allocator_traits<allocator_type> __alloc_traits;\n\n static_assert(__check_valid_allocator<allocator_type>::value, \"\");\n\n __base __tree_;\n\npublic:\n typedef typename __base::pointer pointer;\n typedef typename __base::const_pointer const_pointer;\n typedef typename __base::size_type size_type;\n typedef typename __base::difference_type difference_type;\n typedef typename __base::const_iterator iterator;\n typedef typename __base::const_iterator const_iterator;\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n\n# if _LIBCPP_STD_VER >= 17\n typedef __set_node_handle<typename __base::__node, allocator_type> node_type;\n typedef __insert_return_type<iterator, node_type> insert_return_type;\n# endif\n\n template <class _Key2, class _Compare2, class _Alloc2>\n friend class _LIBCPP_TEMPLATE_VIS set;\n template <class _Key2, class _Compare2, class _Alloc2>\n friend class _LIBCPP_TEMPLATE_VIS multiset;\n\n _LIBCPP_HIDE_FROM_ABI set() _NOEXCEPT_(\n is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&\n is_nothrow_copy_constructible<key_compare>::value)\n : __tree_(value_compare()) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit set(const value_compare& __comp) _NOEXCEPT_(\n is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_copy_constructible<key_compare>::value)\n : __tree_(__comp) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit set(const value_compare& __comp, const allocator_type& __a) : __tree_(__comp, __a) {}\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const value_compare& __comp = value_compare())\n : __tree_(__comp) {\n insert(__f, __l);\n }\n\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI\n set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, const allocator_type& __a)\n : __tree_(__comp, __a) {\n insert(__f, __l);\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI\n set(from_range_t,\n _Range&& __range,\n const key_compare& __comp = key_compare(),\n const allocator_type& __a = allocator_type())\n : __tree_(__comp, __a) {\n insert_range(std::forward<_Range>(__range));\n }\n# endif\n\n# if _LIBCPP_STD_VER >= 14\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)\n : set(__f, __l, key_compare(), __a) {}\n# endif\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI set(from_range_t, _Range&& __range, const allocator_type& __a)\n : set(from_range, std::forward<_Range>(__range), key_compare(), __a) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); }\n\n _LIBCPP_HIDE_FROM_ABI set& operator=(const set& __s) {\n __tree_ = __s.__tree_;\n return *this;\n }\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value)\n : __tree_(std::move(__s.__tree_)) {}\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {}\n\n _LIBCPP_HIDE_FROM_ABI set(const set& __s, const allocator_type& __a) : __tree_(__s.__tree_.value_comp(), __a) {\n insert(__s.begin(), __s.end());\n }\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI set(set&& __s, const allocator_type& __a);\n\n _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())\n : __tree_(__comp) {\n insert(__il.begin(), __il.end());\n }\n\n _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp, const allocator_type& __a)\n : __tree_(__comp, __a) {\n insert(__il.begin(), __il.end());\n }\n\n# if _LIBCPP_STD_VER >= 14\n _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const allocator_type& __a)\n : set(__il, key_compare(), __a) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI set& operator=(initializer_list<value_type> __il) {\n __tree_.__assign_unique(__il.begin(), __il.end());\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI set& operator=(set&& __s) noexcept(is_nothrow_move_assignable<__base>::value) {\n __tree_ = std::move(__s.__tree_);\n return *this;\n }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), \"\"); }\n\n _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }\n _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }\n\n _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }\n _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); }\n\n _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }\n\n [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }\n _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }\n _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }\n\n // modifiers:\n# ifndef _LIBCPP_CXX03_LANG\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {\n return __tree_.__emplace_unique(std::forward<_Args>(__args)...);\n }\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {\n return __tree_.__emplace_hint_unique(__p, std::forward<_Args>(__args)...);\n }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); }\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {\n return __tree_.__insert_unique(__p, __v);\n }\n\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {\n for (const_iterator __e = cend(); __f != __l; ++__f)\n __tree_.__insert_unique(__e, *__f);\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {\n const_iterator __end = cend();\n for (auto&& __element : __range) {\n __tree_.__insert_unique(__end, std::forward<decltype(__element)>(__element));\n }\n }\n# endif\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {\n return __tree_.__insert_unique(std::move(__v));\n }\n\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {\n return __tree_.__insert_unique(__p, std::move(__v));\n }\n\n _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }\n _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); }\n _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }\n _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }\n\n# if _LIBCPP_STD_VER >= 17\n _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),\n \"node_type with incompatible allocator passed to set::insert()\");\n return __tree_.template __node_handle_insert_unique< node_type, insert_return_type>(std::move(__nh));\n }\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),\n \"node_type with incompatible allocator passed to set::insert()\");\n return __tree_.template __node_handle_insert_unique<node_type>(__hint, std::move(__nh));\n }\n _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {\n return __tree_.template __node_handle_extract<node_type>(__key);\n }\n _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {\n return __tree_.template __node_handle_extract<node_type>(__it);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(set<key_type, _Compare2, allocator_type>& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_unique(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(set<key_type, _Compare2, allocator_type>&& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_unique(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(multiset<key_type, _Compare2, allocator_type>& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_unique(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(multiset<key_type, _Compare2, allocator_type>&& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_unique(__source.__tree_);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); }\n\n _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); }\n _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); }\n _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); }\n\n // set operations:\n _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {\n return __tree_.find(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {\n return __tree_.find(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {\n return __tree_.__count_multi(__k);\n }\n# endif\n\n# if _LIBCPP_STD_VER >= 20\n _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {\n return find(__k) != end();\n }\n# endif // _LIBCPP_STD_VER >= 20\n\n _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {\n return __tree_.lower_bound(__k);\n }\n\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {\n return __tree_.lower_bound(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {\n return __tree_.upper_bound(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {\n return __tree_.upper_bound(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {\n return __tree_.__equal_range_unique(__k);\n }\n _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {\n return __tree_.__equal_range_unique(__k);\n }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {\n return __tree_.__equal_range_multi(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {\n return __tree_.__equal_range_multi(__k);\n }\n# endif\n};\n\n# if _LIBCPP_STD_VER >= 17\ntemplate <class _InputIterator,\n class _Compare = less<__iter_value_type<_InputIterator>>,\n class _Allocator = allocator<__iter_value_type<_InputIterator>>,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>>\nset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())\n -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>;\n\n# if _LIBCPP_STD_VER >= 23\ntemplate <ranges::input_range _Range,\n class _Compare = less<ranges::range_value_t<_Range>>,\n class _Allocator = allocator<ranges::range_value_t<_Range>>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>>\nset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())\n -> set<ranges::range_value_t<_Range>, _Compare, _Allocator>;\n# endif\n\ntemplate <class _Key,\n class _Compare = less<_Key>,\n class _Allocator = allocator<_Key>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) -> set<_Key, _Compare, _Allocator>;\n\ntemplate <class _InputIterator,\n class _Allocator,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nset(_InputIterator,\n _InputIterator,\n _Allocator) -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>;\n\n# if _LIBCPP_STD_VER >= 23\ntemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nset(from_range_t,\n _Range&&,\n _Allocator) -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;\n# endif\n\ntemplate <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nset(initializer_list<_Key>, _Allocator) -> set<_Key, less<_Key>, _Allocator>;\n# endif\n\n# ifndef _LIBCPP_CXX03_LANG\n\ntemplate <class _Key, class _Compare, class _Allocator>\nset<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __tree_(std::move(__s.__tree_), __a) {\n if (__a != __s.get_allocator()) {\n const_iterator __e = cend();\n while (!__s.empty())\n insert(__e, std::move(__s.__tree_.remove(__s.begin())->__value_));\n }\n}\n\n# endif // _LIBCPP_CXX03_LANG\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator==(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {\n return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());\n}\n\n# if _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {\n return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());\n}\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator!=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {\n return !(__x == __y);\n}\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {\n return __y < __x;\n}\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {\n return !(__x < __y);\n}\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {\n return !(__y < __x);\n}\n\n# else // _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Compare, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>\noperator<=>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {\n return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);\n}\n\n# endif // _LIBCPP_STD_VER <= 17\n\n// specialized algorithms:\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI void swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y)\n _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {\n __x.swap(__y);\n}\n\n# if _LIBCPP_STD_VER >= 20\ntemplate <class _Key, class _Compare, class _Allocator, class _Predicate>\ninline _LIBCPP_HIDE_FROM_ABI typename set<_Key, _Compare, _Allocator>::size_type\nerase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {\n return std::__libcpp_erase_if_container(__c, __pred);\n}\n# endif\n\ntemplate <class _Key, class _Compare, class _Allocator>\nstruct __container_traits<set<_Key, _Compare, _Allocator> > {\n // http://eel.is/c++draft/associative.reqmts.except#2\n // For associative containers, if an exception is thrown by any operation from within\n // an insert or emplace function inserting a single element, the insertion has no effect.\n static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;\n};\n\ntemplate <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >\nclass _LIBCPP_TEMPLATE_VIS multiset {\npublic:\n // types:\n typedef _Key key_type;\n typedef key_type value_type;\n typedef __type_identity_t<_Compare> key_compare;\n typedef key_compare value_compare;\n typedef __type_identity_t<_Allocator> allocator_type;\n typedef value_type& reference;\n typedef const value_type& const_reference;\n\n static_assert(is_same<typename allocator_type::value_type, value_type>::value,\n \"Allocator::value_type must be same type as value_type\");\n\nprivate:\n typedef __tree<value_type, value_compare, allocator_type> __base;\n typedef allocator_traits<allocator_type> __alloc_traits;\n\n static_assert(__check_valid_allocator<allocator_type>::value, \"\");\n\n __base __tree_;\n\npublic:\n typedef typename __base::pointer pointer;\n typedef typename __base::const_pointer const_pointer;\n typedef typename __base::size_type size_type;\n typedef typename __base::difference_type difference_type;\n typedef typename __base::const_iterator iterator;\n typedef typename __base::const_iterator const_iterator;\n typedef std::reverse_iterator<iterator> reverse_iterator;\n typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n\n# if _LIBCPP_STD_VER >= 17\n typedef __set_node_handle<typename __base::__node, allocator_type> node_type;\n# endif\n\n template <class _Key2, class _Compare2, class _Alloc2>\n friend class _LIBCPP_TEMPLATE_VIS set;\n template <class _Key2, class _Compare2, class _Alloc2>\n friend class _LIBCPP_TEMPLATE_VIS multiset;\n\n // construct/copy/destroy:\n _LIBCPP_HIDE_FROM_ABI multiset() _NOEXCEPT_(\n is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&\n is_nothrow_copy_constructible<key_compare>::value)\n : __tree_(value_compare()) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit multiset(const value_compare& __comp) _NOEXCEPT_(\n is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_copy_constructible<key_compare>::value)\n : __tree_(__comp) {}\n\n _LIBCPP_HIDE_FROM_ABI explicit multiset(const value_compare& __comp, const allocator_type& __a)\n : __tree_(__comp, __a) {}\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI multiset(_InputIterator __f, _InputIterator __l, const value_compare& __comp = value_compare())\n : __tree_(__comp) {\n insert(__f, __l);\n }\n\n# if _LIBCPP_STD_VER >= 14\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)\n : multiset(__f, __l, key_compare(), __a) {}\n# endif\n\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI\n multiset(_InputIterator __f, _InputIterator __l, const value_compare& __comp, const allocator_type& __a)\n : __tree_(__comp, __a) {\n insert(__f, __l);\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI\n multiset(from_range_t,\n _Range&& __range,\n const key_compare& __comp = key_compare(),\n const allocator_type& __a = allocator_type())\n : __tree_(__comp, __a) {\n insert_range(std::forward<_Range>(__range));\n }\n\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI multiset(from_range_t, _Range&& __range, const allocator_type& __a)\n : multiset(from_range, std::forward<_Range>(__range), key_compare(), __a) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s)\n : __tree_(__s.__tree_.value_comp(),\n __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc())) {\n insert(__s.begin(), __s.end());\n }\n\n _LIBCPP_HIDE_FROM_ABI multiset& operator=(const multiset& __s) {\n __tree_ = __s.__tree_;\n return *this;\n }\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value)\n : __tree_(std::move(__s.__tree_)) {}\n\n _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a);\n# endif // _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI explicit multiset(const allocator_type& __a) : __tree_(__a) {}\n _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s, const allocator_type& __a)\n : __tree_(__s.__tree_.value_comp(), __a) {\n insert(__s.begin(), __s.end());\n }\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())\n : __tree_(__comp) {\n insert(__il.begin(), __il.end());\n }\n\n _LIBCPP_HIDE_FROM_ABI\n multiset(initializer_list<value_type> __il, const value_compare& __comp, const allocator_type& __a)\n : __tree_(__comp, __a) {\n insert(__il.begin(), __il.end());\n }\n\n# if _LIBCPP_STD_VER >= 14\n _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const allocator_type& __a)\n : multiset(__il, key_compare(), __a) {}\n# endif\n\n _LIBCPP_HIDE_FROM_ABI multiset& operator=(initializer_list<value_type> __il) {\n __tree_.__assign_multi(__il.begin(), __il.end());\n return *this;\n }\n\n _LIBCPP_HIDE_FROM_ABI multiset& operator=(multiset&& __s) _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) {\n __tree_ = std::move(__s.__tree_);\n return *this;\n }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI ~multiset() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), \"\"); }\n\n _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }\n _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }\n\n _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }\n _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); }\n\n _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }\n _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }\n _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }\n\n [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }\n _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }\n _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }\n\n // modifiers:\n# ifndef _LIBCPP_CXX03_LANG\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {\n return __tree_.__emplace_multi(std::forward<_Args>(__args)...);\n }\n template <class... _Args>\n _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {\n return __tree_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...);\n }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); }\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {\n return __tree_.__insert_multi(__p, __v);\n }\n\n template <class _InputIterator>\n _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {\n for (const_iterator __e = cend(); __f != __l; ++__f)\n __tree_.__insert_multi(__e, *__f);\n }\n\n# if _LIBCPP_STD_VER >= 23\n template <_ContainerCompatibleRange<value_type> _Range>\n _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {\n const_iterator __end = cend();\n for (auto&& __element : __range) {\n __tree_.__insert_multi(__end, std::forward<decltype(__element)>(__element));\n }\n }\n# endif\n\n# ifndef _LIBCPP_CXX03_LANG\n _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); }\n\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {\n return __tree_.__insert_multi(__p, std::move(__v));\n }\n\n _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }\n# endif // _LIBCPP_CXX03_LANG\n\n _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }\n _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); }\n _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }\n _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }\n\n# if _LIBCPP_STD_VER >= 17\n _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),\n \"node_type with incompatible allocator passed to multiset::insert()\");\n return __tree_.template __node_handle_insert_multi<node_type>(std::move(__nh));\n }\n _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),\n \"node_type with incompatible allocator passed to multiset::insert()\");\n return __tree_.template __node_handle_insert_multi<node_type>(__hint, std::move(__nh));\n }\n _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {\n return __tree_.template __node_handle_extract<node_type>(__key);\n }\n _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {\n return __tree_.template __node_handle_extract<node_type>(__it);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(multiset<key_type, _Compare2, allocator_type>& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_multi(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(multiset<key_type, _Compare2, allocator_type>&& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_multi(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(set<key_type, _Compare2, allocator_type>& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_multi(__source.__tree_);\n }\n template <class _Compare2>\n _LIBCPP_HIDE_FROM_ABI void merge(set<key_type, _Compare2, allocator_type>&& __source) {\n _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(\n __source.get_allocator() == get_allocator(), \"merging container with incompatible allocator\");\n __tree_.__node_handle_merge_multi(__source.__tree_);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {\n __tree_.swap(__s.__tree_);\n }\n\n _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); }\n _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); }\n _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); }\n\n // set operations:\n _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {\n return __tree_.find(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {\n return __tree_.find(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {\n return __tree_.__count_multi(__k);\n }\n# endif\n\n# if _LIBCPP_STD_VER >= 20\n _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {\n return find(__k) != end();\n }\n# endif // _LIBCPP_STD_VER >= 20\n\n _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {\n return __tree_.lower_bound(__k);\n }\n\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {\n return __tree_.lower_bound(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }\n _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {\n return __tree_.upper_bound(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {\n return __tree_.upper_bound(__k);\n }\n# endif\n\n _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {\n return __tree_.__equal_range_multi(__k);\n }\n _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {\n return __tree_.__equal_range_multi(__k);\n }\n# if _LIBCPP_STD_VER >= 14\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {\n return __tree_.__equal_range_multi(__k);\n }\n template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>\n _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {\n return __tree_.__equal_range_multi(__k);\n }\n# endif\n};\n\n# if _LIBCPP_STD_VER >= 17\ntemplate <class _InputIterator,\n class _Compare = less<__iter_value_type<_InputIterator>>,\n class _Allocator = allocator<__iter_value_type<_InputIterator>>,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>>\nmultiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())\n -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>;\n\n# if _LIBCPP_STD_VER >= 23\ntemplate <ranges::input_range _Range,\n class _Compare = less<ranges::range_value_t<_Range>>,\n class _Allocator = allocator<ranges::range_value_t<_Range>>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>>\nmultiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())\n -> multiset<ranges::range_value_t<_Range>, _Compare, _Allocator>;\n# endif\n\ntemplate <class _Key,\n class _Compare = less<_Key>,\n class _Allocator = allocator<_Key>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>,\n class = enable_if_t<!__is_allocator<_Compare>::value, void>>\nmultiset(initializer_list<_Key>,\n _Compare = _Compare(),\n _Allocator = _Allocator()) -> multiset<_Key, _Compare, _Allocator>;\n\ntemplate <class _InputIterator,\n class _Allocator,\n class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>,\n class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmultiset(_InputIterator, _InputIterator, _Allocator)\n -> multiset<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>;\n\n# if _LIBCPP_STD_VER >= 23\ntemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmultiset(from_range_t,\n _Range&&,\n _Allocator) -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;\n# endif\n\ntemplate <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>\nmultiset(initializer_list<_Key>, _Allocator) -> multiset<_Key, less<_Key>, _Allocator>;\n# endif\n\n# ifndef _LIBCPP_CXX03_LANG\n\ntemplate <class _Key, class _Compare, class _Allocator>\nmultiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)\n : __tree_(std::move(__s.__tree_), __a) {\n if (__a != __s.get_allocator()) {\n const_iterator __e = cend();\n while (!__s.empty())\n insert(__e, std::move(__s.__tree_.remove(__s.begin())->__value_));\n }\n}\n\n# endif // _LIBCPP_CXX03_LANG\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator==(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {\n return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());\n}\n\n# if _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {\n return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());\n}\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator!=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {\n return !(__x == __y);\n}\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {\n return __y < __x;\n}\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator>=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {\n return !(__x < __y);\n}\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI bool\noperator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {\n return !(__y < __x);\n}\n\n# else // _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Compare, class _Allocator>\n_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>\noperator<=>(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {\n return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);\n}\n\n# endif // _LIBCPP_STD_VER <= 17\n\ntemplate <class _Key, class _Compare, class _Allocator>\ninline _LIBCPP_HIDE_FROM_ABI void\nswap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Allocator>& __y)\n _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {\n __x.swap(__y);\n}\n\n# if _LIBCPP_STD_VER >= 20\ntemplate <class _Key, class _Compare, class _Allocator, class _Predicate>\ninline _LIBCPP_HIDE_FROM_ABI typename multiset<_Key, _Compare, _Allocator>::size_type\nerase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {\n return std::__libcpp_erase_if_container(__c, __pred);\n}\n# endif\n\ntemplate <class _Key, class _Compare, class _Allocator>\nstruct __container_traits<multiset<_Key, _Compare, _Allocator> > {\n // http://eel.is/c++draft/associative.reqmts.except#2\n // For associative containers, if an exception is thrown by any operation from within\n // an insert or emplace function inserting a single element, the insertion has no effect.\n static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;\n};\n\n_LIBCPP_END_NAMESPACE_STD\n\n# if _LIBCPP_STD_VER >= 17\n_LIBCPP_BEGIN_NAMESPACE_STD\nnamespace pmr {\ntemplate <class _KeyT, class _CompareT = std::less<_KeyT>>\nusing set _LIBCPP_AVAILABILITY_PMR = std::set<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>;\n\ntemplate <class _KeyT, class _CompareT = std::less<_KeyT>>\nusing multiset _LIBCPP_AVAILABILITY_PMR = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>;\n} // namespace pmr\n_LIBCPP_END_NAMESPACE_STD\n# endif\n\n_LIBCPP_POP_MACROS\n\n# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20\n# include <concepts>\n# include <cstdlib>\n# include <functional>\n# include <iterator>\n# include <stdexcept>\n# include <type_traits>\n# endif\n#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n\n#endif // _LIBCPP_SET\n","#include <cstring>\n\n#include <ds/helper.hh>\n#include <ds/item.hh>\n#include <ds/list.hh>\n#include <ds/rule.hh>\n#include <ds/string.hh>\n#include <ds/term.hh>\n#include <ds/variable.hh>\n\nnamespace ds {\n // 一般的unification算法中,两侧变量视为同一个变量。\n // 但是我们这里需要区分他们,只有在出现variable: variable的情况下才会将两侧变量视为同一个变量。\n // 这里认为每个term中的变量存在某个scope中。\n namespace {\n struct unify_job_t {\n term_t* term_1;\n term_t* term_2;\n const char* scope_1;\n const char* scope_2;\n };\n struct unify_substitution_t {\n term_t* begin;\n term_t* end;\n length_t count;\n std::byte* check_tail;\n };\n\n bool term_equal(term_t* term_1, term_t* term_2);\n void unify(unify_job_t* job, unify_substitution_t* substitution);\n void unify_variable(unify_job_t* job, unify_substitution_t* substitution);\n void record_substitution(unify_job_t* job, unify_substitution_t* substitution);\n bool occur_check(unify_job_t* job, unify_substitution_t* substitution);\n term_t* found_in_substitution(variable_t* variable, const char* scope, unify_substitution_t* substitution);\n\n bool term_equal(term_t* term_1, term_t* term_2) {\n if (term_1->data_size() != term_2->data_size()) {\n return false;\n }\n length_t data_size = term_1->data_size();\n if (memcmp(term_1, term_2, data_size) != 0) {\n return false;\n }\n return true;\n }\n\n void unify(unify_job_t* job, unify_substitution_t* substitution) {\n if (job->term_1->variable() && job->term_2->variable()) {\n if (strcmp(job->scope_1, job->scope_2) == 0) {\n if (term_equal(job->term_1, job->term_2)) {\n return;\n }\n }\n }\n\n if (job->term_1->variable()) {\n unify_job_t new_job = {.term_1 = job->term_1, .term_2 = job->term_2, .scope_1 = job->scope_1, .scope_2 = job->scope_2};\n unify_variable(&new_job, substitution);\n return;\n }\n\n if (job->term_2->variable()) {\n unify_job_t new_job = {.term_1 = job->term_2, .term_2 = job->term_1, .scope_1 = job->scope_2, .scope_2 = job->scope_1};\n unify_variable(&new_job, substitution);\n return;\n }\n\n if (job->term_1->item() && job->term_2->item()) {\n if (!term_equal(job->term_1, job->term_2)) {\n substitution->end = nullptr;\n }\n return;\n }\n\n if (job->term_1->list() && job->term_2->list()) {\n list_t* list_1 = job->term_1->list();\n list_t* list_2 = job->term_2->list();\n if (list_1->get_list_size() != list_2->get_list_size()) {\n substitution->end = nullptr;\n return;\n }\n for (length_t index = 0; index < list_1->get_list_size(); ++index) {\n unify_job_t new_job = {\n .term_1 = list_1->term(index),\n .term_2 = list_2->term(index),\n .scope_1 = job->scope_1,\n .scope_2 = job->scope_2};\n unify(&new_job, substitution);\n if (substitution->end == nullptr) {\n return;\n }\n }\n return;\n }\n\n substitution->end = nullptr;\n }\n\n void unify_variable(unify_job_t* job, unify_substitution_t* substitution) {\n auto found = found_in_substitution(job->term_1->variable(), job->scope_1, substitution);\n if (found) {\n unify_job_t new_job = {\n .term_1 = found->list()->term(3),\n .term_2 = job->term_2,\n .scope_1 = found->list()->term(1)->item()->name()->get_string(),\n .scope_2 = job->scope_2};\n unify(&new_job, substitution);\n return;\n }\n\n if (job->term_2->variable()) {\n auto found = found_in_substitution(job->term_2->variable(), job->scope_2, substitution);\n if (found) {\n unify_job_t new_job = {\n .term_1 = job->term_1,\n .term_2 = found->list()->term(3),\n .scope_1 = job->scope_1,\n .scope_2 = found->list()->term(1)->item()->name()->get_string()};\n unify_variable(&new_job, substitution);\n return;\n }\n }\n\n if (occur_check(job, substitution)) {\n substitution->end = nullptr;\n return;\n }\n\n record_substitution(job, substitution);\n }\n\n void record_substitution(unify_job_t* job, unify_substitution_t* substitution) {\n if (substitution->end->set_list(substitution->check_tail) == nullptr) [[unlikely]] {\n substitution->end = nullptr;\n return;\n }\n list_t* tuple = substitution->end->list();\n if (tuple->set_list_size(4, substitution->check_tail) == nullptr) [[unlikely]] {\n substitution->end = nullptr;\n return;\n }\n if (tuple->term(0)->set_item(substitution->check_tail) == nullptr) [[unlikely]] {\n substitution->end = nullptr;\n return;\n }\n if (tuple->term(0)->item()->name()->set_null_string(job->scope_1, substitution->check_tail) == nullptr) [[unlikely]] {\n substitution->end = nullptr;\n return;\n }\n tuple->update_term_size(0);\n if (tuple->term(1)->set_item(substitution->check_tail) == nullptr) [[unlikely]] {\n substitution->end = nullptr;\n return;\n }\n if (tuple->term(1)->item()->name()->set_null_string(job->scope_2, substitution->check_tail) == nullptr) [[unlikely]] {\n substitution->end = nullptr;\n return;\n }\n tuple->update_term_size(1);\n if (check_before_fail(substitution->check_tail, tuple->term(2), job->term_1->data_size())) [[unlikely]] {\n substitution->end = nullptr;\n return;\n }\n memcpy(reinterpret_cast<std::byte*>(tuple->term(2)), reinterpret_cast<std::byte*>(job->term_1), job->term_1->data_size());\n tuple->update_term_size(2);\n if (check_before_fail(substitution->check_tail, tuple->term(3), job->term_2->data_size())) [[unlikely]] {\n substitution->end = nullptr;\n return;\n }\n memcpy(reinterpret_cast<std::byte*>(tuple->term(3)), reinterpret_cast<std::byte*>(job->term_2), job->term_2->data_size());\n tuple->update_term_size(3);\n substitution->end = reinterpret_cast<term_t*>(substitution->end->tail());\n substitution->count += 1;\n }\n\n bool occur_check(unify_job_t* job, unify_substitution_t* substitution) {\n if (job->term_2->variable()) {\n if (strcmp(job->scope_1, job->scope_2) == 0) {\n if (term_equal(job->term_1, job->term_2)) {\n return true;\n }\n }\n\n auto found = found_in_substitution(job->term_2->variable(), job->scope_2, substitution);\n if (found) {\n unify_job_t new_job = {\n .term_1 = job->term_1,\n .term_2 = found->list()->term(3),\n .scope_1 = job->scope_1,\n .scope_2 = found->list()->term(1)->item()->name()->get_string()};\n return occur_check(&new_job, substitution);\n }\n }\n\n if (job->term_2->list()) {\n list_t* list = job->term_2->list();\n for (length_t index = 0; index < list->get_list_size(); ++index) {\n unify_job_t new_job = {.term_1 = job->term_1, .term_2 = list->term(index), .scope_1 = job->scope_1, .scope_2 = job->scope_2};\n if (occur_check(&new_job, substitution)) {\n return true;\n }\n }\n }\n return false;\n }\n\n term_t* found_in_substitution(variable_t* variable, const char* scope, unify_substitution_t* substitution) {\n const char* variable_name = variable->name()->get_string();\n term_t* current = substitution->begin;\n while (current != substitution->end) {\n list_t* tuple = current->list();\n const char* scope_key = tuple->term(0)->item()->name()->get_string();\n if (strcmp(scope_key, scope) == 0) {\n const char* key_name = tuple->term(2)->variable()->name()->get_string();\n if (strcmp(key_name, variable_name) == 0) {\n return current;\n }\n }\n current = reinterpret_cast<term_t*>(current->tail());\n }\n return nullptr;\n }\n } // namespace\n\n term_t* term_t::match(term_t* term_1, term_t* term_2, const char* scope_1, const char* scope_2, std::byte* check_tail) {\n // 检查是否能存下非法结果,存不下直接返回nullptr\n // 在此之后,所有非法结果在返回前都会调用set_null(nullptr)\n if (check_before_fail(check_tail, this, sizeof(term_type_t))) [[unlikely]] {\n return nullptr;\n }\n // 将自己作为暂时的buffer用于存储一群tuple形式的term\n // 公用的部分都放在substitution中\n unify_job_t job = {.term_1 = term_1, .term_2 = term_2, .scope_1 = scope_1, .scope_2 = scope_2};\n unify_substitution_t substitution = {.begin = this, .end = this, .count = 0, .check_tail = check_tail};\n unify(&job, &substitution);\n if (substitution.end == nullptr) [[unlikely]] {\n set_null(nullptr);\n return nullptr;\n }\n length_t offset = sizeof(term_type_t) + sizeof(length_t) + sizeof(length_t) * substitution.count;\n if (check_before_fail(check_tail, substitution.end, offset)) [[unlikely]] {\n return nullptr;\n }\n memmove(\n reinterpret_cast<std::byte*>(substitution.begin) + offset,\n reinterpret_cast<std::byte*>(substitution.begin),\n reinterpret_cast<std::byte*>(substitution.end) - reinterpret_cast<std::byte*>(substitution.begin)\n );\n // 前面的元信息不需要检查尾指针\n set_list(nullptr)->list()->set_list_size(substitution.count, nullptr);\n for (length_t index = 0; index < substitution.count; ++index) {\n list()->update_term_size(index);\n }\n return this;\n }\n\n rule_t* rule_t::match(rule_t* rule_1, rule_t* rule_2, std::byte* check_tail) {\n // 检查是否能存下非法结果,存不下直接返回nullptr\n // 在此之后,所有非法结果在返回前都会调用set_null(nullptr)\n if (check_before_fail(check_tail, this, sizeof(length_t))) [[unlikely]] {\n return nullptr;\n }\n // 前者不是真rule,后者不是真fact,则直接报告非法\n if (rule_1->premises_count() == 0 || rule_2->premises_count() != 0) [[unlikely]] {\n set_null(nullptr);\n return nullptr;\n }\n // 拿自己当buffer存dict\n term_t* dict = reinterpret_cast<term_t*>(this);\n if (dict->match(rule_1->premises(0), rule_2->only_conclusion(), \"r\", \"f\", check_tail) == nullptr) [[unlikely]] {\n set_null(nullptr);\n return nullptr;\n }\n // 那自己继续当buffer存ground的结果\n rule_t* candidate_1 = reinterpret_cast<rule_t*>(dict->tail());\n if (candidate_1->ground(rule_1, dict, \"r\", check_tail) == nullptr) [[unlikely]] {\n set_null(nullptr);\n return nullptr;\n }\n rule_t* candidate_2 = reinterpret_cast<rule_t*>(candidate_1->tail());\n if (candidate_2->ground(rule_2, dict, \"f\", check_tail) == nullptr) [[unlikely]] {\n set_null(nullptr);\n return nullptr;\n }\n // 检查两个candidate的对应位置是否相同\n term_t* term_1 = candidate_1->premises(0);\n term_t* term_2 = candidate_2->conclusion();\n if (!term_equal(term_1, term_2)) [[unlikely]] {\n set_null(nullptr);\n return nullptr;\n }\n // 进行向前位移\n length_t list_size = rule_1->get_list_size() - 1;\n length_t offset = sizeof(length_t) + sizeof(length_t) * list_size;\n memmove(\n reinterpret_cast<std::byte*>(this) + offset,\n reinterpret_cast<std::byte*>(candidate_1->premises(0)->tail()),\n reinterpret_cast<std::byte*>(candidate_1->tail()) - reinterpret_cast<std::byte*>(candidate_1->premises(0)->tail())\n );\n set_list_size(list_size, nullptr);\n for (length_t index = 0; index < list_size; ++index) {\n update_term_size(index);\n }\n return this;\n }\n} // namespace ds\n","#include \"pthread_impl.h\"\n#include <threads.h>\n\nstatic pthread_t __pthread_self_internal()\n{\n\treturn __pthread_self();\n}\n\nweak_alias(__pthread_self_internal, pthread_self);\nweak_alias(__pthread_self_internal, thrd_current);\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP_TYPEINFO\n#define _LIBCPP_TYPEINFO\n\n/*\n\n typeinfo synopsis\n\nnamespace std {\n\nclass type_info\n{\npublic:\n virtual ~type_info();\n\n bool operator==(const type_info& rhs) const noexcept; // constexpr since C++23\n bool operator!=(const type_info& rhs) const noexcept; // removed in C++20\n\n bool before(const type_info& rhs) const noexcept;\n size_t hash_code() const noexcept;\n const char* name() const noexcept;\n\n type_info(const type_info& rhs) = delete;\n type_info& operator=(const type_info& rhs) = delete;\n};\n\nclass bad_cast\n : public exception\n{\npublic:\n bad_cast() noexcept;\n bad_cast(const bad_cast&) noexcept;\n bad_cast& operator=(const bad_cast&) noexcept;\n virtual const char* what() const noexcept;\n};\n\nclass bad_typeid\n : public exception\n{\npublic:\n bad_typeid() noexcept;\n bad_typeid(const bad_typeid&) noexcept;\n bad_typeid& operator=(const bad_typeid&) noexcept;\n virtual const char* what() const noexcept;\n};\n\n} // std\n\n*/\n\n#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n# include <__cxx03/typeinfo>\n#else\n# include <__config>\n# include <__cstddef/size_t.h>\n# include <__exception/exception.h>\n# include <__type_traits/integral_constant.h>\n# include <__type_traits/is_constant_evaluated.h>\n# include <__verbose_abort>\n# include <cstdint>\n# include <version>\n\n# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n# endif\n\n# if defined(_LIBCPP_ABI_VCRUNTIME)\n# include <vcruntime_typeinfo.h>\n# else\n\nnamespace std // purposefully not using versioning namespace\n{\n\n# if defined(_LIBCPP_ABI_MICROSOFT)\n\nclass _LIBCPP_EXPORTED_FROM_ABI type_info {\n type_info& operator=(const type_info&);\n type_info(const type_info&);\n\n mutable struct {\n const char* __undecorated_name;\n const char __decorated_name[1];\n } __data;\n\n int __compare(const type_info& __rhs) const _NOEXCEPT;\n\npublic:\n virtual ~type_info();\n\n const char* name() const _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI bool before(const type_info& __arg) const _NOEXCEPT { return __compare(__arg) < 0; }\n\n size_t hash_code() const _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {\n // When evaluated in a constant expression, both type infos simply can't come\n // from different translation units, so it is sufficient to compare their addresses.\n if (__libcpp_is_constant_evaluated()) {\n return this == &__arg;\n }\n return __compare(__arg) == 0;\n }\n\n# if _LIBCPP_STD_VER <= 17\n _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }\n# endif\n};\n\n# else // !defined(_LIBCPP_ABI_MICROSOFT)\n\n// ========================================================================== //\n// Implementations\n// ========================================================================== //\n// ------------------------------------------------------------------------- //\n// Unique\n// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 1)\n// ------------------------------------------------------------------------- //\n// This implementation of type_info assumes a unique copy of the RTTI for a\n// given type inside a program. This is a valid assumption when abiding to the\n// Itanium ABI (http://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-components).\n// Under this assumption, we can always compare the addresses of the type names\n// to implement equality-comparison of type_infos instead of having to perform\n// a deep string comparison.\n// -------------------------------------------------------------------------- //\n// NonUnique\n// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 2)\n// -------------------------------------------------------------------------- //\n// This implementation of type_info does not assume there is always a unique\n// copy of the RTTI for a given type inside a program. For various reasons\n// the linker may have failed to merge every copy of a types RTTI\n// (For example: -Bsymbolic or llvm.org/PR37398). Under this assumption, two\n// type_infos are equal if their addresses are equal or if a deep string\n// comparison is equal.\n// -------------------------------------------------------------------------- //\n// NonUniqueARMRTTIBit\n// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 3)\n// -------------------------------------------------------------------------- //\n// This implementation is specific to ARM64 on Apple platforms.\n//\n// This implementation of type_info does not assume always a unique copy of\n// the RTTI for a given type inside a program. When constructing the type_info,\n// the compiler packs the pointer to the type name into a uintptr_t and reserves\n// the high bit of that pointer, which is assumed to be free for use under that\n// ABI. If that high bit is set, that specific copy of the RTTI can't be assumed\n// to be unique within the program. If the high bit is unset, then the RTTI can\n// be assumed to be unique within the program.\n//\n// When comparing type_infos, if both RTTIs can be assumed to be unique, it\n// suffices to compare their addresses. If both the RTTIs can't be assumed to\n// be unique, we must perform a deep string comparison of the type names.\n// However, if one of the RTTIs is guaranteed unique and the other one isn't,\n// then both RTTIs are necessarily not to be considered equal.\n//\n// The intent of this design is to remove the need for weak symbols. Specifically,\n// if a type would normally have a default-visibility RTTI emitted as a weak\n// symbol, it is given hidden visibility instead and the non-unique bit is set.\n// Otherwise, types declared with hidden visibility are always considered to have\n// a unique RTTI: the RTTI is emitted with linkonce_odr linkage and is assumed\n// to be deduplicated by the linker within the linked image. Across linked image\n// boundaries, such types are thus considered different types.\n\n// This value can be overriden in the __config_site. When it's not overriden,\n// we pick a default implementation based on the platform here.\n# ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION\n\n// Windows and AIX binaries can't merge typeinfos, so use the NonUnique implementation.\n# if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)\n# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2\n\n// On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.\n# elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)\n# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3\n\n// On all other platforms, assume the Itanium C++ ABI and use the Unique implementation.\n# else\n# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1\n# endif\n# endif\n\nstruct __type_info_implementations {\n struct __string_impl_base {\n typedef const char* __type_name_t;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static const char*\n __type_name_to_string(__type_name_t __v) _NOEXCEPT {\n return __v;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static __type_name_t\n __string_to_type_name(const char* __v) _NOEXCEPT {\n return __v;\n }\n };\n\n struct __unique_impl : __string_impl_base {\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {\n return reinterpret_cast<size_t>(__v);\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n return __lhs == __rhs;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n return __lhs < __rhs;\n }\n };\n\n struct __non_unique_impl : __string_impl_base {\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __ptr) _NOEXCEPT {\n size_t __hash = 5381;\n while (unsigned char __c = static_cast<unsigned char>(*__ptr++))\n __hash = (__hash * 33) ^ __c;\n return __hash;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n return __lhs == __rhs || __builtin_strcmp(__lhs, __rhs) == 0;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n return __builtin_strcmp(__lhs, __rhs) < 0;\n }\n };\n\n struct __non_unique_arm_rtti_bit_impl {\n typedef uintptr_t __type_name_t;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static const char* __type_name_to_string(__type_name_t __v) _NOEXCEPT {\n return reinterpret_cast<const char*>(__v & ~__non_unique_rtti_bit::value);\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static __type_name_t __string_to_type_name(const char* __v) _NOEXCEPT {\n return reinterpret_cast<__type_name_t>(__v);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {\n if (__is_type_name_unique(__v))\n return __v;\n return __non_unique_impl::__hash(__type_name_to_string(__v));\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n if (__lhs == __rhs)\n return true;\n if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))\n // Either both are unique and have a different address, or one of them\n // is unique and the other one isn't. In both cases they are unequal.\n return false;\n return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) == 0;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))\n return __lhs < __rhs;\n return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) < 0;\n }\n\n private:\n // The unique bit is the top bit. It is expected that __type_name_t is 64 bits when\n // this implementation is actually used.\n typedef integral_constant<__type_name_t, (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))>\n __non_unique_rtti_bit;\n\n _LIBCPP_HIDE_FROM_ABI static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT {\n return !(__lhs & __non_unique_rtti_bit::value);\n }\n };\n\n typedef\n# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1\n __unique_impl\n# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2\n __non_unique_impl\n# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3\n __non_unique_arm_rtti_bit_impl\n# else\n# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION\n# endif\n __impl;\n};\n\n# if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__)\n# if __has_feature(ptrauth_type_info_vtable_pointer_discrimination)\n# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \\\n [[_Clang::__ptrauth_vtable_pointer__(process_independent, address_discrimination, type_discrimination)]]\n# else\n# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \\\n [[_Clang::__ptrauth_vtable_pointer__( \\\n process_independent, no_address_discrimination, no_extra_discrimination)]]\n# endif\n# else\n# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH\n# endif\n\nclass _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH type_info {\n type_info& operator=(const type_info&);\n type_info(const type_info&);\n\nprotected:\n typedef __type_info_implementations::__impl __impl;\n\n __impl::__type_name_t __type_name;\n\n _LIBCPP_HIDE_FROM_ABI explicit type_info(const char* __n) : __type_name(__impl::__string_to_type_name(__n)) {}\n\npublic:\n virtual ~type_info();\n\n _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { return __impl::__type_name_to_string(__type_name); }\n\n _LIBCPP_HIDE_FROM_ABI bool before(const type_info& __arg) const _NOEXCEPT {\n return __impl::__lt(__type_name, __arg.__type_name);\n }\n\n _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __impl::__hash(__type_name); }\n\n // XXX Emscripten: adding `always_inline` fixes\n // https://github.com/emscripten-core/emscripten/issues/13330\n __attribute__((always_inline)) _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool\n operator==(const type_info& __arg) const _NOEXCEPT {\n // When evaluated in a constant expression, both type infos simply can't come\n // from different translation units, so it is sufficient to compare their addresses.\n if (__libcpp_is_constant_evaluated()) {\n return this == &__arg;\n }\n return __impl::__eq(__type_name, __arg.__type_name);\n }\n\n# if _LIBCPP_STD_VER <= 17\n _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }\n# endif\n};\n# endif // defined(_LIBCPP_ABI_MICROSOFT)\n\nclass _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception {\npublic:\n bad_cast() _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI bad_cast& operator=(const bad_cast&) _NOEXCEPT = default;\n ~bad_cast() _NOEXCEPT override;\n const char* what() const _NOEXCEPT override;\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception {\npublic:\n bad_typeid() _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI bad_typeid& operator=(const bad_typeid&) _NOEXCEPT = default;\n ~bad_typeid() _NOEXCEPT override;\n const char* what() const _NOEXCEPT override;\n};\n\n} // namespace std\n\n# endif // defined(_LIBCPP_ABI_VCRUNTIME)\n\n# if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0\n\nnamespace std {\n\nclass bad_cast : public exception {\npublic:\n bad_cast() _NOEXCEPT : exception(\"bad cast\") {}\n\nprivate:\n bad_cast(const char* const __message) _NOEXCEPT : exception(__message) {}\n};\n\nclass bad_typeid : public exception {\npublic:\n bad_typeid() _NOEXCEPT : exception(\"bad typeid\") {}\n\nprivate:\n bad_typeid(const char* const __message) _NOEXCEPT : exception(__message) {}\n};\n\n} // namespace std\n\n# endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_cast() {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw bad_cast();\n# else\n _LIBCPP_VERBOSE_ABORT(\"bad_cast was thrown in -fno-exceptions mode\");\n# endif\n}\n_LIBCPP_END_NAMESPACE_STD\n\n# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20\n# include <cstddef>\n# include <cstdlib>\n# include <type_traits>\n# endif\n#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n\n#endif // _LIBCPP_TYPEINFO\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP_STDEXCEPT\n#define _LIBCPP_STDEXCEPT\n\n/*\n stdexcept synopsis\n\nnamespace std\n{\n\nclass logic_error;\nclass domain_error;\nclass invalid_argument;\nclass length_error;\nclass out_of_range;\nclass runtime_error;\nclass range_error;\nclass overflow_error;\nclass underflow_error;\n\nfor each class xxx_error:\n\nclass xxx_error : public exception // at least indirectly\n{\npublic:\n explicit xxx_error(const string& what_arg);\n explicit xxx_error(const char* what_arg);\n\n virtual const char* what() const noexcept // returns what_arg\n};\n\n} // std\n\n*/\n\n#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n# include <__cxx03/stdexcept>\n#else\n# include <__config>\n# include <__exception/exception.h>\n# include <__fwd/string.h>\n# include <__verbose_abort>\n\n# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n# endif\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\n# ifndef _LIBCPP_ABI_VCRUNTIME\nclass _LIBCPP_HIDDEN __libcpp_refstring {\n const char* __imp_;\n\n bool __uses_refcount() const;\n\npublic:\n explicit __libcpp_refstring(const char* __msg);\n __libcpp_refstring(const __libcpp_refstring& __s) _NOEXCEPT;\n __libcpp_refstring& operator=(const __libcpp_refstring& __s) _NOEXCEPT;\n ~__libcpp_refstring();\n\n _LIBCPP_HIDE_FROM_ABI const char* c_str() const _NOEXCEPT { return __imp_; }\n};\n# endif // !_LIBCPP_ABI_VCRUNTIME\n\n_LIBCPP_END_NAMESPACE_STD\n\nnamespace std // purposefully not using versioning namespace\n{\n\nclass _LIBCPP_EXPORTED_FROM_ABI logic_error : public exception {\n# ifndef _LIBCPP_ABI_VCRUNTIME\n\nprivate:\n std::__libcpp_refstring __imp_;\n\npublic:\n explicit logic_error(const string&);\n explicit logic_error(const char*);\n\n logic_error(const logic_error&) _NOEXCEPT;\n logic_error& operator=(const logic_error&) _NOEXCEPT;\n\n ~logic_error() _NOEXCEPT override;\n\n const char* what() const _NOEXCEPT override;\n# else\n\npublic:\n explicit logic_error(const std::string&); // Symbol uses versioned std::string\n _LIBCPP_HIDE_FROM_ABI explicit logic_error(const char* __s) : exception(__s) {}\n# endif\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI runtime_error : public exception {\n# ifndef _LIBCPP_ABI_VCRUNTIME\n\nprivate:\n std::__libcpp_refstring __imp_;\n\npublic:\n explicit runtime_error(const string&);\n explicit runtime_error(const char*);\n\n runtime_error(const runtime_error&) _NOEXCEPT;\n runtime_error& operator=(const runtime_error&) _NOEXCEPT;\n\n ~runtime_error() _NOEXCEPT override;\n\n const char* what() const _NOEXCEPT override;\n# else\n\npublic:\n explicit runtime_error(const std::string&); // Symbol uses versioned std::string\n _LIBCPP_HIDE_FROM_ABI explicit runtime_error(const char* __s) : exception(__s) {}\n# endif // _LIBCPP_ABI_VCRUNTIME\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI domain_error : public logic_error {\npublic:\n _LIBCPP_HIDE_FROM_ABI explicit domain_error(const string& __s) : logic_error(__s) {}\n _LIBCPP_HIDE_FROM_ABI explicit domain_error(const char* __s) : logic_error(__s) {}\n\n# ifndef _LIBCPP_ABI_VCRUNTIME\n _LIBCPP_HIDE_FROM_ABI domain_error(const domain_error&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI domain_error& operator=(const domain_error&) _NOEXCEPT = default;\n ~domain_error() _NOEXCEPT override;\n# endif\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI invalid_argument : public logic_error {\npublic:\n _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const string& __s) : logic_error(__s) {}\n _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const char* __s) : logic_error(__s) {}\n\n# ifndef _LIBCPP_ABI_VCRUNTIME\n _LIBCPP_HIDE_FROM_ABI invalid_argument(const invalid_argument&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI invalid_argument& operator=(const invalid_argument&) _NOEXCEPT = default;\n ~invalid_argument() _NOEXCEPT override;\n# endif\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI length_error : public logic_error {\npublic:\n _LIBCPP_HIDE_FROM_ABI explicit length_error(const string& __s) : logic_error(__s) {}\n _LIBCPP_HIDE_FROM_ABI explicit length_error(const char* __s) : logic_error(__s) {}\n# ifndef _LIBCPP_ABI_VCRUNTIME\n _LIBCPP_HIDE_FROM_ABI length_error(const length_error&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI length_error& operator=(const length_error&) _NOEXCEPT = default;\n ~length_error() _NOEXCEPT override;\n# endif\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI out_of_range : public logic_error {\npublic:\n _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const string& __s) : logic_error(__s) {}\n _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const char* __s) : logic_error(__s) {}\n\n# ifndef _LIBCPP_ABI_VCRUNTIME\n _LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI out_of_range& operator=(const out_of_range&) _NOEXCEPT = default;\n ~out_of_range() _NOEXCEPT override;\n# endif\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI range_error : public runtime_error {\npublic:\n _LIBCPP_HIDE_FROM_ABI explicit range_error(const string& __s) : runtime_error(__s) {}\n _LIBCPP_HIDE_FROM_ABI explicit range_error(const char* __s) : runtime_error(__s) {}\n\n# ifndef _LIBCPP_ABI_VCRUNTIME\n _LIBCPP_HIDE_FROM_ABI range_error(const range_error&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI range_error& operator=(const range_error&) _NOEXCEPT = default;\n ~range_error() _NOEXCEPT override;\n# endif\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI overflow_error : public runtime_error {\npublic:\n _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const string& __s) : runtime_error(__s) {}\n _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const char* __s) : runtime_error(__s) {}\n\n# ifndef _LIBCPP_ABI_VCRUNTIME\n _LIBCPP_HIDE_FROM_ABI overflow_error(const overflow_error&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI overflow_error& operator=(const overflow_error&) _NOEXCEPT = default;\n ~overflow_error() _NOEXCEPT override;\n# endif\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI underflow_error : public runtime_error {\npublic:\n _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const string& __s) : runtime_error(__s) {}\n _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const char* __s) : runtime_error(__s) {}\n\n# ifndef _LIBCPP_ABI_VCRUNTIME\n _LIBCPP_HIDE_FROM_ABI underflow_error(const underflow_error&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI underflow_error& operator=(const underflow_error&) _NOEXCEPT = default;\n ~underflow_error() _NOEXCEPT override;\n# endif\n};\n\n} // namespace std\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\n// in the dylib\n[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*);\n\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw logic_error(__msg);\n# else\n _LIBCPP_VERBOSE_ABORT(\"logic_error was thrown in -fno-exceptions mode with message \\\"%s\\\"\", __msg);\n# endif\n}\n\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw domain_error(__msg);\n# else\n _LIBCPP_VERBOSE_ABORT(\"domain_error was thrown in -fno-exceptions mode with message \\\"%s\\\"\", __msg);\n# endif\n}\n\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw invalid_argument(__msg);\n# else\n _LIBCPP_VERBOSE_ABORT(\"invalid_argument was thrown in -fno-exceptions mode with message \\\"%s\\\"\", __msg);\n# endif\n}\n\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw length_error(__msg);\n# else\n _LIBCPP_VERBOSE_ABORT(\"length_error was thrown in -fno-exceptions mode with message \\\"%s\\\"\", __msg);\n# endif\n}\n\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw out_of_range(__msg);\n# else\n _LIBCPP_VERBOSE_ABORT(\"out_of_range was thrown in -fno-exceptions mode with message \\\"%s\\\"\", __msg);\n# endif\n}\n\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw range_error(__msg);\n# else\n _LIBCPP_VERBOSE_ABORT(\"range_error was thrown in -fno-exceptions mode with message \\\"%s\\\"\", __msg);\n# endif\n}\n\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw overflow_error(__msg);\n# else\n _LIBCPP_VERBOSE_ABORT(\"overflow_error was thrown in -fno-exceptions mode with message \\\"%s\\\"\", __msg);\n# endif\n}\n\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw underflow_error(__msg);\n# else\n _LIBCPP_VERBOSE_ABORT(\"underflow_error was thrown in -fno-exceptions mode with message \\\"%s\\\"\", __msg);\n# endif\n}\n\n_LIBCPP_END_NAMESPACE_STD\n\n# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20\n# include <cstddef>\n# include <cstdlib>\n# include <exception>\n# include <iosfwd>\n# include <new>\n# endif\n#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n\n#endif // _LIBCPP_STDEXCEPT\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// This file implements the \"Exception Handling APIs\"\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n//\n//===----------------------------------------------------------------------===//\n\n// Support functions for the no-exceptions libc++ library\n\n#include \"cxxabi.h\"\n\n#include <exception> // for std::terminate\n#include \"cxa_exception.h\"\n#include \"cxa_handlers.h\"\n\nnamespace __cxxabiv1 {\n\nextern \"C\" {\n\nvoid\n__cxa_increment_exception_refcount(void *thrown_object) throw() {\n if (thrown_object != nullptr)\n std::terminate();\n}\n\nvoid\n__cxa_decrement_exception_refcount(void *thrown_object) throw() {\n if (thrown_object != nullptr)\n std::terminate();\n}\n\n\nvoid *__cxa_current_primary_exception() throw() { return nullptr; }\n\nvoid\n__cxa_rethrow_primary_exception(void* thrown_object) {\n if (thrown_object != nullptr)\n std::terminate();\n}\n\nbool\n__cxa_uncaught_exception() throw() { return false; }\n\nunsigned int\n__cxa_uncaught_exceptions() throw() { return 0; }\n\n#if __EMSCRIPTEN__\n// Under emscripten this code is also linked when building when\n// DISABLE_EXCEPTION_CATCHING is set but DISABLE_EXCEPTION_THROWING is not.\n// TODO(sbc): Perhaps just call std::terminate here. It could\n// just be some test code that needs updating.\nvoid *__cxa_allocate_exception(size_t thrown_size) throw() {\n char* allocation = (char*)malloc(thrown_size + sizeof(__cxa_exception));\n return allocation + sizeof(__cxa_exception);\n}\n\nstatic\ninline\n__cxa_exception*\ncxa_exception_from_thrown_object(void* thrown_object)\n{\n return static_cast<__cxa_exception*>(thrown_object) - 1;\n}\n\n// Free a __cxa_exception object allocated with __cxa_allocate_exception.\nvoid __cxa_free_exception(void *thrown_object) throw() {\n // Compute the size of the padding before the header.\n char *raw_buffer =\n ((char *)cxa_exception_from_thrown_object(thrown_object));\n free((void *)raw_buffer);\n}\n\n// This function is called from make_exception_ptr in libcxx unless\n// -fno-exceptions is not given. We have definitions of this function in\n// cxa_exception.cpp and cxa_exception_emscripten.cpp, but unlike other\n// platforms, we use those files only when one of Emscripten EH or Wasm EH is\n// used, and we use this cxa_noexceptions.cpp in case of -fignore-exceptions,\n// which is our default. So we add a definition here to prevent a link failure.\n__cxa_exception*\n__cxa_init_primary_exception(void* object,\n std::type_info* tinfo,\n void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() {\n __cxa_exception* exception_header = cxa_exception_from_thrown_object(object);\n return exception_header;\n}\n#endif\n\n} // extern \"C\"\n\n// provide dummy implementations for the 'no exceptions' case.\nuint64_t __getExceptionClass (const _Unwind_Exception*) { return 0; }\nvoid __setExceptionClass ( _Unwind_Exception*, uint64_t) {}\nbool __isOurExceptionClass(const _Unwind_Exception*) { return false; }\n\n} // abi\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#include \"stdexcept\"\n#include \"new\"\n#include <cstdlib>\n#include <cstring>\n#include <cstdint>\n#include <cstddef>\n#include \"include/refstring.h\" // from libc++\n\nstatic_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), \"\");\n\nnamespace std // purposefully not using versioning namespace\n{\n\nlogic_error::~logic_error() noexcept {}\n\nconst char*\nlogic_error::what() const noexcept\n{\n return __imp_.c_str();\n}\n\nruntime_error::~runtime_error() noexcept {}\n\nconst char*\nruntime_error::what() const noexcept\n{\n return __imp_.c_str();\n}\n\ndomain_error::~domain_error() noexcept {}\ninvalid_argument::~invalid_argument() noexcept {}\nlength_error::~length_error() noexcept {}\nout_of_range::~out_of_range() noexcept {}\n\nrange_error::~range_error() noexcept {}\noverflow_error::~overflow_error() noexcept {}\nunderflow_error::~underflow_error() noexcept {}\n\n} // std\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#include \"../../include/refstring.h\"\n\n/* For _LIBCPPABI_VERSION */\n#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(LIBCXXRT))\n# include <cxxabi.h>\n#endif\n\nstatic_assert(sizeof(std::__libcpp_refstring) == sizeof(const char*), \"\");\n\nnamespace std // purposefully not using versioning namespace\n{\n\nlogic_error::logic_error(const string& msg) : __imp_(msg.c_str()) {}\n\nlogic_error::logic_error(const char* msg) : __imp_(msg) {}\n\nlogic_error::logic_error(const logic_error& le) noexcept : __imp_(le.__imp_) {}\n\nlogic_error& logic_error::operator=(const logic_error& le) noexcept {\n __imp_ = le.__imp_;\n return *this;\n}\n\nruntime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) {}\n\nruntime_error::runtime_error(const char* msg) : __imp_(msg) {}\n\nruntime_error::runtime_error(const runtime_error& re) noexcept : __imp_(re.__imp_) {}\n\nruntime_error& runtime_error::operator=(const runtime_error& re) noexcept {\n __imp_ = re.__imp_;\n return *this;\n}\n\n#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)\n\nconst char* logic_error::what() const noexcept { return __imp_.c_str(); }\n\nconst char* runtime_error::what() const noexcept { return __imp_.c_str(); }\n\nlogic_error::~logic_error() noexcept {}\ndomain_error::~domain_error() noexcept {}\ninvalid_argument::~invalid_argument() noexcept {}\nlength_error::~length_error() noexcept {}\nout_of_range::~out_of_range() noexcept {}\n\nruntime_error::~runtime_error() noexcept {}\nrange_error::~range_error() noexcept {}\noverflow_error::~overflow_error() noexcept {}\nunderflow_error::~underflow_error() noexcept {}\n\n#endif\n\n} // namespace std\n","#include <string.h>\n#include <stdint.h>\n#include <limits.h>\n\n#define SS (sizeof(size_t))\n#define ALIGN (sizeof(size_t)-1)\n#define ONES ((size_t)-1/UCHAR_MAX)\n#define HIGHS (ONES * (UCHAR_MAX/2+1))\n#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)\n\nvoid *memchr(const void *src, int c, size_t n)\n{\n\tconst unsigned char *s = src;\n\tc = (unsigned char)c;\n/* XXX EMSCRIPTEN: add __has_feature check */\n#if defined(__GNUC__) && !__has_feature(address_sanitizer)\n\tfor (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--);\n\tif (n && *s != c) {\n\t\ttypedef size_t __attribute__((__may_alias__)) word;\n\t\tconst word *w;\n\t\tsize_t k = ONES * c;\n\t\tfor (w = (const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS);\n\t\ts = (const void *)w;\n\t}\n#endif\n\tfor (; n && *s != c; s++, n--);\n\treturn n ? (void *)s : 0;\n}\n","#include <string.h>\n\nint strcmp(const char *l, const char *r)\n{\n\tfor (; *l==*r && *l; l++, r++);\n\treturn *(unsigned char *)l - *(unsigned char *)r;\n}\n","#if __EMSCRIPTEN__\n#include <stdint.h>\n#endif\n#include <string.h>\n\nint memcmp(const void *vl, const void *vr, size_t n)\n{\n\tconst unsigned char *l=vl, *r=vr;\n\n// XXX EMSCRIPTEN: add an optimized version.\n#if !defined(EMSCRIPTEN_OPTIMIZE_FOR_OZ) && !__has_feature(address_sanitizer)\n\t// If we have enough bytes, and everything is aligned, loop on words instead\n\t// of single bytes.\n\tif (n >= 4 && !((((uintptr_t)l) & 3) | (((uintptr_t)r) & 3))) {\n\t\twhile (n >= 4) {\n\t\t\tif (*((uint32_t *)l) != *((uint32_t *)r)) {\n\t\t\t\t// Go to the single-byte loop to find the specific byte.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tl += 4;\n\t\t\tr += 4;\n\t\t\tn -= 4;\n\t\t}\n\t}\n#endif\n\n#if defined(EMSCRIPTEN_OPTIMIZE_FOR_OZ)\n#pragma clang loop unroll(disable)\n#endif\n\tfor (; n && *l == *r; n--, l++, r++);\n\treturn n ? *l-*r : 0;\n}\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#include <functional>\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\nbad_function_call::~bad_function_call() noexcept {}\n\n#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE\nconst char* bad_function_call::what() const noexcept { return \"std::bad_function_call\"; }\n#endif\n\n_LIBCPP_END_NAMESPACE_STD\n","/*\n * Copyright 2012 The Emscripten Authors. All rights reserved.\n * Emscripten is available under two separate licenses, the MIT license and the\n * University of Illinois/NCSA Open Source License. Both these licenses can be\n * found in the LICENSE file.\n */\n\n#pragma once\n\n#include <cassert>\n#include <cstddef>\n#include <functional>\n#include <map>\n#include <string>\n#include <type_traits>\n#include <vector>\n#if __cplusplus >= 201703L\n#include <optional>\n#endif\n\n#include <emscripten/em_asm.h>\n#include <emscripten/val.h>\n#include <emscripten/wire.h>\n\n#if __has_feature(leak_sanitizer) || __has_feature(address_sanitizer)\n#include <sanitizer/lsan_interface.h>\n#endif\n\nnamespace emscripten {\n\nenum class sharing_policy {\n NONE = 0,\n INTRUSIVE = 1,\n BY_EMVAL = 2,\n};\n\nnamespace internal {\n\ntypedef int GenericEnumValue;\n\ntypedef void* GenericFunction;\ntypedef void (*VoidFunctionPtr)(void);\n\n// Implemented in JavaScript. Don't call these directly.\nextern \"C\" {\n\nvoid _embind_fatal_error(\n const char* name,\n const char* payload) __attribute__((__noreturn__));\n\nvoid _embind_register_void(\n TYPEID voidType,\n const char* name);\n\nvoid _embind_register_bool(\n TYPEID boolType,\n const char* name,\n bool trueValue,\n bool falseValue);\n\nvoid _embind_register_integer(\n TYPEID integerType,\n const char* name,\n size_t size,\n int32_t minRange,\n uint32_t maxRange);\n\nvoid _embind_register_bigint(\n TYPEID integerType,\n const char* name,\n size_t size,\n int64_t minRange,\n uint64_t maxRange);\n\nvoid _embind_register_float(\n TYPEID floatType,\n const char* name,\n size_t size);\n\nvoid _embind_register_std_string(\n TYPEID stringType,\n const char* name);\n\nvoid _embind_register_std_wstring(\n TYPEID stringType,\n size_t charSize,\n const char* name);\n\nvoid _embind_register_emval(\n TYPEID emvalType);\n\nvoid _embind_register_memory_view(\n TYPEID memoryViewType,\n unsigned typedArrayIndex,\n const char* name);\n\nvoid _embind_register_function(\n const char* name,\n unsigned argCount,\n const TYPEID argTypes[],\n const char* signature,\n GenericFunction invoker,\n GenericFunction function,\n bool isAsync,\n bool isNonnullReturn);\n\nvoid _embind_register_value_array(\n TYPEID tupleType,\n const char* name,\n const char* constructorSignature,\n GenericFunction constructor,\n const char* destructorSignature,\n GenericFunction destructor);\n\nvoid _embind_register_value_array_element(\n TYPEID tupleType,\n TYPEID getterReturnType,\n const char* getterSignature,\n GenericFunction getter,\n void* getterContext,\n TYPEID setterArgumentType,\n const char* setterSignature,\n GenericFunction setter,\n void* setterContext);\n\nvoid _embind_finalize_value_array(TYPEID tupleType);\n\nvoid _embind_register_value_object(\n TYPEID structType,\n const char* fieldName,\n const char* constructorSignature,\n GenericFunction constructor,\n const char* destructorSignature,\n GenericFunction destructor);\n\nvoid _embind_register_value_object_field(\n TYPEID structType,\n const char* fieldName,\n TYPEID getterReturnType,\n const char* getterSignature,\n GenericFunction getter,\n void* getterContext,\n TYPEID setterArgumentType,\n const char* setterSignature,\n GenericFunction setter,\n void* setterContext);\n\nvoid _embind_finalize_value_object(TYPEID structType);\n\nvoid _embind_register_class(\n TYPEID classType,\n TYPEID pointerType,\n TYPEID constPointerType,\n TYPEID baseClassType,\n const char* getActualTypeSignature,\n GenericFunction getActualType,\n const char* upcastSignature,\n GenericFunction upcast,\n const char* downcastSignature,\n GenericFunction downcast,\n const char* className,\n const char* destructorSignature,\n GenericFunction destructor);\n\nvoid _embind_register_class_constructor(\n TYPEID classType,\n unsigned argCount,\n const TYPEID argTypes[],\n const char* invokerSignature,\n GenericFunction invoker,\n GenericFunction constructor);\n\nvoid _embind_register_class_function(\n TYPEID classType,\n const char* methodName,\n unsigned argCount,\n const TYPEID argTypes[],\n const char* invokerSignature,\n GenericFunction invoker,\n void* context,\n unsigned isPureVirtual,\n bool isAsync,\n bool isNonnullReturn);\n\nvoid _embind_register_class_property(\n TYPEID classType,\n const char* fieldName,\n TYPEID getterReturnType,\n const char* getterSignature,\n GenericFunction getter,\n void* getterContext,\n TYPEID setterArgumentType,\n const char* setterSignature,\n GenericFunction setter,\n void* setterContext);\n\nvoid _embind_register_class_class_function(\n TYPEID classType,\n const char* methodName,\n unsigned argCount,\n const TYPEID argTypes[],\n const char* invokerSignature,\n GenericFunction invoker,\n GenericFunction method,\n bool isAsync,\n bool isNonnullReturn);\n\nvoid _embind_register_class_class_property(\n TYPEID classType,\n const char* fieldName,\n TYPEID fieldType,\n const void* fieldContext,\n const char* getterSignature,\n GenericFunction getter,\n const char* setterSignature,\n GenericFunction setter);\n\nEM_VAL _embind_create_inheriting_constructor(\n const char* constructorName,\n TYPEID wrapperType,\n EM_VAL properties);\n\nvoid _embind_register_enum(\n TYPEID enumType,\n const char* name,\n size_t size,\n bool isSigned);\n\nvoid _embind_register_smart_ptr(\n TYPEID pointerType,\n TYPEID pointeeType,\n const char* pointerName,\n sharing_policy sharingPolicy,\n const char* getPointeeSignature,\n GenericFunction getPointee,\n const char* constructorSignature,\n GenericFunction constructor,\n const char* shareSignature,\n GenericFunction share,\n const char* destructorSignature,\n GenericFunction destructor);\n\nvoid _embind_register_enum_value(\n TYPEID enumType,\n const char* valueName,\n GenericEnumValue value);\n\nvoid _embind_register_constant(\n const char* name,\n TYPEID constantType,\n double value);\n\nvoid _embind_register_optional(\n TYPEID optionalType,\n TYPEID type);\n\nvoid _embind_register_user_type(\n TYPEID type,\n const char* typeName);\n\nvoid _embind_register_user_type_definition(\n TYPEID type,\n const char* typeName,\n const char* typeDefinition);\n\n// Register an InitFunc in the global linked list of init functions.\nvoid _embind_register_bindings(struct InitFunc* f);\n\n// Binding initialization functions registered by EMSCRIPTEN_BINDINGS macro\n// below. Stored as linked list of static data object avoiding std containers\n// to avoid static constructor ordering issues.\nstruct InitFunc {\n InitFunc(void (*init_func)()) : init_func(init_func) {\n // This the function immediately upon constructions, and also register\n // it so that it can be called again on each worker that starts.\n init_func();\n _embind_register_bindings(this);\n }\n void (*init_func)();\n InitFunc* next = nullptr;\n};\n\n} // end extern \"C\"\n\n} // end namespace internal\n\n////////////////////////////////////////////////////////////////////////////////\n// select_overload and select_const\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename Signature>\nSignature* select_overload(Signature* fn) {\n return fn;\n}\n\ntemplate<typename Signature, typename ClassType>\nauto select_overload(Signature (ClassType::*fn)) -> decltype(fn) {\n return fn;\n}\n\ntemplate<typename ClassType, typename ReturnType, typename... Args>\nauto select_const(ReturnType (ClassType::*method)(Args...) const) -> decltype(method) {\n return method;\n}\n\nnamespace internal {\n// this should be in <type_traits>, but alas, it's not\ntemplate<typename T> struct remove_class;\ntemplate<typename C, typename R, typename... A>\nstruct remove_class<R(C::*)(A...)> { using type = R(A...); };\ntemplate<typename C, typename R, typename... A>\nstruct remove_class<R(C::*)(A...) const> { using type = R(A...); };\ntemplate<typename C, typename R, typename... A>\nstruct remove_class<R(C::*)(A...) volatile> { using type = R(A...); };\ntemplate<typename C, typename R, typename... A>\nstruct remove_class<R(C::*)(A...) const volatile> { using type = R(A...); };\n\ntemplate<typename LambdaType>\nusing LambdaSignature = typename remove_class<\n decltype(&LambdaType::operator())\n>::type;\n} // end namespace internal\n\n// requires captureless lambda because implicitly coerces to function pointer\ntemplate<typename LambdaType>\ninternal::LambdaSignature<LambdaType>* optional_override(const LambdaType& fp) {\n return fp;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// Invoker\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\ntemplate<typename ReturnPolicy, typename ReturnType, typename... Args>\nstruct Invoker {\n static typename internal::BindingType<ReturnType>::WireType invoke(\n ReturnType (*fn)(Args...),\n typename internal::BindingType<Args>::WireType... args\n ) {\n return internal::BindingType<ReturnType>::toWireType(\n fn(internal::BindingType<Args>::fromWireType(args)...),\n ReturnPolicy{}\n );\n }\n};\n\ntemplate<typename ReturnPolicy, typename... Args>\nstruct Invoker<ReturnPolicy, void, Args...> {\n static void invoke(\n void (*fn)(Args...),\n typename internal::BindingType<Args>::WireType... args\n ) {\n return fn(\n internal::BindingType<Args>::fromWireType(args)...\n );\n }\n};\n\ntemplate<typename ReturnPolicy, typename FunctorType, typename ReturnType, typename... Args>\nstruct FunctorInvoker {\n static typename internal::BindingType<ReturnType>::WireType invoke(\n FunctorType& function,\n typename internal::BindingType<Args>::WireType... args\n ) {\n return internal::BindingType<ReturnType>::toWireType(\n function(\n internal::BindingType<Args>::fromWireType(args)...)\n , ReturnPolicy{}\n );\n }\n};\n\ntemplate<typename ReturnPolicy, typename FunctorType, typename... Args>\nstruct FunctorInvoker<ReturnPolicy, FunctorType, void, Args...> {\n static void invoke(\n FunctorType& function,\n typename internal::BindingType<Args>::WireType... args\n ) {\n function(\n internal::BindingType<Args>::fromWireType(args)...);\n }\n};\n\n} // end namespace internal\n\n////////////////////////////////////////////////////////////////////////////////\n// SignatureCode, SignatureString\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\n// TODO: this is a historical default, but we should probably use 'p' instead,\n// and only enable it for smart_ptr_trait<> descendants.\ntemplate<typename T, typename = decltype(__em_asm_sig<int>::value)>\nstruct SignatureCode : __em_asm_sig<int> {};\n\ntemplate<typename T>\nstruct SignatureCode<T, decltype(__em_asm_sig<T>::value)> : __em_asm_sig<T> {};\n\ntemplate<typename T>\nstruct SignatureCode<T&> : SignatureCode<T*> {};\n\ntemplate<>\nstruct SignatureCode<void> {\n static constexpr char value = 'v';\n};\n\ntemplate<typename... Args>\nconstexpr const char Signature[] = { SignatureCode<Args>::value..., 0 };\n\ntemplate<typename Return, typename... Args>\nconstexpr const char* getSignature(Return (*)(Args...)) {\n return Signature<Return, Args...>;\n}\n\n} // end namespace internal\n\n////////////////////////////////////////////////////////////////////////////////\n// FUNCTIONS\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename ReturnType, typename... Args, typename... Policies>\nvoid function(const char* name, ReturnType (*fn)(Args...), Policies...) {\n using namespace internal;\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = Invoker<ReturnPolicy, ReturnType, Args...>::invoke;\n _embind_register_function(\n name,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(fn),\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n}\n\nnamespace internal {\n\ntemplate<typename ClassType, typename... Args>\nClassType* operator_new(Args&&... args) {\n return new ClassType(std::forward<Args>(args)...);\n}\n\ntemplate<typename WrapperType, typename ClassType, typename... Args>\nWrapperType wrapped_new(Args&&... args) {\n return WrapperType(new ClassType(std::forward<Args>(args)...));\n}\n\ntemplate<typename ClassType, typename... Args>\nClassType* raw_constructor(\n typename internal::BindingType<Args>::WireType... args\n) {\n return new ClassType(\n internal::BindingType<Args>::fromWireType(args)...\n );\n}\n\ntemplate<typename ClassType>\nvoid raw_destructor(ClassType* ptr) {\n delete ptr;\n}\n\ntemplate<typename ReturnPolicy, typename FunctionPointerType, typename ReturnType, typename ThisType, typename... Args>\nstruct FunctionInvoker {\n static typename internal::BindingType<ReturnType>::WireType invoke(\n FunctionPointerType* function,\n typename internal::BindingType<ThisType>::WireType wireThis,\n typename internal::BindingType<Args>::WireType... args\n ) {\n return internal::BindingType<ReturnType>::toWireType(\n (*function)(\n internal::BindingType<ThisType>::fromWireType(wireThis),\n internal::BindingType<Args>::fromWireType(args)...),\n ReturnPolicy{}\n );\n }\n};\n\ntemplate<typename ReturnPolicy, typename FunctionPointerType, typename ThisType, typename... Args>\nstruct FunctionInvoker<ReturnPolicy, FunctionPointerType, void, ThisType, Args...> {\n static void invoke(\n FunctionPointerType* function,\n typename internal::BindingType<ThisType>::WireType wireThis,\n typename internal::BindingType<Args>::WireType... args\n ) {\n (*function)(\n internal::BindingType<ThisType>::fromWireType(wireThis),\n internal::BindingType<Args>::fromWireType(args)...);\n }\n};\n\ntemplate<typename ReturnPolicy,\n typename MemberPointer,\n typename ReturnType,\n typename ThisType,\n typename... Args>\nstruct MethodInvoker {\n static typename internal::BindingType<ReturnType>::WireType invoke(\n const MemberPointer& method,\n typename internal::BindingType<ThisType>::WireType wireThis,\n typename internal::BindingType<Args>::WireType... args\n ) {\n return internal::BindingType<ReturnType>::toWireType(\n (internal::BindingType<ThisType>::fromWireType(wireThis)->*method)(\n internal::BindingType<Args>::fromWireType(args)...\n )\n ,\n ReturnPolicy{}\n );\n }\n};\n\ntemplate<typename ReturnPolicy,\n typename MemberPointer,\n typename ThisType,\n typename... Args>\nstruct MethodInvoker<ReturnPolicy, MemberPointer, void, ThisType, Args...> {\n static void invoke(\n const MemberPointer& method,\n typename internal::BindingType<ThisType>::WireType wireThis,\n typename internal::BindingType<Args>::WireType... args\n ) {\n return (internal::BindingType<ThisType>::fromWireType(wireThis)->*method)(\n internal::BindingType<Args>::fromWireType(args)...\n );\n }\n};\n\ntemplate<typename InstanceType, typename MemberType>\nstruct MemberAccess {\n typedef MemberType InstanceType::*MemberPointer;\n typedef internal::BindingType<MemberType> MemberBinding;\n typedef typename MemberBinding::WireType WireType;\n\n template<typename ClassType, typename ReturnPolicy = rvp::default_tag>\n static WireType getWire(\n const MemberPointer& field,\n ClassType& ptr\n ) {\n return MemberBinding::toWireType(ptr.*field, ReturnPolicy{});\n }\n\n template<typename ClassType>\n static void setWire(\n const MemberPointer& field,\n ClassType& ptr,\n WireType value\n ) {\n ptr.*field = MemberBinding::fromWireType(value);\n }\n};\n\ntemplate<typename FieldType>\nstruct GlobalAccess {\n typedef internal::BindingType<FieldType> MemberBinding;\n typedef typename MemberBinding::WireType WireType;\n\n static WireType get(FieldType* context) {\n return MemberBinding::toWireType(*context, rvp::default_tag{});\n }\n\n static void set(FieldType* context, WireType value) {\n *context = MemberBinding::fromWireType(value);\n }\n};\n\n// TODO: This could do a reinterpret-cast if sizeof(T) === sizeof(void*)\ntemplate<typename T>\ninline T* getContext(const T& t) {\n // not a leak because this is called once per binding\n auto* ret = new T(t);\n#if __has_feature(leak_sanitizer) || __has_feature(address_sanitizer)\n __lsan_ignore_object(ret);\n#endif\n return ret;\n}\n\ntemplate<typename Func, typename ValueTypeOrSignature>\nstruct FunctionTag {};\n\ntemplate<typename T>\nstruct GetterPolicy;\n\ntemplate<typename GetterReturnType, typename GetterThisType>\nstruct GetterPolicy<GetterReturnType (GetterThisType::*)() const> {\n typedef GetterReturnType ReturnType;\n typedef GetterReturnType (GetterThisType::*Context)() const;\n\n typedef internal::BindingType<ReturnType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType, typename ReturnPolicy>\n static WireType get(const Context& context, const ClassType& ptr) {\n return Binding::toWireType((ptr.*context)(), ReturnPolicy{});\n }\n\n static void* getContext(Context context) {\n return internal::getContext(context);\n }\n};\n\n#ifdef __cpp_noexcept_function_type\ntemplate<typename GetterReturnType, typename GetterThisType>\nstruct GetterPolicy<GetterReturnType (GetterThisType::*)() const noexcept>\n : GetterPolicy<GetterReturnType (GetterThisType::*)() const> {};\n#endif\n\ntemplate<typename GetterReturnType, typename GetterThisType>\nstruct GetterPolicy<GetterReturnType (*)(const GetterThisType&)> {\n typedef GetterReturnType ReturnType;\n typedef GetterReturnType (*Context)(const GetterThisType&);\n\n typedef internal::BindingType<ReturnType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType, typename ReturnPolicy>\n static WireType get(const Context& context, const ClassType& ptr) {\n return Binding::toWireType(context(ptr), ReturnPolicy{});\n }\n\n static void* getContext(Context context) {\n return internal::getContext(context);\n }\n};\n\ntemplate<typename GetterReturnType, typename GetterThisType>\nstruct GetterPolicy<std::function<GetterReturnType(const GetterThisType&)>> {\n typedef GetterReturnType ReturnType;\n typedef std::function<GetterReturnType(const GetterThisType&)> Context;\n\n typedef internal::BindingType<ReturnType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType, typename ReturnPolicy>\n static WireType get(const Context& context, const ClassType& ptr) {\n return Binding::toWireType(context(ptr), ReturnPolicy{});\n }\n\n static void* getContext(const Context& context) {\n return internal::getContext(context);\n }\n};\n\ntemplate<typename Getter, typename GetterReturnType>\nstruct GetterPolicy<FunctionTag<Getter, GetterReturnType>> {\n typedef GetterReturnType ReturnType;\n typedef Getter Context;\n\n typedef internal::BindingType<ReturnType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType, typename ReturnPolicy>\n static WireType get(const Context& context, const ClassType& ptr) {\n return Binding::toWireType(context(ptr), ReturnPolicy{});\n }\n\n static void* getContext(const Context& context) {\n return internal::getContext(context);\n }\n};\n\ntemplate<typename T>\nstruct SetterPolicy;\n\ntemplate<typename SetterReturnType, typename SetterThisType, typename SetterArgumentType>\nstruct SetterPolicy<SetterReturnType (SetterThisType::*)(SetterArgumentType)> {\n typedef SetterArgumentType ArgumentType;\n typedef SetterReturnType (SetterThisType::*Context)(SetterArgumentType);\n\n typedef internal::BindingType<SetterArgumentType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType>\n static void set(const Context& context, ClassType& ptr, WireType wt) {\n (ptr.*context)(Binding::fromWireType(wt));\n }\n\n static void* getContext(Context context) {\n return internal::getContext(context);\n }\n};\n\n#ifdef __cpp_noexcept_function_type\ntemplate<typename SetterReturnType, typename SetterThisType, typename SetterArgumentType>\nstruct SetterPolicy<SetterReturnType (SetterThisType::*)(SetterArgumentType) noexcept>\n : SetterPolicy<SetterReturnType (SetterThisType::*)(SetterArgumentType)> {};\n#endif\n\ntemplate<typename SetterReturnType, typename SetterThisType, typename SetterArgumentType>\nstruct SetterPolicy<SetterReturnType (*)(SetterThisType&, SetterArgumentType)> {\n typedef SetterArgumentType ArgumentType;\n typedef SetterReturnType (*Context)(SetterThisType&, SetterArgumentType);\n\n typedef internal::BindingType<SetterArgumentType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType>\n static void set(const Context& context, ClassType& ptr, WireType wt) {\n context(ptr, Binding::fromWireType(wt));\n }\n\n static void* getContext(Context context) {\n return internal::getContext(context);\n }\n};\n\ntemplate<typename SetterReturnType, typename SetterThisType, typename SetterArgumentType>\nstruct SetterPolicy<std::function<SetterReturnType(SetterThisType&, SetterArgumentType)>> {\n typedef SetterArgumentType ArgumentType;\n typedef std::function<SetterReturnType(SetterThisType&, SetterArgumentType)> Context;\n\n typedef internal::BindingType<SetterArgumentType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType>\n static void set(const Context& context, ClassType& ptr, WireType wt) {\n context(ptr, Binding::fromWireType(wt));\n }\n\n static void* getContext(const Context& context) {\n return internal::getContext(context);\n }\n};\n\ntemplate<typename Setter, typename SetterArgumentType>\nstruct SetterPolicy<FunctionTag<Setter, SetterArgumentType>> {\n typedef SetterArgumentType ArgumentType;\n typedef Setter Context;\n\n typedef internal::BindingType<SetterArgumentType> Binding;\n typedef typename Binding::WireType WireType;\n\n template<typename ClassType>\n static void set(const Context& context, ClassType& ptr, WireType wt) {\n context(ptr, Binding::fromWireType(wt));\n }\n\n static void* getContext(const Context& context) {\n return internal::getContext(context);\n }\n};\n\nclass noncopyable {\nprotected:\n noncopyable() {}\n ~noncopyable() {}\nprivate:\n noncopyable(const noncopyable&) = delete;\n const noncopyable& operator=(const noncopyable&) = delete;\n};\n\ntemplate<typename ClassType, typename ElementType>\ntypename BindingType<ElementType>::WireType get_by_index(int index, ClassType& ptr) {\n return BindingType<ElementType>::toWireType(ptr[index], rvp::default_tag{});\n}\n\ntemplate<typename ClassType, typename ElementType>\nvoid set_by_index(int index, ClassType& ptr, typename BindingType<ElementType>::WireType wt) {\n ptr[index] = BindingType<ElementType>::fromWireType(wt);\n}\n\n} // end namespace internal\n\ntemplate<int Index>\nstruct index {\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// VALUE TUPLES\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename ClassType>\nclass value_array : public internal::noncopyable {\npublic:\n typedef ClassType class_type;\n\n value_array(const char* name) {\n using namespace internal;\n\n auto constructor = &raw_constructor<ClassType>;\n auto destructor = &raw_destructor<ClassType>;\n _embind_register_value_array(\n TypeID<ClassType>::get(),\n name,\n getSignature(constructor),\n reinterpret_cast<GenericFunction>(constructor),\n getSignature(destructor),\n reinterpret_cast<GenericFunction>(destructor));\n }\n\n ~value_array() {\n using namespace internal;\n _embind_finalize_value_array(TypeID<ClassType>::get());\n }\n\n template<typename InstanceType, typename ElementType>\n value_array& element(ElementType InstanceType::*field) {\n using namespace internal;\n\n auto getter = &MemberAccess<InstanceType, ElementType>\n ::template getWire<ClassType>;\n auto setter = &MemberAccess<InstanceType, ElementType>\n ::template setWire<ClassType>;\n\n _embind_register_value_array_element(\n TypeID<ClassType>::get(),\n TypeID<ElementType>::get(),\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getContext(field),\n TypeID<ElementType>::get(),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n getContext(field));\n return *this;\n }\n\n template<typename Getter, typename Setter>\n value_array& element(Getter getter, Setter setter) {\n using namespace internal;\n typedef GetterPolicy<Getter> GP;\n typedef SetterPolicy<Setter> SP;\n\n auto g = &GP::template get<ClassType, rvp::default_tag>;\n auto s = &SP::template set<ClassType>;\n\n _embind_register_value_array_element(\n TypeID<ClassType>::get(),\n TypeID<typename GP::ReturnType>::get(),\n getSignature(g),\n reinterpret_cast<GenericFunction>(g),\n GP::getContext(getter),\n TypeID<typename SP::ArgumentType>::get(),\n getSignature(s),\n reinterpret_cast<GenericFunction>(s),\n SP::getContext(setter));\n return *this;\n }\n\n template<int Index>\n value_array& element(index<Index>) {\n using namespace internal;\n ClassType* null = 0;\n typedef typename std::remove_reference<decltype((*null)[Index])>::type ElementType;\n auto getter = &internal::get_by_index<ClassType, ElementType>;\n auto setter = &internal::set_by_index<ClassType, ElementType>;\n\n _embind_register_value_array_element(\n TypeID<ClassType>::get(),\n TypeID<ElementType>::get(),\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n reinterpret_cast<void*>(Index),\n TypeID<ElementType>::get(),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n reinterpret_cast<void*>(Index));\n return *this;\n }\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// VALUE STRUCTS\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename ClassType>\nclass value_object : public internal::noncopyable {\npublic:\n typedef ClassType class_type;\n\n value_object(const char* name) {\n using namespace internal;\n\n auto ctor = &raw_constructor<ClassType>;\n auto dtor = &raw_destructor<ClassType>;\n\n _embind_register_value_object(\n TypeID<ClassType>::get(),\n name,\n getSignature(ctor),\n reinterpret_cast<GenericFunction>(ctor),\n getSignature(dtor),\n reinterpret_cast<GenericFunction>(dtor));\n }\n\n ~value_object() {\n using namespace internal;\n _embind_finalize_value_object(internal::TypeID<ClassType>::get());\n }\n\n template<typename InstanceType, typename FieldType>\n value_object& field(const char* fieldName, FieldType InstanceType::*field) {\n using namespace internal;\n\n auto getter = &MemberAccess<InstanceType, FieldType>\n ::template getWire<ClassType>;\n auto setter = &MemberAccess<InstanceType, FieldType>\n ::template setWire<ClassType>;\n\n _embind_register_value_object_field(\n TypeID<ClassType>::get(),\n fieldName,\n TypeID<FieldType>::get(),\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getContext(field),\n TypeID<FieldType>::get(),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n getContext(field));\n return *this;\n }\n\n template<typename InstanceType, typename ElementType, int N>\n value_object& field(const char* fieldName, ElementType (InstanceType::*field)[N]) {\n using namespace internal;\n\n typedef std::array<ElementType, N> FieldType;\n static_assert(sizeof(FieldType) == sizeof(ElementType[N]));\n\n auto getter = &MemberAccess<InstanceType, FieldType>\n ::template getWire<ClassType>;\n auto setter = &MemberAccess<InstanceType, FieldType>\n ::template setWire<ClassType>;\n\n _embind_register_value_object_field(\n TypeID<ClassType>::get(),\n fieldName,\n TypeID<FieldType>::get(),\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getContext(field),\n TypeID<FieldType>::get(),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n getContext(field));\n return *this;\n }\n\n template<typename Getter, typename Setter>\n value_object& field(\n const char* fieldName,\n Getter getter,\n Setter setter\n ) {\n using namespace internal;\n typedef GetterPolicy<Getter> GP;\n typedef SetterPolicy<Setter> SP;\n\n auto g = &GP::template get<ClassType, rvp::default_tag>;\n auto s = &SP::template set<ClassType>;\n\n _embind_register_value_object_field(\n TypeID<ClassType>::get(),\n fieldName,\n TypeID<typename GP::ReturnType>::get(),\n getSignature(g),\n reinterpret_cast<GenericFunction>(g),\n GP::getContext(getter),\n TypeID<typename SP::ArgumentType>::get(),\n getSignature(s),\n reinterpret_cast<GenericFunction>(s),\n SP::getContext(setter));\n return *this;\n }\n\n template<int Index>\n value_object& field(const char* fieldName, index<Index>) {\n using namespace internal;\n ClassType* null = 0;\n typedef typename std::remove_reference<decltype((*null)[Index])>::type ElementType;\n\n auto getter = &internal::get_by_index<ClassType, ElementType>;\n auto setter = &internal::set_by_index<ClassType, ElementType>;\n\n _embind_register_value_object_field(\n TypeID<ClassType>::get(),\n fieldName,\n TypeID<ElementType>::get(),\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n reinterpret_cast<void*>(Index),\n TypeID<ElementType>::get(),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n reinterpret_cast<void*>(Index));\n return *this;\n }\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// SMART POINTERS\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename PointerType>\nstruct default_smart_ptr_trait {\n static sharing_policy get_sharing_policy() {\n return sharing_policy::NONE;\n }\n\n static void* share(void* v) {\n return 0; // no sharing\n }\n\n static PointerType* construct_null() {\n return new PointerType;\n }\n};\n\n// specialize if you have a different pointer type\ntemplate<typename PointerType>\nstruct smart_ptr_trait : public default_smart_ptr_trait<PointerType> {\n typedef typename PointerType::element_type element_type;\n\n static element_type* get(const PointerType& ptr) {\n return ptr.get();\n }\n};\n\ntemplate<typename PointeeType>\nstruct smart_ptr_trait<std::shared_ptr<PointeeType>> {\n typedef std::shared_ptr<PointeeType> PointerType;\n typedef typename PointerType::element_type element_type;\n\n static element_type* get(const PointerType& ptr) {\n return ptr.get();\n }\n\n static sharing_policy get_sharing_policy() {\n return sharing_policy::BY_EMVAL;\n }\n\n static std::shared_ptr<PointeeType>* share(PointeeType* p, EM_VAL v) {\n return new std::shared_ptr<PointeeType>(\n p,\n val_deleter(val::take_ownership(v)));\n }\n\n static PointerType* construct_null() {\n return new PointerType;\n }\n\nprivate:\n class val_deleter {\n public:\n val_deleter() = delete;\n explicit val_deleter(val v)\n : v(v)\n {}\n void operator()(void const*) {\n v();\n // eventually we'll need to support emptied out val\n v = val::undefined();\n }\n private:\n val v;\n };\n};\n\n\n////////////////////////////////////////////////////////////////////////////////\n// CLASSES\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\nclass WrapperBase {\npublic:\n void setNotifyJSOnDestruction(bool notify) {\n notifyJSOnDestruction = notify;\n }\n\nprotected:\n bool notifyJSOnDestruction = false;\n};\n\n} // end namespace internal\n\n// abstract classes\ntemplate<typename T>\nclass wrapper : public T, public internal::WrapperBase {\npublic:\n typedef T class_type;\n\n template<typename... Args>\n explicit wrapper(val&& wrapped, Args&&... args)\n : T(std::forward<Args>(args)...)\n , wrapped(std::forward<val>(wrapped))\n {}\n\n ~wrapper() {\n if (notifyJSOnDestruction) {\n call<void>(\"__destruct\");\n }\n }\n\n template<typename ReturnType, typename... Args>\n ReturnType call(const char* name, Args&&... args) const {\n return wrapped.call<ReturnType>(name, std::forward<Args>(args)...);\n }\n\nprivate:\n val wrapped;\n};\n\n#define EMSCRIPTEN_WRAPPER(T) \\\ntemplate<typename... Args> \\\nT(::emscripten::val&& v, Args&&... args) \\\n : wrapper(std::forward<::emscripten::val>(v), std::forward<Args>(args)...) \\\n{}\n\nnamespace internal {\n\nstruct NoBaseClass {\n template<typename ClassType>\n static void verify() {\n }\n\n static TYPEID get() {\n return nullptr;\n }\n\n template<typename ClassType>\n static VoidFunctionPtr getUpcaster() {\n return nullptr;\n }\n\n template<typename ClassType>\n static VoidFunctionPtr getDowncaster() {\n return nullptr;\n }\n};\n\n// NOTE: this returns the class type, not the pointer type\ntemplate<typename T>\ninline TYPEID getActualType(T* ptr) {\n return getLightTypeID(*ptr);\n};\n\n} // end namespace internal\n\ntemplate<typename BaseClass>\nstruct base {\n typedef BaseClass class_type;\n\n template<typename ClassType>\n static void verify() {\n static_assert(!std::is_same<ClassType, BaseClass>::value, \"Base must not have same type as class\");\n static_assert(std::is_base_of<BaseClass, ClassType>::value, \"Derived class must derive from base\");\n }\n\n static internal::TYPEID get() {\n return internal::TypeID<BaseClass>::get();\n }\n\n template<typename ClassType>\n using Upcaster = BaseClass* (*)(ClassType*);\n\n template<typename ClassType>\n using Downcaster = ClassType* (*)(BaseClass*);\n\n template<typename ClassType>\n static Upcaster<ClassType> getUpcaster() {\n return &convertPointer<ClassType, BaseClass>;\n }\n\n template<typename ClassType>\n static Downcaster<ClassType> getDowncaster() {\n return &convertPointer<BaseClass, ClassType>;\n }\n\n template<typename From, typename To>\n static To* convertPointer(From* ptr) {\n return static_cast<To*>(ptr);\n }\n};\n\nnamespace internal {\n\ntemplate<typename WrapperType>\nval wrapped_extend(const std::string& name, const val& properties) {\n return val::take_ownership(_embind_create_inheriting_constructor(\n name.c_str(),\n TypeID<WrapperType>::get(),\n properties.as_handle()));\n}\n\n} // end namespace internal\n\nnamespace internal {\n\ntemplate<typename... Policies>\nstruct isPureVirtual;\n\ntemplate<typename... Rest>\nstruct isPureVirtual<pure_virtual, Rest...> {\n static constexpr bool value = true;\n};\n\ntemplate<typename T, typename... Rest>\nstruct isPureVirtual<T, Rest...> {\n static constexpr bool value = isPureVirtual<Rest...>::value;\n};\n\ntemplate<>\nstruct isPureVirtual<> {\n static constexpr bool value = false;\n};\n\nstruct DeduceArgumentsTag {};\n\n////////////////////////////////////////////////////////////////////////////\n// RegisterClassConstructor\n////////////////////////////////////////////////////////////////////////////\n\ntemplate <typename T>\nstruct RegisterClassConstructor;\n\ntemplate<typename ReturnType, typename... Args>\nstruct RegisterClassConstructor<ReturnType (*)(Args...)> {\n\n template <typename ClassType, typename... Policies>\n static void invoke(ReturnType (*factory)(Args...)) {\n typename WithPolicies<allow_raw_pointers, Policies...>::template ArgTypeList<ReturnType, Args...> args;\n using ReturnPolicy = rvp::take_ownership;\n auto invoke = &Invoker<ReturnPolicy, ReturnType, Args...>::invoke;\n _embind_register_class_constructor(\n TypeID<ClassType>::get(),\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(factory));\n }\n};\n\ntemplate<typename ReturnType, typename... Args>\nstruct RegisterClassConstructor<std::function<ReturnType (Args...)>> {\n\n template <typename ClassType, typename... Policies>\n static void invoke(std::function<ReturnType (Args...)> factory) {\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, Args...> args;\n using ReturnPolicy = rvp::take_ownership;\n auto invoke = &FunctorInvoker<ReturnPolicy, decltype(factory), ReturnType, Args...>::invoke;\n _embind_register_class_constructor(\n TypeID<ClassType>::get(),\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(getContext(factory)));\n }\n};\n\ntemplate<typename Callable, typename ReturnType, typename... Args>\nstruct RegisterClassConstructor<FunctionTag<Callable, ReturnType (Args...)>> {\n template <typename ClassType, typename... Policies>\n static void invoke(Callable& factory) {\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, Args...> args;\n using ReturnPolicy = rvp::take_ownership;\n auto invoke = &FunctorInvoker<ReturnPolicy, decltype(factory), ReturnType, Args...>::invoke;\n _embind_register_class_constructor(\n TypeID<ClassType>::get(),\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(getContext(factory)));\n }\n};\n\n////////////////////////////////////////////////////////////////////////////\n// RegisterClassMethod\n////////////////////////////////////////////////////////////////////////////\n\ntemplate <typename T>\nstruct RegisterClassMethod;\n\ntemplate<typename ClassType, typename ReturnType, typename... Args>\nstruct RegisterClassMethod<ReturnType (ClassType::*)(Args...)> {\n\n template <typename CT, typename... Policies>\n static void invoke(const char* methodName,\n ReturnType (ClassType::*memberFunction)(Args...)) {\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = MethodInvoker<ReturnPolicy, decltype(memberFunction), ReturnType, ClassType*, Args...>::invoke;\n\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, AllowedRawPointer<ClassType>, Args...> args;\n _embind_register_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n getContext(memberFunction),\n isPureVirtual<Policies...>::value,\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n }\n};\n\n#ifdef __cpp_noexcept_function_type\ntemplate<typename ClassType, typename ReturnType, typename... Args>\nstruct RegisterClassMethod<ReturnType (ClassType::*)(Args...) noexcept>\n : RegisterClassMethod<ReturnType (ClassType::*)(Args...)> {};\n#endif\n\ntemplate<typename ClassType, typename ReturnType, typename... Args>\nstruct RegisterClassMethod<ReturnType (ClassType::*)(Args...) const> {\n\n template <typename CT, typename... Policies>\n static void invoke(const char* methodName,\n ReturnType (ClassType::*memberFunction)(Args...) const) {\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = MethodInvoker<ReturnPolicy, decltype(memberFunction), ReturnType, const ClassType*, Args...>::invoke;\n\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, AllowedRawPointer<const ClassType>, Args...> args;\n _embind_register_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n getContext(memberFunction),\n isPureVirtual<Policies...>::value,\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n }\n};\n\n#ifdef __cpp_noexcept_function_type\ntemplate<typename ClassType, typename ReturnType, typename... Args>\nstruct RegisterClassMethod<ReturnType (ClassType::*)(Args...) const noexcept>\n : RegisterClassMethod<ReturnType (ClassType::*)(Args...) const> {};\n#endif\n\ntemplate<typename ReturnType, typename ThisType, typename... Args>\nstruct RegisterClassMethod<ReturnType (*)(ThisType, Args...)> {\n\n template <typename ClassType, typename... Policies>\n static void invoke(const char* methodName,\n ReturnType (*function)(ThisType, Args...)) {\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, ThisType, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = FunctionInvoker<ReturnPolicy, decltype(function), ReturnType, ThisType, Args...>::invoke;\n _embind_register_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n getContext(function),\n false,\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n }\n};\n\n#ifdef __cpp_noexcept_function_type\ntemplate<typename ReturnType, typename ThisType, typename... Args>\nstruct RegisterClassMethod<ReturnType (*)(ThisType, Args...) noexcept>\n : RegisterClassMethod<ReturnType (*)(ThisType, Args...)> {};\n#endif\n\ntemplate<typename ReturnType, typename ThisType, typename... Args>\nstruct RegisterClassMethod<std::function<ReturnType (ThisType, Args...)>> {\n\n template <typename ClassType, typename... Policies>\n static void invoke(const char* methodName,\n std::function<ReturnType (ThisType, Args...)> function) {\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, ThisType, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = FunctorInvoker<ReturnPolicy, decltype(function), ReturnType, ThisType, Args...>::invoke;\n _embind_register_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n getContext(function),\n false,\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n }\n};\n\ntemplate<typename Callable, typename ReturnType, typename ThisType, typename... Args>\nstruct RegisterClassMethod<FunctionTag<Callable, ReturnType (ThisType, Args...)>> {\n\n template <typename ClassType, typename... Policies>\n static void invoke(const char* methodName,\n Callable& callable) {\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, ThisType, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = FunctorInvoker<ReturnPolicy, decltype(callable), ReturnType, ThisType, Args...>::invoke;\n _embind_register_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n getContext(callable),\n false,\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n }\n};\n\n} // end namespace internal\n\ntemplate<typename... ConstructorArgs>\nstruct constructor {\n};\n\ntemplate<typename ClassType, typename BaseSpecifier = internal::NoBaseClass>\nclass class_ {\npublic:\n typedef ClassType class_type;\n typedef BaseSpecifier base_specifier;\n\n class_() = delete;\n\n EMSCRIPTEN_ALWAYS_INLINE explicit class_(const char* name) {\n using namespace internal;\n\n BaseSpecifier::template verify<ClassType>();\n\n auto _getActualType = &getActualType<ClassType>;\n auto upcast = BaseSpecifier::template getUpcaster<ClassType>();\n auto downcast = BaseSpecifier::template getDowncaster<ClassType>();\n auto destructor = &raw_destructor<ClassType>;\n\n _embind_register_class(\n TypeID<ClassType>::get(),\n TypeID<AllowedRawPointer<ClassType>>::get(),\n TypeID<AllowedRawPointer<const ClassType>>::get(),\n BaseSpecifier::get(),\n getSignature(_getActualType),\n reinterpret_cast<GenericFunction>(_getActualType),\n getSignature(upcast),\n reinterpret_cast<GenericFunction>(upcast),\n getSignature(downcast),\n reinterpret_cast<GenericFunction>(downcast),\n name,\n getSignature(destructor),\n reinterpret_cast<GenericFunction>(destructor));\n }\n\n template<typename PointerType>\n EMSCRIPTEN_ALWAYS_INLINE const class_& smart_ptr(const char* name) const {\n using namespace internal;\n\n typedef smart_ptr_trait<PointerType> PointerTrait;\n typedef typename PointerTrait::element_type PointeeType;\n\n static_assert(std::is_same<ClassType, typename std::remove_cv<PointeeType>::type>::value, \"smart pointer must point to this class\");\n\n auto get = &PointerTrait::get;\n auto construct_null = &PointerTrait::construct_null;\n auto share = &PointerTrait::share;\n auto destructor = &raw_destructor<PointerType>;\n\n _embind_register_smart_ptr(\n TypeID<PointerType>::get(),\n TypeID<PointeeType>::get(),\n name,\n PointerTrait::get_sharing_policy(),\n getSignature(get),\n reinterpret_cast<GenericFunction>(get),\n getSignature(construct_null),\n reinterpret_cast<GenericFunction>(construct_null),\n getSignature(share),\n reinterpret_cast<GenericFunction>(share),\n getSignature(destructor),\n reinterpret_cast<GenericFunction>(destructor));\n return *this;\n };\n\n template<typename... ConstructorArgs, typename... Policies>\n EMSCRIPTEN_ALWAYS_INLINE const class_& constructor(Policies... policies) const {\n return constructor(\n &internal::operator_new<ClassType, ConstructorArgs...>,\n policies...);\n }\n\n template<typename Signature = internal::DeduceArgumentsTag, typename Callable, typename... Policies>\n EMSCRIPTEN_ALWAYS_INLINE const class_& constructor(Callable callable, Policies...) const {\n\n using invoker = internal::RegisterClassConstructor<\n typename std::conditional<std::is_same<Signature, internal::DeduceArgumentsTag>::value,\n Callable,\n internal::FunctionTag<Callable, Signature>>::type>;\n\n invoker::template invoke<ClassType, Policies...>(callable);\n return *this;\n }\n\n template<typename SmartPtr, typename... Args, typename... Policies>\n EMSCRIPTEN_ALWAYS_INLINE const class_& smart_ptr_constructor(const char* smartPtrName, SmartPtr (*factory)(Args...), Policies...) const {\n using namespace internal;\n\n smart_ptr<SmartPtr>(smartPtrName);\n\n typename WithPolicies<Policies...>::template ArgTypeList<SmartPtr, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<SmartPtr, return_value_policy::take_ownership>::tag;\n auto invoke = &Invoker<ReturnPolicy, SmartPtr, Args...>::invoke;\n _embind_register_class_constructor(\n TypeID<ClassType>::get(),\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(factory));\n return *this;\n }\n\n template<typename WrapperType, typename... ConstructorArgs>\n EMSCRIPTEN_ALWAYS_INLINE const class_& allow_subclass(\n const char* wrapperClassName,\n ::emscripten::constructor<ConstructorArgs...> = ::emscripten::constructor<>()\n ) const {\n using namespace internal;\n\n auto cls = class_<WrapperType, base<ClassType>>(wrapperClassName)\n .function(\"notifyOnDestruction\", select_overload<void(WrapperType&)>([](WrapperType& wrapper) {\n wrapper.setNotifyJSOnDestruction(true);\n }))\n ;\n\n return\n class_function(\n \"implement\",\n &wrapped_new<WrapperType*, WrapperType, val, ConstructorArgs...>,\n allow_raw_pointer<ret_val>(), nonnull<ret_val>())\n .class_function(\n \"extend\",\n &wrapped_extend<WrapperType>)\n ;\n }\n\n template<typename WrapperType, typename PointerType, typename... ConstructorArgs>\n EMSCRIPTEN_ALWAYS_INLINE const class_& allow_subclass(\n const char* wrapperClassName,\n const char* pointerName,\n ::emscripten::constructor<ConstructorArgs...> = ::emscripten::constructor<>()\n ) const {\n using namespace internal;\n\n auto cls = class_<WrapperType, base<ClassType>>(wrapperClassName)\n .function(\"notifyOnDestruction\", select_overload<void(WrapperType&)>([](WrapperType& wrapper) {\n wrapper.setNotifyJSOnDestruction(true);\n }))\n .template smart_ptr<PointerType>(pointerName)\n ;\n\n return\n class_function(\n \"implement\",\n &wrapped_new<PointerType, WrapperType, val, ConstructorArgs...>,\n allow_raw_pointer<ret_val>())\n .class_function(\n \"extend\",\n &wrapped_extend<WrapperType>)\n ;\n }\n\n template<typename Signature = internal::DeduceArgumentsTag, typename Callable, typename... Policies>\n EMSCRIPTEN_ALWAYS_INLINE const class_& function(const char* methodName, Callable callable, Policies...) const {\n using invoker = internal::RegisterClassMethod<\n typename std::conditional<std::is_same<Signature, internal::DeduceArgumentsTag>::value,\n Callable,\n internal::FunctionTag<Callable, Signature>>::type>;\n\n invoker::template invoke<ClassType, Policies...>(methodName, callable);\n return *this;\n }\n\n template<\n typename FieldType,\n typename... Policies,\n // Prevent the template from wrongly matching the getter function\n // overload.\n typename = typename std::enable_if<\n !std::is_function<FieldType>::value &&\n internal::conjunction<internal::isPolicy<Policies>...>::value>::type>\n EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, const FieldType ClassType::*field, Policies...) const {\n using namespace internal;\n using ReturnPolicy = GetReturnValuePolicy<FieldType, Policies...>::tag;\n typename WithPolicies<Policies...>::template ArgTypeList<FieldType> returnType;\n\n auto getter = &MemberAccess<ClassType, FieldType>::template getWire<ClassType, ReturnPolicy>;\n _embind_register_class_property(\n TypeID<ClassType>::get(),\n fieldName,\n returnType.getTypes()[0],\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getContext(field),\n 0,\n 0,\n 0,\n 0);\n return *this;\n }\n\n template<\n typename FieldType,\n typename... Policies,\n // Prevent the template from wrongly matching the getter function\n // overload.\n typename = typename std::enable_if<\n !std::is_function<FieldType>::value &&\n internal::conjunction<internal::isPolicy<Policies>...>::value>::type>\n EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, FieldType ClassType::*field, Policies...) const {\n using namespace internal;\n using ReturnPolicy = GetReturnValuePolicy<FieldType, Policies...>::tag;\n typename WithPolicies<Policies...>::template ArgTypeList<FieldType> returnType;\n\n auto getter = &MemberAccess<ClassType, FieldType>::template getWire<ClassType, ReturnPolicy>;\n auto setter = &MemberAccess<ClassType, FieldType>::template setWire<ClassType>;\n _embind_register_class_property(\n TypeID<ClassType>::get(),\n fieldName,\n returnType.getTypes()[0],\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getContext(field),\n returnType.getTypes()[0],\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter),\n getContext(field));\n return *this;\n }\n\n template<\n typename PropertyType = internal::DeduceArgumentsTag,\n typename Getter,\n typename... Policies,\n // Prevent the template from wrongly matching the getter/setter overload\n // of this function.\n typename = typename std::enable_if<\n internal::conjunction<internal::isPolicy<Policies>...>::value>::type>\n EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, Getter getter, Policies...) const {\n using namespace internal;\n\n typedef GetterPolicy<\n typename std::conditional<std::is_same<PropertyType, internal::DeduceArgumentsTag>::value,\n Getter,\n FunctionTag<Getter, PropertyType>>::type> GP;\n using ReturnPolicy = GetReturnValuePolicy<typename GP::ReturnType, Policies...>::tag;\n auto gter = &GP::template get<ClassType, ReturnPolicy>;\n typename WithPolicies<Policies...>::template ArgTypeList<typename GP::ReturnType> returnType;\n _embind_register_class_property(\n TypeID<ClassType>::get(),\n fieldName,\n returnType.getTypes()[0],\n getSignature(gter),\n reinterpret_cast<GenericFunction>(gter),\n GP::getContext(getter),\n 0,\n 0,\n 0,\n 0);\n return *this;\n }\n\n template<\n typename PropertyType = internal::DeduceArgumentsTag,\n typename Getter,\n typename Setter,\n typename... Policies,\n // Similar to the other variadic property overloads this can greedily\n // match the wrong overload so we need to ensure the setter is not a\n // policy argument.\n typename = typename std::enable_if<!internal::isPolicy<Setter>::value>::type>\n EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, Getter getter, Setter setter, Policies...) const {\n using namespace internal;\n\n typedef GetterPolicy<\n typename std::conditional<std::is_same<PropertyType, internal::DeduceArgumentsTag>::value,\n Getter,\n FunctionTag<Getter, PropertyType>>::type> GP;\n typedef SetterPolicy<\n typename std::conditional<std::is_same<PropertyType, internal::DeduceArgumentsTag>::value,\n Setter,\n FunctionTag<Setter, PropertyType>>::type> SP;\n\n\n using ReturnPolicy = GetReturnValuePolicy<typename GP::ReturnType, Policies...>::tag;\n auto gter = &GP::template get<ClassType, ReturnPolicy>;\n auto ster = &SP::template set<ClassType>;\n\n typename WithPolicies<Policies...>::template ArgTypeList<typename GP::ReturnType> returnType;\n // XXX: This currently applies all the polices (including return value polices) to the\n // setter function argument to allow pointers. Using return value polices doesn't really\n // make sense on an argument, but we don't have separate argument policies yet.\n typename WithPolicies<Policies...>::template ArgTypeList<typename SP::ArgumentType> argType;\n\n _embind_register_class_property(\n TypeID<ClassType>::get(),\n fieldName,\n returnType.getTypes()[0],\n getSignature(gter),\n reinterpret_cast<GenericFunction>(gter),\n GP::getContext(getter),\n argType.getTypes()[0],\n getSignature(ster),\n reinterpret_cast<GenericFunction>(ster),\n SP::getContext(setter));\n return *this;\n }\n\n template<typename ReturnType, typename... Args, typename... Policies>\n EMSCRIPTEN_ALWAYS_INLINE const class_& class_function(const char* methodName, ReturnType (*classMethod)(Args...), Policies...) const {\n using namespace internal;\n\n typename WithPolicies<Policies...>::template ArgTypeList<ReturnType, Args...> args;\n using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;\n auto invoke = internal::Invoker<ReturnPolicy, ReturnType, Args...>::invoke;\n _embind_register_class_class_function(\n TypeID<ClassType>::get(),\n methodName,\n args.getCount(),\n args.getTypes(),\n getSignature(invoke),\n reinterpret_cast<GenericFunction>(invoke),\n reinterpret_cast<GenericFunction>(classMethod),\n isAsync<Policies...>::value,\n isNonnullReturn<Policies...>::value);\n return *this;\n }\n\n template<typename FieldType>\n EMSCRIPTEN_ALWAYS_INLINE const class_& class_property(const char* name, const FieldType* field) const {\n using namespace internal;\n\n auto getter = &GlobalAccess<FieldType>::get;\n _embind_register_class_class_property(\n TypeID<ClassType>::get(),\n name,\n TypeID<FieldType>::get(),\n field,\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n 0,\n 0);\n return *this;\n }\n\n template<typename FieldType>\n EMSCRIPTEN_ALWAYS_INLINE const class_& class_property(const char* name, FieldType* field) const {\n using namespace internal;\n\n auto getter = &GlobalAccess<FieldType>::get;\n auto setter = &GlobalAccess<FieldType>::set;\n _embind_register_class_class_property(\n TypeID<ClassType>::get(),\n name,\n TypeID<FieldType>::get(),\n field,\n getSignature(getter),\n reinterpret_cast<GenericFunction>(getter),\n getSignature(setter),\n reinterpret_cast<GenericFunction>(setter));\n return *this;\n }\n};\n\n#if __cplusplus >= 201703L\ntemplate<typename T>\nvoid register_optional() {\n // Optional types are automatically registered for some internal types so\n // only run the register method once so we don't conflict with a user's\n // bindings if they also register the optional type.\n thread_local bool hasRun;\n if (hasRun) {\n return;\n }\n hasRun = true;\n internal::_embind_register_optional(\n internal::TypeID<std::optional<T>>::get(),\n internal::TypeID<typename std::remove_pointer<T>::type>::get());\n}\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n// VECTORS\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\ntemplate<typename VectorType>\nstruct VectorAccess {\n// This nearly duplicated code is used for generating more specific TypeScript\n// types when using more modern C++ versions.\n#if __cplusplus >= 201703L\n static std::optional<typename VectorType::value_type> get(\n const VectorType& v,\n unsigned int index\n ) {\n if (index < v.size()) {\n return v[index];\n } else {\n return {};\n }\n }\n#else\n static val get(\n const VectorType& v,\n unsigned int index\n ) {\n if (index < v.size()) {\n return val(v[index], allow_raw_pointers());\n } else {\n return val::undefined();\n }\n }\n#endif\n\n static bool set(\n VectorType& v,\n unsigned int index,\n const typename VectorType::value_type& value\n ) {\n v[index] = value;\n return true;\n }\n\n static unsigned int size(const VectorType& v) {\n return v.size();\n }\n\n static void resize(\n VectorType& v,\n unsigned int len,\n const typename VectorType::value_type& value\n ) {\n v.resize(len, value);\n }\n\n static void push_back(\n VectorType& v,\n typename VectorType::value_type&& value\n ) {\n v.push_back(std::move(value));\n }\n};\n\n} // end namespace internal\n\ntemplate<typename T, class Allocator=std::allocator<T>>\nclass_<std::vector<T, Allocator>> register_vector(const char* name) {\n typedef std::vector<T, Allocator> VecType;\n#if __cplusplus >= 201703L\n register_optional<T>();\n#endif\n\n return class_<VecType>(name)\n .template constructor<>()\n .function(\"push_back\", internal::VectorAccess<VecType>::push_back, allow_raw_pointers())\n .function(\"resize\", internal::VectorAccess<VecType>::resize, allow_raw_pointers())\n .function(\"size\", internal::VectorAccess<VecType>::size, allow_raw_pointers())\n .function(\"get\", internal::VectorAccess<VecType>::get, allow_raw_pointers())\n .function(\"set\", internal::VectorAccess<VecType>::set, allow_raw_pointers())\n ;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// MAPS\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\ntemplate<typename MapType>\nstruct MapAccess {\n// This nearly duplicated code is used for generating more specific TypeScript\n// types when using more modern C++ versions.\n#if __cplusplus >= 201703L\n static std::optional<typename MapType::mapped_type> get(\n const MapType& m,\n const typename MapType::key_type& k\n ) {\n auto i = m.find(k);\n if (i == m.end()) {\n return {};\n } else {\n return i->second;\n }\n }\n#else\n static val get(\n const MapType& m,\n const typename MapType::key_type& k\n ) {\n auto i = m.find(k);\n if (i == m.end()) {\n return val::undefined();\n } else {\n return val(i->second);\n }\n }\n#endif\n\n static void set(\n MapType& m,\n const typename MapType::key_type& k,\n const typename MapType::mapped_type& v\n ) {\n m[k] = v;\n }\n\n static std::vector<typename MapType::key_type> keys(\n const MapType& m\n ) {\n std::vector<typename MapType::key_type> keys;\n keys.reserve(m.size());\n for (const auto& pair : m) {\n keys.push_back(pair.first);\n }\n return keys;\n }\n\n static unsigned int size(const MapType& m) {\n return m.size();\n }\n};\n\n} // end namespace internal\n\ntemplate<typename K, typename V, class Compare = std::less<K>,\n class Allocator = std::allocator<std::pair<const K, V>>>\nclass_<std::map<K, V, Compare, Allocator>> register_map(const char* name) {\n typedef std::map<K,V, Compare, Allocator> MapType;\n#if __cplusplus >= 201703L\n register_optional<V>();\n#endif\n\n return class_<MapType>(name)\n .template constructor<>()\n .function(\"size\", internal::MapAccess<MapType>::size)\n .function(\"get\", internal::MapAccess<MapType>::get)\n .function(\"set\", internal::MapAccess<MapType>::set)\n .function(\"keys\", internal::MapAccess<MapType>::keys)\n ;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// std::optional\n////////////////////////////////////////////////////////////////////////////////\n\n#if __cplusplus >= 201703L\nnamespace internal {\ntemplate <typename T>\nstruct BindingType<std::optional<T>> {\n using ValBinding = BindingType<val>;\n using WireType = ValBinding::WireType;\n\n template<typename ReturnPolicy = void>\n static WireType toWireType(std::optional<T> value, rvp::default_tag) {\n if (value) {\n return ValBinding::toWireType(val(*value, allow_raw_pointers()), rvp::default_tag{});\n }\n return ValBinding::toWireType(val::undefined(), rvp::default_tag{});\n }\n\n\n static std::optional<T> fromWireType(WireType value) {\n val optional = val::take_ownership(value);\n if (optional.isUndefined()) {\n return {};\n }\n return optional.as<T>();\n }\n};\n} // end namespace internal\n#endif\n\n\n////////////////////////////////////////////////////////////////////////////////\n// ENUMS\n////////////////////////////////////////////////////////////////////////////////\n\ntemplate<typename EnumType>\nclass enum_ {\npublic:\n typedef EnumType enum_type;\n\n enum_(const char* name) {\n using namespace internal;\n _embind_register_enum(\n internal::TypeID<EnumType>::get(),\n name,\n sizeof(EnumType),\n std::is_signed<typename std::underlying_type<EnumType>::type>::value);\n }\n\n enum_& value(const char* name, EnumType value) {\n using namespace internal;\n // TODO: there's still an issue here.\n // if EnumType is an unsigned long, then JS may receive it as a signed long\n static_assert(sizeof(value) <= sizeof(internal::GenericEnumValue), \"enum type must fit in a GenericEnumValue\");\n\n _embind_register_enum_value(\n internal::TypeID<EnumType>::get(),\n name,\n static_cast<internal::GenericEnumValue>(value));\n return *this;\n }\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// CONSTANTS\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace internal {\n\ntemplate<typename T> double asGenericValue(T t) {\n return static_cast<double>(t);\n}\n\ntemplate<typename T> uintptr_t asGenericValue(T* p) {\n return reinterpret_cast<uintptr_t>(p);\n}\n\n}\n\ntemplate<typename ConstantType>\nvoid constant(const char* name, const ConstantType& v) {\n using namespace internal;\n typedef BindingType<const ConstantType&> BT;\n _embind_register_constant(\n name,\n TypeID<const ConstantType&>::get(),\n static_cast<double>(asGenericValue(BT::toWireType(v, rvp::default_tag{}))));\n}\n\ntemplate <typename T>\ninline void register_type(const char* name) {\n using namespace internal;\n _embind_register_user_type(TypeID<T>::get(), name);\n}\n\ntemplate <typename T>\ninline void register_type(const char* name, const char* definition) {\n using namespace internal;\n _embind_register_user_type_definition(TypeID<T>::get(), name, definition);\n}\n\n// EMSCRIPTEN_BINDINGS creates a static struct to initialize the binding which\n// will get included in the program if the translation unit in which it is\n// defined gets linked into the program. Using a C++ constructor here ensures it\n// occurs after any other C++ constructors in this file, which is not true for\n// __attribute__((constructor)) (they run before C++ constructors in the same\n// file).\n#define EMSCRIPTEN_BINDINGS(name) \\\n static void embind_init_##name(); \\\n static struct EmBindInit_##name : emscripten::internal::InitFunc { \\\n EmBindInit_##name() : InitFunc(embind_init_##name) {} \\\n } EmBindInit_##name##_instance; \\\n static void embind_init_##name()\n\n} // end namespace emscripten\n","// -*- C++ -*-\n//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP_TYPEINFO\n#define _LIBCPP_TYPEINFO\n\n/*\n\n typeinfo synopsis\n\nnamespace std {\n\nclass type_info\n{\npublic:\n virtual ~type_info();\n\n bool operator==(const type_info& rhs) const noexcept; // constexpr since C++23\n bool operator!=(const type_info& rhs) const noexcept; // removed in C++20\n\n bool before(const type_info& rhs) const noexcept;\n size_t hash_code() const noexcept;\n const char* name() const noexcept;\n\n type_info(const type_info& rhs) = delete;\n type_info& operator=(const type_info& rhs) = delete;\n};\n\nclass bad_cast\n : public exception\n{\npublic:\n bad_cast() noexcept;\n bad_cast(const bad_cast&) noexcept;\n bad_cast& operator=(const bad_cast&) noexcept;\n virtual const char* what() const noexcept;\n};\n\nclass bad_typeid\n : public exception\n{\npublic:\n bad_typeid() noexcept;\n bad_typeid(const bad_typeid&) noexcept;\n bad_typeid& operator=(const bad_typeid&) noexcept;\n virtual const char* what() const noexcept;\n};\n\n} // std\n\n*/\n\n#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n# include <__cxx03/typeinfo>\n#else\n# include <__config>\n# include <__cstddef/size_t.h>\n# include <__exception/exception.h>\n# include <__type_traits/integral_constant.h>\n# include <__type_traits/is_constant_evaluated.h>\n# include <__verbose_abort>\n# include <cstdint>\n# include <version>\n\n# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n# endif\n\n# if defined(_LIBCPP_ABI_VCRUNTIME)\n# include <vcruntime_typeinfo.h>\n# else\n\nnamespace std // purposefully not using versioning namespace\n{\n\n# if defined(_LIBCPP_ABI_MICROSOFT)\n\nclass _LIBCPP_EXPORTED_FROM_ABI type_info {\n type_info& operator=(const type_info&);\n type_info(const type_info&);\n\n mutable struct {\n const char* __undecorated_name;\n const char __decorated_name[1];\n } __data;\n\n int __compare(const type_info& __rhs) const _NOEXCEPT;\n\npublic:\n virtual ~type_info();\n\n const char* name() const _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI bool before(const type_info& __arg) const _NOEXCEPT { return __compare(__arg) < 0; }\n\n size_t hash_code() const _NOEXCEPT;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {\n // When evaluated in a constant expression, both type infos simply can't come\n // from different translation units, so it is sufficient to compare their addresses.\n if (__libcpp_is_constant_evaluated()) {\n return this == &__arg;\n }\n return __compare(__arg) == 0;\n }\n\n# if _LIBCPP_STD_VER <= 17\n _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }\n# endif\n};\n\n# else // !defined(_LIBCPP_ABI_MICROSOFT)\n\n// ========================================================================== //\n// Implementations\n// ========================================================================== //\n// ------------------------------------------------------------------------- //\n// Unique\n// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 1)\n// ------------------------------------------------------------------------- //\n// This implementation of type_info assumes a unique copy of the RTTI for a\n// given type inside a program. This is a valid assumption when abiding to the\n// Itanium ABI (http://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-components).\n// Under this assumption, we can always compare the addresses of the type names\n// to implement equality-comparison of type_infos instead of having to perform\n// a deep string comparison.\n// -------------------------------------------------------------------------- //\n// NonUnique\n// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 2)\n// -------------------------------------------------------------------------- //\n// This implementation of type_info does not assume there is always a unique\n// copy of the RTTI for a given type inside a program. For various reasons\n// the linker may have failed to merge every copy of a types RTTI\n// (For example: -Bsymbolic or llvm.org/PR37398). Under this assumption, two\n// type_infos are equal if their addresses are equal or if a deep string\n// comparison is equal.\n// -------------------------------------------------------------------------- //\n// NonUniqueARMRTTIBit\n// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 3)\n// -------------------------------------------------------------------------- //\n// This implementation is specific to ARM64 on Apple platforms.\n//\n// This implementation of type_info does not assume always a unique copy of\n// the RTTI for a given type inside a program. When constructing the type_info,\n// the compiler packs the pointer to the type name into a uintptr_t and reserves\n// the high bit of that pointer, which is assumed to be free for use under that\n// ABI. If that high bit is set, that specific copy of the RTTI can't be assumed\n// to be unique within the program. If the high bit is unset, then the RTTI can\n// be assumed to be unique within the program.\n//\n// When comparing type_infos, if both RTTIs can be assumed to be unique, it\n// suffices to compare their addresses. If both the RTTIs can't be assumed to\n// be unique, we must perform a deep string comparison of the type names.\n// However, if one of the RTTIs is guaranteed unique and the other one isn't,\n// then both RTTIs are necessarily not to be considered equal.\n//\n// The intent of this design is to remove the need for weak symbols. Specifically,\n// if a type would normally have a default-visibility RTTI emitted as a weak\n// symbol, it is given hidden visibility instead and the non-unique bit is set.\n// Otherwise, types declared with hidden visibility are always considered to have\n// a unique RTTI: the RTTI is emitted with linkonce_odr linkage and is assumed\n// to be deduplicated by the linker within the linked image. Across linked image\n// boundaries, such types are thus considered different types.\n\n// This value can be overriden in the __config_site. When it's not overriden,\n// we pick a default implementation based on the platform here.\n# ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION\n\n// Windows and AIX binaries can't merge typeinfos, so use the NonUnique implementation.\n# if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)\n# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2\n\n// On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.\n# elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)\n# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3\n\n// On all other platforms, assume the Itanium C++ ABI and use the Unique implementation.\n# else\n# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1\n# endif\n# endif\n\nstruct __type_info_implementations {\n struct __string_impl_base {\n typedef const char* __type_name_t;\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static const char*\n __type_name_to_string(__type_name_t __v) _NOEXCEPT {\n return __v;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static __type_name_t\n __string_to_type_name(const char* __v) _NOEXCEPT {\n return __v;\n }\n };\n\n struct __unique_impl : __string_impl_base {\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {\n return reinterpret_cast<size_t>(__v);\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n return __lhs == __rhs;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n return __lhs < __rhs;\n }\n };\n\n struct __non_unique_impl : __string_impl_base {\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __ptr) _NOEXCEPT {\n size_t __hash = 5381;\n while (unsigned char __c = static_cast<unsigned char>(*__ptr++))\n __hash = (__hash * 33) ^ __c;\n return __hash;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n return __lhs == __rhs || __builtin_strcmp(__lhs, __rhs) == 0;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n return __builtin_strcmp(__lhs, __rhs) < 0;\n }\n };\n\n struct __non_unique_arm_rtti_bit_impl {\n typedef uintptr_t __type_name_t;\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static const char* __type_name_to_string(__type_name_t __v) _NOEXCEPT {\n return reinterpret_cast<const char*>(__v & ~__non_unique_rtti_bit::value);\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static __type_name_t __string_to_type_name(const char* __v) _NOEXCEPT {\n return reinterpret_cast<__type_name_t>(__v);\n }\n\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {\n if (__is_type_name_unique(__v))\n return __v;\n return __non_unique_impl::__hash(__type_name_to_string(__v));\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n if (__lhs == __rhs)\n return true;\n if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))\n // Either both are unique and have a different address, or one of them\n // is unique and the other one isn't. In both cases they are unequal.\n return false;\n return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) == 0;\n }\n _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {\n if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))\n return __lhs < __rhs;\n return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) < 0;\n }\n\n private:\n // The unique bit is the top bit. It is expected that __type_name_t is 64 bits when\n // this implementation is actually used.\n typedef integral_constant<__type_name_t, (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))>\n __non_unique_rtti_bit;\n\n _LIBCPP_HIDE_FROM_ABI static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT {\n return !(__lhs & __non_unique_rtti_bit::value);\n }\n };\n\n typedef\n# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1\n __unique_impl\n# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2\n __non_unique_impl\n# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3\n __non_unique_arm_rtti_bit_impl\n# else\n# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION\n# endif\n __impl;\n};\n\n# if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__)\n# if __has_feature(ptrauth_type_info_vtable_pointer_discrimination)\n# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \\\n [[_Clang::__ptrauth_vtable_pointer__(process_independent, address_discrimination, type_discrimination)]]\n# else\n# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \\\n [[_Clang::__ptrauth_vtable_pointer__( \\\n process_independent, no_address_discrimination, no_extra_discrimination)]]\n# endif\n# else\n# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH\n# endif\n\nclass _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH type_info {\n type_info& operator=(const type_info&);\n type_info(const type_info&);\n\nprotected:\n typedef __type_info_implementations::__impl __impl;\n\n __impl::__type_name_t __type_name;\n\n _LIBCPP_HIDE_FROM_ABI explicit type_info(const char* __n) : __type_name(__impl::__string_to_type_name(__n)) {}\n\npublic:\n virtual ~type_info();\n\n _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { return __impl::__type_name_to_string(__type_name); }\n\n _LIBCPP_HIDE_FROM_ABI bool before(const type_info& __arg) const _NOEXCEPT {\n return __impl::__lt(__type_name, __arg.__type_name);\n }\n\n _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __impl::__hash(__type_name); }\n\n // XXX Emscripten: adding `always_inline` fixes\n // https://github.com/emscripten-core/emscripten/issues/13330\n __attribute__((always_inline)) _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool\n operator==(const type_info& __arg) const _NOEXCEPT {\n // When evaluated in a constant expression, both type infos simply can't come\n // from different translation units, so it is sufficient to compare their addresses.\n if (__libcpp_is_constant_evaluated()) {\n return this == &__arg;\n }\n return __impl::__eq(__type_name, __arg.__type_name);\n }\n\n# if _LIBCPP_STD_VER <= 17\n _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }\n# endif\n};\n# endif // defined(_LIBCPP_ABI_MICROSOFT)\n\nclass _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception {\npublic:\n bad_cast() _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI bad_cast& operator=(const bad_cast&) _NOEXCEPT = default;\n ~bad_cast() _NOEXCEPT override;\n const char* what() const _NOEXCEPT override;\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception {\npublic:\n bad_typeid() _NOEXCEPT;\n _LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI bad_typeid& operator=(const bad_typeid&) _NOEXCEPT = default;\n ~bad_typeid() _NOEXCEPT override;\n const char* what() const _NOEXCEPT override;\n};\n\n} // namespace std\n\n# endif // defined(_LIBCPP_ABI_VCRUNTIME)\n\n# if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0\n\nnamespace std {\n\nclass bad_cast : public exception {\npublic:\n bad_cast() _NOEXCEPT : exception(\"bad cast\") {}\n\nprivate:\n bad_cast(const char* const __message) _NOEXCEPT : exception(__message) {}\n};\n\nclass bad_typeid : public exception {\npublic:\n bad_typeid() _NOEXCEPT : exception(\"bad typeid\") {}\n\nprivate:\n bad_typeid(const char* const __message) _NOEXCEPT : exception(__message) {}\n};\n\n} // namespace std\n\n# endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_cast() {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw bad_cast();\n# else\n _LIBCPP_VERBOSE_ABORT(\"bad_cast was thrown in -fno-exceptions mode\");\n# endif\n}\n_LIBCPP_END_NAMESPACE_STD\n\n# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20\n# include <cstddef>\n# include <cstdlib>\n# include <type_traits>\n# endif\n#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)\n\n#endif // _LIBCPP_TYPEINFO\n","#include <stdlib.h>\n#include <string.h>\n\nchar *strdup(const char *s)\n{\n\tsize_t l = strlen(s);\n\tchar *d = malloc(l+1);\n\tif (!d) return NULL;\n\treturn memcpy(d, s, l+1);\n}\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#include <new>\n#include <exception>\n\nnamespace std\n{\n\n// exception\n\nexception::~exception() noexcept\n{\n}\n\nconst char* exception::what() const noexcept\n{\n return \"std::exception\";\n}\n\n// bad_exception\n\nbad_exception::~bad_exception() noexcept\n{\n}\n\nconst char* bad_exception::what() const noexcept\n{\n return \"std::bad_exception\";\n}\n\n\n// bad_alloc\n\nbad_alloc::bad_alloc() noexcept\n{\n}\n\nbad_alloc::~bad_alloc() noexcept\n{\n}\n\nconst char*\nbad_alloc::what() const noexcept\n{\n return \"std::bad_alloc\";\n}\n\n// bad_array_new_length\n\nbad_array_new_length::bad_array_new_length() noexcept\n{\n}\n\nbad_array_new_length::~bad_array_new_length() noexcept\n{\n}\n\nconst char*\nbad_array_new_length::what() const noexcept\n{\n return \"bad_array_new_length\";\n}\n\n} // std\n","/*\n * Copyright 2021 The Emscripten Authors. All rights reserved.\n * Emscripten is available under two separate licenses, the MIT license and the\n * University of Illinois/NCSA Open Source License. Both these licenses can be\n * found in the LICENSE file.\n */\n\n#include \"pthread_impl.h\"\n#include <unistd.h>\n#include <emscripten/stack.h>\n\nstatic struct pthread __main_pthread;\n\nuintptr_t __get_tp(void) {\n return (uintptr_t)&__main_pthread;\n}\n\n// In case the stub syscall is not linked it\nstatic int dummy_getpid() {\n return 42;\n}\nweak_alias(dummy_getpid, __syscall_getpid);\n\npthread_t emscripten_main_runtime_thread_id() {\n return &__main_pthread;\n}\n\nextern int __stack_high;\nextern int __stack_low;\n\n__attribute__((constructor))\nstatic void init_pthread_self(void) {\n __main_pthread.locale = &libc.global_locale;\n __main_pthread.tid = getpid();\n __main_pthread.stack = &__stack_high;\n __main_pthread.stack_size = ((size_t)&__stack_high) - ((size_t)&__stack_low);\n __main_pthread.guard_size = __default_guardsize;\n}\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// This file implements the functionality associated with the terminate_handler,\n// unexpected_handler, and new_handler.\n//===----------------------------------------------------------------------===//\n\n#include <stdexcept>\n#include <new>\n#include <exception>\n#include \"abort_message.h\"\n#include \"cxxabi.h\"\n#include \"cxa_handlers.h\"\n#include \"cxa_exception.h\"\n#include \"private_typeinfo.h\"\n#include \"include/atomic_support.h\" // from libc++\n\nnamespace std\n{\n\nunexpected_handler\nget_unexpected() noexcept\n{\n return __libcpp_atomic_load(&__cxa_unexpected_handler, _AO_Acquire);\n}\n\nvoid\n__unexpected(unexpected_handler func)\n{\n func();\n // unexpected handler should not return\n __abort_message(\"unexpected_handler unexpectedly returned\");\n}\n\n__attribute__((noreturn))\nvoid\nunexpected()\n{\n __unexpected(get_unexpected());\n}\n\nterminate_handler\nget_terminate() noexcept\n{\n return __libcpp_atomic_load(&__cxa_terminate_handler, _AO_Acquire);\n}\n\nvoid\n__terminate(terminate_handler func) noexcept\n{\n#ifndef _LIBCXXABI_NO_EXCEPTIONS\n try\n {\n#endif // _LIBCXXABI_NO_EXCEPTIONS\n func();\n // handler should not return\n __abort_message(\"terminate_handler unexpectedly returned\");\n#ifndef _LIBCXXABI_NO_EXCEPTIONS\n }\n catch (...)\n {\n // handler should not throw exception\n __abort_message(\"terminate_handler unexpectedly threw an exception\");\n }\n#endif // _LIBCXXABI_NO_EXCEPTIONS\n}\n\n__attribute__((noreturn))\nvoid\nterminate() noexcept\n{\n#if !defined(_LIBCXXABI_NO_EXCEPTIONS) && !defined(__EMSCRIPTEN_EXCEPTIONS__)\n // If there might be an uncaught exception\n using namespace __cxxabiv1;\n __cxa_eh_globals* globals = __cxa_get_globals_fast();\n if (globals)\n {\n __cxa_exception* exception_header = globals->caughtExceptions;\n if (exception_header)\n {\n _Unwind_Exception* unwind_exception =\n reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1;\n if (__isOurExceptionClass(unwind_exception))\n __terminate(exception_header->terminateHandler);\n }\n }\n#endif\n __terminate(get_terminate());\n}\n\nnew_handler\nget_new_handler() noexcept\n{\n return __libcpp_atomic_load(&__cxa_new_handler, _AO_Acquire);\n}\n\n} // std\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#include <__verbose_abort>\n#include <new>\n\nnamespace std { // purposefully not versioned\n\n#ifndef __GLIBCXX__\nconst nothrow_t nothrow{};\n#endif\n\n#ifndef LIBSTDCXX\n\nvoid __throw_bad_alloc() {\n# if _LIBCPP_HAS_EXCEPTIONS\n throw bad_alloc();\n# else\n _LIBCPP_VERBOSE_ABORT(\"bad_alloc was thrown in -fno-exceptions mode\");\n# endif\n}\n\n#endif // !LIBSTDCXX\n\n} // namespace std\n","#include <stdlib.h>\n#include <signal.h>\n#include \"syscall.h\"\n#include \"pthread_impl.h\"\n#include \"atomic.h\"\n#include \"lock.h\"\n#include \"ksigaction.h\"\n\n#if __EMSCRIPTEN__\n#include \"emscripten_internal.h\"\n#endif\n\n_Noreturn void abort(void)\n{\n#if __EMSCRIPTEN__\n\t/* In emscripten we call out to JS to perform the actual abort where it can\n\t * produce a nice error.\n\t * Note that the JS library function is not called `abort` to avoid conflict\n\t * with the JavaScript abort helper (which takes a JS string as an argument\n\t * and is itself used to implement `_abort_js`) */\n\t_abort_js();\n#else\n\traise(SIGABRT);\n\n\t/* If there was a SIGABRT handler installed and it returned, or if\n\t * SIGABRT was blocked or ignored, take an AS-safe lock to prevent\n\t * sigaction from installing a new SIGABRT handler, uninstall any\n\t * handler that may be present, and re-raise the signal to generate\n\t * the default action of abnormal termination. */\n\t__block_all_sigs(0);\n\tLOCK(__abort_lock);\n\t__syscall(SYS_rt_sigaction, SIGABRT,\n\t\t&(struct k_sigaction){.handler = SIG_DFL}, 0, _NSIG/8);\n\t__syscall(SYS_tkill, __pthread_self()->tid, SIGABRT);\n\t__syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,\n\t\t&(long[_NSIG/(8*sizeof(long))]){1UL<<(SIGABRT-1)}, 0, _NSIG/8);\n\n\t/* Beyond this point should be unreachable. */\n\ta_crash();\n\traise(SIGKILL);\n\t_Exit(127);\n#endif\n}\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP___EXCEPTION_EXCEPTION_H\n#define _LIBCPP___EXCEPTION_EXCEPTION_H\n\n#include <__config>\n\n// <vcruntime_exception.h> defines its own std::exception and std::bad_exception types,\n// which we use in order to be ABI-compatible with other STLs on Windows.\n#if defined(_LIBCPP_ABI_VCRUNTIME)\n# include <vcruntime_exception.h>\n#endif\n\n#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)\n# pragma GCC system_header\n#endif\n\nnamespace std { // purposefully not using versioning namespace\n\n#if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)\n// The std::exception class was already included above, but we're explicit about this condition here for clarity.\n\n#elif defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0\n// However, <vcruntime_exception.h> does not define std::exception and std::bad_exception\n// when _HAS_EXCEPTIONS == 0.\n//\n// Since libc++ still wants to provide the std::exception hierarchy even when _HAS_EXCEPTIONS == 0\n// (after all those are simply types like any other), we define an ABI-compatible version\n// of the VCRuntime std::exception and std::bad_exception types in that mode.\n\nstruct __std_exception_data {\n char const* _What;\n bool _DoFree;\n};\n\nclass exception { // base of all library exceptions\npublic:\n exception() _NOEXCEPT : __data_() {}\n\n explicit exception(char const* __message) _NOEXCEPT : __data_() {\n __data_._What = __message;\n __data_._DoFree = true;\n }\n\n exception(exception const&) _NOEXCEPT {}\n\n exception& operator=(exception const&) _NOEXCEPT { return *this; }\n\n virtual ~exception() _NOEXCEPT {}\n\n virtual char const* what() const _NOEXCEPT { return __data_._What ? __data_._What : \"Unknown exception\"; }\n\nprivate:\n __std_exception_data __data_;\n};\n\nclass bad_exception : public exception {\npublic:\n bad_exception() _NOEXCEPT : exception(\"bad exception\") {}\n};\n\n#else // !defined(_LIBCPP_ABI_VCRUNTIME)\n// On all other platforms, we define our own std::exception and std::bad_exception types\n// regardless of whether exceptions are turned on as a language feature.\n\nclass _LIBCPP_EXPORTED_FROM_ABI exception {\npublic:\n _LIBCPP_HIDE_FROM_ABI exception() _NOEXCEPT {}\n _LIBCPP_HIDE_FROM_ABI exception(const exception&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI exception& operator=(const exception&) _NOEXCEPT = default;\n\n virtual ~exception() _NOEXCEPT;\n virtual const char* what() const _NOEXCEPT;\n};\n\nclass _LIBCPP_EXPORTED_FROM_ABI bad_exception : public exception {\npublic:\n _LIBCPP_HIDE_FROM_ABI bad_exception() _NOEXCEPT {}\n _LIBCPP_HIDE_FROM_ABI bad_exception(const bad_exception&) _NOEXCEPT = default;\n _LIBCPP_HIDE_FROM_ABI bad_exception& operator=(const bad_exception&) _NOEXCEPT = default;\n ~bad_exception() _NOEXCEPT override;\n const char* what() const _NOEXCEPT override;\n};\n#endif // !_LIBCPP_ABI_VCRUNTIME\n\n} // namespace std\n\n#endif // _LIBCPP___EXCEPTION_EXCEPTION_H\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP_REFSTRING_H\n#define _LIBCPP_REFSTRING_H\n\n#include \"atomic_support.h\"\n#include <__config>\n#include <cstddef>\n#include <cstring>\n#include <stdexcept>\n\n// MacOS and iOS used to ship with libstdc++, and still support old applications\n// linking against libstdc++. The libc++ and libstdc++ exceptions are supposed\n// to be ABI compatible, such that they can be thrown from one library and caught\n// in the other.\n//\n// For that reason, we must look for libstdc++ in the same process and if found,\n// check the string stored in the exception object to see if it is the GCC empty\n// string singleton before manipulating the reference count. This is done so that\n// if an exception is created with a zero-length string in libstdc++, libc++abi\n// won't try to delete the memory.\n#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)\n# define _LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE\n# include <dlfcn.h>\n# include <mach-o/dyld.h>\n#endif\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\nnamespace __refstring_imp {\nnamespace {\ntypedef int count_t;\n\nstruct _Rep_base {\n std::size_t len;\n std::size_t cap;\n count_t count;\n};\n\ninline _Rep_base* rep_from_data(const char* data_) noexcept {\n char* data = const_cast<char*>(data_);\n return reinterpret_cast<_Rep_base*>(data - sizeof(_Rep_base));\n}\n\ninline char* data_from_rep(_Rep_base* rep) noexcept {\n char* data = reinterpret_cast<char*>(rep);\n return data + sizeof(*rep);\n}\n\n#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)\ninline const char* compute_gcc_empty_string_storage() noexcept {\n void* handle = dlopen(\"/usr/lib/libstdc++.6.dylib\", RTLD_NOLOAD);\n if (handle == nullptr)\n return nullptr;\n void* sym = dlsym(handle, \"_ZNSs4_Rep20_S_empty_rep_storageE\");\n if (sym == nullptr)\n return nullptr;\n return data_from_rep(reinterpret_cast<_Rep_base*>(sym));\n}\n\ninline const char* get_gcc_empty_string_storage() noexcept {\n static const char* p = compute_gcc_empty_string_storage();\n return p;\n}\n#endif\n\n} // namespace\n} // namespace __refstring_imp\n\nusing namespace __refstring_imp;\n\ninline __libcpp_refstring::__libcpp_refstring(const char* msg) {\n std::size_t len = strlen(msg);\n _Rep_base* rep = static_cast<_Rep_base*>(::operator new(sizeof(*rep) + len + 1));\n rep->len = len;\n rep->cap = len;\n rep->count = 0;\n char* data = data_from_rep(rep);\n std::memcpy(data, msg, len + 1);\n __imp_ = data;\n}\n\ninline __libcpp_refstring::__libcpp_refstring(const __libcpp_refstring& s) noexcept : __imp_(s.__imp_) {\n if (__uses_refcount())\n __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);\n}\n\ninline __libcpp_refstring& __libcpp_refstring::operator=(__libcpp_refstring const& s) noexcept {\n bool adjust_old_count = __uses_refcount();\n struct _Rep_base* old_rep = rep_from_data(__imp_);\n __imp_ = s.__imp_;\n if (__uses_refcount())\n __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);\n if (adjust_old_count) {\n if (__libcpp_atomic_add(&old_rep->count, count_t(-1)) < 0) {\n ::operator delete(old_rep);\n }\n }\n return *this;\n}\n\ninline __libcpp_refstring::~__libcpp_refstring() {\n if (__uses_refcount()) {\n _Rep_base* rep = rep_from_data(__imp_);\n if (__libcpp_atomic_add(&rep->count, count_t(-1)) < 0) {\n ::operator delete(rep);\n }\n }\n}\n\ninline bool __libcpp_refstring::__uses_refcount() const {\n#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)\n return __imp_ != get_gcc_empty_string_storage();\n#else\n return true;\n#endif\n}\n\n_LIBCPP_END_NAMESPACE_STD\n\n#endif // _LIBCPP_REFSTRING_H\n","//===----------------------------------------------------------------------===////\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===////\n\n#ifndef ATOMIC_SUPPORT_H\n#define ATOMIC_SUPPORT_H\n\n#include <__config>\n#include <memory> // for __libcpp_relaxed_load\n\n#if defined(__clang__) && __has_builtin(__atomic_load_n) && __has_builtin(__atomic_store_n) && \\\n __has_builtin(__atomic_add_fetch) && __has_builtin(__atomic_exchange_n) && \\\n __has_builtin(__atomic_compare_exchange_n) && defined(__ATOMIC_RELAXED) && defined(__ATOMIC_CONSUME) && \\\n defined(__ATOMIC_ACQUIRE) && defined(__ATOMIC_RELEASE) && defined(__ATOMIC_ACQ_REL) && defined(__ATOMIC_SEQ_CST)\n# define _LIBCPP_HAS_ATOMIC_BUILTINS\n#elif defined(_LIBCPP_COMPILER_GCC)\n# define _LIBCPP_HAS_ATOMIC_BUILTINS\n#endif\n\n#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && _LIBCPP_HAS_THREADS\n# if defined(_LIBCPP_WARNING)\n_LIBCPP_WARNING(\"Building libc++ without __atomic builtins is unsupported\")\n# else\n# warning Building libc++ without __atomic builtins is unsupported\n# endif\n#endif\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\nnamespace {\n\n#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && _LIBCPP_HAS_THREADS\n\nenum __libcpp_atomic_order {\n _AO_Relaxed = __ATOMIC_RELAXED,\n _AO_Consume = __ATOMIC_CONSUME,\n _AO_Acquire = __ATOMIC_ACQUIRE,\n _AO_Release = __ATOMIC_RELEASE,\n _AO_Acq_Rel = __ATOMIC_ACQ_REL,\n _AO_Seq = __ATOMIC_SEQ_CST\n};\n\ntemplate <class _ValueType, class _FromType>\ninline _LIBCPP_HIDE_FROM_ABI void __libcpp_atomic_store(_ValueType* __dest, _FromType __val, int __order = _AO_Seq) {\n __atomic_store_n(__dest, __val, __order);\n}\n\ntemplate <class _ValueType, class _FromType>\ninline _LIBCPP_HIDE_FROM_ABI void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val) {\n __atomic_store_n(__dest, __val, _AO_Relaxed);\n}\n\ntemplate <class _ValueType>\ninline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_atomic_load(_ValueType const* __val, int __order = _AO_Seq) {\n return __atomic_load_n(__val, __order);\n}\n\ntemplate <class _ValueType, class _AddType>\ninline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a, int __order = _AO_Seq) {\n return __atomic_add_fetch(__val, __a, __order);\n}\n\ntemplate <class _ValueType>\ninline _LIBCPP_HIDE_FROM_ABI _ValueType\n__libcpp_atomic_exchange(_ValueType* __target, _ValueType __value, int __order = _AO_Seq) {\n return __atomic_exchange_n(__target, __value, __order);\n}\n\ntemplate <class _ValueType>\ninline _LIBCPP_HIDE_FROM_ABI bool __libcpp_atomic_compare_exchange(\n _ValueType* __val,\n _ValueType* __expected,\n _ValueType __after,\n int __success_order = _AO_Seq,\n int __fail_order = _AO_Seq) {\n return __atomic_compare_exchange_n(__val, __expected, __after, true, __success_order, __fail_order);\n}\n\n#else // _LIBCPP_HAS_THREADS\n\nenum __libcpp_atomic_order { _AO_Relaxed, _AO_Consume, _AO_Acquire, _AO_Release, _AO_Acq_Rel, _AO_Seq };\n\ntemplate <class _ValueType, class _FromType>\ninline _LIBCPP_HIDE_FROM_ABI void __libcpp_atomic_store(_ValueType* __dest, _FromType __val, int = 0) {\n *__dest = __val;\n}\n\ntemplate <class _ValueType, class _FromType>\ninline _LIBCPP_HIDE_FROM_ABI void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val) {\n *__dest = __val;\n}\n\ntemplate <class _ValueType>\ninline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_atomic_load(_ValueType const* __val, int = 0) {\n return *__val;\n}\n\ntemplate <class _ValueType, class _AddType>\ninline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a, int = 0) {\n return *__val += __a;\n}\n\ntemplate <class _ValueType>\ninline _LIBCPP_HIDE_FROM_ABI _ValueType\n__libcpp_atomic_exchange(_ValueType* __target, _ValueType __value, int = _AO_Seq) {\n _ValueType old = *__target;\n *__target = __value;\n return old;\n}\n\ntemplate <class _ValueType>\ninline _LIBCPP_HIDE_FROM_ABI bool\n__libcpp_atomic_compare_exchange(_ValueType* __val, _ValueType* __expected, _ValueType __after, int = 0, int = 0) {\n if (*__val == *__expected) {\n *__val = __after;\n return true;\n }\n *__expected = *__val;\n return false;\n}\n\n#endif // _LIBCPP_HAS_THREADS\n\n} // namespace\n\n_LIBCPP_END_NAMESPACE_STD\n\n#endif // ATOMIC_SUPPORT_H\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <stdarg.h>\n#include \"abort_message.h\"\n\n#ifdef __BIONIC__\n# include <syslog.h>\nextern \"C\" void android_set_abort_message(const char* msg);\n#endif // __BIONIC__\n\n#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)\n# include <CrashReporterClient.h>\n# define _LIBCXXABI_USE_CRASHREPORTER_CLIENT\n#endif\n\nvoid __abort_message(const char* format, ...)\n{\n // Write message to stderr. We do this before formatting into a\n // variable-size buffer so that we still get some information if\n // formatting into the variable-sized buffer fails.\n#if !defined(NDEBUG) || !defined(LIBCXXABI_BAREMETAL)\n {\n#if defined(__EMSCRIPTEN__) && defined(NDEBUG)\n // Just trap in a non-debug build. These internal libcxxabi assertions are\n // very rare, and it's not worth linking in vfprintf stdio support or\n // even minimal logging for them, as we'll have a proper call stack, which\n // will show a call into \"abort_message\", and can help debugging. (In a\n // debug build that won't be inlined.)\n abort();\n#else\n fprintf(stderr, \"libc++abi: \");\n va_list list;\n va_start(list, format);\n vfprintf(stderr, format, list);\n va_end(list);\n fprintf(stderr, \"\\n\");\n#endif\n }\n#endif\n\n // Format the arguments into an allocated buffer. We leak the buffer on\n // purpose, since we're about to abort() anyway.\n#if defined(_LIBCXXABI_USE_CRASHREPORTER_CLIENT)\n char* buffer;\n va_list list;\n va_start(list, format);\n vasprintf(&buffer, format, list);\n va_end(list);\n\n CRSetCrashLogMessage(buffer);\n#elif defined(__BIONIC__)\n char* buffer;\n va_list list;\n va_start(list, format);\n vasprintf(&buffer, format, list);\n va_end(list);\n\n // Show error in tombstone.\n android_set_abort_message(buffer);\n\n // Show error in logcat.\n openlog(\"libc++abi\", 0, 0);\n syslog(LOG_CRIT, \"%s\", buffer);\n closelog();\n#endif // __BIONIC__\n\n abort();\n}\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// This file implements the default terminate_handler, unexpected_handler and\n// new_handler.\n//===----------------------------------------------------------------------===//\n\n#include <exception>\n#include <new>\n#include \"abort_message.h\"\n#include \"cxxabi.h\"\n#include \"cxa_handlers.h\"\n#include \"cxa_exception.h\"\n#include \"private_typeinfo.h\"\n#include \"include/atomic_support.h\" // from libc++\n\n#if !defined(LIBCXXABI_SILENT_TERMINATE)\n\nstatic constinit const char* cause = \"uncaught\";\n\n# ifndef _LIBCXXABI_NO_EXCEPTIONS\n__attribute__((noreturn))\nstatic void demangling_terminate_handler()\n{\n using namespace __cxxabiv1;\n __cxa_eh_globals* globals = __cxa_get_globals_fast();\n\n // If there is no uncaught exception, just note that we're terminating\n if (!globals)\n __abort_message(\"terminating\");\n\n __cxa_exception* exception_header = globals->caughtExceptions;\n if (!exception_header)\n __abort_message(\"terminating\");\n\n _Unwind_Exception* unwind_exception =\n reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1;\n\n // If we're terminating due to a foreign exception\n if (!__isOurExceptionClass(unwind_exception))\n __abort_message(\"terminating due to %s foreign exception\", cause);\n\n void* thrown_object =\n __getExceptionClass(unwind_exception) == kOurDependentExceptionClass ?\n ((__cxa_dependent_exception*)exception_header)->primaryException :\n exception_header + 1;\n const __shim_type_info* thrown_type =\n static_cast<const __shim_type_info*>(exception_header->exceptionType);\n\n auto name = [str = thrown_type->name()] {\n# ifndef LIBCXXABI_NON_DEMANGLING_TERMINATE\n if (const char* result = __cxxabiv1::__cxa_demangle(str, nullptr, nullptr, nullptr))\n // We're about to abort(), this memory can never be freed; so it's fine\n // to just return a raw pointer\n return result;\n# endif\n return str;\n }();\n\n // If the uncaught exception can be caught with std::exception&\n const __shim_type_info* catch_type =\n static_cast<const __shim_type_info*>(&typeid(std::exception));\n if (catch_type->can_catch(thrown_type, thrown_object))\n {\n // Include the what() message from the exception\n const std::exception* e = static_cast<const std::exception*>(thrown_object);\n __abort_message(\"terminating due to %s exception of type %s: %s\", cause, name, e->what());\n }\n else\n {\n // Else just note that we're terminating due to an exception\n __abort_message(\"terminating due to %s exception of type %s\", cause, name);\n }\n}\n#else // !_LIBCXXABI_NO_EXCEPTIONS\n__attribute__((noreturn))\nstatic void demangling_terminate_handler()\n{\n __abort_message(\"terminating\");\n}\n#endif // !_LIBCXXABI_NO_EXCEPTIONS\n\n__attribute__((noreturn))\nstatic void demangling_unexpected_handler()\n{\n cause = \"unexpected\";\n std::terminate();\n}\n\nstatic constexpr std::terminate_handler default_terminate_handler = demangling_terminate_handler;\nstatic constexpr std::terminate_handler default_unexpected_handler = demangling_unexpected_handler;\n#else // !LIBCXXABI_SILENT_TERMINATE\nstatic constexpr std::terminate_handler default_terminate_handler = ::abort;\nstatic constexpr std::terminate_handler default_unexpected_handler = std::terminate;\n#endif // !LIBCXXABI_SILENT_TERMINATE\n\n//\n// Global variables that hold the pointers to the current handler\n//\n_LIBCXXABI_DATA_VIS\nconstinit std::terminate_handler __cxa_terminate_handler = default_terminate_handler;\n\n_LIBCXXABI_DATA_VIS\nconstinit std::unexpected_handler __cxa_unexpected_handler = default_unexpected_handler;\n\n_LIBCXXABI_DATA_VIS\nconstinit std::new_handler __cxa_new_handler = nullptr;\n\nnamespace std\n{\n\nunexpected_handler\nset_unexpected(unexpected_handler func) noexcept\n{\n if (func == 0)\n func = default_unexpected_handler;\n return __libcpp_atomic_exchange(&__cxa_unexpected_handler, func,\n _AO_Acq_Rel);\n}\n\nterminate_handler\nset_terminate(terminate_handler func) noexcept\n{\n if (func == 0)\n func = default_terminate_handler;\n return __libcpp_atomic_exchange(&__cxa_terminate_handler, func,\n _AO_Acq_Rel);\n}\n\nnew_handler\nset_new_handler(new_handler handler) noexcept\n{\n return __libcpp_atomic_exchange(&__cxa_new_handler, handler, _AO_Acq_Rel);\n}\n\n}\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#include \"private_typeinfo.h\"\n\n// The flag _LIBCXXABI_FORGIVING_DYNAMIC_CAST is used to make dynamic_cast\n// more forgiving when type_info's mistakenly have hidden visibility and\n// thus multiple type_infos can exist for a single type.\n//\n// When _LIBCXXABI_FORGIVING_DYNAMIC_CAST is defined, and only in the case where\n// there is a detected inconsistency in the type_info hierarchy during a\n// dynamic_cast, then the equality operation will fall back to using strcmp\n// on type_info names to determine type_info equality.\n//\n// This change happens *only* under dynamic_cast, and only when\n// dynamic_cast is faced with the choice: abort, or possibly give back the\n// wrong answer. If when the dynamic_cast is done with this fallback\n// algorithm and an inconsistency is still detected, dynamic_cast will call\n// abort with an appropriate message.\n//\n// The current implementation of _LIBCXXABI_FORGIVING_DYNAMIC_CAST requires a\n// printf-like function called syslog:\n//\n// void syslog(int facility_priority, const char* format, ...);\n//\n// If you want this functionality but your platform doesn't have syslog,\n// just implement it in terms of fprintf(stderr, ...).\n//\n// _LIBCXXABI_FORGIVING_DYNAMIC_CAST is currently off by default.\n\n// On Windows, typeids are different between DLLs and EXEs, so comparing\n// type_info* will work for typeids from the same compiled file but fail\n// for typeids from a DLL and an executable. Among other things, exceptions\n// are not caught by handlers since can_catch() returns false.\n//\n// Defining _LIBCXXABI_FORGIVING_DYNAMIC_CAST does not help since can_catch() calls\n// is_equal() with use_strcmp=false so the string names are not compared.\n\n#include <cassert>\n#include <cstddef>\n#include <cstdint>\n#include <string.h>\n\n#include \"abort_message.h\"\n\n#ifdef _LIBCXXABI_FORGIVING_DYNAMIC_CAST\n#include <sys/syslog.h>\n#include <atomic>\n#endif\n\n#if __has_feature(ptrauth_calls)\n#include <ptrauth.h>\n#endif\n\ntemplate <typename T>\nstatic inline T* strip_vtable(T* vtable) {\n#if __has_feature(ptrauth_calls)\n vtable = ptrauth_strip(vtable, ptrauth_key_cxx_vtable_pointer);\n#endif\n return vtable;\n}\n\nstatic inline\nbool\nis_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)\n{\n // Use std::type_info's default comparison unless we've explicitly asked\n // for strcmp.\n if (!use_strcmp)\n return *x == *y;\n // Still allow pointer equality to short circut.\n return x == y || strcmp(x->name(), y->name()) == 0;\n}\n\nstatic inline ptrdiff_t update_offset_to_base(const char* vtable,\n ptrdiff_t offset_to_base) {\n#if __has_feature(cxx_abi_relative_vtable)\n // VTable components are 32 bits in the relative vtables ABI.\n return *reinterpret_cast<const int32_t*>(vtable + offset_to_base);\n#else\n return *reinterpret_cast<const ptrdiff_t*>(vtable + offset_to_base);\n#endif\n}\n\nnamespace __cxxabiv1\n{\n\nnamespace {\n\nstruct derived_object_info {\n const void* dynamic_ptr;\n const __class_type_info* dynamic_type;\n std::ptrdiff_t offset_to_derived;\n};\n\n/// A helper function that gets (dynamic_ptr, dynamic_type, offset_to_derived) from static_ptr.\nvoid dyn_cast_get_derived_info(derived_object_info* info, const void* static_ptr)\n{\n#if __has_feature(cxx_abi_relative_vtable)\n // The vtable address will point to the first virtual function, which is 8\n // bytes after the start of the vtable (4 for the offset from top + 4 for\n // the typeinfo component).\n const int32_t* vtable =\n *reinterpret_cast<const int32_t* const*>(static_ptr);\n info->offset_to_derived = static_cast<std::ptrdiff_t>(vtable[-2]);\n info->dynamic_ptr = static_cast<const char*>(static_ptr) + info->offset_to_derived;\n\n // The typeinfo component is now a relative offset to a proxy.\n int32_t offset_to_ti_proxy = vtable[-1];\n const uint8_t* ptr_to_ti_proxy =\n reinterpret_cast<const uint8_t*>(vtable) + offset_to_ti_proxy;\n info->dynamic_type = *(reinterpret_cast<const __class_type_info* const*>(ptr_to_ti_proxy));\n#else\n void** vtable = strip_vtable(*static_cast<void** const*>(static_ptr));\n info->offset_to_derived = reinterpret_cast<ptrdiff_t>(vtable[-2]);\n info->dynamic_ptr = static_cast<const char*>(static_ptr) + info->offset_to_derived;\n info->dynamic_type = static_cast<const __class_type_info*>(vtable[-1]);\n#endif\n}\n\n/// A helper function for __dynamic_cast that casts a base sub-object pointer\n/// to the object's dynamic type.\n///\n/// This function returns the casting result directly. No further processing\n/// required.\n///\n/// Specifically, this function can only be called if the following pre-\n/// condition holds:\n/// * The dynamic type of the object pointed to by `static_ptr` is exactly\n/// the same as `dst_type`.\nconst void* dyn_cast_to_derived(const void* static_ptr,\n const void* dynamic_ptr,\n const __class_type_info* static_type,\n const __class_type_info* dst_type,\n std::ptrdiff_t offset_to_derived,\n std::ptrdiff_t src2dst_offset)\n{\n // We're downcasting from src_type to the complete object's dynamic type.\n // This is a really hot path that can be further optimized with the\n // `src2dst_offset` hint.\n // In such a case, dynamic_ptr already gives the casting result if the\n // casting ever succeeds. All we have to do now is to check static_ptr\n // points to a public base sub-object of dynamic_ptr.\n\n if (src2dst_offset >= 0)\n {\n // The static type is a unique public non-virtual base type of\n // dst_type at offset `src2dst_offset` from the origin of dst.\n // Note that there might be other non-public static_type bases. The\n // hint only guarantees that the public base is non-virtual and\n // unique. So we have to check whether static_ptr points to that\n // unique public base sub-object.\n if (offset_to_derived != -src2dst_offset)\n return nullptr;\n return dynamic_ptr;\n }\n\n if (src2dst_offset == -2)\n {\n // static_type is not a public base of dst_type.\n return nullptr;\n }\n\n // If src2dst_offset == -3, then:\n // src_type is a multiple public base type but never a virtual\n // base type. We can't conclude that static_ptr points to those\n // public base sub-objects because there might be other non-\n // public static_type bases. The search is inevitable.\n\n // Fallback to the slow path to check that static_type is a public\n // base type of dynamic_type.\n // Using giant short cut. Add that information to info.\n __dynamic_cast_info info = {dst_type, static_ptr, static_type, src2dst_offset, 0, 0, 0, 0, 0, 0, 0, 0,\n 1, // number_of_dst_type\n false, false, false, true, nullptr};\n // Do the search\n dst_type->search_above_dst(&info, dynamic_ptr, dynamic_ptr, public_path, false);\n#ifdef _LIBCXXABI_FORGIVING_DYNAMIC_CAST\n // The following if should always be false because we should\n // definitely find (static_ptr, static_type), either on a public\n // or private path\n if (info.path_dst_ptr_to_static_ptr == unknown)\n {\n // We get here only if there is some kind of visibility problem\n // in client code.\n static_assert(std::atomic<size_t>::is_always_lock_free, \"\");\n static std::atomic<size_t> error_count(0);\n size_t error_count_snapshot = error_count.fetch_add(1, std::memory_order_relaxed);\n if ((error_count_snapshot & (error_count_snapshot-1)) == 0)\n syslog(LOG_ERR, \"dynamic_cast error 1: Both of the following type_info's \"\n \"should have public visibility. At least one of them is hidden. %s\"\n \", %s.\\n\", static_type->name(), dst_type->name());\n // Redo the search comparing type_info's using strcmp\n info = {dst_type, static_ptr, static_type, src2dst_offset, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, false, false, false, true, nullptr};\n info.number_of_dst_type = 1;\n dst_type->search_above_dst(&info, dynamic_ptr, dynamic_ptr, public_path, true);\n }\n#endif // _LIBCXXABI_FORGIVING_DYNAMIC_CAST\n // Query the search.\n if (info.path_dst_ptr_to_static_ptr != public_path)\n return nullptr;\n\n return dynamic_ptr;\n}\n\n/// A helper function for __dynamic_cast that tries to perform a downcast\n/// before giving up and falling back to the slow path.\nconst void* dyn_cast_try_downcast(const void* static_ptr,\n const void* dynamic_ptr,\n const __class_type_info* dst_type,\n const __class_type_info* dynamic_type,\n std::ptrdiff_t src2dst_offset)\n{\n if (src2dst_offset < 0)\n {\n // We can only optimize the case if the static type is a unique public\n // base of dst_type. Give up.\n return nullptr;\n }\n\n // Pretend there is a dst_type object that leads to static_ptr. Later we\n // will check whether this imagined dst_type object exists. If it exists\n // then it will be the casting result.\n const void* dst_ptr_to_static = reinterpret_cast<const char*>(static_ptr) - src2dst_offset;\n\n if (reinterpret_cast<std::intptr_t>(dst_ptr_to_static) < reinterpret_cast<std::intptr_t>(dynamic_ptr))\n {\n // The imagined dst_type object does not exist. Bail-out quickly.\n return nullptr;\n }\n\n // Try to search a path from dynamic_type to dst_type.\n __dynamic_cast_info dynamic_to_dst_info = {dynamic_type,\n dst_ptr_to_static,\n dst_type,\n src2dst_offset,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n 1, // number_of_dst_type\n false,\n false,\n false,\n true,\n nullptr};\n dynamic_type->search_above_dst(&dynamic_to_dst_info, dynamic_ptr, dynamic_ptr, public_path, false);\n if (dynamic_to_dst_info.path_dst_ptr_to_static_ptr != unknown) {\n // We have found at least one path from dynamic_ptr to dst_ptr. The\n // downcast can succeed.\n return dst_ptr_to_static;\n }\n\n return nullptr;\n}\n\nconst void* dyn_cast_slow(const void* static_ptr,\n const void* dynamic_ptr,\n const __class_type_info* static_type,\n const __class_type_info* dst_type,\n const __class_type_info* dynamic_type,\n std::ptrdiff_t src2dst_offset)\n{\n // Not using giant short cut. Do the search\n\n // Initialize info struct for this search.\n __dynamic_cast_info info = {dst_type, static_ptr, static_type, src2dst_offset, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, false, false, false, true, nullptr};\n\n dynamic_type->search_below_dst(&info, dynamic_ptr, public_path, false);\n#ifdef _LIBCXXABI_FORGIVING_DYNAMIC_CAST\n // The following if should always be false because we should\n // definitely find (static_ptr, static_type), either on a public\n // or private path\n if (info.path_dst_ptr_to_static_ptr == unknown &&\n info.path_dynamic_ptr_to_static_ptr == unknown)\n {\n static_assert(std::atomic<size_t>::is_always_lock_free, \"\");\n static std::atomic<size_t> error_count(0);\n size_t error_count_snapshot = error_count.fetch_add(1, std::memory_order_relaxed);\n if ((error_count_snapshot & (error_count_snapshot-1)) == 0)\n syslog(LOG_ERR, \"dynamic_cast error 2: One or more of the following type_info's \"\n \"has hidden visibility or is defined in more than one translation \"\n \"unit. They should all have public visibility. \"\n \"%s, %s, %s.\\n\", static_type->name(), dynamic_type->name(),\n dst_type->name());\n // Redo the search comparing type_info's using strcmp\n info = {dst_type, static_ptr, static_type, src2dst_offset, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, false, false, false, true, nullptr};\n dynamic_type->search_below_dst(&info, dynamic_ptr, public_path, true);\n }\n#endif // _LIBCXXABI_FORGIVING_DYNAMIC_CAST\n // Query the search.\n switch (info.number_to_static_ptr)\n {\n case 0:\n if (info.number_to_dst_ptr == 1 &&\n info.path_dynamic_ptr_to_static_ptr == public_path &&\n info.path_dynamic_ptr_to_dst_ptr == public_path)\n return info.dst_ptr_not_leading_to_static_ptr;\n break;\n case 1:\n if (info.path_dst_ptr_to_static_ptr == public_path ||\n (\n info.number_to_dst_ptr == 0 &&\n info.path_dynamic_ptr_to_static_ptr == public_path &&\n info.path_dynamic_ptr_to_dst_ptr == public_path\n )\n )\n return info.dst_ptr_leading_to_static_ptr;\n break;\n }\n\n return nullptr;\n}\n\n} // namespace\n\n// __shim_type_info\n\n__shim_type_info::~__shim_type_info()\n{\n}\n\nvoid __shim_type_info::noop1() const {}\nvoid __shim_type_info::noop2() const {}\n\n// __fundamental_type_info\n\n// This miraculously (compiler magic) emits the type_info's for:\n// 1. all of the fundamental types\n// 2. pointers to all of the fundamental types\n// 3. pointers to all of the const fundamental types\n__fundamental_type_info::~__fundamental_type_info()\n{\n}\n\n// __array_type_info\n\n__array_type_info::~__array_type_info()\n{\n}\n\n// __function_type_info\n\n__function_type_info::~__function_type_info()\n{\n}\n\n// __enum_type_info\n\n__enum_type_info::~__enum_type_info()\n{\n}\n\n// __class_type_info\n\n__class_type_info::~__class_type_info()\n{\n}\n\n// __si_class_type_info\n\n__si_class_type_info::~__si_class_type_info()\n{\n}\n\n// __vmi_class_type_info\n\n__vmi_class_type_info::~__vmi_class_type_info()\n{\n}\n\n// __pbase_type_info\n\n__pbase_type_info::~__pbase_type_info()\n{\n}\n\n// __pointer_type_info\n\n__pointer_type_info::~__pointer_type_info()\n{\n}\n\n// __pointer_to_member_type_info\n\n__pointer_to_member_type_info::~__pointer_to_member_type_info()\n{\n}\n\n// can_catch\n\n// A handler is a match for an exception object of type E if\n// 1. The handler is of type cv T or cv T& and E and T are the same type\n// (ignoring the top-level cv-qualifiers), or\n// 2. the handler is of type cv T or cv T& and T is an unambiguous public\n// base class of E, or\n// 3. the handler is of type cv1 T* cv2 and E is a pointer type that can be\n// converted to the type of the handler by either or both of\n// A. a standard pointer conversion (4.10) not involving conversions to\n// pointers to private or protected or ambiguous classes\n// B. a qualification conversion\n// 4. the handler is a pointer or pointer to member type and E is\n// std::nullptr_t.\n\n// adjustedPtr:\n//\n// catch (A& a) : adjustedPtr == &a\n// catch (A* a) : adjustedPtr == a\n// catch (A** a) : adjustedPtr == a\n//\n// catch (D2& d2) : adjustedPtr == &d2 (d2 is base class of thrown object)\n// catch (D2* d2) : adjustedPtr == d2\n// catch (D2*& d2) : adjustedPtr == d2\n//\n// catch (...) : adjustedPtr == & of the exception\n//\n// If the thrown type is nullptr_t and the caught type is a pointer to\n// member type, adjustedPtr points to a statically-allocated null pointer\n// representation of that type.\n\n// Handles bullet 1\nbool\n__fundamental_type_info::can_catch(const __shim_type_info* thrown_type,\n void*&) const\n{\n return is_equal(this, thrown_type, false);\n}\n\nbool\n__array_type_info::can_catch(const __shim_type_info*, void*&) const\n{\n // We can get here if someone tries to catch an array by reference.\n // However if someone tries to throw an array, it immediately gets\n // converted to a pointer, which will not convert back to an array\n // at the catch clause. So this can never catch anything.\n return false;\n}\n\nbool\n__function_type_info::can_catch(const __shim_type_info*, void*&) const\n{\n // We can get here if someone tries to catch a function by reference.\n // However if someone tries to throw a function, it immediately gets\n // converted to a pointer, which will not convert back to a function\n // at the catch clause. So this can never catch anything.\n return false;\n}\n\n// Handles bullet 1\nbool\n__enum_type_info::can_catch(const __shim_type_info* thrown_type,\n void*&) const\n{\n return is_equal(this, thrown_type, false);\n}\n\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wmissing-field-initializers\"\n#endif\n\n// Handles bullets 1 and 2\nbool\n__class_type_info::can_catch(const __shim_type_info* thrown_type,\n void*& adjustedPtr) const\n{\n // bullet 1\n if (is_equal(this, thrown_type, false))\n return true;\n const __class_type_info* thrown_class_type =\n dynamic_cast<const __class_type_info*>(thrown_type);\n if (thrown_class_type == 0)\n return false;\n // bullet 2\n _LIBCXXABI_ASSERT(adjustedPtr, \"catching a class without an object?\");\n __dynamic_cast_info info = {thrown_class_type, 0, this, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true, nullptr};\n info.number_of_dst_type = 1;\n thrown_class_type->has_unambiguous_public_base(&info, adjustedPtr, public_path);\n if (info.path_dst_ptr_to_static_ptr == public_path)\n {\n adjustedPtr = const_cast<void*>(info.dst_ptr_leading_to_static_ptr);\n return true;\n }\n return false;\n}\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n// When we have an object to inspect - we just pass the pointer to the sub-\n// object that matched the static_type we just checked. If that is different\n// from any previously recorded pointer to that object type, then we have\n// an ambiguous case.\n\n// When we have no object to inspect, we need to account for virtual bases\n// explicitly.\n// info->vbase_cookie is a pointer to the name of the innermost virtual base\n// type, or nullptr if there is no virtual base on the path so far.\n// adjustedPtr points to the subobject we just found.\n// If vbase_cookie != any previously recorded (including the case of nullptr\n// representing an already-found static sub-object) then we have an ambiguous\n// case. Assuming that the vbase_cookie values agree; if then we have a\n// different offset (adjustedPtr) from any previously recorded, this indicates\n// an ambiguous case within the virtual base.\n\nvoid\n__class_type_info::process_found_base_class(__dynamic_cast_info* info,\n void* adjustedPtr,\n int path_below) const\n{\n if (info->number_to_static_ptr == 0) {\n // First time we found this base\n info->dst_ptr_leading_to_static_ptr = adjustedPtr;\n info->path_dst_ptr_to_static_ptr = path_below;\n // stash the virtual base cookie.\n info->dst_ptr_not_leading_to_static_ptr = info->vbase_cookie;\n info->number_to_static_ptr = 1;\n } else if (info->dst_ptr_not_leading_to_static_ptr == info->vbase_cookie &&\n info->dst_ptr_leading_to_static_ptr == adjustedPtr) {\n // We've been here before. Update path to \"most public\"\n if (info->path_dst_ptr_to_static_ptr == not_public_path)\n info->path_dst_ptr_to_static_ptr = path_below;\n } else {\n // We've detected an ambiguous cast from (thrown_class_type, adjustedPtr)\n // to a static_type.\n info->number_to_static_ptr += 1;\n info->path_dst_ptr_to_static_ptr = not_public_path;\n info->search_done = true;\n }\n}\n\nvoid\n__class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,\n void* adjustedPtr,\n int path_below) const\n{\n if (is_equal(this, info->static_type, false))\n process_found_base_class(info, adjustedPtr, path_below);\n}\n\nvoid\n__si_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,\n void* adjustedPtr,\n int path_below) const\n{\n if (is_equal(this, info->static_type, false))\n process_found_base_class(info, adjustedPtr, path_below);\n else\n __base_type->has_unambiguous_public_base(info, adjustedPtr, path_below);\n}\n\nvoid\n__base_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,\n void* adjustedPtr,\n int path_below) const\n{\n bool is_virtual = __offset_flags & __virtual_mask;\n ptrdiff_t offset_to_base = 0;\n if (info->have_object) {\n /* We have an object to inspect, we can look through its vtables to\n find the layout. */\n offset_to_base = __offset_flags >> __offset_shift;\n if (is_virtual) {\n const char* vtable = strip_vtable(*static_cast<const char* const*>(adjustedPtr));\n offset_to_base = update_offset_to_base(vtable, offset_to_base);\n }\n } else if (!is_virtual) {\n /* We have no object; however, for non-virtual bases, (since we do not\n need to inspect any content) we can pretend to have an object based\n at '0'. */\n offset_to_base = __offset_flags >> __offset_shift;\n } else {\n /* No object to inspect, and the next base is virtual.\n We cannot indirect through the vtable to find the actual object offset.\n So, update vbase_cookie to the new innermost virtual base using the\n pointer to the typeinfo name as a key. */\n info->vbase_cookie = static_cast<const void*>(__base_type->name());\n // .. and reset the pointer.\n adjustedPtr = nullptr;\n }\n __base_type->has_unambiguous_public_base(\n info, reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(adjustedPtr) + offset_to_base),\n (__offset_flags & __public_mask) ? path_below : not_public_path);\n}\n\nvoid\n__vmi_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,\n void* adjustedPtr,\n int path_below) const\n{\n if (is_equal(this, info->static_type, false))\n process_found_base_class(info, adjustedPtr, path_below);\n else\n {\n typedef const __base_class_type_info* Iter;\n const Iter e = __base_info + __base_count;\n Iter p = __base_info;\n p->has_unambiguous_public_base(info, adjustedPtr, path_below);\n if (++p < e)\n {\n do\n {\n p->has_unambiguous_public_base(info, adjustedPtr, path_below);\n if (info->search_done)\n break;\n } while (++p < e);\n }\n }\n}\n\n// Handles bullet 1 for both pointers and member pointers\nbool\n__pbase_type_info::can_catch(const __shim_type_info* thrown_type,\n void*&) const\n{\n bool use_strcmp = this->__flags & (__incomplete_class_mask |\n __incomplete_mask);\n if (!use_strcmp) {\n const __pbase_type_info* thrown_pbase = dynamic_cast<const __pbase_type_info*>(\n thrown_type);\n if (!thrown_pbase) return false;\n use_strcmp = thrown_pbase->__flags & (__incomplete_class_mask |\n __incomplete_mask);\n }\n return is_equal(this, thrown_type, use_strcmp);\n}\n\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wmissing-field-initializers\"\n#endif\n\n// Handles bullets 1, 3 and 4\n// NOTE: It might not be safe to adjust the pointer if it is not not a pointer\n// type. Only adjust the pointer after we know it is safe to do so.\nbool\n__pointer_type_info::can_catch(const __shim_type_info* thrown_type,\n void*& adjustedPtr) const\n{\n // bullet 4\n if (is_equal(thrown_type, &typeid(std::nullptr_t), false)) {\n adjustedPtr = nullptr;\n return true;\n }\n\n // bullet 1\n if (__pbase_type_info::can_catch(thrown_type, adjustedPtr)) {\n if (adjustedPtr != NULL)\n adjustedPtr = *static_cast<void**>(adjustedPtr);\n return true;\n }\n // bullet 3\n const __pointer_type_info* thrown_pointer_type =\n dynamic_cast<const __pointer_type_info*>(thrown_type);\n if (thrown_pointer_type == 0)\n return false;\n // Do the dereference adjustment\n if (adjustedPtr != NULL)\n adjustedPtr = *static_cast<void**>(adjustedPtr);\n // bullet 3B and 3C\n if (thrown_pointer_type->__flags & ~__flags & __no_remove_flags_mask)\n return false;\n if (__flags & ~thrown_pointer_type->__flags & __no_add_flags_mask)\n return false;\n if (is_equal(__pointee, thrown_pointer_type->__pointee, false))\n return true;\n // bullet 3A\n if (is_equal(__pointee, &typeid(void), false)) {\n // pointers to functions cannot be converted to void*.\n // pointers to member functions are not handled here.\n const __function_type_info* thrown_function =\n dynamic_cast<const __function_type_info*>(thrown_pointer_type->__pointee);\n return (thrown_function == nullptr);\n }\n // Handle pointer to pointer\n const __pointer_type_info* nested_pointer_type =\n dynamic_cast<const __pointer_type_info*>(__pointee);\n if (nested_pointer_type) {\n if (~__flags & __const_mask) return false;\n return nested_pointer_type->can_catch_nested(thrown_pointer_type->__pointee);\n }\n\n // Handle pointer to pointer to member\n const __pointer_to_member_type_info* member_ptr_type =\n dynamic_cast<const __pointer_to_member_type_info*>(__pointee);\n if (member_ptr_type) {\n if (~__flags & __const_mask) return false;\n return member_ptr_type->can_catch_nested(thrown_pointer_type->__pointee);\n }\n\n // Handle pointer to class type\n const __class_type_info* catch_class_type =\n dynamic_cast<const __class_type_info*>(__pointee);\n if (catch_class_type == 0)\n return false;\n const __class_type_info* thrown_class_type =\n dynamic_cast<const __class_type_info*>(thrown_pointer_type->__pointee);\n if (thrown_class_type == 0)\n return false;\n bool have_object = adjustedPtr != nullptr;\n __dynamic_cast_info info = {thrown_class_type, 0, catch_class_type, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n have_object, nullptr};\n info.number_of_dst_type = 1;\n thrown_class_type->has_unambiguous_public_base(&info, adjustedPtr, public_path);\n if (info.path_dst_ptr_to_static_ptr == public_path)\n {\n // In the case of a thrown null pointer, we have no object but we might\n // well have computed the offset to where a public sub-object would be.\n // However, we do not want to return that offset to the user; we still\n // want them to catch a null ptr.\n if (have_object)\n adjustedPtr = const_cast<void*>(info.dst_ptr_leading_to_static_ptr);\n else\n adjustedPtr = nullptr;\n return true;\n }\n return false;\n}\n\nbool __pointer_type_info::can_catch_nested(\n const __shim_type_info* thrown_type) const\n{\n const __pointer_type_info* thrown_pointer_type =\n dynamic_cast<const __pointer_type_info*>(thrown_type);\n if (thrown_pointer_type == 0)\n return false;\n // bullet 3B\n if (thrown_pointer_type->__flags & ~__flags)\n return false;\n if (is_equal(__pointee, thrown_pointer_type->__pointee, false))\n return true;\n // If the pointed to types differ then the catch type must be const\n // qualified.\n if (~__flags & __const_mask)\n return false;\n\n // Handle pointer to pointer\n const __pointer_type_info* nested_pointer_type =\n dynamic_cast<const __pointer_type_info*>(__pointee);\n if (nested_pointer_type) {\n return nested_pointer_type->can_catch_nested(\n thrown_pointer_type->__pointee);\n }\n\n // Handle pointer to pointer to member\n const __pointer_to_member_type_info* member_ptr_type =\n dynamic_cast<const __pointer_to_member_type_info*>(__pointee);\n if (member_ptr_type) {\n return member_ptr_type->can_catch_nested(thrown_pointer_type->__pointee);\n }\n\n return false;\n}\n\nbool __pointer_to_member_type_info::can_catch(\n const __shim_type_info* thrown_type, void*& adjustedPtr) const {\n // bullet 4\n if (is_equal(thrown_type, &typeid(std::nullptr_t), false)) {\n // We assume that the pointer to member representation is the same for\n // all pointers to data members and for all pointers to member functions.\n struct X {};\n if (dynamic_cast<const __function_type_info*>(__pointee)) {\n static int (X::*const null_ptr_rep)() = nullptr;\n adjustedPtr = const_cast<int (X::**)()>(&null_ptr_rep);\n } else {\n static int X::*const null_ptr_rep = nullptr;\n adjustedPtr = const_cast<int X::**>(&null_ptr_rep);\n }\n return true;\n }\n\n // bullet 1\n if (__pbase_type_info::can_catch(thrown_type, adjustedPtr))\n return true;\n\n const __pointer_to_member_type_info* thrown_pointer_type =\n dynamic_cast<const __pointer_to_member_type_info*>(thrown_type);\n if (thrown_pointer_type == 0)\n return false;\n if (thrown_pointer_type->__flags & ~__flags & __no_remove_flags_mask)\n return false;\n if (__flags & ~thrown_pointer_type->__flags & __no_add_flags_mask)\n return false;\n if (!is_equal(__pointee, thrown_pointer_type->__pointee, false))\n return false;\n if (is_equal(__context, thrown_pointer_type->__context, false))\n return true;\n\n // [except.handle] does not allow the pointer-to-member conversions mentioned\n // in [mem.conv] to take place. For this reason we don't check Derived->Base\n // for Derived->Base conversions.\n\n return false;\n}\n\nbool __pointer_to_member_type_info::can_catch_nested(\n const __shim_type_info* thrown_type) const\n{\n const __pointer_to_member_type_info* thrown_member_ptr_type =\n dynamic_cast<const __pointer_to_member_type_info*>(thrown_type);\n if (thrown_member_ptr_type == 0)\n return false;\n if (~__flags & thrown_member_ptr_type->__flags)\n return false;\n if (!is_equal(__pointee, thrown_member_ptr_type->__pointee, false))\n return false;\n if (!is_equal(__context, thrown_member_ptr_type->__context, false))\n return false;\n return true;\n}\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wmissing-field-initializers\"\n#endif\n\n// __dynamic_cast\n\n// static_ptr: pointer to an object of type static_type; nonnull, and since the\n// object is polymorphic, *(void**)static_ptr is a virtual table pointer.\n// static_ptr is &v in the expression dynamic_cast<T>(v).\n// static_type: static type of the object pointed to by static_ptr.\n// dst_type: destination type of the cast (the \"T\" in \"dynamic_cast<T>(v)\").\n// src2dst_offset: a static hint about the location of the\n// source subobject with respect to the complete object;\n// special negative values are:\n// -1: no hint\n// -2: static_type is not a public base of dst_type\n// -3: static_type is a multiple public base type but never a\n// virtual base type\n// otherwise, the static_type type is a unique public nonvirtual\n// base type of dst_type at offset src2dst_offset from the\n// origin of dst_type.\n//\n// (dynamic_ptr, dynamic_type) are the run time type of the complete object\n// referred to by static_ptr and a pointer to it. These can be found from\n// static_ptr for polymorphic types.\n// static_type is guaranteed to be a polymorphic type.\n//\n// (dynamic_ptr, dynamic_type) is the root of a DAG that grows upward. Each\n// node of the tree represents a base class/object of its parent (or parents) below.\n// Each node is uniquely represented by a pointer to the object, and a pointer\n// to a type_info - its type. Different nodes may have the same pointer and\n// different nodes may have the same type. But only one node has a specific\n// (pointer-value, type) pair. In C++ two objects of the same type can not\n// share the same address.\n//\n// There are two flavors of nodes which have the type dst_type:\n// 1. Those that are derived from (below) (static_ptr, static_type).\n// 2. Those that are not derived from (below) (static_ptr, static_type).\n//\n// Invariants of the DAG:\n//\n// There is at least one path from the root (dynamic_ptr, dynamic_type) to\n// the node (static_ptr, static_type). This path may or may not be public.\n// There may be more than one such path (some public some not). Such a path may\n// or may not go through a node having type dst_type.\n//\n// No node of type T appears above a node of the same type. That means that\n// there is only one node with dynamic_type. And if dynamic_type == dst_type,\n// then there is only one dst_type in the DAG.\n//\n// No node of type dst_type appears above a node of type static_type. Such\n// DAG's are possible in C++, but the compiler computes those dynamic_casts at\n// compile time, and only calls __dynamic_cast when dst_type lies below\n// static_type in the DAG.\n//\n// dst_type != static_type: The compiler computes the dynamic_cast in this case too.\n// dynamic_type != static_type: The compiler computes the dynamic_cast in this case too.\n//\n// Returns:\n//\n// If there is exactly one dst_type of flavor 1, and\n// If there is a public path from that dst_type to (static_ptr, static_type), or\n// If there are 0 dst_types of flavor 2, and there is a public path from\n// (dynamic_ptr, dynamic_type) to (static_ptr, static_type) and a public\n// path from (dynamic_ptr, dynamic_type) to the one dst_type, then return\n// a pointer to that dst_type.\n// Else if there are 0 dst_types of flavor 1 and exactly 1 dst_type of flavor 2, and\n// if there is a public path from (dynamic_ptr, dynamic_type) to\n// (static_ptr, static_type) and a public path from (dynamic_ptr, dynamic_type)\n// to the one dst_type, then return a pointer to that one dst_type.\n// Else return nullptr.\n//\n// If dynamic_type == dst_type, then the above algorithm collapses to the\n// following cheaper algorithm:\n//\n// If there is a public path from (dynamic_ptr, dynamic_type) to\n// (static_ptr, static_type), then return dynamic_ptr.\n// Else return nullptr.\n\nextern \"C\" _LIBCXXABI_FUNC_VIS void *\n__dynamic_cast(const void *static_ptr, const __class_type_info *static_type,\n const __class_type_info *dst_type,\n std::ptrdiff_t src2dst_offset) {\n // Get (dynamic_ptr, dynamic_type) from static_ptr\n derived_object_info derived_info;\n dyn_cast_get_derived_info(&derived_info, static_ptr);\n\n // Initialize answer to nullptr. This will be changed from the search\n // results if a non-null answer is found. Regardless, this is what will\n // be returned.\n const void* dst_ptr = 0;\n\n // Find out if we can use a giant short cut in the search\n if (is_equal(derived_info.dynamic_type, dst_type, false))\n {\n dst_ptr = dyn_cast_to_derived(static_ptr,\n derived_info.dynamic_ptr,\n static_type,\n dst_type,\n derived_info.offset_to_derived,\n src2dst_offset);\n }\n else\n {\n // Optimize toward downcasting: let's first try to do a downcast before\n // falling back to the slow path.\n dst_ptr = dyn_cast_try_downcast(static_ptr,\n derived_info.dynamic_ptr,\n dst_type,\n derived_info.dynamic_type,\n src2dst_offset);\n\n if (!dst_ptr)\n {\n dst_ptr = dyn_cast_slow(static_ptr,\n derived_info.dynamic_ptr,\n static_type,\n dst_type,\n derived_info.dynamic_type,\n src2dst_offset);\n }\n }\n\n return const_cast<void*>(dst_ptr);\n}\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n// Call this function when you hit a static_type which is a base (above) a dst_type.\n// Let caller know you hit a static_type. But only start recording details if\n// this is (static_ptr, static_type) -- the node we are casting from.\n// If this is (static_ptr, static_type)\n// Record the path (public or not) from the dst_type to here. There may be\n// multiple paths from the same dst_type to here, record the \"most public\" one.\n// Record the dst_ptr as pointing to (static_ptr, static_type).\n// If more than one (dst_ptr, dst_type) points to (static_ptr, static_type),\n// then mark this dyanmic_cast as ambiguous and stop the search.\nvoid\n__class_type_info::process_static_type_above_dst(__dynamic_cast_info* info,\n const void* dst_ptr,\n const void* current_ptr,\n int path_below) const\n{\n // Record that we found a static_type\n info->found_any_static_type = true;\n if (current_ptr == info->static_ptr)\n {\n // Record that we found (static_ptr, static_type)\n info->found_our_static_ptr = true;\n if (info->dst_ptr_leading_to_static_ptr == 0)\n {\n // First time here\n info->dst_ptr_leading_to_static_ptr = dst_ptr;\n info->path_dst_ptr_to_static_ptr = path_below;\n info->number_to_static_ptr = 1;\n // If there is only one dst_type in the entire tree and the path from\n // there to here is public then we are done!\n if (info->number_of_dst_type == 1 && info->path_dst_ptr_to_static_ptr == public_path)\n info->search_done = true;\n }\n else if (info->dst_ptr_leading_to_static_ptr == dst_ptr)\n {\n // We've been here before. Update path to \"most public\"\n if (info->path_dst_ptr_to_static_ptr == not_public_path)\n info->path_dst_ptr_to_static_ptr = path_below;\n // If there is only one dst_type in the entire tree and the path from\n // there to here is public then we are done!\n if (info->number_of_dst_type == 1 && info->path_dst_ptr_to_static_ptr == public_path)\n info->search_done = true;\n }\n else\n {\n // We've detected an ambiguous cast from (static_ptr, static_type)\n // to a dst_type\n info->number_to_static_ptr += 1;\n info->search_done = true;\n }\n }\n}\n\n// Call this function when you hit a static_type which is not a base (above) a dst_type.\n// If this is (static_ptr, static_type)\n// Record the path (public or not) from (dynamic_ptr, dynamic_type) to here. There may be\n// multiple paths from (dynamic_ptr, dynamic_type) to here, record the \"most public\" one.\nvoid\n__class_type_info::process_static_type_below_dst(__dynamic_cast_info* info,\n const void* current_ptr,\n int path_below) const\n{\n if (current_ptr == info->static_ptr)\n {\n // Record the most public path from (dynamic_ptr, dynamic_type) to\n // (static_ptr, static_type)\n if (info->path_dynamic_ptr_to_static_ptr != public_path)\n info->path_dynamic_ptr_to_static_ptr = path_below;\n }\n}\n\n// Call this function when searching below a dst_type node. This function searches\n// for a path to (static_ptr, static_type) and for paths to one or more dst_type nodes.\n// If it finds a static_type node, there is no need to further search base classes\n// above.\n// If it finds a dst_type node it should search base classes using search_above_dst\n// to find out if this dst_type points to (static_ptr, static_type) or not.\n// Either way, the dst_type is recorded as one of two \"flavors\": one that does\n// or does not point to (static_ptr, static_type).\n// If this is neither a static_type nor a dst_type node, continue searching\n// base classes above.\n// All the hoopla surrounding the search code is doing nothing but looking for\n// excuses to stop the search prematurely (break out of the for-loop). That is,\n// the algorithm below is simply an optimization of this:\n// void\n// __vmi_class_type_info::search_below_dst(__dynamic_cast_info* info,\n// const void* current_ptr,\n// int path_below) const\n// {\n// typedef const __base_class_type_info* Iter;\n// if (this == info->static_type)\n// process_static_type_below_dst(info, current_ptr, path_below);\n// else if (this == info->dst_type)\n// {\n// // Record the most public access path that got us here\n// if (info->path_dynamic_ptr_to_dst_ptr != public_path)\n// info->path_dynamic_ptr_to_dst_ptr = path_below;\n// bool does_dst_type_point_to_our_static_type = false;\n// for (Iter p = __base_info, e= __base_info + __base_count; p < e; ++p)\n// {\n// p->search_above_dst(info, current_ptr, current_ptr, public_path);\n// if (info->found_our_static_ptr)\n// does_dst_type_point_to_our_static_type = true;\n// // break out early here if you can detect it doesn't matter if you do\n// }\n// if (!does_dst_type_point_to_our_static_type)\n// {\n// // We found a dst_type that doesn't point to (static_ptr, static_type)\n// // So record the address of this dst_ptr and increment the\n// // count of the number of such dst_types found in the tree.\n// info->dst_ptr_not_leading_to_static_ptr = current_ptr;\n// info->number_to_dst_ptr += 1;\n// }\n// }\n// else\n// {\n// // This is not a static_type and not a dst_type.\n// for (Iter p = __base_info, e = __base_info + __base_count; p < e; ++p)\n// {\n// p->search_below_dst(info, current_ptr, public_path);\n// // break out early here if you can detect it doesn't matter if you do\n// }\n// }\n// }\nvoid\n__vmi_class_type_info::search_below_dst(__dynamic_cast_info* info,\n const void* current_ptr,\n int path_below,\n bool use_strcmp) const\n{\n typedef const __base_class_type_info* Iter;\n if (is_equal(this, info->static_type, use_strcmp))\n process_static_type_below_dst(info, current_ptr, path_below);\n else if (is_equal(this, info->dst_type, use_strcmp))\n {\n // We've been here before if we've recorded current_ptr in one of these\n // two places:\n if (current_ptr == info->dst_ptr_leading_to_static_ptr ||\n current_ptr == info->dst_ptr_not_leading_to_static_ptr)\n {\n // We've seen this node before, and therefore have already searched\n // its base classes above.\n // Update path to here that is \"most public\".\n if (path_below == public_path)\n info->path_dynamic_ptr_to_dst_ptr = public_path;\n }\n else // We have haven't been here before\n {\n // Record the access path that got us here\n // If there is more than one dst_type this path doesn't matter.\n info->path_dynamic_ptr_to_dst_ptr = path_below;\n bool does_dst_type_point_to_our_static_type = false;\n // Only search above here if dst_type derives from static_type, or\n // if it is unknown if dst_type derives from static_type.\n if (info->is_dst_type_derived_from_static_type != no)\n {\n // Set up flags to record results from all base classes\n bool is_dst_type_derived_from_static_type = false;\n\n // We've found a dst_type with a potentially public path to here.\n // We have to assume the path is public because it may become\n // public later (if we get back to here with a public path).\n // We can stop looking above if:\n // 1. We've found a public path to (static_ptr, static_type).\n // 2. We've found an ambiguous cast from (static_ptr, static_type) to a dst_type.\n // This is detected at the (static_ptr, static_type).\n // 3. We can prove that there is no public path to (static_ptr, static_type)\n // above here.\n const Iter e = __base_info + __base_count;\n for (Iter p = __base_info; p < e; ++p)\n {\n // Zero out found flags\n info->found_our_static_ptr = false;\n info->found_any_static_type = false;\n p->search_above_dst(info, current_ptr, current_ptr, public_path, use_strcmp);\n if (info->search_done)\n break;\n if (info->found_any_static_type)\n {\n is_dst_type_derived_from_static_type = true;\n if (info->found_our_static_ptr)\n {\n does_dst_type_point_to_our_static_type = true;\n // If we found what we're looking for, stop looking above.\n if (info->path_dst_ptr_to_static_ptr == public_path)\n break;\n // We found a private path to (static_ptr, static_type)\n // If there is no diamond then there is only one path\n // to (static_ptr, static_type) and we just found it.\n if (!(__flags & __diamond_shaped_mask))\n break;\n }\n else\n {\n // If we found a static_type that isn't the one we're looking\n // for, and if there are no repeated types above here,\n // then stop looking.\n if (!(__flags & __non_diamond_repeat_mask))\n break;\n }\n }\n }\n // If we found no static_type,s then dst_type doesn't derive\n // from static_type, else it does. Record this result so that\n // next time we hit a dst_type we will know not to search above\n // it if it doesn't derive from static_type.\n if (is_dst_type_derived_from_static_type)\n info->is_dst_type_derived_from_static_type = yes;\n else\n info->is_dst_type_derived_from_static_type = no;\n }\n if (!does_dst_type_point_to_our_static_type)\n {\n // We found a dst_type that doesn't point to (static_ptr, static_type)\n // So record the address of this dst_ptr and increment the\n // count of the number of such dst_types found in the tree.\n info->dst_ptr_not_leading_to_static_ptr = current_ptr;\n info->number_to_dst_ptr += 1;\n // If there exists another dst with a private path to\n // (static_ptr, static_type), then the cast from\n // (dynamic_ptr, dynamic_type) to dst_type is now ambiguous,\n // so stop search.\n if (info->number_to_static_ptr == 1 &&\n info->path_dst_ptr_to_static_ptr == not_public_path)\n info->search_done = true;\n }\n }\n }\n else\n {\n // This is not a static_type and not a dst_type.\n const Iter e = __base_info + __base_count;\n Iter p = __base_info;\n p->search_below_dst(info, current_ptr, path_below, use_strcmp);\n if (++p < e)\n {\n if ((__flags & __diamond_shaped_mask) || info->number_to_static_ptr == 1)\n {\n // If there are multiple paths to a base above from here, or if\n // a dst_type pointing to (static_ptr, static_type) has been found,\n // then there is no way to break out of this loop early unless\n // something below detects the search is done.\n do\n {\n if (info->search_done)\n break;\n p->search_below_dst(info, current_ptr, path_below, use_strcmp);\n } while (++p < e);\n }\n else if (__flags & __non_diamond_repeat_mask)\n {\n // There are not multiple paths to any base class from here and a\n // dst_type pointing to (static_ptr, static_type) has not yet been\n // found.\n do\n {\n if (info->search_done)\n break;\n // If we just found a dst_type with a public path to (static_ptr, static_type),\n // then the only reason to continue the search is to make sure\n // no other dst_type points to (static_ptr, static_type).\n // If !diamond, then we don't need to search here.\n if (info->number_to_static_ptr == 1 &&\n info->path_dst_ptr_to_static_ptr == public_path)\n break;\n p->search_below_dst(info, current_ptr, path_below, use_strcmp);\n } while (++p < e);\n }\n else\n {\n // There are no repeated types above this node.\n // There are no nodes with multiple parents above this node.\n // no dst_type has been found to (static_ptr, static_type)\n do\n {\n if (info->search_done)\n break;\n // If we just found a dst_type with a public path to (static_ptr, static_type),\n // then the only reason to continue the search is to make sure\n // no other dst_type points to (static_ptr, static_type).\n // If !diamond, then we don't need to search here.\n // if we just found a dst_type with a private path to (static_ptr, static_type),\n // then we're only looking for a public path to (static_ptr, static_type)\n // and to check for other dst_types.\n // If !diamond & !repeat, then there is not a pointer to (static_ptr, static_type)\n // and not a dst_type under here.\n if (info->number_to_static_ptr == 1)\n break;\n p->search_below_dst(info, current_ptr, path_below, use_strcmp);\n } while (++p < e);\n }\n }\n }\n}\n\n// This is the same algorithm as __vmi_class_type_info::search_below_dst but\n// simplified to the case that there is only a single base class.\nvoid\n__si_class_type_info::search_below_dst(__dynamic_cast_info* info,\n const void* current_ptr,\n int path_below,\n bool use_strcmp) const\n{\n if (is_equal(this, info->static_type, use_strcmp))\n process_static_type_below_dst(info, current_ptr, path_below);\n else if (is_equal(this, info->dst_type, use_strcmp))\n {\n // We've been here before if we've recorded current_ptr in one of these\n // two places:\n if (current_ptr == info->dst_ptr_leading_to_static_ptr ||\n current_ptr == info->dst_ptr_not_leading_to_static_ptr)\n {\n // We've seen this node before, and therefore have already searched\n // its base classes above.\n // Update path to here that is \"most public\".\n if (path_below == public_path)\n info->path_dynamic_ptr_to_dst_ptr = public_path;\n }\n else // We have haven't been here before\n {\n // Record the access path that got us here\n // If there is more than one dst_type this path doesn't matter.\n info->path_dynamic_ptr_to_dst_ptr = path_below;\n bool does_dst_type_point_to_our_static_type = false;\n // Only search above here if dst_type derives from static_type, or\n // if it is unknown if dst_type derives from static_type.\n if (info->is_dst_type_derived_from_static_type != no)\n {\n // Set up flags to record results from all base classes\n bool is_dst_type_derived_from_static_type = false;\n // Zero out found flags\n info->found_our_static_ptr = false;\n info->found_any_static_type = false;\n __base_type->search_above_dst(info, current_ptr, current_ptr, public_path, use_strcmp);\n if (info->found_any_static_type)\n {\n is_dst_type_derived_from_static_type = true;\n if (info->found_our_static_ptr)\n does_dst_type_point_to_our_static_type = true;\n }\n // If we found no static_type,s then dst_type doesn't derive\n // from static_type, else it does. Record this result so that\n // next time we hit a dst_type we will know not to search above\n // it if it doesn't derive from static_type.\n if (is_dst_type_derived_from_static_type)\n info->is_dst_type_derived_from_static_type = yes;\n else\n info->is_dst_type_derived_from_static_type = no;\n }\n if (!does_dst_type_point_to_our_static_type)\n {\n // We found a dst_type that doesn't point to (static_ptr, static_type)\n // So record the address of this dst_ptr and increment the\n // count of the number of such dst_types found in the tree.\n info->dst_ptr_not_leading_to_static_ptr = current_ptr;\n info->number_to_dst_ptr += 1;\n // If there exists another dst with a private path to\n // (static_ptr, static_type), then the cast from\n // (dynamic_ptr, dynamic_type) to dst_type is now ambiguous.\n if (info->number_to_static_ptr == 1 &&\n info->path_dst_ptr_to_static_ptr == not_public_path)\n info->search_done = true;\n }\n }\n }\n else\n {\n // This is not a static_type and not a dst_type\n __base_type->search_below_dst(info, current_ptr, path_below, use_strcmp);\n }\n}\n\n// This is the same algorithm as __vmi_class_type_info::search_below_dst but\n// simplified to the case that there is no base class.\nvoid\n__class_type_info::search_below_dst(__dynamic_cast_info* info,\n const void* current_ptr,\n int path_below,\n bool use_strcmp) const\n{\n if (is_equal(this, info->static_type, use_strcmp))\n process_static_type_below_dst(info, current_ptr, path_below);\n else if (is_equal(this, info->dst_type, use_strcmp))\n {\n // We've been here before if we've recorded current_ptr in one of these\n // two places:\n if (current_ptr == info->dst_ptr_leading_to_static_ptr ||\n current_ptr == info->dst_ptr_not_leading_to_static_ptr)\n {\n // We've seen this node before, and therefore have already searched\n // its base classes above.\n // Update path to here that is \"most public\".\n if (path_below == public_path)\n info->path_dynamic_ptr_to_dst_ptr = public_path;\n }\n else // We have haven't been here before\n {\n // Record the access path that got us here\n // If there is more than one dst_type this path doesn't matter.\n info->path_dynamic_ptr_to_dst_ptr = path_below;\n // We found a dst_type that doesn't point to (static_ptr, static_type)\n // So record the address of this dst_ptr and increment the\n // count of the number of such dst_types found in the tree.\n info->dst_ptr_not_leading_to_static_ptr = current_ptr;\n info->number_to_dst_ptr += 1;\n // If there exists another dst with a private path to\n // (static_ptr, static_type), then the cast from\n // (dynamic_ptr, dynamic_type) to dst_type is now ambiguous.\n if (info->number_to_static_ptr == 1 &&\n info->path_dst_ptr_to_static_ptr == not_public_path)\n info->search_done = true;\n // We found that dst_type does not derive from static_type\n info->is_dst_type_derived_from_static_type = no;\n }\n }\n}\n\n// Call this function when searching above a dst_type node. This function searches\n// for a public path to (static_ptr, static_type).\n// This function is guaranteed not to find a node of type dst_type.\n// Theoretically this is a very simple function which just stops if it finds a\n// static_type node: All the hoopla surrounding the search code is doing\n// nothing but looking for excuses to stop the search prematurely (break out of\n// the for-loop). That is, the algorithm below is simply an optimization of this:\n// void\n// __vmi_class_type_info::search_above_dst(__dynamic_cast_info* info,\n// const void* dst_ptr,\n// const void* current_ptr,\n// int path_below) const\n// {\n// if (this == info->static_type)\n// process_static_type_above_dst(info, dst_ptr, current_ptr, path_below);\n// else\n// {\n// typedef const __base_class_type_info* Iter;\n// // This is not a static_type and not a dst_type\n// for (Iter p = __base_info, e = __base_info + __base_count; p < e; ++p)\n// {\n// p->search_above_dst(info, dst_ptr, current_ptr, public_path);\n// // break out early here if you can detect it doesn't matter if you do\n// }\n// }\n// }\nvoid\n__vmi_class_type_info::search_above_dst(__dynamic_cast_info* info,\n const void* dst_ptr,\n const void* current_ptr,\n int path_below,\n bool use_strcmp) const\n{\n if (is_equal(this, info->static_type, use_strcmp))\n process_static_type_above_dst(info, dst_ptr, current_ptr, path_below);\n else\n {\n typedef const __base_class_type_info* Iter;\n // This is not a static_type and not a dst_type\n // Save flags so they can be restored when returning to nodes below.\n bool found_our_static_ptr = info->found_our_static_ptr;\n bool found_any_static_type = info->found_any_static_type;\n // We've found a dst_type below with a path to here. If the path\n // to here is not public, there may be another path to here that\n // is public. So we have to assume that the path to here is public.\n // We can stop looking above if:\n // 1. We've found a public path to (static_ptr, static_type).\n // 2. We've found an ambiguous cast from (static_ptr, static_type) to a dst_type.\n // This is detected at the (static_ptr, static_type).\n // 3. We can prove that there is no public path to (static_ptr, static_type)\n // above here.\n const Iter e = __base_info + __base_count;\n Iter p = __base_info;\n // Zero out found flags\n info->found_our_static_ptr = false;\n info->found_any_static_type = false;\n p->search_above_dst(info, dst_ptr, current_ptr, path_below, use_strcmp);\n found_our_static_ptr |= info->found_our_static_ptr;\n found_any_static_type |= info->found_any_static_type;\n if (++p < e)\n {\n do\n {\n if (info->search_done)\n break;\n if (info->found_our_static_ptr)\n {\n // If we found what we're looking for, stop looking above.\n if (info->path_dst_ptr_to_static_ptr == public_path)\n break;\n // We found a private path to (static_ptr, static_type)\n // If there is no diamond then there is only one path\n // to (static_ptr, static_type) from here and we just found it.\n if (!(__flags & __diamond_shaped_mask))\n break;\n }\n else if (info->found_any_static_type)\n {\n // If we found a static_type that isn't the one we're looking\n // for, and if there are no repeated types above here,\n // then stop looking.\n if (!(__flags & __non_diamond_repeat_mask))\n break;\n }\n // Zero out found flags\n info->found_our_static_ptr = false;\n info->found_any_static_type = false;\n p->search_above_dst(info, dst_ptr, current_ptr, path_below, use_strcmp);\n found_our_static_ptr |= info->found_our_static_ptr;\n found_any_static_type |= info->found_any_static_type;\n } while (++p < e);\n }\n // Restore flags\n info->found_our_static_ptr = found_our_static_ptr;\n info->found_any_static_type = found_any_static_type;\n }\n}\n\n// This is the same algorithm as __vmi_class_type_info::search_above_dst but\n// simplified to the case that there is only a single base class.\nvoid\n__si_class_type_info::search_above_dst(__dynamic_cast_info* info,\n const void* dst_ptr,\n const void* current_ptr,\n int path_below,\n bool use_strcmp) const\n{\n if (is_equal(this, info->static_type, use_strcmp))\n process_static_type_above_dst(info, dst_ptr, current_ptr, path_below);\n else\n __base_type->search_above_dst(info, dst_ptr, current_ptr, path_below, use_strcmp);\n}\n\n// This is the same algorithm as __vmi_class_type_info::search_above_dst but\n// simplified to the case that there is no base class.\nvoid\n__class_type_info::search_above_dst(__dynamic_cast_info* info,\n const void* dst_ptr,\n const void* current_ptr,\n int path_below,\n bool use_strcmp) const\n{\n if (is_equal(this, info->static_type, use_strcmp))\n process_static_type_above_dst(info, dst_ptr, current_ptr, path_below);\n}\n\n// The search functions for __base_class_type_info are simply convenience\n// functions for adjusting the current_ptr and path_below as the search is\n// passed up to the base class node.\n\nvoid\n__base_class_type_info::search_above_dst(__dynamic_cast_info* info,\n const void* dst_ptr,\n const void* current_ptr,\n int path_below,\n bool use_strcmp) const\n{\n ptrdiff_t offset_to_base = __offset_flags >> __offset_shift;\n if (__offset_flags & __virtual_mask)\n {\n const char* vtable = strip_vtable(*static_cast<const char* const*>(current_ptr));\n offset_to_base = update_offset_to_base(vtable, offset_to_base);\n }\n __base_type->search_above_dst(info, dst_ptr,\n static_cast<const char*>(current_ptr) + offset_to_base,\n (__offset_flags & __public_mask) ?\n path_below :\n not_public_path,\n use_strcmp);\n}\n\nvoid\n__base_class_type_info::search_below_dst(__dynamic_cast_info* info,\n const void* current_ptr,\n int path_below,\n bool use_strcmp) const\n{\n ptrdiff_t offset_to_base = __offset_flags >> __offset_shift;\n if (__offset_flags & __virtual_mask)\n {\n const char* vtable = strip_vtable(*static_cast<const char* const*>(current_ptr));\n offset_to_base = update_offset_to_base(vtable, offset_to_base);\n }\n __base_type->search_below_dst(info,\n static_cast<const char*>(current_ptr) + offset_to_base,\n (__offset_flags & __public_mask) ?\n path_below :\n not_public_path,\n use_strcmp);\n}\n} // __cxxabiv1\n\n\n// XXX EMSCRIPTEN\n#if defined(__wasm__) && !defined(__WASM_EXCEPTIONS__)\n\n#include \"cxa_exception.h\"\n\nnamespace __cxxabiv1\n{\n\n// These functions are used by the emscripten-style exception handling\n// mechanism.\n// Note that they need to be included even in the `-noexcept` build of\n// libc++abi to support the case where some parts of a project are built\n// with exception catching enabled, but at link time exception catching\n// is disabled. In this case dependencies to these functions (and the JS\n// functions which call them) will still exist in the final build.\nextern \"C\" {\n\nint __cxa_can_catch(__shim_type_info* catchType, __shim_type_info* excpType, void **thrown) {\n //std::type_info *t1 = static_cast<std::type_info*>(catchType);\n //std::type_info *t2 = static_cast<std::type_info*>(excpType);\n //printf(\"can %s catch %s (%p)?\\n\", t1->name(), t2->name(), thrown);\n\n void *temp = *thrown;\n int ret = catchType->can_catch(excpType, temp);\n if (ret) *thrown = temp; // apply changes only if we are catching\n return ret;\n}\n\nstatic\ninline\n__cxa_exception*\ncxa_exception_from_thrown_object(void* thrown_object)\n{\n return static_cast<__cxa_exception*>(thrown_object) - 1;\n}\n\nvoid *__cxa_get_exception_ptr(void *thrown_object) throw() {\n // Get pointer which is expected to be received by catch clause in C++ code.\n // It may be adjusted when the pointer is casted to some of the exception\n // object base classes (e.g. when virtual inheritance is used). When a pointer\n // is thrown this method should return the thrown pointer itself.\n // Work around a fastcomp bug, this code is still included for some reason in\n // a build without exceptions support.\n __cxa_exception* ex = cxa_exception_from_thrown_object(thrown_object);\n bool is_pointer = !!dynamic_cast<__pointer_type_info*>(ex->exceptionType);\n if (is_pointer)\n return *(void**)thrown_object;\n if (ex->adjustedPtr)\n return ex->adjustedPtr;\n return ex;\n}\n\n}\n\n} // __cxxabiv1\n\n#endif // __wasm__ && !__WASM_EXCEPTIONS__\n\n","//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef _LIBCPP_REFSTRING_H\n#define _LIBCPP_REFSTRING_H\n\n#include \"atomic_support.h\"\n#include <__config>\n#include <cstddef>\n#include <cstring>\n#include <stdexcept>\n\n// MacOS and iOS used to ship with libstdc++, and still support old applications\n// linking against libstdc++. The libc++ and libstdc++ exceptions are supposed\n// to be ABI compatible, such that they can be thrown from one library and caught\n// in the other.\n//\n// For that reason, we must look for libstdc++ in the same process and if found,\n// check the string stored in the exception object to see if it is the GCC empty\n// string singleton before manipulating the reference count. This is done so that\n// if an exception is created with a zero-length string in libstdc++, libc++abi\n// won't try to delete the memory.\n#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)\n# define _LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE\n# include <dlfcn.h>\n# include <mach-o/dyld.h>\n#endif\n\n_LIBCPP_BEGIN_NAMESPACE_STD\n\nnamespace __refstring_imp {\nnamespace {\ntypedef int count_t;\n\nstruct _Rep_base {\n std::size_t len;\n std::size_t cap;\n count_t count;\n};\n\ninline _Rep_base* rep_from_data(const char* data_) noexcept {\n char* data = const_cast<char*>(data_);\n return reinterpret_cast<_Rep_base*>(data - sizeof(_Rep_base));\n}\n\ninline char* data_from_rep(_Rep_base* rep) noexcept {\n char* data = reinterpret_cast<char*>(rep);\n return data + sizeof(*rep);\n}\n\n#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)\ninline const char* compute_gcc_empty_string_storage() noexcept {\n void* handle = dlopen(\"/usr/lib/libstdc++.6.dylib\", RTLD_NOLOAD);\n if (handle == nullptr)\n return nullptr;\n void* sym = dlsym(handle, \"_ZNSs4_Rep20_S_empty_rep_storageE\");\n if (sym == nullptr)\n return nullptr;\n return data_from_rep(reinterpret_cast<_Rep_base*>(sym));\n}\n\ninline const char* get_gcc_empty_string_storage() noexcept {\n static const char* p = compute_gcc_empty_string_storage();\n return p;\n}\n#endif\n\n} // namespace\n} // namespace __refstring_imp\n\nusing namespace __refstring_imp;\n\ninline __libcpp_refstring::__libcpp_refstring(const char* msg) {\n std::size_t len = strlen(msg);\n _Rep_base* rep = static_cast<_Rep_base*>(::operator new(sizeof(*rep) + len + 1));\n rep->len = len;\n rep->cap = len;\n rep->count = 0;\n char* data = data_from_rep(rep);\n std::memcpy(data, msg, len + 1);\n __imp_ = data;\n}\n\ninline __libcpp_refstring::__libcpp_refstring(const __libcpp_refstring& s) noexcept : __imp_(s.__imp_) {\n if (__uses_refcount())\n __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);\n}\n\ninline __libcpp_refstring& __libcpp_refstring::operator=(__libcpp_refstring const& s) noexcept {\n bool adjust_old_count = __uses_refcount();\n struct _Rep_base* old_rep = rep_from_data(__imp_);\n __imp_ = s.__imp_;\n if (__uses_refcount())\n __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);\n if (adjust_old_count) {\n if (__libcpp_atomic_add(&old_rep->count, count_t(-1)) < 0) {\n ::operator delete(old_rep);\n }\n }\n return *this;\n}\n\ninline __libcpp_refstring::~__libcpp_refstring() {\n if (__uses_refcount()) {\n _Rep_base* rep = rep_from_data(__imp_);\n if (__libcpp_atomic_add(&rep->count, count_t(-1)) < 0) {\n ::operator delete(rep);\n }\n }\n}\n\ninline bool __libcpp_refstring::__uses_refcount() const {\n#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)\n return __imp_ != get_gcc_empty_string_storage();\n#else\n return true;\n#endif\n}\n\n_LIBCPP_END_NAMESPACE_STD\n\n#endif // _LIBCPP_REFSTRING_H\n","#include <sys/time.h>\n#include <errno.h>\n#include \"syscall.h\"\n\n#define IS32BIT(x) !((x)+0x80000000ULL>>32)\n\n#ifdef __EMSCRIPTEN__\n#include <emscripten/emscripten.h>\n#include <signal.h>\n#include <stdint.h>\n#include <stdio.h>\n\n#include \"emscripten_internal.h\"\n\n// Timeouts can either fire directly from the JS event loop (which calls\n// `_emscripten_timeout`), or from `_emscripten_check_timers` (which is called\n// from `_emscripten_yield`). In order to be able to check the timers here we\n// cache the current timeout and interval for each the 3 types of timer\n// (ITIMER_PROF/ITIMER_VIRTUAL/ITIMER_REAL).\nstatic double current_timeout_ms[3];\nstatic double current_intervals_ms[3];\n\n#define MAX(a,b) ((a)>(b)?(a):(b))\n\nvoid __getitimer(int which, struct itimerval *old, double now)\n{\n\tdouble remaining_ms = MAX(current_timeout_ms[which] - now, 0);\n\told->it_value.tv_sec = remaining_ms / 1000;\n\told->it_value.tv_usec = remaining_ms * 1000;\n\told->it_interval.tv_sec = current_intervals_ms[which] / 1000;\n\told->it_interval.tv_usec = current_intervals_ms[which] * 1000;\n}\n\nvoid _emscripten_timeout(int which, double now)\n{\n\tint signum = SIGALRM;\n\tif (which == ITIMER_PROF)\n\t\tsignum = SIGPROF;\n\telse if (which == ITIMER_VIRTUAL)\n\t\tsignum = SIGVTALRM;\n\tdouble next_timeout = 0.0;\n\tif (current_intervals_ms[which]) {\n\t\t// If time went backwards, schedule the next timer as if it didn't.\n\t\tnow = __builtin_wasm_max_f64(now, current_timeout_ms[which]);\n\t\t// The next alarm is due 'interval' ms after the previous one.\n\t\t// If this alarm was delayed, that is sooner than 'interval' ms\n\t\t// from now. The delay could even be so long that we missed the\n\t\t// next alarm(s) entirely. Schedule the alarm for the next\n\t\t// multiple of 'interval' ms from the original due time.\n\t\tuint64_t intervals =\n\t\t\t(uint64_t)(now - current_timeout_ms[which]) /\n\t\t\t (uint64_t)current_intervals_ms[which] +\n\t\t\t1;\n\t\tcurrent_timeout_ms[which] +=\n\t\t\tintervals * current_intervals_ms[which];\n\t\tnext_timeout = current_timeout_ms[which] - now;\n\t} else {\n\t\tcurrent_timeout_ms[which] = 0;\n\t}\n\t_setitimer_js(which, next_timeout);\n\traise(signum);\n}\n\nvoid _emscripten_check_timers(double now)\n{\n\tfor (int which = 0; which < 3; which++) {\n\t\tif (current_timeout_ms[which]) {\n\t\t\t// Only call out to JS to get the current time if it was not passed in\n\t\t\t// *and* we have one or more timers set.\n\t\t\tif (!now)\n\t\t\t \tnow = emscripten_get_now();\n\t\t\tif (now >= current_timeout_ms[which])\n\t\t\t\t_emscripten_timeout(which, now);\n\t\t}\n\t}\n}\n#endif\n\nint setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old)\n{\n#ifdef __EMSCRIPTEN__\n\tif (which > ITIMER_PROF) return EINVAL;\n\tdouble now = emscripten_get_now();\n\tif (old) {\n\t\t__getitimer(which, old, now);\n\t}\n\tif (new->it_value.tv_sec || new->it_value.tv_usec) {\n\t\tcurrent_timeout_ms[which] = now + new->it_value.tv_sec * 1000 + new->it_value.tv_usec / 1000;\n\t\tcurrent_intervals_ms[which] = new->it_interval.tv_sec * 1000 + new->it_interval.tv_usec / 1000;\n\t} else {\n\t\tcurrent_timeout_ms[which] = 0;\n\t\tcurrent_intervals_ms[which] = 0;\n\t}\n\treturn _setitimer_js(which, new->it_value.tv_sec * 1000 + new->it_value.tv_usec / 1000);\n#else\n\tif (sizeof(time_t) > sizeof(long)) {\n\t\ttime_t is = new->it_interval.tv_sec, vs = new->it_value.tv_sec;\n\t\tlong ius = new->it_interval.tv_usec, vus = new->it_value.tv_usec;\n\t\tif (!IS32BIT(is) || !IS32BIT(vs))\n\t\t\treturn __syscall_ret(-ENOTSUP);\n\t\tlong old32[4];\n\t\tint r = __syscall(SYS_setitimer, which,\n\t\t\t((long[]){is, ius, vs, vus}), old32);\n\t\tif (!r && old) {\n\t\t\told->it_interval.tv_sec = old32[0];\n\t\t\told->it_interval.tv_usec = old32[1];\n\t\t\told->it_value.tv_sec = old32[2];\n\t\t\told->it_value.tv_usec = old32[3];\n\t\t}\n\t\treturn __syscall_ret(r);\n\t}\n\treturn syscall(SYS_setitimer, which, new, old);\n#endif\n}\n","/*\n * Copyright 2021 The Emscripten Authors. All rights reserved.\n * Emscripten is available under two separate licenses, the MIT license and the\n * University of Illinois/NCSA Open Source License. Both these licenses can be\n * found in the LICENSE file.\n */\n\n#define _GNU_SOURCE // for sighandler_t\n#include <stdbool.h>\n#include <stddef.h>\n#include <signal.h>\n\n#include \"emscripten_internal.h\"\n\nextern struct sigaction __sig_actions[_NSIG];\nextern sigset_t __sig_pending;\n\nbool __sig_is_blocked(int sig);\n\n// Default handler actions ~auto-generated from https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html.\n// Note that stop and continue actions are not supported and treated as ignored.\n\nvoid action_abort(int sig) {\n abort();\n}\n\nvoid action_terminate(int sig) {\n // Prepare to forcibly shut down runtime even if it has async work in flight.\n _emscripten_runtime_keepalive_clear();\n // Intentionally exiting via a function that doesn't call atexit handlers.\n _Exit(128 + sig);\n}\n\nstatic sighandler_t default_actions[_NSIG] = {\n [SIGABRT] = action_abort,\n [SIGALRM] = action_terminate,\n [SIGBUS] = action_abort,\n [SIGFPE] = action_abort,\n [SIGHUP] = action_terminate,\n [SIGILL] = action_abort,\n [SIGINT] = action_terminate,\n [SIGKILL] = action_terminate,\n [SIGPIPE] = action_terminate,\n [SIGQUIT] = action_abort,\n [SIGSEGV] = action_abort,\n [SIGTERM] = action_terminate,\n [SIGUSR1] = action_terminate,\n [SIGUSR2] = action_terminate,\n [SIGPOLL] = action_terminate,\n [SIGPROF] = action_terminate,\n [SIGSYS] = action_abort,\n [SIGTRAP] = action_abort,\n [SIGVTALRM] = action_terminate,\n [SIGXCPU] = action_abort,\n [SIGXFSZ] = action_abort,\n};\n\nint raise(int sig) {\n if (__sig_is_blocked(sig)) {\n sigaddset(&__sig_pending, sig);\n return 0;\n }\n if (__sig_actions[sig].sa_flags & SA_SIGINFO) {\n siginfo_t t = {0};\n __sig_actions[sig].sa_sigaction(sig, &t, NULL);\n } else {\n sighandler_t handler = __sig_actions[sig].sa_handler;\n if (handler == SIG_DFL) {\n handler = default_actions[sig];\n if (handler) {\n handler(sig);\n }\n } else if (handler != SIG_IGN) {\n // Avoid a direct call to the handler, and instead call via JS so we can\n // avoid strict signature checking.\n // https://github.com/emscripten-core/posixtestsuite/issues/6\n __call_sighandler(handler, sig);\n }\n }\n return 0;\n}\n","#include <stdlib.h>\n#include \"syscall.h\"\n\n_Noreturn void _Exit(int ec)\n{\n#ifdef __EMSCRIPTEN__\n\t__wasi_proc_exit(ec);\n#else\n\t__syscall(SYS_exit_group, ec);\n\tfor (;;) __syscall(SYS_exit, ec);\n#endif\n}\n","/*\n * Copyright 2021 The Emscripten Authors. All rights reserved.\n * Emscripten is available under two separate licenses, the MIT license and the\n * University of Illinois/NCSA Open Source License. Both these licenses can be\n * found in the LICENSE file.\n */\n\n#define _GNU_SOURCE // for sigorset/sigandset\n#include <stdbool.h>\n#include <threads.h>\n#include <signal.h>\n#include <errno.h>\n#include \"libc.h\"\n\n#define SST_SIZE (_NSIG/8/sizeof(long))\n\nstatic thread_local sigset_t __sig_mask;\nsigset_t __sig_pending;\n\nstatic int siginvertset(sigset_t *dest, const sigset_t *src) {\n unsigned long i = 0, *d = (void*) dest, *s = (void*) src;\n for(; i < SST_SIZE; i++) d[i] = ~s[i];\n return 0;\n}\n\nbool __sig_is_blocked(int sig) {\n return sigismember(&__sig_mask, sig);\n}\n\nint pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old) {\n if (old) {\n *old = __sig_mask;\n }\n\n switch (how) {\n case SIG_SETMASK:\n __sig_mask = *set;\n break;\n case SIG_BLOCK:\n sigorset(&__sig_mask, &__sig_mask, set);\n break;\n case SIG_UNBLOCK: {\n sigset_t tmp;\n siginvertset(&tmp, set);\n sigandset(&__sig_mask, &__sig_mask, &tmp);\n break;\n }\n default:\n return EINVAL;\n }\n\n // These two signals can never be blocked.\n sigdelset(&__sig_mask, SIGKILL);\n sigdelset(&__sig_mask, SIGSTOP);\n\n // Raise any pending signals that are now unblocked.\n for (int sig = 0; sig < _NSIG; sig++) {\n if (sigismember(&__sig_pending, sig) && !sigismember(&__sig_mask, sig)) {\n sigdelset(&__sig_pending, sig);\n raise(sig);\n }\n }\n\n return 0;\n}\n\nint sigpending(sigset_t *set) {\n *set = __sig_pending;\n return 0;\n}\n","#include <signal.h>\n#include <errno.h>\n\nint sigaddset(sigset_t *set, int sig)\n{\n\tunsigned s = sig-1;\n\tif (s >= _NSIG-1 || sig-32U < 3) {\n\t\terrno = EINVAL;\n\t\treturn -1;\n\t}\n\tset->__bits[s/8/sizeof *set->__bits] |= 1UL<<(s&8*sizeof *set->__bits-1);\n\treturn 0;\n}\n","#include <signal.h>\n\nint sigismember(const sigset_t *set, int sig)\n{\n\tunsigned s = sig-1;\n\tif (s >= _NSIG-1) return 0;\n\treturn !!(set->__bits[s/8/sizeof *set->__bits] & 1UL<<(s&8*sizeof *set->__bits-1));\n}\n"],"names":[],"mappings":"ozBa6BA,EAiBY,EAjBZ,IACW,IAGG,QAAZ,EAAY,E,GkDyBL,MlDrBD,OAKN,GAJI,Q,EASE,E,CADI,EAER,IACF,G,KTynJU,WAKW,OAYsB,QACd,CACE,WACZ,CAAD,MAEI,WAOiB,WAGL,CAAR,kBACa,GADb,EACM,CADN,EAEI,2KAEY,SAAK,GAAc,MACpB,WACX,qBAkEhC,EAtEgC,kLAaJ,KAAiB,EAAG,UAA5B,eACK,C,CADL,EACI,GACgB,GADhB,EACS,CADT,EACS,GAEG,WADmB,iBAEX,CAAR,QACK,GAAP,QAES,QADJ,GAkDvC,KA3C6C,GAAP,EA2CtC,EA3CsC,CA2CtC,EA3CsC,GAEH,WADmB,iBAE1B,cAwC5B,MApC2C,CACT,KACN,kMASJ,gCATI,kKACA,cACM,UACS,KA+B3C,OAvBwB,CAuBxB,EAvBwB,KACA,uBADA,CACA,I,CAAA,sDAsBxB,aAjBwB,CAiBxB,EAjBwB,+B,EAAA,2C,CAAA,sMAEI,UAAqB,OAejD,C,E8DzsJQ,E,CAAA,EZ6PgB,KAAmB,KAxHxB,CYjInB,EADa,O,EAAA,EACb,EAD+B,KAAW,GAArB,EAA6B,CAClD,C,ChEnEA,aAMqB,CAApB,GAAuC,K,CAAA,E,EAAA,EAMxC,MAN+B,KAAV,CAApB,GAAuC,KAAD,MACvC,QAA0C,QAAN,KAAT,oBAA1B,WAGY,GAAL,KAAP,SAED,C,EOocY,UADJ,C,EyDsbR,Y,EAGI,EA5xB2B,OACyB,IAA9B,K,EACiC,KAAvC,G,EAAA,IACyC,IAAxC,GAyxBjB,OAQ0B,aAAtB,EAAsB,EA7wB9B,EAmxBmD,OAnxBnD,CA+wBkB,EAMd,GAxsBJ,SA6sBkB,IAhsByC,GAOb,uDAkB5B,8BACU,SAO5B,SAqqBY,IA7pBZ,SAI+B,UA2pBT,EA3pBS,KA2pBT,EA3pBS,iCA2pBT,EAxpBJ,KAwpBI,EAxpBJ,eAwBD,WAAb,qBAGoC,cAAvB,OAAkB,CAAK,MAMvB,OAA2B,CAA3B,EAEI,KAAuB,uBAKpB,QAKxB,SA2mBsB,GASlB,U,EtCr4BJ,WApC8E,CAW/D,SAXqG,MAAnB,GA0B/E,sBAnB0G,GAPR,MAAnB,CAOW,GAAF,GCV3F,OAwDP,QAE6C,SAAd,CDlBsB,GAxCvC,GC4D2B,SAAV,CDpBsB,GAxCvC,GAcP,KAeG,E,CAfH,EAeG,IAW2C,GAxCvC,OAG8F,eAAtC,CA6B/D,GAYiB,GCkBO,IDtBsB,OAxCvC,GCAP,aAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,UD3D6E,MAAnB,CAqC/D,KAC9B,C,EW+ME,E1B5JkD,E0B4JlD,C,IJ+vCK,IACmC,KAA1C,EAC0C,KAA1C,ED7tCgB,WACF,GACV,IA7NJ,ErB2BoD,GD3DtD,EC2DsD,GsBk6CxD,C,Ed0sBI,O,E8B9sEJ,WAOO,CAPP,EAOsC,QAA1B,EAEL,OAAoB,KAAH,OAKnB,OADA,OAEA,KAPM,CAAT,IAeQ,MAAG,OAAM,OAAH,GAAH,EAAZ,IAAiC,OAAL,OAAL,CAAd,QACI,KAAb,K,I1C6dsE,WAA3D,IAA2D,OAA3D,EAA2D,IAA3D,CAA2D,EAA3D,Y,GAAA,GADJ,C,IyCtfI,OAAJ,OAAO,YAAH,SAAJ,KAAO,gCACa,CAA3B,C,KfoRwB,OAAN,KACI,MAgX+D,OAhXnC,KAAjD,EA9KmB,SAAW,KAAnB,EAAQ,EAAR,CAAQ,EAiL2C,OACvC,KAAS,KAAT,MAEA,GAEM,OAAN,OACA,MAvLO,SAAnB,CAAmB,EAyLpB,OAvDW,OACA,KAAP,KACI,I,CAAA,EAEH,OAEW,OAAxB,GAwZ+D,OA1Z3C,KAtIQ,KAsIf,OAtIJ,KAwIe,OAAxB,GAEiC,QACtB,OAqZoD,OAFmB,KAzYhE,YAyCG,OAEA,GA1CH,OAAP,KACI,IAyYgD,QAvY3C,OAAP,KAzJe,SAAnB,CAAmB,EA2JJ,OAAxB,GAEiC,QACrB,OAkYmD,OAtUnE,EApByB,KAAS,KAAT,MAEA,GAEM,OAAN,OACA,QA7BZ,SA9KmB,OAAnB,EAAmB,EAAnB,CAAmB,EA6MpB,OAvDU,OAAP,KACI,IAyYgD,OAvY3C,QAAP,E,EAAA,GAzJe,SAAnB,CAAmB,EA2JJ,OAAxB,GAEiC,QACrB,OAkYmD,OAFmB,YA5U7D,OAEA,GAlFF,OACA,KAAP,KACI,IA4Z+C,QA1Z3C,OAAP,KAtIe,SAAnB,CAAmB,EAwIJ,OAAxB,GAEiC,QACtB,OAqZoD,QAtUnE,C,EAw0CA,OA9tB6E,GAsBxB,KA2sB1C,E,CA3sB0C,EA2sB1C,OA0BX,kC,EAAA,cPnnDqE,IAZtD,IAHG,I,EAGH,I,GAYsD,MM+N+B,KN7PrF,KAeG,EM8OkF,EN9OlF,MA1BkG,WAAtC,CA6B/D,I,GAAA,IAYiB,CAAqC,IQ9ChD,GRkCN,EQ/BM,OAGT,UAAgD,CDmoDlD,OACQ,KAAQ,eP3mDR,UA1BkG,MAAtC,CA6B/D,I,GAYsD,MAfnD,I,EAGH,I,GAYsD,IQ9ChD,GR8CgD,EQ3ChD,OAGT,UAAgD,CD2oD3C,OACC,QAAS,MADV,OAgBjB,G,EHjqDA,GHEe,iBGDP,YHiDe,GAhDR,OAgDQ,iCG7CN,QRJyD,GQI/B,SAA/B,IJ0BM,UAnB0G,GAPR,MAAnB,CA6BlF,I,GAtB2F,OCsCnF,GAhDR,OAgDQ,IDlCR,4BILC,oBH+BO,GAxCR,OAwCQ,ILzCmD,GQsBtD,WHmBG,GAxCR,OAwCQ,ILzCmD,OIiC3D,KJjC2D,IIIuB,CAOS,KC8BnF,GAxCR,OAwCQ,ILzCmD,EIe3D,EAPgB,KAAT,WAJ2E,eA0B/E,OA1B4D,OAAsC,MAAnB,SAAmB,CAAnB,IA6BlF,IAtB2F,IAI3F,EAPgB,OAAT,OAJwD,OAAsC,MAAnB,OAAmB,CAAnB,IA6BlF,GAtB2F,EAH3E,EIwBM,MAAG,MAAH,SRhCqC,CQmCtD,EAA2D,MAGrD,aAsCtB,MAxEgE,GAAxD,INLW,KG4D8B,WAAd,CH3DgE,CAAF,CAA5C,KM4ErD,EN7EmB,KG8D0B,WAAV,CH7DgE,CAAF,CAA5C,MADlC,E,EACkC,OADlC,G,CAAA,MGSC,GDOT,OFhBQ,YEoB6D,GAAnB,CFnBsC,CAAF,CAA5C,IEsB5B,WACU,CADV,EACrB,EIqDJ,MJrDI,MAC8B,EIoDlC,EJpDkC,aApB2D,EAoB3D,KApB2D,QAWlF,SAXqG,MAAnB,CI8D3D,QAAwD,OAGzE,MAJsB,cAA/B,EAWR,EJxE6F,MAO2B,GAPR,MAAnB,GA6BlF,GI2CX,MJxEgH,MAAnB,CAOS,CAPT,KA6BlF,GAlBA,SAXqG,MAAnB,CAOS,CIuDpE,QAUlC,EAPiB,UAJ8C,GAAvD,G,EAWR,E,IAAA,e,CAAA,mB,EDnFI,G,MzBgHS,EA9CO,MACA,GA6CP,KAxDU,OAAsB,CAWR,SAKR,CAwChB,EAvCE,GAAF,EDlER,IAA8B,CCkEtB,CAA6B,EAAI,IAA7C,G,GACC,EAAM,KAsCV,EAxBY,QAwBZ,G,EGgOF,YAEY,cWoDG,MT2JoB,OAFzB,GA7R6B,OAAd,OA4Tb,GA5T2B,EAAvC,SAySY,GC3gBH,MD8gBa,KAEW,OAAX,KWnVlB,eXifc,QA5dQ,IAufT,OChsBf,EC2DsD,GJ6OhD,WE2NF,I,IAhLkC,KAAe,KAAR,CD7VQ,IC6Vf,KA6DL,KA7DY,GD5V3C,EC4VoC,ED5VpC,WAEJ,G,EDgTY,OADJ,C,CADR,YAEY,gBY87BD,KA+kBW,YA/kBX,ODh8B2C,CAAtB,EACb,cACX,QAAR,QAAQ,WC6gDc,CD7gDd,ERzSN,EC2DsD,GJ6OhD,U,EADR,YWMkC,aC89DvB,CD99DuB,EC89DvB,QAtcuF,CAscvF,EAGL,IApRM,KAwRiE,CT3xEpE,cSw6DiB,IASH,OA3BA,OC1tDF,GDgtDK,cChtDL,MACjB,WFyHJ,CEzHI,ODsmEkB,OE3uEb,Gd0PG,YY6gDU,OAAX,CAAW,EAuH8B,KRl3DI,GJ6OhD,SYo+DJ,I,EZ12DA,MIvWoD,GJwWxD,C,EwCrcA,QAEK,GAGiB,MAKO,KAJhB,CAIgB,EAJtB,mBAGW,mBAC4B,KAAE,GAAX,oBAAnC,MAAoD,OAAK,KAA9B,CAAK,GAIxB,cAAG,OAAG,GAAf,MAAsB,OAAK,CAAlB,WACT,G,EtCguB6E,O,EiBvrB9E,UF/CuB,MEmDH,OAAJ,GA7CD,YA8CP,qBAzD4G,MAAnB,CCHlF,OA6EP,aHrEe,OCIH,OAAJ,GHiDD,KAAP,mBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,QAAO,KAAP,mBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,YKbe,CAmCI,MDfJ,UAtDR,OA8CwB,CAA/B,SFpDe,MEyDK,OAAJ,GAnDT,QAXkF,IAO2B,CAPR,KAAnB,CA6BlF,GAlBA,SAXqG,MAAnB,CAOS,CCV3F,OA6EP,YA7Be,CAmCI,MDfJ,aF5DA,OCIH,OAAJ,GHiDD,KAAP,mBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,QAAO,KAAP,E,CAAO,EAAP,yBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,UIDkD,CA9C3C,OA8CwB,CAA/B,SFpDe,MEmEH,OAAJ,IAEZ,G,EKlBJ,GJ3De,iBI4DH,gBP9DW,2BGSC,SLRkD,WEA6B,GAAF,CAA5C,K,EFW/B,KS+DF,YACJ,IAApB,OAAoB,OAEa,QP7EwB,QO6EzC,EAAhB,KAAgB,aACQ,YAAW,EACf,KAApB,gBAAoB,WAEJ,GAAiB,KA8BzB,EJlDyC,WAAV,CH7DgE,GAAF,CAA5C,GOwFpB,EAArB,0BPzFO,MGSC,GDOT,aAIqE,KAAnB,CFnBsC,CAAF,CAA5C,GEsB5B,WACU,CAA/B,SAC8B,EAD9B,EAC8B,wBApB8E,MAAnB,MAWlF,SAXqG,MAAnB,CKiGzE,MAAwE,OAGvE,MAJsB,YAA/B,ELhGiF,MAO2B,GAPR,MAAnB,GA6BlF,GKmEC,MLhGoG,MAAnB,CAOS,CAPT,KA6BlF,GAlBA,SAXqG,MAAnB,CAOS,CK0FlF,MADR,EAIS,UAJ8C,GAAvD,KAWR,O,E7B25IR,qCA+BkB,CA/BlB,EAoC4B,cAFX,SAAO,CAAP,KACC,CACmB,OAEV,CAFC,EAEO,MAED,IAAd,OACA,OACG,QAEP,QANmB,EAMnB,6CACA,8BAMc,GAAN,KACM,IAIqB,IAAU,WAAV,KAAQ,CAEvC,KACI,OACG,QAEP,QAN+B,EAM/B,wCAMI,IACI,KANoB,WAOxB,cACA,sC,CAAA,oFAOK,GAAa,KAhHtC,KACS,CAAD,IACA,QAAa,SAET,W,CAAA,OAAZ,MACkB,QAAa,GAClB,2BAFb,IAYQ,sDAAZ,EAAY,8EAsGW,OAGN,WACG,GAAa,SAjM7B,OAiM6B,OAjM7B,CAiM6B,EAjM7B,mC,EAAA,EACU,CAAD,IAAqB,E,CAD9B,EAC8B,mBAEF,EAFE,EAEF,MAAH,GAIH,YAAa,GAClB,eAEc,aAGlB,iBACD,IADI,CACJ,MACQ,YAMH,KAJH,IAOR,K,CAAA,EAAK,MACa,WAAwB,GAC/B,KAGT,KACK,CAAD,O,EAIZ,IACkB,UAAa,GAClB,OAIL,2B,GAAA,QANR,IAUW,UAAuB,GAAO,GAArB,CAAT,EAKC,sDAAhB,EAAgB,qEAsJD,EAtJC,GAsJM,GAAP,GAtJC,EAsJD,GAEe,KADQ,WAEhB,CAFgB,EAGC,WAEvB,oBACA,IACJ,SAKI,mDAEE,MAKE,EALF,GAKQ,GAAN,GALF,EAKE,GACmB,gBACT,GACM,KAAF,WACN,CAAR,SACR,QACM,MA3+CC,QAk4BP,GATR,aASQ,GATR,QAn4B2B,cADL,MAqCR,eAGmC,QApCtB,QAOZ,OAy3Bf,EASQ,WACE,UAEH,GAAgB,EAFb,EAEa,GACJ,GAAU,KAClB,KAAgB,eA0BC,M,CA1BD,EA0BH,WAGC,GAAJ,EAHG,EAGH,KAt2CD,OAAP,EAAO,EAAP,CAAO,EAA8B,SAAN,CAAX,CAAR,GAEP,KAAM,QAw2CI,MACX,UAGA,aAHA,EAIkC,KAAzB,WAAJ,I,EAEA,GACyC,KAC3C,GAAqB,EADsB,EACtB,WACpB,KAAe,UACN,IAAuB,KADa,KASlD,QAGU,IAA8B,OAAS,KAAL,CAAX,CADU,WAQ5C,UAEO,CAFP,EACgD,OAES,GAAzC,KAAyC,KAAzC,OAEQ,MACX,cALmC,OAFjD,UAuBF,UAoBS,QACC,QAEP,CAAU,gBACM,WACJ,CAAL,UAUA,cAAe,GAAf,EAAU,CAAV,EAAU,GACP,WAEhB,GAAD,EAFiB,EAEjB,KAyB+B,SAAW,OAAN,GAAZ,GACkB,aA1B1C,GACO,GAAgB,E,EAAA,K,EADvB,EACuB,GACL,aAEN,QADA,UAIM,SADC,GAAV,QADK,SA7QJ,SACN,MAAU,YAFM,KAAd,CAAd,UAoRgD,KApShC,MAEV,GAGK,QAJc,KAGlB,WAES,CAAR,GAEqB,OAAK,SACV,GAAV,GA2RF,QAiBuB,gBAAvC,CAAuC,EAGd,iBAxTL,MACS,GAGlB,WAqT4B,GAAQ,GAvTrC,KAGK,WACK,CAAR,GAEqB,OAAK,SACV,GAAV,GAiTN,OA+TA,OAtCI,MAvRe,GAuRf,EAvRU,CAuRV,EAvRU,GACQ,kBAEI,IAAK,EAAL,KAAK,GAAL,EACoB,KAD3B,QAGV,QAAsB,SA5+CnB,SAAP,EAAO,EAAP,CAAO,EAA8B,SAAN,CAAX,GAAR,GAEP,OAAM,IAFC,OA+wCW,KArGpB,MAEV,GAGK,QAJc,KAGlB,WAES,CAAR,GAEqB,OAAK,SACV,GAAV,SAkFE,MADM,GAEJ,SACU,CAAX,CAAL,KAYZ,QACS,wBAXsB,CAenB,MAFA,QADA,UAEE,OAbI,SAmBN,OAEa,KAHH,GAGU,MAQxB,OAIJ,aAFmB,WAEnB,kBACA,CADA,EACA,iC,CAAA,8F,EAAA,yC,CAAA,6LA4MY,GAAL,UACuB,gBACT,GACM,KAAF,WACL,CAAR,SACR,QAGO,M,GAIf,YArByB,OACA,aA3R7B,IA4R2B,EA3RT,OA2RS,EA3RT,EAKd,QAsRuB,EA1RF,KAEP,OACO,UAQF,GARE,EAQR,CARQ,EAQR,GAEF,WADmB,iBAEV,CAAR,GAEZ,MACwB,GADxB,EACkB,CADlB,EACkB,GAER,WADmB,iBAEzB,cACJ,GAES,eAAD,IACe,GACf,mWAEM,OADK,KAGf,2CACA,CADA,EACA,iC,CAAA,sG,EAAA,yC,CAAA,iLAKG,CAuPgB,KA4QX,2GAAsB,KAAtB,EAAsB,EAAtB,eAAsB,KAAtB,0BACU,CADV,EAEsC,WAAlC,+BAEA,eACA,mBACA,CADA,EACA,iC,CAAA,sG,EAAA,mC,CAAA,wLAEG,GAwIU,GA1GrB,yGAAsB,KAAtB,EAAsB,EAAtB,eAAsB,KAAtB,0BACU,CADV,EAEsC,WAAlC,+BAEA,eACA,cACA,sC,CAAA,4EAEG,IAoJnB,U,C8DpqGA,OAC8C,GAO0B,IAP1B,IACvB,CADuB,EAIvB,EADiB,KA16C/B,K,GA86C+D,WACtB,CAAhB,CAFjB,aAMjB,C,ExBz1CA,YACqB,WbpKN,OaoKC,QACgB,OAAc,OAA1B,IAAmC,MACf,abtKzB,SAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,UatCH,CbkCiB,OAAd,MalCH,uBbgC5B,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IalCA,OAAvB,EA0IQ,YbtID,Ca2IM,cACT,KAEmB,OADG,Ob7HnB,GDtCmF,EAI3F,gBAkBA,OChCA,Oa6K2B,Wb7HnB,ID7C6F,Mc0K1E,Qb7HnB,ED7CuD,CAAmB,GAOS,CcmKhE,GdtKpB,GcsKoB,oBdtKX,CAAT,E,EAAA,ICPP,OAgDQ,MD7CuD,KAAsC,MAAnB,CA6BlF,KAtB2F,EAI3F,EAJ2F,EC8BnF,GAxCR,OAwCQ,ILzCmD,CkB8KhC,GAKf,wBAMoB,CANpB,EAMX,OAC0C,OAAhB,gBdtL0E,QAAnB,CcsLvD,GAAqE,OAArE,GAA8F,OAA9F,GAClB,+BAFuB,SAA/B,OAC0C,OAAhB,ad/KkF,GAPR,MAAnB,CA6BlF,GAtB2F,Cc+KhE,GAAqE,OAArE,GAA8F,OAA9F,OAD8B,GAEhD,WAMhB,U,EA9JR,iBblCe,OamCM,ObnCN,SAgCQ,CaGF,EAAmB,IbHjB,GaGiB,EACR,KAAc,KAA1B,EAAmC,EbsBF,YalCjB,GbkCiB,QAAd,Ca9BA,CAAvB,EASQ,IAOc,OAAuC,OAAvC,GAA+D,OAA/D,GAAwF,OAAxF,GACtB,WbbO,GaaP,EAKsB,cAA+D,OAA/D,GAAwF,OAAxF,GACtB,ebXO,Caea,SbKa,YapCb,CboCa,UAAV,CahCA,CAAvB,EA4BI,QACkB,GACtB,WbVO,Caca,SdhDrB,UcmD6B,OdnD7B,UcuDC,edlEoG,MAAnB,CcmEvD,UdxD3B,WAPO,aAAS,CAAT,Cc+DoB,GAGF,OAHE,GAIF,OAJE,GAKtB,MACkB,QAPS,YAA/B,IdlEiF,MAO2B,GAPR,MAAnB,GA6BlF,GcqCC,MdlEoG,MAAnB,CAOS,Cc4DhE,Kd/DX,YAAT,GAJ2E,KA6BlF,GAzBO,MAJ8F,MAAnB,CAOS,Ec4DhE,GAGF,OAHE,GAIF,OAJE,OADgC,GAMtD,MACkB,WAdF,IAqBN,UAjBQ,IAkB9B,Q,IPm6CG,IACmC,KAA1C,EAC0C,KAA1C,ED7tCgB,WACF,GACV,IA7NJ,ErB2BoD,GD3DtD,EC2DsD,GsBk6CxD,C,EAyhBA,OAnnC6E,GAsBxB,SAspCnD,mC,EAAA,UCllEU,EF6QwF,KN7PrF,KAeG,EM8OkF,EN9OlF,IA1BkG,eAAtC,CA6B/D,GAYiB,GAZxB,E,GQlCI,CR8CyD,EAfnD,I,EAGH,IAHG,GAemD,IQ9ChD,GAAT,EAAS,IDmlEb,MChlEa,cAGT,gBAAgD,CD6kEpD,sBADN,KA91CoB,KAuyCH,M,EPz/DJ,IAHG,GAemD,MQ9ChD,EF6Q+E,KN7PrF,KAeG,EM8OkF,EN9OlF,IA1BkG,eAAtC,CA6B/D,GAYiB,GAZxB,EAHU,GQ/BG,MAGA,OAGT,UAAgD,CDqhEtD,QAGN,G,KP9gEe,OFhBQ,cEoB6D,GAAnB,CFnBsC,CAAF,CAA5C,IEsB5B,WACU,CADV,EACrB,EIoEJ,MJpEI,MAC8B,EImElC,EJnEkC,kBApB2D,UAWlF,SAXqG,MAAnB,CIiF/D,QAAwD,OAGzE,MAJsB,cAA/B,EAOJ,EJvF6F,MAO2B,GAPR,MAAnB,GA6BlF,GI0DX,MJvFgH,MAAnB,CAOS,CAPT,KA6BlF,GAlBA,SAXqG,MAAnB,CAOS,CI0ExE,QAAwD,GAGzE,UAJ8C,GAAvD,G,EAOJ,G,EtB7Cc,OcEc,CdFrB,CAAP,C,IAP0E,OcS9C,CdTuC,CAAb,IACnB,OcQP,CdRA,CAA5B,EAAmC,EAAnC,WAEJ,G,CAZA,OC4fmC,OAFzB,GDxfe,OcgBO,iBb8wCrB,IAldM,GCn1BR,MEGA,cCkSsB,OE7RzB,oBPAF,eAEJ,EC00BI,I,CuD+mBJ,OAC8C,GAO0B,MAP1B,IACvB,CADuB,EAIvB,EADiB,KAt5C/B,K,GA05C+D,WACtB,CAAhB,CAFjB,aAMjB,C,IAz+BY,KAAqB,E,CAArB,EAGyB,OADG,WAIT,GADqB,OAAR,GAc5C,EAZmB,SAA2C,KAAT,CAAsB,EACxD,KAA8B,GAD0B,EAG7D,OAA2B,GACF,OAQvC,MAFsB,OADe,SADN,KAI/B,C,EA+aA,KAEgC,GACH,SAAT,OAGe,GACjB,OAA8B,E,CAA9B,EAA8B,IAKT,GADM,OADG,YAKF,EAA9C,OAA8C,MAGO,OAG/B,SAA2B,CAA3B,EAC2B,YAG3B,OAAmB,CAAK,YAOP,sBAIvC,C,KxBhyB2B,OAAf,ObrMG,eAgDQ,CDlCR,SAXqG,QAAnB,KJJvB,CkByMtD,IAAyB,EdxK9B,OAtB2F,GJXhC,CkB2MlD,QAOhB,gBbzJA,eAII,WDzDwG,MAAtC,CA6B/D,GAYiB,GCkBO,IAWf,KAAF,Ca4HK,KAAf,MAYJ,C,EA3HR,YACoD,WbvD7B,CauDsD,KAApD,kBACT,EADoC,EACpC,IbxCO,GDtCmF,EAI3F,gBAPO,EAyBP,KCgBQ,ID7C6F,MAI9F,ICPP,OAgDQ,ED7CuD,CAAmB,GAOS,Cc+EpE,GAEH,OAFG,GdlFhB,OckFgB,GAEH,OAFG,GdlFhB,EckFgB,IdlFP,CAAT,E,EAAA,ICPP,OAgDQ,MD7CuD,KAAsC,MAAnB,CA6BlF,KAtB2F,EAI3F,EAJ2F,EC8BnF,GAxCR,OAwCQ,ILzCmD,CkB0FpC,GAIF,OAJE,GAKtB,SAIK,OblGN,OAgCQ,CakEP,MblEO,CamE0D,KAApD,MACT,KACsB,WbrDnB,GDtCmF,EAI3F,gBAkBA,OChCA,OaqG2B,WbrDnB,ID7C6F,MckG1E,QbrDnB,ED7CuD,CAAmB,GAOS,Cc2FhE,Gd9FpB,Gc8FoB,oBd9FX,CAAT,E,EAAA,ICPP,OAgDQ,MD7CuD,KAAsC,MAAnB,CA6BlF,KAtB2F,EAI3F,EAJ2F,EC8BnF,GAxCR,OAwCQ,ILzCmD,CkBsGhC,GAKtB,SAKJ,UACkB,KAClB,UAO0C,OhB1HnC,cgB2HW,KAClB,ObnHQ,GHTD,I,EAAA,Q,EAAA,MEyBe,OAFT,Gc4G0B,OhBnIhC,iBgBoIW,KAClB,Ob5HQ,GHTD,E,EAAA,EgBuI8C,KlBhG3C,UK9BF,ILRkD,GEDnD,E,CAAA,EFYG,WAYa,CAZb,EAYlB,QACQ,Q,CAAA,EAGa,QACE,gBALuB,IAAK,CAApB,EAnBxB,SAmBuC,CAAf,CAA/B,IAUA,UAAsB,mBI7BgD,CAW/D,WAXqG,MAAnB,CCHlF,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,OD9CG,KAeG,SA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IDtBL,OAjCZ,QcmIiC,OhB5IhC,yBgB6IW,KAClB,ObrIQ,eDAO,CAAT,C,EAAA,ECiCC,GAxCR,SAwCQ,ILzCmD,GEDnD,I,EAAA,IgBgJ8C,KlBzG3C,UEvCH,E,EAAA,E,EFYG,SAYa,CAZb,EAYlB,QACQ,Q,CAAA,EAGa,QACE,gBALuB,IAAK,CAApB,E,EAnBxB,OAmBuC,CAAf,CAA/B,IAUA,UAAsB,OKQP,CasGiF,KACtE,KAClB,OdlID,mBAXqG,MAAnB,CAOW,OAAF,GCV3F,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IDtBsB,OAA3B,Kc2Gc,OhBrJzB,SgBqJ0D,abnJlE,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IDvDjB,EFRiF,GEQjF,UAAS,GAAT,CFR+E,CAA5C,KgBqJvB,KAClB,OAEmF,abvJpF,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IayFqE,GAAhG,EAAgG,EAAhG,aAAZ,CAAY,adzIG,mBAXqG,MAAnB,CAOW,OAAF,GCV3F,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IDtBsB,OAA3B,KciHc,OhB3JzB,SgB2J0D,abzJlE,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IDvDjB,EFRiF,GEQjF,UAAS,GAAT,CFR+E,CAA5C,KgB2JvB,KAClB,OAEmF,ab7JpF,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,OD9CG,KAeG,SA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,Ia+FqE,GAAhG,EAAgG,EAAhG,aAAZ,CAAY,iBd/IG,QAJ6F,KAAF,EAI3F,SAXqG,MAAnB,CAOS,CCV3F,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IDtBsB,OAA3B,acuHsC,Gb/JzD,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,I,EAWf,KAAF,CasFQ,GACE,kBAlCE,KAClB,KAOkB,MAjB1B,Q,EdtCR,OAIQ,GAIQ,aAAQ,CAAR,EAAQ,oBAAR,KHtBP,CG0BO,kBAJA,WAKA,OALQ,gBFzFD,YG+FH,CH/FG,EG+FH,YAtFI,WLRkD,WGkB1E,GHyDqC,KCT5B,IDSkC,OElEpB,EFwEF,WAAJ,OAPT,G,EKoBY,IAtFI,OLRkD,KA2ErC,OCT5B,I,CDS4B,EAAM,KElEpB,EFwEF,WAAJ,OAAW,GAPpB,IACmC,KElEpB,SGDC,GAyFsB,QDAvB,YFxFA,2BGRR,eAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,QDsC3B,GC3BY,KAAF,GDcN,SAAQ,aAesC,KAAnB,MFxGpB,EE+GwB,KAHvC,EAGuC,EAHvC,qBArFqB,YACU,CAA/B,gBAC8B,EAD9B,EAC8B,cApB2D,aCHlF,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IDtBL,aAyEK,MAA/B,4BAvGoH,KAPR,MAAnB,CAOW,GAAF,GCV3F,OAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,ID3D0D,KAqCpC,KAA3B,OAyEkB,CAAb,KAA/B,IAIJ,G,EWgLJ,C,ETlNA,eAQgB,KAAQ,cAAR,KL1BP,CK6BO,kBAHA,WAIA,GAJQ,aAOE,CAAO,EAAG,OAAU,CAAb,MACV,WAAQ,OAAI,CAAnB,OARA,KAAQ,QAaG,QACJ,E,CADI,E,EAAA,EAwBvB,IDhIW,eAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,QC+C3B,GDpCY,KAAF,KCqCN,KAnBQ,QAuBsC,KAAnB,MAvBnB,E,EAAA,EA8BuB,KAHvC,EAGuC,EAHvC,cFjGqB,cACU,CADV,EACrB,WAC8B,EAD9B,EAC8B,aEsG1B,aADwC,EAAb,KAA/B,IAIJ,G,EGrHJ,GJXe,WAgDQ,CInCY,OLCpB,OKDgD,CAA5B,YJbpB,OAgDQ,CI7BgB,EANJ,E,EAAA,EAsC3B,mBAhC+B,EAgC/B,E,EAAA,MA3BmB,OADA,YLTZ,KKW8B,MJzB9B,OAwCQ,CIbS,aT5B0C,CS+B3C,GAEuB,SAAa,CAApC,QAMJ,OADA,YLvBZ,KKyB8B,MJvC9B,OAwCQ,CICS,aT1C0C,CS6C3C,GAEuB,SAAa,CAApC,SAKvB,G,ESiMR,mBhBtPuB,qBEgBR,Yc6O2B,Ed7O3B,Oc6OuD,CAA5B,EhB7PnB,E,EgB6PmB,OhB7PnB,G,CAAA,EgB8NG,sBdzNuE,CcyNvE,WZjNJ,gBAAS,CAAT,CYiNI,GACkB,4BACpC,SACiB,KAAI,KhBjON,E,EAAA,EgBqO4E,OAAf,GAAnB,IhBrO1C,I,CAAA,EgB0O+B,OAEK,GAHnD,EAC8C,EAD9C,kBbhOgB,GasOsC,OdxNjC,eACU,CADV,EACrB,UAC8B,EAD9B,EAC8B,acwNlB,aADyC,EAAtB,KAA/B,Ob9OO,aAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,Q,EAAA,IAeG,C,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IAWf,KAAF,Ca8LG,aAAsC,GdzPhD,KAeG,EAfH,EAeG,IA1BkG,eAAtC,CA6B/D,GAYiB,GAZxB,CESgB,EFZN,GEYI,GYmOG,aAAsC,Od9PhD,WEHO,YFGP,YEnBa,OFQkD,OAAsC,QAAnB,WA0B/E,CA1B+E,EA0B/E,MA1BkG,MAAnB,CA6BlF,I,GAtB2F,IAI3F,ECdA,iBAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,QA9DxB,eAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,UatCH,2BbgC5B,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,IalCA,OAAvB,EAuPJ,QZxQU,kBDXP,eAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,SDjCrB,I,CAAA,MEYI,KA9BA,SFR8F,OAAtC,OAAsC,MAAnB,CA6BlF,GAYiB,GAAqC,CEH7C,CAAF,GA9BA,EA8BA,IA9BS,CAAT,EA8BA,CA9BA,QFR8F,CAAnB,EA0B/E,EA1B+E,SCHlF,eAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,WAWf,OAAF,CaoNwC,CAHtD,EbjNgB,EaiNhB,sBdrQqB,ECyCU,KDzCV,GACrB,EADqB,IACU,Cc0Q/B,Ed3QqB,Cc2QrB,Ud1QA,CAC8B,EcyQ9B,EdzQ8B,Uc0Q1B,aADwC,EAAb,KAA/B,Yd3QqB,Gc2QrB,GAIJ,Q,KjCw8CI,M,CAAA,OAGG,GACP,SA3VI,yCAnNA,cAhpBQ,SAm2BR,GA1FA,yBAzwBQ,SAm2BR,GA1FA,yBAzwBQ,SAm2BR,GA1FA,yBAzwBQ,SAm2BR,GA1FA,yBAzwBQ,SAm2BR,GA1FA,uBA0FA,2NA+RA,qBA/RA,GA+RA,qBA/RA,GA+RA,qBA/RA,GA+RA,uBAloCQ,SAm2BR,GA1FA,yBAzwBQ,SAm2BR,GA1FA,uBA0FA,GA+RA,qBA/RA,GA+RA,qBA/RA,GA+RA,qBA/RA,GA+RA,uBAloCQ,SAm2BR,GA1FA,yBAzwBQ,SAm2BR,GA1FA,uBA0FA,GA+RA,qBA/RA,GA+RA,qBA/RA,GA+RA,qBA/RA,GA+RA,uBAloCQ,SAm2BR,GA1FA,yBAzwBQ,SAm2BR,GA1FA,uBA0FA,GA+RA,uBA/RA,GA+RA,uBA/RA,GA+RA,uBA/RA,GA+RA,yBAloCQ,UAm2BR,GA1FA,0BAzwBQ,UAm2BR,GA1FA,wBA0FA,GA+RA,uBA/RA,GA+RA,uBA/RA,GA+RA,uBA/RA,GA+RA,yBAloCQ,UAm2BR,GA1FA,0BAzwBQ,UAm2BR,GA1FA,wBA0FA,GA+RA,uBA/RA,GA+RA,uBA/RA,GA+RA,uBA/RA,GA+RA,yBAloCQ,UAm2BR,GA1FA,0BAzwBQ,UAm2BR,GA1FA,0BAzwBQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,wBAksBA,eA7iBA,KA0jBA,EAbA,GA7iBA,KA0jBA,EAbA,GA7iBA,KA0jBA,EAbA,GAaA,SA75CQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,wBAqJA,GA+RA,uBA/RA,GA+RA,uBA/RA,GA+RA,uBA/RA,GA+RA,uBA/RA,GA+RA,uBA/RA,2CAnNA,gBAhpBQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,0BA9sBQ,iBAm2BR,GArJA,0BA9sBQ,UAm2BR,GA1FA,0BAzwBQ,UAm2BR,GA1FA,wBCtpCR,C,EDqKY,WADJ,C,EADR,YWMkC,aC89DvB,CD99DuB,EC89DvB,QAtcuF,CAscvF,EAGL,IApRM,KAwRiE,CT3xEpE,cSw6DiB,IASH,OA3BA,OC1tDF,GDgtDK,cChtDL,MACjB,WFyHJ,CEzHI,ODsmEkB,OE3uEb,Gd0PG,gBY6gDU,OAAX,CAAW,EAuH8B,KRl3DI,GJ6OhD,SYo+DJ,I,IZ9zDmE,WAA3D,IAA2D,OAA3D,EAA2D,IAA3D,CAA2D,EAA3D,Y,GAAA,GADJ,C,ImBheO,KAeG,E,CAfH,E,EAAA,ElB+BX,IkB1CgH,eAAtC,CA6B/D,GAYiB,GAZxB,ClBaG,CAAP,C,CARJ,WkBvBe,KAeG,EAfH,EAeG,IA1BkG,eAAtC,CA6B/D,GAYiB,GAZxB,ClBM+D,E,GAAb,IkBxB3C,KAeG,EAfH,EAeG,IA1BkG,eAAtC,CA6B/D,GAYiB,GAZxB,ClBOwB,I,EAA5B,aAEJ,G,EAZA,OC4fmC,OAFzB,GiBvfK,EAlBA,KAeG,EAfH,EAeG,MA1BkG,WAAtC,CA6B/D,I,GAAA,IAYiB,CAAqC,UAZtD,ElBDf,OC40BiB,GCn1BR,MEGA,cCkSsB,OE7RzB,oBWHY,UA1BkG,MAAtC,CA6B/D,IAHG,GAemD,GlBZpC,CAA7B,EkBYiE,ElBZjE,WAEJ,EC00BI,I,KDn2BsC,QcoD3B,SAAP,EAAO,EAAP,qBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,cdlDwB,GACxB,EGgFgD,EHhFhD,IWu9BA,UXh9BR,MAJkB,GYmCT,YD0vEE,CC1vEF,ED0vEE,QAtcuF,CAscvF,EAGL,IApRM,KAwRiE,CT3xEpE,cSw6DiB,IASH,OA3BA,WC1tDF,GDgtDK,OChtDL,MACjB,gBDsmEkB,OE3uEb,Gb/DL,EG2EoD,EHzExD,EW0xEI,I,KX/yEmC,WWy1DjB,SAAX,CA6IA,GXr+D6E,WcAd,KA2ErC,SCT5B,I,CDS4B,EAAM,KElEpB,EFwEF,WAAJ,OAAW,GAPpB,IACmC,KElEpB,MF6EV,GACM,SA5EO,GdL1B,IAJQ,EG2FgD,EH3FhD,EAIR,C,EqCIqC,IlCmFmB,EkCnFlB,C,CmBqxBtC,GAEQ,cACuB,KAEY,KAAlC,OAAD,CAAS,CAAT,EAEU,KAAmC,OAA5C,EAAD,GAEU,KAAmC,OAA5C,KAGT,G,CA9PA,OACmC,GAEvB,SAAN,CAAM,EAAN,IAG8B,GAC5B,K,CAEe,EADiB,KA3e/B,IA6eL,GACS,IAIuB,CAJvB,E,CAKX,EALW,CAKX,IAK6D,GAAxC,UAlBX,EAuBiE,iBACvD,CAAhB,CAFS,WAGf,C,CAhKA,OACW,EAAP,C,ENjaH,I,EDGC,I,E9CHqC,I,GL4GrC,QAEA,YApDA,yJAMA,8CAMA,oBAgEA,QACA,UACA,UACA,UACA,KArCA,8LAmEF,C,EqBvFA,eH3FuB,EG+FX,cAAQ,YAtFI,OLRkD,aGkB1E,GHyDqC,KCT5B,IDSkC,OElEpB,EFwEF,WAAJ,OAPT,IACmC,KElEpB,MF6EV,GACM,SA5EO,KK0FtB,MA7FoB,GAyFsB,QAI1C,MA7FoB,OLRkD,KA2ErC,OCT5B,I,CDS4B,EAAM,KElEpB,EFwEF,WAAJ,OAAW,GAPpB,IACmC,KElEpB,MF6EV,GACM,SA5EO,QK0FtB,G,CkB3FJ,QAAqC,G,EoBwFF,GAhEnC,EAE2C,C,IJgBlC,WAAP,EI+CM,EAA8C,CADnB,EAE7B,EtDPkD,GkCnFlB,G,CDmCtC,MAC+C,CAAnB,KACR,CAAlB,C,CDsLF,KAEE,EG5NW,EamDb,GAA8C,GAAC,EbnDlC,GAA2C,GH4NhD,EiBpKY,MAC0D,CAAlC,MAG1B,GADA,OADA,OAGE,EAjCpB,EAEc,CA+BM,MACS,CAA3B,EADkB,EAClB,W,EACO,Kd/DgD,EHmIQ,GAAiB,GAAC,EAyFjF,U,EV4FF,GAQuB,IARvB,IAQuB,GAAmB,EAAnB,EAA2B,KAAjC,SAhLH,KAAZ,MAkL6D,KAIrD,IAhPW,aAgPX,GACgB,OAAP,QAPI,EA1OS,OAAnB,EAAmB,EAAnB,CAAmB,EAmPJ,OAChB,kBACwB,OAA9B,GAI+B,QAIP,OAGpB,OAEgB,OAAP,KAlQa,SAAnB,CAAmB,EAoQF,OAAxB,GAEiC,QACf,OAAP,KAyRkD,OAvR1C,OAAP,KACI,IAsR6C,QApRvC,OAAP,GACN,aAKO,E,EAAA,WAaV,aA/RS,OAAW,KAAnB,EAAQ,EAAR,CAAQ,EAwST,K,CAAA,EAEE,IACkC,OACA,GA1KzB,OACA,KAAP,KACI,IA4Z+C,QA1Z3C,OAAP,KAtIe,SAAnB,CAAmB,EAwIJ,OAAxB,GAEiC,QACtB,OAqZoD,OAhPpC,WAAR,MAGS,QAGZ,I,EAAA,GAAmB,EAAnB,EAAoC,OAAa,IACjD,OAAoB,KAAkB,OADW,cAExC,GAGT,EAmOkE,KAnOlE,GAmOkE,EAnO/C,KAAT,OACC,GAuE/B,EA/DqB,OAAoB,KAAkB,OAAlB,OAd4B,OAgB7B,OACA,GAjLlB,OAAP,KACI,IAyYgD,QAvY3C,OAAP,KAzJe,SAAnB,CAAmB,EA2JJ,OAAxB,GAEiC,QACrB,OAkYmD,YAFmB,OAhNZ,KAA1B,OACA,OACA,GA9MzB,OACA,KAAP,KACI,IA4Z+C,QA1Z3C,OAAP,KAtIe,SAAnB,CAAmB,EAwIJ,OAAxB,GAEiC,QACtB,OAqZoD,OA7JnE,O,CAAA,EA9Cc,IACkC,OACA,GAjM1B,OAAP,KACI,IAyYgD,QAvY3C,OAAP,KAzJe,SAAnB,CAAmB,EA2JJ,OAAxB,GAEiC,QACrB,OAkYmD,OArMpC,WAAR,MAGU,QAGb,I,EAAA,GAAmB,KAAiB,OAAa,OAc7B,GAbpB,OAAoB,EAApB,EAAsC,OADW,QAExC,GA2LyD,KAxLhE,OAAY,M,CAAA,MACH,GA4B/B,EApBwC,OAAiB,OAAjB,cAEC,OACA,GA/OlB,OAAP,KACI,IA4Z+C,QA1Z3C,OAAP,KAtIe,SAAnB,CAAmB,EAwIJ,OAAxB,GAEiC,QACtB,OAqZoD,YAFmB,OArKZ,KAA1B,OACA,OACA,GAtO1B,OACA,KAAP,KACI,IAyYgD,QAvY3C,OAAP,KAzJe,SAAnB,CAAmB,EA2JJ,OAAxB,GAEiC,QACrB,OAkYmD,OA7JnE,EAnYqB,WAAW,OAAnB,QAuSP,G,EARM,IACW,IAmGvB,C,E1BqoBI,I,CA5pBJ,YAEY,OUsFJ,OAAuB,E,GAAP,GVtFZ,YU4FD,SAAO,CAAP,EAhML,KVmGE,Q,EChWR,Y6B0CQ,YA8GgG,GA6F3F,UJ+7BsB,I,EAAA,CAGlB,SArrBqC,GAkrBnB,I,EAAA,CAGlB,SArrBqC,OCvjBb,GD85B4B,qBAtDa,CA9K5D,GC1rBiB,ED85B8B,KApO/C,EAoO+C,KApO/C,UAoO+C,EApO/C,EAoO+C,KApO/C,GAoO+C,EC55BjD,IAAe,KAAH,EAAZ,KAAY,CAAZ,EAA6B,KAAY,GAAf,GFiNsD,KACP,YE/MM,OAAF,CAAzE,GF8M4E,KN7PrF,KQgDK,KAGsB,KAHtB,IR3DgG,KAyCpF,SAzCoF,QAAtC,CA6B/D,GAYsD,EQqB7B,SAGK,CAHL,EI6wCoC,ML5lBtD,GC5qBoC,EK8uBkB,SNmBtD,GCjwBE,YRnE4F,CAAtC,CA6B/D,GAYsD,CQ6B8B,CAAb,IFmMO,KN9P9E,KAeG,EM+O2E,EN/O3E,IA1BkG,eAAtC,CA6B/D,GAYiB,GAZxB,CQ0CiD,ER7CvC,GM+O2E,EElMzE,aD4pDa,cAC4B,K,CAD5B,EAGnB,EvBjtDL,EsByLD,OC0hDa,OAnBG,OAFA,GAId,OACJ,KAAgB,GAAQ,EAAxB,EACa,QAC8B,KAA/C,IACA,aDh8CM,GA7NJ,ErB2BoD,EqBmMlD,GM+iCsE,ML5lBtD,GCpqBoC,EKsuBkB,SNmBtD,GCzvBE,YR3EyE,EA6BlF,GAYsD,CQqC8B,CAAb,IF2LO,KN9P9E,KAeG,EM+O2E,EN/O3E,IA1BkG,eAAtC,CA6B/D,GAYiB,GAZxB,CQkDiD,ERrDvC,GM+O2E,EE1LzE,aDopDa,cAC4B,K,CAD5B,EAGnB,EvBjtDL,EsByLD,OC0hDa,OAnBG,OAFA,GAId,OACJ,KAAgB,GAAQ,EAAxB,EACa,QAC8B,KAA/C,IACA,aDh8CM,GA7NJ,ErB2BoD,GqBgLqC,UKyJrF,KAAK,KAEF,qBJjPA,OAAS,EAAT,EAAS,IA5BN,KAAZ,O,EA1DmB,SAAW,KAAnB,KAwFX,IA0jBoB,EA1jBpB,IA0jBoB,CCzrBqB,ID6HhC,OAAS,EAAT,EAAS,IA5BN,KAAZ,O,EA1DmB,SAAW,KAAnB,KAwFX,IA0jBoB,EA1jBpB,IA0jBoB,CC1rBiB,IAwCd,OAAF,KACf,GACA,kBK2mBkE,cNyQL,KA/I/C,KCnuBd,EDkFG,yBA5BG,2BA1DO,SAAW,KAAnB,KAwFX,OAxFmB,SAAW,KAAnB,KAwFX,IAurDmB,EAAf,KAAe,CAAf,EACa,QACjB,aACiC,KAAjC,IA5I+B,cAC4B,K,CAD5B,EAGnB,EvBjtDL,IsB8PS,WACF,GAtER,OI9DuC,OAAP,GHwlDnB,OAnBG,OAFA,GAId,OACJ,KAAgB,GAAQ,EAAxB,EACa,QAC8B,KAA/C,IACA,cDl8CkB,WACF,GACV,IA7NJ,ErB2BoD,GD3DtD,EC2DsD,EsB2uBlC,EvBtyBpB,IuBsyBoB,CCnuBd,MGjCR,EAEE,OApB+F,GAoB/F,YJkwBoB,EA+I+C,KA/I/C,GA+I+C,EC92B7D,OD8EG,yBA5BG,2BA1DO,SAAW,KAAnB,KAwFX,OAxFmB,SAAW,KAAnB,KAwFX,IAurDmB,EAAf,KAAe,CAAf,EACa,QACjB,aACiC,KAAjC,IA5I+B,cAC4B,K,CAD5B,EAGnB,EvBjtDL,IsB8PS,WACF,GAtER,OI9DuC,OAAP,GHwlDnB,OAnBG,OAFA,GAId,OACJ,KAAgB,GAAQ,EAAxB,EACa,QAC8B,KAA/C,IACA,cDl8CkB,WACF,GACV,IA7NJ,ErB2BoD,GD3DtD,EC2DsD,EsB2uBlC,EvBtyBpB,IuBsyBoB,CC/tBd,IDk1B6C,KAwjBnD,EAxjBmD,KAwjBnD,EI5mCa,OAAK,QAAL,EAAK,GAEP,QAFE,EAEF,iB7B1RT,O0BXuC,K1BWvC,E,ED8VJ,YW9HkC,aC89DvB,CD99DuB,EC89DvB,eAtcuF,CAscvF,EAGL,IApRM,KAwRiE,CT3xEpE,cSw6DiB,IASH,OA3BA,OC1tDF,GDgtDK,cChtDL,MACjB,mBDsmEkB,OE3uEb,Gd8XG,YYy4CU,OAAX,CAAW,EAuH8B,KRl3DI,GJiXhD,SYg2DJ,I,EXpsEJ,YW8uDsB,cepzD6B,OCtBH,chB00DrC,CA6IA,CgBt9DwE,KAAhD,EACX,E,CDoB2B,ECnBvC,ExB4E4C,EwB5E5C,GDqBI,KAAc,OAAH,CAAX,EAAW,MACX,KRxBD,WQ0B6B,CR1B7B,EQ0B6B,IAC5B,CD6rDiB,SAC4B,KAE/C,IvBjtDL,EsByLD,OI9DuC,OAAP,GHwlDnB,OAnBG,OAFA,GAId,OACJ,KAAgB,GAAQ,EAAxB,E,EACa,MAC8B,KAA/C,IACA,oBCnrDc,CD2rDiB,SAC4B,KAE/C,IvBjtDL,EsByLD,OI9DuC,OAAP,GHwlDnB,OAnBG,OAFA,GAId,OACJ,KAAgB,GAAQ,EAAxB,E,EACa,MAC8B,KAA/C,IACA,mBDh8CM,KA7NJ,ErB2BoD,GHcpD,W2B3FoB,C3B2FpB,C,IDwZsE,WAA3D,IAA2D,OAA3D,EAA2D,IAA3D,CAA2D,EAA3D,Y,GAAA,GAAP,C,C2BveR,KACmB,GD85BkC,KAimBnD,QAvnB2E,CAynBrD,OACA,GApmB6B,KAimBnD,QAvnB2E,CAynBrD,OACA,GC9/CpB,C,IAVgB,OAC+C,MFqQ/C,OACF,OACV,IA7NJ,ErB2BoD,GqB3BpD,IEzCe,GACf,C,I3ByesE,WAA3D,IAA2D,OAA3D,IAA2D,IAA3D,CAA2D,EAA3D,Y,GAAA,GAAP,C,C2BlfR,KAEmB,GADA,OAEf,C,E3B4ZJ,KACW,I2BzZqE,O3ByZvD,W0B+L6B,SAkrBnB,CAGlB,SArrBqC,ODxba,SC0mChC,CAGlB,SClxCE,GADA,OAKC,OAC+C,MFqQ/C,OACF,OACV,IA7NJ,ErB2BoD,GqB3BpD,IErCe,GD85BkC,KAimBnD,EAEsB,WACA,GApmB6B,KAimBnD,EAEsB,WACA,G1B9mCpB,G,CAxGJ,YAEe,cAAH,eADJ,Q,IA0HJ,IyBvKgB,WACF,GACV,IA7NJ,ErB2BoD,GsB81BH,KAwjBnD,EAxjBmD,KAwjBnD,E1B/iCE,EIvWoD,GJwWxD,C,EAoqBI,I,ECxgCJ,YACgD,MkBnFjC,WEXa,OFAqE,CK8HpF,IAAD,GLnHG,WAIqE,KAAnB,CFnBsC,CAA9C,GEsB5B,WACU,CAA/B,SAC8B,EAD9B,EAC8B,wBApB8E,MAAnB,MAWlF,SAXqG,MAAnB,CKuIjF,ELpHR,OKoHQ,EAAyE,OAGxE,MAJsB,YAA/B,ELtIyF,MAO2B,GAPR,MAAnB,GA6BlF,GKyGP,MLtI4G,MAAnB,CAOS,CAPT,KA6BlF,GAlBA,SAXqG,MAAnB,CAOS,CKgI1F,MAAyE,GAGxE,UAJ8C,GAAvD,G,EvBtCA,EGPgD,EHOhD,KAIR,U,CAhBA,YACgD,MuB4BnC,UvB3BwE,WuB8BtE,EvB9BgF,GACvF,EGEgD,EHFhD,KAIR,U,IAfgD,IAC2B,WAA3D,EADgC,E,GAExC,EGWgD,EHXhD,GAIR,C,IWkwDsB,OA/kBX,OXnsCiB,OACoB,YoBnEpB,GFWb,OEXa,UTo1DN,CXlxDM,KWmsCjB,OXnsCiB,CAE6D,KsBsB1E,EtBvBiC,EACmD,EAKnG,EAJQ,EGoBgD,EHpBhD,EAIR,C,IW2wDsB,OA/kBX,OX7sCiB,OACoB,kBW2xD1B,CX5xDM,KW6sCjB,OX7sCiB,CAE6D,KAAzE,EADgC,EACmD,EAKnG,EAJQ,EG8BgD,EH9BhD,EAIR,C,ID6auE,WAA3D,IAA2D,OAA3D,IAA2D,IAA3D,CAA2D,EAA3D,Y,GAAA,GADJ,C,CqBpeR,SACkB,CAAI,EFGP,SEHmC,CAAnB,GAAT,aFRwD,OAAsC,MAAnB,GA0B/E,UAnB0G,GAPR,MAAnB,CA6BlF,IAHG,GAnBwF,MEKtG,G,IFDW,Y,EAAA,EEdX,IFG0E,OAAsC,QAAnB,WA0B/E,CA1B+E,EA0B/E,EA1BkG,UAAnB,CA6BlF,I,GAtB2F,GEVtG,C,EFcW,OEIgB,CAAvB,E,CD6BR,KACuB,GAhDR,OAgDQ,EAKnB,C,CAdJ,KACuB,GAxCR,OAwCQ,EAKnB,C,CAdJ,KACuB,GAhCR,OAgCQ,EAKnB,C,EArCW,KAAP,C,IpB+e+D,WAA3D,IAA2D,OAA3D,IAA2D,IAA3D,CAA2D,EAA3D,Y,GAAA,GADJ,C,CmB3cR,SA5BkB,CAAI,EAOP,OAPgB,GAAT,MAJwD,OAAsC,MAAnB,GA0B/E,UAnB0G,GAPR,MAAnB,CA6BlF,IAHG,GAnBwF,MA0BlG,G,EAtBO,KAAP,C,KlBLkC,MkBK3B,SE+BH,iCA3BmB,CAkCQ,CAP3B,EAO2B,CAP3B,ED7CG,QDOgB,GEOhB,GFPgB,GAAT,SAJ8F,MAAnB,GA0B/E,UAnB0G,GAPR,MAAnB,CA6BlF,IAHG,GAnBwF,IAH3E,ECPhB,KA6EP,aHrEe,OCIH,OAAJ,GHiDD,KAAP,mBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,YAAO,KAAP,mBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,YKbe,CAmCI,SC7BJ,gBAQC,GALkB,KACjB,OAAc,GAAF,CAAZ,OANkC,OAUvC,GFhDL,OEsCP,IJ3CgG,OAAF,GAA7C,OI2DhB,CJ3DgB,EI2DjD,OACgB,EADhB,EACgB,UADhB,Q,EAAA,EAGY,GFzDL,WAXqG,MAAnB,OA6BlF,OAtB2F,QAPT,IA0B/E,CA1B+E,EA0B/E,MA1BkG,SAAnB,CA6BlF,I,GAtB2F,GCV3F,OA6EP,aHrEe,OCIH,OAAJ,GHiDD,KAAP,mBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,QAAO,KAAP,mBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,YKbe,CAmCI,SCVR,gBAMC,OAAJ,OpBpEgB,GACxB,EGgFgD,EHhFhD,IWu9BA,UXh9BR,E,EAAA,EAJkB,GYmCT,YD0vEE,CC1vEF,ED0vEE,QAtcuF,CAscvF,EAGL,IApRM,KAwRiE,CT3xEpE,cSw6DiB,IASH,OA3BA,WC1tDF,GDgtDK,OChtDL,MACjB,gBDsmEkB,OE3uEb,Gb/DL,EG2EoD,EHzExD,EW0xEI,I,IX/yEmC,WWy1DjB,SAAX,CA6IA,CXr+D6E,KAAzD,EADQ,EAEnB,EAKpB,EAJQ,EG2FgD,EH3FhD,EAIR,C,CAuCA,O,EmB5Ce,WAwDP,QD1CO,KAeG,E,CAfH,E,EAAA,ElB+BX,IkB1CgH,eAAtC,CA6B/D,GAYiB,GCkBO,InBjB5B,G,EmBa0C,OAAd,CnBb5B,CAAP,C,EARJ,WmBrCe,eAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,InBxBgC,GAAb,ImBtC3C,eAwDP,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,InBvBP,GAA5B,EAA4B,EAA5B,WAEJ,G,EAZA,OC4fmC,OAFzB,OkBvhBK,uBAwDP,QAE6C,OAAd,CAA3B,GAEqC,OAAV,CAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,EA9DxB,EA8DwB,IlB+vC5B,C,CkB/vC4B,ElB+vC5B,GD9xCO,OC40BD,ICn1BR,MEGA,cCkSsB,OE7RzB,oCYwBE,QAE6C,OAAd,GAA3B,GAEqC,OAAV,GAA3B,GD9CG,KAeG,E,CAfH,EAeG,WA1BkG,eAAtC,CA6B/D,GAYiB,GCkBO,InB9BN,GAA7B,EAA6B,EAA7B,WAEJ,EC00BI,I,KDn2BsC,IACmC,OmBV9D,mBA6EP,aHrEe,OCIH,OAAJ,GHiDD,KAAP,mBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,YAAO,KAAP,mBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,YKbe,CAmCI,SnBxEK,gBACxB,EGgFgD,EHhFhD,IWu9BA,UXh9BR,MAJkB,GYmCT,YD0vEE,CC1vEF,ED0vEE,QAtcuF,CAscvF,EAGL,IApRM,KAwRiE,CT3xEpE,cSw6DiB,IASH,OA3BA,WC1tDF,GDgtDK,OChtDL,MACjB,gBDsmEkB,OE3uEb,Gb/DL,EG2EoD,EHzExD,EW0xEI,I,IX/yEmC,WWy1DjB,SAAX,CA6IA,CXr+D6E,KAAzD,EADQ,EAEnB,EAKpB,EAJQ,EG2FgD,EH3FhD,EAIR,C,KAI0C,MACmC,OAA9C,EACC,E,EAAA,Q,EAFU,EAGlC,EGgFgD,EHhFhD,IWu9BA,UXh9BR,MAJkB,GYmCT,YD0vEE,CC1vEF,ED0vEE,QAtcuF,CAscvF,EAGL,IApRM,KAwRiE,CT3xEpE,cSw6DiB,IASH,OA3BA,WC1tDF,GDgtDK,OChtDL,MACjB,gBDsmEkB,OE3uEb,Gb/DL,EG2EoD,EHzExD,EW0xEI,I,IX/yEmC,WWy1DjB,SAAX,CA6IA,CXr+D6E,KAAzD,EADQ,EAEnB,EAKpB,EAJQ,EG2FgD,EH3FhD,EAIR,C,KAI0C,egBDnB,OCIH,OAAJ,GHiDD,KAAP,EAAO,EAAP,qBErDe,EFyDF,WAAJ,GAJF,WAIa,GAJpB,cdlDwB,GACxB,EGgFgD,EHhFhD,IWu9BA,UXh9BR,MAJkB,GYmCT,YD0vEE,CC1vEF,ED0vEE,QAtcuF,CAscvF,EAGL,IApRM,KAwRiE,CT3xEpE,cSw6DiB,IASH,OA3BA,WC1tDF,GDgtDK,OChtDL,MACjB,gBDsmEkB,OE3uEb,Gb/DL,EG2EoD,EHzExD,EW0xEI,I,KX/yEmC,WWy1DjB,SAAX,CA6IA,GXr+D6E,WcAd,KA2ErC,SCT5B,I,CDS4B,EAAM,KElEpB,SFwEF,WAAJ,GAPT,IACmC,KElEpB,MF6EV,GACM,SA5EO,GdL1B,IAJQ,EG2FgD,EH3FhD,EAIR,C,EDmmCI,I,EAAA,I,EAAA,I,EAAA,I,EAAA,I,EAAA,I,CA5pBJ,YAEY,OAEI,OAFJ,cADJ,Q,EEtES,KAAN,GFs5CQ,KAAF,KACT,C,EAl1CR,YAEY,8BSnHqE,CTykDrE,UUz1CR,gBAgBI,KAhBJ,KAA6B,SAA7B,iBApXa,WAuXE,SAYoC,YA3cM,IAkdpC,KAxejB,KACF,KVmVE,U,CAuzCR,GEh5CwC,KAAe,KAAR,GAAP,EFi5CtB,CEj5CsB,EO/CzB,IPsEJ,KOtEI,oBTq8CX,C,EEt5CoC,KAAe,KAAR,CF86CvC,C,CAt0CR,YACQ,OAEI,OAFJ,cAGJ,Q,KE5GoC,SAAe,OAAR,GAk9BpC,EAl9B6B,EAk9B7B,CAl9B6B,EAm9BhB,KAzZkC,EAAvB,KAAO,KAAgB,CAAvB,EGn5B1B,iBHoqBsD,OAO7C,GFqmCd,MEh8Ba,GAGL,MAvfmC,SAufnC,qBCt1BH,MEGA,oBE6lBL,eD3T2B,OE7RzB,GFuJgB,OEvJhB,UFmSA,KHlSJ,EC2DsD,EJ+sDpD,EEneY,OAC2B,OAxmB1B,IF0kCb,EE/7BA,I,E0D51BF,OAEU,CCxBX,GDwBC,C,EAPA,I,CDWF,cAyBC,G,EGjCQ,MHiCR,UAvBU,QCsBL,EIvDN,EACiB,CAET,IJoDF,EGhDgC,WHiDlC,EGjDkC,EALrB,CAK2B,CAAN,IHsEtC,OAZgB,KACN,EAWV,EAVQ,SDTR,C,ErBnCkB,KAAd,C,ESJF,I,EUm8C2B,OAArB,IAAqB,EACrB,WACR,C,CzDn/BA,YACQ,OAEI,OAFJ,YAGJ,Q,KyDo5ByB,OAArB,IAAqB,EACrB,UA8DR,EAvD2C,KAUN,WAID,GAfM,SAcP,GAExB,sBAC2B,KAAT,KACU,KAAT,WACd,oBAAJ,GAIc,OAAN,QAEA,CAFA,EAKU,OAA2B,GAKhC,QAAD,SAGC,IAKA,QAAD,QAImB,GAExB,sBAE4B,KAAT,UADQ,KAAT,cAEhB,CAAI,KAAb,IATY,MAaY,UADD,IAGnC,C,GArI6B,OAArB,IAAqB,EA9TA,EA+TrB,IA/TqB,GAAT,GAIF,OAA+B,GACA,QA4VjD,EAjCkC,SAArB,OAIoB,SAAT,CAAS,EACA,OAAT,CADuC,OAMpC,OACuB,GAsBlD,EAZoD,OAJN,OAKV,aAId,SAAqB,CAAK,EACtB,OAA2B,CADL,MAEd,QAEqB,IAGvD,C,KA5R6B,OAArB,IAAqB,EArEA,EAsErB,IAtEqB,GAAT,GAIF,OAA+B,GACA,QAkOjD,EAhKkC,SAArB,IAAqB,EAID,SAAT,CAAS,EACA,OAAT,CADuC,OAMpC,OACuB,GAqJlD,EA/I8C,OAIxB,SAAqC,OAc5B,CAAc,SAAF,QACE,WAA7B,MAG+B,GAExB,sBACO,KAAN,EAEM,SAAN,GAGU,OAAN,CAAM,EAII,OAA2B,CAA3B,EAA2B,QAKhC,QAAD,UAwGhC,MAhGiC,QAAD,QA5BkB,GAAlC,IAMQ,cAoCN,kBAKwC,OAChB,aAKd,OAAqB,CAAK,EACtB,OAA2B,CADL,MAEd,GAqExC,EA9DqC,OAE1B,wBACK,uBAEC,WAAQ,C,CAAR,EAA0C,OAAqB,CAA9B,GAQpB,OAAN,EAED,wBACE,CAAI,KAAb,MAXkC,IAarB,C,CAbqB,EAuCpB,SAWA,OAAqB,GAE5B,wBACE,CAAI,KAAb,K,EAjCc,OAAN,EAMM,OAAqB,CAArB,EACM,OAA2B,CADP,GAGjC,wBACE,CAAI,KAAb,IA2BhB,C,EAxlBA,YAEQ,iBACU,OACZ,GA3BgB,EA+BK,IA/BL,U,GAG0B,YAEpC,KACS,YAGV,KACX,EAqB2B,MACf,KAAY,KACE,OAAF,GAAZ,GAKJ,YACoB,KAGpB,KAAY,EAAZ,EACc,OAAF,MAES,KAAW,WAAD,CAAF,GAAW,CAAxC,MAEQ,OAAgC,CAAxC,MAES,KAAgC,WAAzC,IAGA,WAII,YACoB,GADpB,OAKJ,YACA,EADA,EACA,IACa,CAAT,G,EA6CJ,gBACoB,KAGC,KAAW,SAAD,CAAF,CAA7B,E,EAES,KAAgC,WAAzC,EAAS,GAuBjB,IAnBiB,CAAT,aAKA,EACA,KAOA,OACA,KACwB,SAIhC,GAzEoC,EAA5B,KAKA,KACA,EANA,EAMA,IACa,CAAT,GACoB,QAAxB,GAKA,OACiB,UAGjB,OACkB,SAGF,cADW,CACJ,4BAEH,GACL,sBACV,SAA2B,CAA3B,EAMH,wBAOV,U,IA/H6B,SAArB,EAAqB,EACrB,QAiBR,EAbqC,OAE1B,wBACK,oBAAJ,GAIO,oBACO,KAAN,gBAKpB,C,EAxE6B,SAArB,EAAqB,EACrB,SACR,C,KvDmkBwB,KACJ,OAAR,GADY,EGnkC4B,OAA3C,SH+rBL,CA2YW,GF6sBX,EE97CmD,OAAR,OAytBsB,KAlOpD,CAvfsC,EIxDxB,EJkjBnB,MAvfmC,SAufnC,qBIzjBA,EJkEmC,EC/VtC,KG6RG,GJkEmC,EI3DhB,CDjSqB,OAA3C,GE6lBL,eD3T2B,OE7RzB,SNgjCM,CMhjCN,YFmSA,IHlSJ,EC2DsD,GFygCzC,OF6sBX,EEt8BA,I,EuD1UyB,SAArB,EAAqB,EACrB,QAGR,EADQ,KAAa,mBACrB,C,GA2rB6B,OAArB,IAAqB,EAjPA,EAkPrB,IAlPqB,GAAT,GAIF,OAA+B,GACA,QA+SjD,EAjEkC,SAArB,IAAqB,EAID,SAAT,CAAS,EACA,OAAT,CADuC,OAMpC,OACuB,GAsDlD,EAhD8C,OAIxB,SAAqC,OAKhB,GAE3B,eAAa,aACH,OAAN,CAAM,EAAN,OAGU,KAYd,cAKwC,OAChB,aAId,OAAqB,CAAK,EACtB,OAA2B,CADL,MAEd,GAStC,EAFQ,KAAa,sBAErB,C,EA0J6B,OAArB,IAAqB,EACrB,UAGR,EADQ,KAAa,uBACrB,C,EAj/BA,wBAEQ,I,CAGA,I,CAAA,YACkB,K,CAGJ,KAAlB,SACoB,YAAO,4BACH,GACL,sBACV,SAA2B,CAA3B,EAEgC,OAAzB,UAIpB,SAVI,I,EdvdmD,I,KEsS2C,KChTtF,MACO,CAAR,IACN,E,IACG,EtDqBR,GAQQ,CARR,EAUW,EDzBX,EACA,EACA,EACA,EACA,KAEA,EC8EA,GAxDY,OACe,U,CAAA,QAEA,C,CAFA,EAEvB,S,CAAA,aACS,SAAF,OAAI,OAAP,KADmB,CAAvB,gBAGqD,UACtB,SACO,CAC3B,GAAT,EAGsB,SAAF,GACM,OAAF,GACE,OAAF,GACE,OAAF,GACE,OAAF,GACE,OAAF,GACE,OAAF,GACE,OAAF,GACE,OAAF,GACE,OAAF,GACG,OAAF,GACE,OAAF,GACE,OAAF,GACE,OAAF,GACE,OAAF,GACE,OAAF,OAErB,OADA,CAnBK,KAAT,IAuBO,KAAT,EACqB,SAAF,OAEf,OADA,CAFK,KAAT,MA/BuB,IAsCA,CAtCA,EAsCA,IAErB,OAAS,CAAT,oBACO,SAAF,GACQ,OAAF,GACE,OAAF,GACE,OAAF,OAEP,OADA,CALK,KAAT,IAWK,OACA,SAAF,OAAI,OAAP,CADK,KAAT,IAIF,I,GOvDI,C,CCgZJ,KACW,MEyGwB,OAFzB,GFvGN,G,EAtGQ,KADJ,C,E8BTN,I,CARF,QKEwB,KAxHL,ILuHR,CAGX,C,EAXA,cACS,iBpByRL,gBAgBI,KAhBJ,KAA6B,GAA7B,EAA6B,IAA7B,iBAjYa,WAoYE,SAYoC,YAO9B,KAxejB,EAweiB,EAvenB,KTZN,GS6dI,M,CT7dJ,ES6dI,EAA6B,SAA7B,iBT7dJ,IS6dI,EAjCc,CAiCd,EAiNE,KAllBW,OAiZT,IAbW,GAaX,UAD+C,YAO9B,KAxejB,EAweiB,EAvenB,SAgbY,CAhbZ,EAgPA,KoBxDJ,gBpB1K+B,CoB0K/B,C,EAnBmB,OA9IkE,QAgHK,GA+B5F,C,CAbA,K3B3PS,E2BiQqB,OArItB,QA+G0F,GAwBlG,G,I9BwKI,IEzNa,KAAS,EAAT,EAufA,OChsBf,EC2DsD,GJuWpD,EIvWoD,GJwWxD,C,GDnZY,GCmNsB,KDnNtB,KC0NA,GAJR,EDtNQ,SAAF,GAAE,GCmNsB,GDlNrB,GADD,G6CmNsB,M7CnNtB,K6C0NA,GAJR,E7CtNQ,SAAF,GAAE,G6CmNsB,G7ClNrB,GiD/Bb,OAK4B,MAFL,YADF,SADG,MAGI,O"}