diff options
Diffstat (limited to 'contrib/libs')
720 files changed, 9833 insertions, 7007 deletions
diff --git a/contrib/libs/backtrace/.yandex_meta/override.nix b/contrib/libs/backtrace/.yandex_meta/override.nix index a5ebbfe32c..9f82eb4d47 100644 --- a/contrib/libs/backtrace/.yandex_meta/override.nix +++ b/contrib/libs/backtrace/.yandex_meta/override.nix @@ -1,11 +1,11 @@ pkgs: attrs: with pkgs; with attrs; rec { - version = "2025-02-10"; + version = "2025-04-08"; src = fetchFromGitHub { owner = "ianlancetaylor"; repo = "libbacktrace"; - rev = "0034e33946824057b48c5e686a3aefc761b37384"; - hash = "sha256-JCut4afd8a2iXTdbjnyabdWX9JomcSh3qj/RScyVGSw="; + rev = "f1104f3270095831df536a2539f4cc408365105c"; + hash = "sha256-+D6oI1EcHh/wMPFBhW5+tjo/8yrqumTv74W90v28BX0="; }; patches = []; diff --git a/contrib/libs/backtrace/atomic.c b/contrib/libs/backtrace/atomic.c index 21785a19e8..97cc8ec9f9 100644 --- a/contrib/libs/backtrace/atomic.c +++ b/contrib/libs/backtrace/atomic.c @@ -103,7 +103,7 @@ backtrace_atomic_store_size_t (size_t *p, size_t v) void backtrace_atomic_store_int (int *p, int v) { - size_t old; + int old; old = *p; while (!__sync_bool_compare_and_swap (p, old, v)) diff --git a/contrib/libs/backtrace/ya.make b/contrib/libs/backtrace/ya.make index b713cab465..faabba1b3c 100644 --- a/contrib/libs/backtrace/ya.make +++ b/contrib/libs/backtrace/ya.make @@ -6,9 +6,9 @@ LICENSE(BSD-3-Clause) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(2025-02-10) +VERSION(2025-04-08) -ORIGINAL_SOURCE(https://github.com/ianlancetaylor/libbacktrace/archive/0034e33946824057b48c5e686a3aefc761b37384.tar.gz) +ORIGINAL_SOURCE(https://github.com/ianlancetaylor/libbacktrace/archive/f1104f3270095831df536a2539f4cc408365105c.tar.gz) ADDINCL( contrib/libs/backtrace diff --git a/contrib/libs/c-ares/.yandex_meta/override.nix b/contrib/libs/c-ares/.yandex_meta/override.nix index 64407f85a0..c7309f5cd9 100644 --- a/contrib/libs/c-ares/.yandex_meta/override.nix +++ b/contrib/libs/c-ares/.yandex_meta/override.nix @@ -1,11 +1,11 @@ pkgs: attrs: with pkgs; with attrs; rec { - version = "1.34.4"; + version = "1.34.5"; src = fetchFromGitHub { owner = "c-ares"; repo = "c-ares"; rev= "v${version}"; - hash = "sha256-6xJSo4ptXAKFwCUBRAji8DSqkxoIL6lpWvnDOM1NQNg="; + hash = "sha256-MeQ4eqt7QyRD7YVomXR+fwBzraiYe2s2Eozz0sE8Xgo="; }; patches = []; diff --git a/contrib/libs/c-ares/RELEASE-NOTES.md b/contrib/libs/c-ares/RELEASE-NOTES.md index 19a204b3ea..1a8d8d2233 100644 --- a/contrib/libs/c-ares/RELEASE-NOTES.md +++ b/contrib/libs/c-ares/RELEASE-NOTES.md @@ -1,25 +1,28 @@ -## c-ares version 1.34.4 - December 14 2024 +## c-ares version 1.34.5 - April 8 2025 -This is a bugfix release. +This is a security release. + +Security: +* CVE-2025-31498. A use-after-free bug has been uncovered in read_answers() that + was introduced in v1.32.3. Please see https://github.com/c-ares/c-ares/security/advisories/GHSA-6hxc-62jh-p29v Changes: -* QNX Port: Port to QNX 8, add primary config reading support, add CI build. [PR #934](https://github.com/c-ares/c-ares/pull/934), [PR #937](https://github.com/c-ares/c-ares/pull/937), [PR #938](https://github.com/c-ares/c-ares/pull/938) +* Restore Windows XP support. [PR #958](https://github.com/c-ares/c-ares/pull/958) Bugfixes: -* Empty TXT records were not being preserved. [PR #922](https://github.com/c-ares/c-ares/pull/922) -* docs: update deprecation notices for `ares_create_query()` and `ares_mkquery()`. [PR #910](https://github.com/c-ares/c-ares/pull/910) -* license: some files weren't properly updated. [PR #920](https://github.com/c-ares/c-ares/pull/920) -* Fix bind local device regression from 1.34.0. [PR #929](https://github.com/c-ares/c-ares/pull/929), [PR #931](https://github.com/c-ares/c-ares/pull/931), [PR #935](https://github.com/c-ares/c-ares/pull/935) -* CMake: set policy version to prevent deprecation warnings. [PR #932](https://github.com/c-ares/c-ares/pull/932) -* CMake: shared and static library names should be the same on unix platforms like autotools uses. [PR #933](https://github.com/c-ares/c-ares/pull/933) -* Update to latest autoconf archive macros for enhanced system compatibility. [PR #936](https://github.com/c-ares/c-ares/pull/936) +* A missing mutex initialization would make busy polling for configuration + changes (platforms other than Windows, Linux, MacOS) eat too much CPU + [PR #974](https://github.com/c-ares/c-ares/pull/974) +* Pkgconfig may be generated wrong for static builds in relation to `-pthread` + [PR #965](https://github.com/c-ares/c-ares/pull/965) +* Localhost resolution can fail if only one address family is in `/etc/hosts` + [PR #947](https://github.com/c-ares/c-ares/pull/947) Thanks go to these friendly people for their efforts and contributions for this release: * Brad House (@bradh352) -* Daniel Stenberg (@bagder) -* Gregor Jasny (@gjasny) -* @marcovsz -* Nikolaos Chatzikonstantinou (@createyourpersonalaccount) -* @vlasovsoft1979 +* Erik Lax (@eriklax) +* Florian Pfisterer (@FlorianPfisterer) +* Kai Pastor (@dg0yt) + diff --git a/contrib/libs/c-ares/include/ares_dns_record.h b/contrib/libs/c-ares/include/ares_dns_record.h index 2896eab24b..cec9f47f63 100644 --- a/contrib/libs/c-ares/include/ares_dns_record.h +++ b/contrib/libs/c-ares/include/ares_dns_record.h @@ -1104,7 +1104,7 @@ CARES_EXTERN ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec, * (such as the ttl decrement capability). * * \param[in] dnsrec Pointer to initialized and filled DNS record object. - * \return duplicted DNS record object, or NULL on out of memory. + * \return duplicated DNS record object, or NULL on out of memory. */ CARES_EXTERN ares_dns_record_t * ares_dns_record_duplicate(const ares_dns_record_t *dnsrec); diff --git a/contrib/libs/c-ares/include/ares_version.h b/contrib/libs/c-ares/include/ares_version.h index 782046bd79..7da82f2a15 100644 --- a/contrib/libs/c-ares/include/ares_version.h +++ b/contrib/libs/c-ares/include/ares_version.h @@ -32,8 +32,8 @@ #define ARES_VERSION_MAJOR 1 #define ARES_VERSION_MINOR 34 -#define ARES_VERSION_PATCH 4 -#define ARES_VERSION_STR "1.34.4" +#define ARES_VERSION_PATCH 5 +#define ARES_VERSION_STR "1.34.5" /* NOTE: We cannot make the version string a C preprocessor stringify operation * due to assumptions made by integrators that aren't properly using diff --git a/contrib/libs/c-ares/src/lib/ares_addrinfo2hostent.c b/contrib/libs/c-ares/src/lib/ares_addrinfo2hostent.c index 2bbc791157..239ca5bce7 100644 --- a/contrib/libs/c-ares/src/lib/ares_addrinfo2hostent.c +++ b/contrib/libs/c-ares/src/lib/ares_addrinfo2hostent.c @@ -47,119 +47,154 @@ # include <limits.h> #endif +static size_t hostent_nalias(const struct hostent *host) +{ + size_t i; + for (i=0; host->h_aliases != NULL && host->h_aliases[i] != NULL; i++) + ; + + return i; +} + +static size_t ai_nalias(const struct ares_addrinfo *ai) +{ + const struct ares_addrinfo_cname *cname; + size_t i = 0; + + for (cname = ai->cnames; cname != NULL; cname=cname->next) { + i++; + } + + return i; +} + +static size_t hostent_naddr(const struct hostent *host) +{ + size_t i; + for (i=0; host->h_addr_list != NULL && host->h_addr_list[i] != NULL; i++) + ; + + return i; +} + +static size_t ai_naddr(const struct ares_addrinfo *ai, int af) +{ + const struct ares_addrinfo_node *node; + size_t i = 0; + + for (node = ai->nodes; node != NULL; node=node->ai_next) { + if (af != AF_UNSPEC && af != node->ai_family) + continue; + i++; + } + + return i; +} ares_status_t ares_addrinfo2hostent(const struct ares_addrinfo *ai, int family, struct hostent **host) { struct ares_addrinfo_node *next; - struct ares_addrinfo_cname *next_cname; char **aliases = NULL; - char *addrs = NULL; + char **addrs = NULL; size_t naliases = 0; size_t naddrs = 0; - size_t alias = 0; size_t i; + size_t ealiases = 0; + size_t eaddrs = 0; if (ai == NULL || host == NULL) { return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */ } - /* Use the first node of the response as the family, since hostent can only + /* Use either the host set in the passed in hosts to be filled in, or the + * first node of the response as the family, since hostent can only * represent one family. We assume getaddrinfo() returned a sorted list if * the user requested AF_UNSPEC. */ - if (family == AF_UNSPEC && ai->nodes) { - family = ai->nodes->ai_family; + if (family == AF_UNSPEC) { + if (*host != NULL && (*host)->h_addrtype != AF_UNSPEC) { + family = (*host)->h_addrtype; + } else if (ai->nodes != NULL) { + family = ai->nodes->ai_family; + } } if (family != AF_INET && family != AF_INET6) { return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */ } - *host = ares_malloc(sizeof(**host)); - if (!(*host)) { - goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ + if (*host == NULL) { + *host = ares_malloc_zero(sizeof(**host)); + if (!(*host)) { + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ + } } - memset(*host, 0, sizeof(**host)); - next = ai->nodes; - while (next) { - if (next->ai_family == family) { - ++naddrs; - } - next = next->ai_next; + (*host)->h_addrtype = (HOSTENT_ADDRTYPE_TYPE)family; + if (family == AF_INET) { + (*host)->h_length = sizeof(struct in_addr); + } else if (family == AF_INET6) { + (*host)->h_length = sizeof(struct ares_in6_addr); } - next_cname = ai->cnames; - while (next_cname) { - if (next_cname->alias) { - ++naliases; + if ((*host)->h_name == NULL) { + if (ai->cnames) { + (*host)->h_name = ares_strdup(ai->cnames->name); + if ((*host)->h_name == NULL && ai->cnames->name) { + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ + } + } else { + (*host)->h_name = ares_strdup(ai->name); + if ((*host)->h_name == NULL && ai->name) { + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ + } } - next_cname = next_cname->next; } - aliases = ares_malloc((naliases + 1) * sizeof(char *)); + naliases = ai_nalias(ai); + ealiases = hostent_nalias(*host); + aliases = ares_realloc_zero((*host)->h_aliases, + ealiases * sizeof(char *), + (naliases + ealiases + 1) * sizeof(char *)); if (!aliases) { goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } (*host)->h_aliases = aliases; - memset(aliases, 0, (naliases + 1) * sizeof(char *)); if (naliases) { - for (next_cname = ai->cnames; next_cname != NULL; - next_cname = next_cname->next) { - if (next_cname->alias == NULL) { + const struct ares_addrinfo_cname *cname; + i = ealiases; + for (cname = ai->cnames; cname != NULL; cname = cname->next) { + if (cname->alias == NULL) { continue; } - aliases[alias] = ares_strdup(next_cname->alias); - if (!aliases[alias]) { + (*host)->h_aliases[i] = ares_strdup(cname->alias); + if ((*host)->h_aliases[i] == NULL) { goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } - alias++; + i++; } } - - (*host)->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *)); - if (!(*host)->h_addr_list) { + naddrs = ai_naddr(ai, family); + eaddrs = hostent_naddr(*host); + addrs = ares_realloc_zero((*host)->h_addr_list, eaddrs * sizeof(char *), + (naddrs + eaddrs + 1) * sizeof(char *)); + if (addrs == NULL) { goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } - - memset((*host)->h_addr_list, 0, (naddrs + 1) * sizeof(char *)); - - if (ai->cnames) { - (*host)->h_name = ares_strdup(ai->cnames->name); - if ((*host)->h_name == NULL && ai->cnames->name) { - goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ - } - } else { - (*host)->h_name = ares_strdup(ai->name); - if ((*host)->h_name == NULL && ai->name) { - goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ - } - } - - (*host)->h_addrtype = (HOSTENT_ADDRTYPE_TYPE)family; - - if (family == AF_INET) { - (*host)->h_length = sizeof(struct in_addr); - } - - if (family == AF_INET6) { - (*host)->h_length = sizeof(struct ares_in6_addr); - } + (*host)->h_addr_list = addrs; if (naddrs) { - addrs = ares_malloc(naddrs * (size_t)(*host)->h_length); - if (!addrs) { - goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ - } - - i = 0; + i = eaddrs; for (next = ai->nodes; next != NULL; next = next->ai_next) { if (next->ai_family != family) { continue; } - (*host)->h_addr_list[i] = addrs + (i * (size_t)(*host)->h_length); + (*host)->h_addr_list[i] = ares_malloc_zero((size_t)(*host)->h_length); + if ((*host)->h_addr_list[i] == NULL) { + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ + } if (family == AF_INET6) { memcpy((*host)->h_addr_list[i], &(CARES_INADDR_CAST(const struct sockaddr_in6 *, next->ai_addr) @@ -172,15 +207,11 @@ ares_status_t ares_addrinfo2hostent(const struct ares_addrinfo *ai, int family, ->sin_addr), (size_t)(*host)->h_length); } - ++i; - } - - if (i == 0) { - ares_free(addrs); + i++; } } - if (naddrs == 0 && naliases == 0) { + if (naddrs + eaddrs == 0 && naliases + ealiases == 0) { ares_free_hostent(*host); *host = NULL; return ARES_ENODATA; diff --git a/contrib/libs/c-ares/src/lib/ares_addrinfo_localhost.c b/contrib/libs/c-ares/src/lib/ares_addrinfo_localhost.c index 6f4f2a373b..2abb0c48a6 100644 --- a/contrib/libs/c-ares/src/lib/ares_addrinfo_localhost.c +++ b/contrib/libs/c-ares/src/lib/ares_addrinfo_localhost.c @@ -49,6 +49,19 @@ # endif #endif +static ares_bool_t ares_ai_has_family(int aftype, + const struct ares_addrinfo_node *nodes) +{ + const struct ares_addrinfo_node *node; + + for (node = nodes; node != NULL; node = node->ai_next) { + if (node->ai_family == aftype) + return ARES_TRUE; + } + + return ARES_FALSE; +} + ares_status_t ares_append_ai_node(int aftype, unsigned short port, unsigned int ttl, const void *adata, struct ares_addrinfo_node **nodes) @@ -107,7 +120,8 @@ static ares_status_t { ares_status_t status = ARES_SUCCESS; - if (aftype == AF_UNSPEC || aftype == AF_INET6) { + if ((aftype == AF_UNSPEC || aftype == AF_INET6) && + !ares_ai_has_family(AF_INET6, *nodes)) { struct ares_in6_addr addr6; ares_inet_pton(AF_INET6, "::1", &addr6); status = ares_append_ai_node(AF_INET6, port, 0, &addr6, nodes); @@ -116,7 +130,8 @@ static ares_status_t } } - if (aftype == AF_UNSPEC || aftype == AF_INET) { + if ((aftype == AF_UNSPEC || aftype == AF_INET) && + !ares_ai_has_family(AF_INET, *nodes)) { struct in_addr addr4; ares_inet_pton(AF_INET, "127.0.0.1", &addr4); status = ares_append_ai_node(AF_INET, port, 0, &addr4, nodes); @@ -150,11 +165,13 @@ static ares_status_t continue; } - if (table->Table[i].Address.si_family == AF_INET) { + if (table->Table[i].Address.si_family == AF_INET && + !ares_ai_has_family(AF_INET, *nodes)) { status = ares_append_ai_node(table->Table[i].Address.si_family, port, 0, &table->Table[i].Address.Ipv4.sin_addr, nodes); - } else if (table->Table[i].Address.si_family == AF_INET6) { + } else if (table->Table[i].Address.si_family == AF_INET6 && + !ares_ai_has_family(AF_INET6, *nodes)) { status = ares_append_ai_node(table->Table[i].Address.si_family, port, 0, &table->Table[i].Address.Ipv6.sin6_addr, nodes); @@ -195,8 +212,7 @@ ares_status_t ares_addrinfo_localhost(const char *name, unsigned short port, const struct ares_addrinfo_hints *hints, struct ares_addrinfo *ai) { - struct ares_addrinfo_node *nodes = NULL; - ares_status_t status; + ares_status_t status; /* Validate family */ switch (hints->ai_family) { @@ -208,26 +224,22 @@ ares_status_t ares_addrinfo_localhost(const char *name, unsigned short port, return ARES_EBADFAMILY; /* LCOV_EXCL_LINE: DefensiveCoding */ } + if (ai->name != NULL) { + ares_free(ai->name); + } ai->name = ares_strdup(name); - if (!ai->name) { - goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ + if (ai->name == NULL) { + status = ARES_ENOMEM; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } - status = ares_system_loopback_addrs(hints->ai_family, port, &nodes); - - if (status == ARES_ENOTFOUND) { - status = ares_default_loopback_addrs(hints->ai_family, port, &nodes); + status = ares_system_loopback_addrs(hints->ai_family, port, &ai->nodes); + if (status != ARES_SUCCESS && status != ARES_ENOTFOUND) { + goto done; } - ares_addrinfo_cat_nodes(&ai->nodes, nodes); + status = ares_default_loopback_addrs(hints->ai_family, port, &ai->nodes); +done: return status; - -/* LCOV_EXCL_START: OutOfMemory */ -enomem: - ares_freeaddrinfo_nodes(nodes); - ares_free(ai->name); - ai->name = NULL; - return ARES_ENOMEM; - /* LCOV_EXCL_STOP */ } diff --git a/contrib/libs/c-ares/src/lib/ares_close_sockets.c b/contrib/libs/c-ares/src/lib/ares_close_sockets.c index fd3bf3c4b1..347f43e6fc 100644 --- a/contrib/libs/c-ares/src/lib/ares_close_sockets.c +++ b/contrib/libs/c-ares/src/lib/ares_close_sockets.c @@ -37,7 +37,7 @@ static void ares_requeue_queries(ares_conn_t *conn, ares_tvnow(&now); while ((query = ares_llist_first_val(conn->queries_to_conn)) != NULL) { - ares_requeue_query(query, &now, requeue_status, ARES_TRUE, NULL); + ares_requeue_query(query, &now, requeue_status, ARES_TRUE, NULL, NULL); } } diff --git a/contrib/libs/c-ares/src/lib/ares_config-linux.h b/contrib/libs/c-ares/src/lib/ares_config-linux.h index 778bf91eed..e0e7bd6c5f 100644 --- a/contrib/libs/c-ares/src/lib/ares_config-linux.h +++ b/contrib/libs/c-ares/src/lib/ares_config-linux.h @@ -145,6 +145,9 @@ /* Define to 1 if you have the `if_nametoindex' function. */ #define HAVE_IF_NAMETOINDEX 1 +/* Define to 1 if you have the `GetBestRoute2' function. */ +/* #undef HAVE_GETBESTROUTE2 */ + /* Define to 1 if you have the `ConvertInterfaceIndexToLuid' function. */ /* #undef HAVE_CONVERTINTERFACEINDEXTOLUID */ diff --git a/contrib/libs/c-ares/src/lib/ares_cookie.c b/contrib/libs/c-ares/src/lib/ares_cookie.c index f31c74e748..509e12050e 100644 --- a/contrib/libs/c-ares/src/lib/ares_cookie.c +++ b/contrib/libs/c-ares/src/lib/ares_cookie.c @@ -115,7 +115,7 @@ * - If `cookie.unsupported_ts` evaluates less than * `COOKIE_UNSUPPORTED_TIMEOUT` * - Ensure there is no EDNS cookie opt (10) set (shouldn't be unless - * requestor had put this themselves), then **skip any remaining + * requester had put this themselves), then **skip any remaining * processing** as we don't want to try to send cookies. * - Otherwise: * - clear all cookie settings, set `cookie.state = INITIAL`. @@ -369,7 +369,8 @@ ares_status_t ares_cookie_apply(ares_dns_record_t *dnsrec, ares_conn_t *conn, ares_status_t ares_cookie_validate(ares_query_t *query, const ares_dns_record_t *dnsresp, - ares_conn_t *conn, const ares_timeval_t *now) + ares_conn_t *conn, const ares_timeval_t *now, + ares_array_t **requeue) { ares_server_t *server = conn->server; ares_cookie_t *cookie = &server->cookie; @@ -427,7 +428,8 @@ ares_status_t ares_cookie_validate(ares_query_t *query, /* Resend the request, hopefully it will work the next time as we should * have recorded a server cookie */ ares_requeue_query(query, now, ARES_SUCCESS, - ARES_FALSE /* Don't increment try count */, NULL); + ARES_FALSE /* Don't increment try count */, NULL, + requeue); /* Parent needs to drop this response */ return ARES_EBADRESP; diff --git a/contrib/libs/c-ares/src/lib/ares_free_hostent.c b/contrib/libs/c-ares/src/lib/ares_free_hostent.c index bf2037238b..dfcbdf4910 100644 --- a/contrib/libs/c-ares/src/lib/ares_free_hostent.c +++ b/contrib/libs/c-ares/src/lib/ares_free_hostent.c @@ -44,9 +44,10 @@ void ares_free_hostent(struct hostent *host) } ares_free(host->h_aliases); if (host->h_addr_list) { - ares_free( - host->h_addr_list[0]); /* no matter if there is one or many entries, - there is only one malloc for all of them */ + size_t i; + for (i=0; host->h_addr_list[i] != NULL; i++) { + ares_free(host->h_addr_list[i]); + } ares_free(host->h_addr_list); } ares_free(host); diff --git a/contrib/libs/c-ares/src/lib/ares_getaddrinfo.c b/contrib/libs/c-ares/src/lib/ares_getaddrinfo.c index 32791dc37d..eabd17fcba 100644 --- a/contrib/libs/c-ares/src/lib/ares_getaddrinfo.c +++ b/contrib/libs/c-ares/src/lib/ares_getaddrinfo.c @@ -418,9 +418,13 @@ done: * SHOULD recognize localhost names as special and SHOULD always return the * IP loopback address for address queries". * We will also ignore ALL errors when trying to resolve localhost, such - * as permissions errors reading /etc/hosts or a malformed /etc/hosts */ - if (status != ARES_SUCCESS && status != ARES_ENOMEM && - ares_is_localhost(hquery->name)) { + * as permissions errors reading /etc/hosts or a malformed /etc/hosts. + * + * Also, just because the query itself returned success from /etc/hosts + * lookup doesn't mean it returned everything it needed to for all requested + * address families. As long as we're not on a critical out of memory + * condition pass it through to fill in any other address classes. */ + if (status != ARES_ENOMEM && ares_is_localhost(hquery->name)) { return ares_addrinfo_localhost(hquery->name, hquery->port, &hquery->hints, hquery->ai); } diff --git a/contrib/libs/c-ares/src/lib/ares_gethostbyaddr.c b/contrib/libs/c-ares/src/lib/ares_gethostbyaddr.c index a7acf3c45c..69c509ab11 100644 --- a/contrib/libs/c-ares/src/lib/ares_gethostbyaddr.c +++ b/contrib/libs/c-ares/src/lib/ares_gethostbyaddr.c @@ -120,7 +120,7 @@ static void next_lookup(struct addr_query *aquery) { const char *p; ares_status_t status; - struct hostent *host; + struct hostent *host = NULL; char *name; for (p = aquery->remaining_lookups; *p; p++) { diff --git a/contrib/libs/c-ares/src/lib/ares_gethostbyname.c b/contrib/libs/c-ares/src/lib/ares_gethostbyname.c index 56de729526..d451b46851 100644 --- a/contrib/libs/c-ares/src/lib/ares_gethostbyname.c +++ b/contrib/libs/c-ares/src/lib/ares_gethostbyname.c @@ -287,6 +287,8 @@ static ares_status_t ares_gethostbyname_file_int(ares_channel_t *channel, return ARES_ENOTFOUND; } + *host = NULL; + /* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */ if (ares_is_onion_domain(name)) { return ARES_ENOTFOUND; @@ -307,9 +309,13 @@ done: * SHOULD recognize localhost names as special and SHOULD always return the * IP loopback address for address queries". * We will also ignore ALL errors when trying to resolve localhost, such - * as permissions errors reading /etc/hosts or a malformed /etc/hosts */ - if (status != ARES_SUCCESS && status != ARES_ENOMEM && - ares_is_localhost(name)) { + * as permissions errors reading /etc/hosts or a malformed /etc/hosts. + * + * Also, just because the query itself returned success from /etc/hosts + * lookup doesn't mean it returned everything it needed to for all requested + * address families. As long as we're not on a critical out of memory + * condition pass it through to fill in any other address classes. */ + if (status != ARES_ENOMEM && ares_is_localhost(name)) { return ares_hostent_localhost(name, family, host); } diff --git a/contrib/libs/c-ares/src/lib/ares_hosts_file.c b/contrib/libs/c-ares/src/lib/ares_hosts_file.c index 0439b8e1d4..d18863b8f6 100644 --- a/contrib/libs/c-ares/src/lib/ares_hosts_file.c +++ b/contrib/libs/c-ares/src/lib/ares_hosts_file.c @@ -845,7 +845,7 @@ ares_status_t ares_hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry, ares_bool_t want_cnames, struct ares_addrinfo *ai) { - ares_status_t status; + ares_status_t status = ARES_ENOTFOUND; struct ares_addrinfo_cname *cnames = NULL; struct ares_addrinfo_node *ainodes = NULL; ares_llist_node_t *node; @@ -860,6 +860,7 @@ ares_status_t ares_hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry, } if (name != NULL) { + ares_free(ai->name); ai->name = ares_strdup(name); if (ai->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ @@ -888,6 +889,11 @@ ares_status_t ares_hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry, } } + /* Might be ARES_ENOTFOUND here if no ips matched requested address family */ + if (status != ARES_SUCCESS) { + goto done; + } + if (want_cnames) { status = ares_hosts_ai_append_cnames(entry, &cnames); if (status != ARES_SUCCESS) { diff --git a/contrib/libs/c-ares/src/lib/ares_ipv6.h b/contrib/libs/c-ares/src/lib/ares_ipv6.h index 5da341b010..d2007cc29e 100644 --- a/contrib/libs/c-ares/src/lib/ares_ipv6.h +++ b/contrib/libs/c-ares/src/lib/ares_ipv6.h @@ -90,6 +90,16 @@ struct addrinfo { # define NS_INT16SZ 2 #endif +/* Windows XP Compatibility with later MSVC/Mingw versions */ +#if defined(_WIN32) +# if !defined(IF_MAX_STRING_SIZE) +# define IF_MAX_STRING_SIZE 256 /* =256 in <ifdef.h> */ +# endif +# if !defined(NDIS_IF_MAX_STRING_SIZE) +# define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE /* =256 in <ifdef.h> */ +# endif +#endif + #ifndef IF_NAMESIZE # ifdef IFNAMSIZ # define IF_NAMESIZE IFNAMSIZ diff --git a/contrib/libs/c-ares/src/lib/ares_metrics.c b/contrib/libs/c-ares/src/lib/ares_metrics.c index 13e34decc0..deb3b7febc 100644 --- a/contrib/libs/c-ares/src/lib/ares_metrics.c +++ b/contrib/libs/c-ares/src/lib/ares_metrics.c @@ -197,7 +197,7 @@ void ares_metrics_record(const ares_query_t *query, ares_server_t *server, } if (query_ms > server->metrics[i].latency_max_ms) { - server->metrics[i].latency_min_ms = query_ms; + server->metrics[i].latency_max_ms = query_ms; } server->metrics[i].total_count++; diff --git a/contrib/libs/c-ares/src/lib/ares_private.h b/contrib/libs/c-ares/src/lib/ares_private.h index e6d44e8b86..3d7cea3d3a 100644 --- a/contrib/libs/c-ares/src/lib/ares_private.h +++ b/contrib/libs/c-ares/src/lib/ares_private.h @@ -321,7 +321,8 @@ ares_status_t ares_send_query(ares_server_t *requested_server /* Optional */, ares_status_t ares_requeue_query(ares_query_t *query, const ares_timeval_t *now, ares_status_t status, ares_bool_t inc_try_count, - const ares_dns_record_t *dnsrec); + const ares_dns_record_t *dnsrec, + ares_array_t **requeue); /*! Count the number of labels (dots+1) in a domain */ size_t ares_name_label_cnt(const char *name); @@ -455,8 +456,10 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, const void *addr, int addrlen, int family, struct hostent **host); +/* host address must be valid or NULL as will create or append */ ares_status_t ares_addrinfo2hostent(const struct ares_addrinfo *ai, int family, struct hostent **host); + ares_status_t ares_addrinfo2addrttl(const struct ares_addrinfo *ai, int family, size_t req_naddrttls, struct ares_addrttl *addrttls, @@ -610,7 +613,8 @@ ares_status_t ares_cookie_apply(ares_dns_record_t *dnsrec, ares_conn_t *conn, ares_status_t ares_cookie_validate(ares_query_t *query, const ares_dns_record_t *dnsresp, ares_conn_t *conn, - const ares_timeval_t *now); + const ares_timeval_t *now, + ares_array_t **requeue); ares_status_t ares_channel_threading_init(ares_channel_t *channel); void ares_channel_threading_destroy(ares_channel_t *channel); diff --git a/contrib/libs/c-ares/src/lib/ares_process.c b/contrib/libs/c-ares/src/lib/ares_process.c index 3d186ea9d5..c5834fa100 100644 --- a/contrib/libs/c-ares/src/lib/ares_process.c +++ b/contrib/libs/c-ares/src/lib/ares_process.c @@ -56,7 +56,8 @@ static ares_status_t process_timeouts(ares_channel_t *channel, static ares_status_t process_answer(ares_channel_t *channel, const unsigned char *abuf, size_t alen, ares_conn_t *conn, - const ares_timeval_t *now); + const ares_timeval_t *now, + ares_array_t **requeue); static void handle_conn_error(ares_conn_t *conn, ares_bool_t critical_failure, ares_status_t failure_status); static ares_bool_t same_questions(const ares_query_t *query, @@ -510,10 +511,38 @@ static ares_status_t read_conn_packets(ares_conn_t *conn) return ARES_SUCCESS; } +/* Simple data structure to store a query that needs to be requeued with + * optional server */ +typedef struct { + unsigned short qid; + ares_server_t *server; /* optional */ +} ares_requeue_t; + +static ares_status_t ares_append_requeue(ares_array_t **requeue, + ares_query_t *query, + ares_server_t *server) +{ + ares_requeue_t entry; + + if (*requeue == NULL) { + *requeue = ares_array_create(sizeof(ares_requeue_t), NULL); + if (*requeue == NULL) { + return ARES_ENOMEM; + } + } + + ares_query_remove_from_conn(query); + + entry.qid = query->qid; + entry.server = server; + return ares_array_insertdata_last(*requeue, &entry); +} + static ares_status_t read_answers(ares_conn_t *conn, const ares_timeval_t *now) { ares_status_t status; ares_channel_t *channel = conn->server->channel; + ares_array_t *requeue = NULL; /* Process all queued answers */ while (1) { @@ -550,15 +579,43 @@ static ares_status_t read_answers(ares_conn_t *conn, const ares_timeval_t *now) data_len -= 2; /* We finished reading this answer; process it */ - status = process_answer(channel, data, data_len, conn, now); + status = process_answer(channel, data, data_len, conn, now, &requeue); if (status != ARES_SUCCESS) { handle_conn_error(conn, ARES_TRUE, status); - return status; + goto cleanup; } /* Since we processed the answer, clear the tag so space can be reclaimed */ ares_buf_tag_clear(conn->in_buf); } + +cleanup: + + /* Flush requeue */ + while (ares_array_len(requeue) > 0) { + ares_query_t *query; + ares_requeue_t entry; + ares_status_t internal_status; + + internal_status = ares_array_claim_at(&entry, sizeof(entry), requeue, 0); + if (internal_status != ARES_SUCCESS) { + break; + } + + /* Query disappeared */ + query = ares_htable_szvp_get_direct(channel->queries_by_qid, entry.qid); + if (query == NULL) { + continue; + } + + internal_status = ares_send_query(entry.server, query, now); + /* We only care about ARES_ENOMEM */ + if (internal_status == ARES_ENOMEM) { + status = ARES_ENOMEM; + } + } + ares_array_destroy(requeue); + return status; } @@ -611,7 +668,8 @@ static ares_status_t process_timeouts(ares_channel_t *channel, conn = query->conn; server_increment_failures(conn->server, query->using_tcp); - status = ares_requeue_query(query, now, ARES_ETIMEOUT, ARES_TRUE, NULL); + status = ares_requeue_query(query, now, ARES_ETIMEOUT, ARES_TRUE, NULL, + NULL); if (status == ARES_ENOMEM) { goto done; } @@ -701,7 +759,8 @@ static ares_bool_t issue_might_be_edns(const ares_dns_record_t *req, static ares_status_t process_answer(ares_channel_t *channel, const unsigned char *abuf, size_t alen, ares_conn_t *conn, - const ares_timeval_t *now) + const ares_timeval_t *now, + ares_array_t **requeue) { ares_query_t *query; /* Cache these as once ares_send_query() gets called, it may end up @@ -745,7 +804,8 @@ static ares_status_t process_answer(ares_channel_t *channel, /* Validate DNS cookie in response. This function may need to requeue the * query. */ - if (ares_cookie_validate(query, rdnsrec, conn, now) != ARES_SUCCESS) { + if (ares_cookie_validate(query, rdnsrec, conn, now, requeue) + != ARES_SUCCESS) { /* Drop response and return */ status = ARES_SUCCESS; goto cleanup; @@ -768,9 +828,8 @@ static ares_status_t process_answer(ares_channel_t *channel, goto cleanup; } - /* Send to same server */ - ares_send_query(server, query, now); - status = ARES_SUCCESS; + /* Requeue to same server */ + status = ares_append_requeue(requeue, query, server); goto cleanup; } @@ -782,8 +841,9 @@ static ares_status_t process_answer(ares_channel_t *channel, !(conn->flags & ARES_CONN_FLAG_TCP) && !(channel->flags & ARES_FLAG_IGNTC)) { query->using_tcp = ARES_TRUE; - ares_send_query(NULL, query, now); - status = ARES_SUCCESS; /* Switched to TCP is ok */ + status = ares_append_requeue(requeue, query, NULL); + /* Status will reflect success except on memory error, which is good since + * requeuing to TCP is ok */ goto cleanup; } @@ -809,11 +869,13 @@ static ares_status_t process_answer(ares_channel_t *channel, } server_increment_failures(server, query->using_tcp); - ares_requeue_query(query, now, status, ARES_TRUE, rdnsrec); + status = ares_requeue_query(query, now, status, ARES_TRUE, rdnsrec, requeue); - /* Should any of these cause a connection termination? - * Maybe SERVER_FAILURE? */ - status = ARES_SUCCESS; + if (status != ARES_ENOMEM) { + /* Should any of these cause a connection termination? + * Maybe SERVER_FAILURE? */ + status = ARES_SUCCESS; + } goto cleanup; } } @@ -854,10 +916,14 @@ static void handle_conn_error(ares_conn_t *conn, ares_bool_t critical_failure, ares_close_connection(conn, failure_status); } +/* Requeue query will normally call ares_send_query() but in some circumstances + * this needs to be delayed, so if requeue is not NULL, it will add the query + * to the queue instead */ ares_status_t ares_requeue_query(ares_query_t *query, const ares_timeval_t *now, ares_status_t status, ares_bool_t inc_try_count, - const ares_dns_record_t *dnsrec) + const ares_dns_record_t *dnsrec, + ares_array_t **requeue) { ares_channel_t *channel = query->channel; size_t max_tries = ares_slist_len(channel->servers) * channel->tries; @@ -873,6 +939,9 @@ ares_status_t ares_requeue_query(ares_query_t *query, const ares_timeval_t *now, } if (query->try_count < max_tries && !query->no_retries) { + if (requeue != NULL) { + return ares_append_requeue(requeue, query, NULL); + } return ares_send_query(NULL, query, now); } @@ -1187,7 +1256,7 @@ ares_status_t ares_send_query(ares_server_t *requested_server, case ARES_ECONNREFUSED: case ARES_EBADFAMILY: server_increment_failures(server, query->using_tcp); - return ares_requeue_query(query, now, status, ARES_TRUE, NULL); + return ares_requeue_query(query, now, status, ARES_TRUE, NULL, NULL); /* Anything else is not retryable, likely ENOMEM */ default: @@ -1213,7 +1282,7 @@ ares_status_t ares_send_query(ares_server_t *requested_server, case ARES_ECONNREFUSED: case ARES_EBADFAMILY: handle_conn_error(conn, ARES_TRUE, status); - status = ares_requeue_query(query, now, status, ARES_TRUE, NULL); + status = ares_requeue_query(query, now, status, ARES_TRUE, NULL, NULL); if (status == ARES_ETIMEOUT) { status = ARES_ECONNREFUSED; } @@ -1221,7 +1290,7 @@ ares_status_t ares_send_query(ares_server_t *requested_server, default: server_increment_failures(server, query->using_tcp); - status = ares_requeue_query(query, now, status, ARES_TRUE, NULL); + status = ares_requeue_query(query, now, status, ARES_TRUE, NULL, NULL); return status; } diff --git a/contrib/libs/c-ares/src/lib/ares_sysconfig_win.c b/contrib/libs/c-ares/src/lib/ares_sysconfig_win.c index f6e07f92e4..01109a89ba 100644 --- a/contrib/libs/c-ares/src/lib/ares_sysconfig_win.c +++ b/contrib/libs/c-ares/src/lib/ares_sysconfig_win.c @@ -176,6 +176,7 @@ static int compareAddresses(const void *arg1, const void *arg2) return 0; } +#if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__) /* There can be multiple routes to "the Internet". And there can be different * DNS servers associated with each of the interfaces that offer those routes. * We have to assume that any DNS server can serve any request. But, some DNS @@ -213,18 +214,6 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */ const SOCKADDR_INET * const dest, const ULONG interfaceMetric) { - /* On this interface, get the best route to that destination. */ -# if defined(__WATCOMC__) - /* OpenWatcom's builtin Windows SDK does not have a definition for - * MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET - * as a variable. Let's work around this by returning the worst possible - * metric, but only when using the OpenWatcom compiler. - * It may be worth investigating using a different version of the Windows - * SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom - * 2.0. - */ - return (ULONG)-1; -# else MIB_IPFORWARD_ROW2 row; SOCKADDR_INET ignored; if (GetBestRoute2(/* The interface to use. The index is ignored since we are @@ -257,8 +246,8 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */ * which describes the combination as a "sum". */ return row.Metric + interfaceMetric; -# endif /* __WATCOMC__ */ } +#endif /* * get_DNS_Windows() @@ -379,9 +368,21 @@ static ares_bool_t get_DNS_Windows(char **outptr) addressesSize = newSize; } +# if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__) + /* OpenWatcom's builtin Windows SDK does not have a definition for + * MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET + * as a variable. Let's work around this by returning the worst possible + * metric, but only when using the OpenWatcom compiler. + * It may be worth investigating using a different version of the Windows + * SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom + * 2.0. + */ addresses[addressesIndex].metric = getBestRouteMetric( &ipaaEntry->Luid, (SOCKADDR_INET *)((void *)(namesrvr.sa)), ipaaEntry->Ipv4Metric); +# else + addresses[addressesIndex].metric = (ULONG)-1; +# endif /* Record insertion index to make qsort stable */ addresses[addressesIndex].orig_idx = addressesIndex; @@ -423,9 +424,13 @@ static ares_bool_t get_DNS_Windows(char **outptr) ll_scope = ipaaEntry->Ipv6IfIndex; } +# if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__) addresses[addressesIndex].metric = getBestRouteMetric( &ipaaEntry->Luid, (SOCKADDR_INET *)((void *)(namesrvr.sa)), ipaaEntry->Ipv6Metric); +# else + addresses[addressesIndex].metric = (ULONG)-1; +# endif /* Record insertion index to make qsort stable */ addresses[addressesIndex].orig_idx = addressesIndex; diff --git a/contrib/libs/c-ares/src/lib/config-win32.h b/contrib/libs/c-ares/src/lib/config-win32.h index 62f8f6f267..f3da8e62b8 100644 --- a/contrib/libs/c-ares/src/lib/config-win32.h +++ b/contrib/libs/c-ares/src/lib/config-win32.h @@ -243,8 +243,10 @@ # undef HAVE_NETIOAPI_H #endif -/* Threading support enabled */ -#define CARES_THREADS 1 +/* Threading support enabled for Vista+ */ +#if !defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0600 +# define CARES_THREADS 1 +#endif /* ---------------------------------------------------------------- */ /* TYPEDEF REPLACEMENTS */ @@ -376,6 +378,8 @@ # define HAVE_CONVERTINTERFACELUIDTONAMEA 1 /* Define to 1 if you have the `NotifyIpInterfaceChange' function. */ # define HAVE_NOTIFYIPINTERFACECHANGE 1 +/* Define to 1 if you have the `GetBestRoute2` function */ +# define HAVE_GETBESTROUTE2 1 #endif /* ---------------------------------------------------------------- */ diff --git a/contrib/libs/c-ares/src/lib/event/ares_event.h b/contrib/libs/c-ares/src/lib/event/ares_event.h index 36cd10dcf8..bf298dfb61 100644 --- a/contrib/libs/c-ares/src/lib/event/ares_event.h +++ b/contrib/libs/c-ares/src/lib/event/ares_event.h @@ -159,30 +159,33 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e, ares_event_signal_cb_t signal_cb); -#ifdef HAVE_PIPE +#ifdef CARES_THREADS +# ifdef HAVE_PIPE ares_event_t *ares_pipeevent_create(ares_event_thread_t *e); -#endif +# endif -#ifdef HAVE_POLL +# ifdef HAVE_POLL extern const ares_event_sys_t ares_evsys_poll; -#endif +# endif -#ifdef HAVE_KQUEUE +# ifdef HAVE_KQUEUE extern const ares_event_sys_t ares_evsys_kqueue; -#endif +# endif -#ifdef HAVE_EPOLL +# ifdef HAVE_EPOLL extern const ares_event_sys_t ares_evsys_epoll; -#endif +# endif -#ifdef _WIN32 +# ifdef _WIN32 extern const ares_event_sys_t ares_evsys_win32; -#endif +# endif /* All systems have select(), but not all have a way to wake, so we require * pipe() to wake the select() */ -#ifdef HAVE_PIPE +# ifdef HAVE_PIPE extern const ares_event_sys_t ares_evsys_select; +# endif + #endif #endif diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_configchg.c b/contrib/libs/c-ares/src/lib/event/ares_event_configchg.c index 5ecc6888ab..2a8c780c2c 100644 --- a/contrib/libs/c-ares/src/lib/event/ares_event_configchg.c +++ b/contrib/libs/c-ares/src/lib/event/ares_event_configchg.c @@ -26,7 +26,7 @@ #include "ares_private.h" #include "ares_event.h" -#ifdef __ANDROID__ +#if defined(__ANDROID__) && defined(CARES_THREADS) ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, ares_event_thread_t *e) @@ -43,7 +43,7 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg) (void)configchg; } -#elif defined(__linux__) +#elif defined(__linux__) && defined(CARES_THREADS) # include <sys/inotify.h> @@ -174,7 +174,7 @@ done: return status; } -#elif defined(USE_WINSOCK) +#elif defined(USE_WINSOCK) && defined(CARES_THREADS) # include <winsock2.h> # include <iphlpapi.h> @@ -379,7 +379,7 @@ done: return status; } -#elif defined(__APPLE__) +#elif defined(__APPLE__) && defined(CARES_THREADS) # include <sys/types.h> # include <unistd.h> @@ -531,7 +531,7 @@ done: return status; } -#elif defined(HAVE_STAT) && !defined(_WIN32) +#elif defined(HAVE_STAT) && !defined(_WIN32) && defined(CARES_THREADS) # ifdef HAVE_SYS_TYPES_H # include <sys/types.h> # endif @@ -665,6 +665,12 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, goto done; } + c->lock = ares_thread_mutex_create(); + if (c->lock == NULL) { + status = ARES_ENOMEM; + goto done; + } + c->resolvconf_path = c->e->channel->resolvconf_path; if (c->resolvconf_path == NULL) { c->resolvconf_path = PATH_RESOLV_CONF; @@ -722,6 +728,8 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg) ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, ares_event_thread_t *e) { + (void)configchg; + (void)e; /* No ability */ return ARES_ENOTIMP; } @@ -729,6 +737,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, void ares_event_configchg_destroy(ares_event_configchg_t *configchg) { /* No-op */ + (void)configchg; } #endif diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_epoll.c b/contrib/libs/c-ares/src/lib/event/ares_event_epoll.c index 538c38b4f9..d451c86a3d 100644 --- a/contrib/libs/c-ares/src/lib/event/ares_event_epoll.c +++ b/contrib/libs/c-ares/src/lib/event/ares_event_epoll.c @@ -26,6 +26,8 @@ #include "ares_private.h" #include "ares_event.h" +#if defined(HAVE_EPOLL) && defined(CARES_THREADS) + #ifdef HAVE_SYS_EPOLL_H # include <sys/epoll.h> #endif @@ -33,8 +35,6 @@ # include <fcntl.h> #endif -#ifdef HAVE_EPOLL - typedef struct { int epoll_fd; } ares_evsys_epoll_t; diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_kqueue.c b/contrib/libs/c-ares/src/lib/event/ares_event_kqueue.c index dbbd0dbd9f..00cdcbe9c2 100644 --- a/contrib/libs/c-ares/src/lib/event/ares_event_kqueue.c +++ b/contrib/libs/c-ares/src/lib/event/ares_event_kqueue.c @@ -26,6 +26,8 @@ #include "ares_private.h" #include "ares_event.h" +#if defined(HAVE_KQUEUE) && defined(CARES_THREADS) + #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif @@ -39,8 +41,6 @@ # include <fcntl.h> #endif -#ifdef HAVE_KQUEUE - typedef struct { int kqueue_fd; struct kevent *changelist; diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_poll.c b/contrib/libs/c-ares/src/lib/event/ares_event_poll.c index c6ab4b6207..28e3c09657 100644 --- a/contrib/libs/c-ares/src/lib/event/ares_event_poll.c +++ b/contrib/libs/c-ares/src/lib/event/ares_event_poll.c @@ -25,12 +25,13 @@ */ #include "ares_private.h" #include "ares_event.h" + +#if defined(HAVE_POLL) && defined(CARES_THREADS) + #ifdef HAVE_POLL_H # include <poll.h> #endif -#if defined(HAVE_POLL) - static ares_bool_t ares_evsys_poll_init(ares_event_thread_t *e) { e->ev_signal = ares_pipeevent_create(e); diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_select.c b/contrib/libs/c-ares/src/lib/event/ares_event_select.c index 4d7c085d87..df758b5a1e 100644 --- a/contrib/libs/c-ares/src/lib/event/ares_event_select.c +++ b/contrib/libs/c-ares/src/lib/event/ares_event_select.c @@ -31,13 +31,14 @@ #include "ares_private.h" #include "ares_event.h" -#ifdef HAVE_SYS_SELECT_H -# include <sys/select.h> -#endif /* All systems have select(), but not all have a way to wake, so we require * pipe() to wake the select() */ -#if defined(HAVE_PIPE) +#if defined(HAVE_PIPE) && defined(CARES_THREADS) + +#ifdef HAVE_SYS_SELECT_H +# include <sys/select.h> +#endif static ares_bool_t ares_evsys_select_init(ares_event_thread_t *e) { diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_thread.c b/contrib/libs/c-ares/src/lib/event/ares_event_thread.c index d59b7880a4..c77514e02c 100644 --- a/contrib/libs/c-ares/src/lib/event/ares_event_thread.c +++ b/contrib/libs/c-ares/src/lib/event/ares_event_thread.c @@ -26,6 +26,7 @@ #include "ares_private.h" #include "ares_event.h" +#ifdef CARES_THREADS static void ares_event_destroy_cb(void *arg) { ares_event_t *event = arg; @@ -549,3 +550,18 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel) return ARES_SUCCESS; } + +#else + +ares_status_t ares_event_thread_init(ares_channel_t *channel) +{ + (void)channel; + return ARES_ENOTIMP; +} + +void ares_event_thread_destroy(ares_channel_t *channel) +{ + (void)channel; +} + +#endif diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_wake_pipe.c b/contrib/libs/c-ares/src/lib/event/ares_event_wake_pipe.c index d3b166a3d6..cd1534bbbd 100644 --- a/contrib/libs/c-ares/src/lib/event/ares_event_wake_pipe.c +++ b/contrib/libs/c-ares/src/lib/event/ares_event_wake_pipe.c @@ -25,14 +25,16 @@ */ #include "ares_private.h" #include "ares_event.h" -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif -#ifdef HAVE_FCNTL_H -# include <fcntl.h> -#endif -#ifdef HAVE_PIPE +#if defined(HAVE_PIPE) && defined(CARES_THREADS) + +# ifdef HAVE_UNISTD_H +# include <unistd.h> +# endif +# ifdef HAVE_FCNTL_H +# include <fcntl.h> +# endif + typedef struct { int filedes[2]; } ares_pipeevent_t; diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_win32.c b/contrib/libs/c-ares/src/lib/event/ares_event_win32.c index 1531b6d81d..d7d1d65735 100644 --- a/contrib/libs/c-ares/src/lib/event/ares_event_win32.c +++ b/contrib/libs/c-ares/src/lib/event/ares_event_win32.c @@ -37,12 +37,14 @@ #include "ares_private.h" #include "ares_event.h" #include "ares_event_win32.h" + + +#if defined(USE_WINSOCK) && defined(CARES_THREADS) + #ifdef HAVE_LIMITS_H # include <limits.h> #endif -#if defined(USE_WINSOCK) - /* IMPLEMENTATION NOTES * ==================== * @@ -667,7 +669,7 @@ static ares_bool_t ares_evsys_win32_afd_cancel(ares_evsys_win32_eventdata_t *ed) /* NtCancelIoFileEx() may return STATUS_NOT_FOUND if the operation completed * just before calling NtCancelIoFileEx(), but we have not yet received the - * notifiction (but it should be queued for the next IOCP event). */ + * notification (but it should be queued for the next IOCP event). */ if (status == STATUS_SUCCESS || status == STATUS_NOT_FOUND) { return ARES_TRUE; } diff --git a/contrib/libs/c-ares/src/lib/legacy/ares_parse_a_reply.c b/contrib/libs/c-ares/src/lib/legacy/ares_parse_a_reply.c index 870aaccf76..9fd4a07ac0 100644 --- a/contrib/libs/c-ares/src/lib/legacy/ares_parse_a_reply.c +++ b/contrib/libs/c-ares/src/lib/legacy/ares_parse_a_reply.c @@ -77,6 +77,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen, } if (host != NULL) { + *host = NULL; status = ares_addrinfo2hostent(&ai, AF_INET, host); if (status != ARES_SUCCESS && status != ARES_ENODATA) { goto fail; /* LCOV_EXCL_LINE: DefensiveCoding */ diff --git a/contrib/libs/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c b/contrib/libs/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c index 278642f0b3..4c177ec9cb 100644 --- a/contrib/libs/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c +++ b/contrib/libs/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c @@ -80,6 +80,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen, } if (host != NULL) { + *host = NULL; status = ares_addrinfo2hostent(&ai, AF_INET6, host); if (status != ARES_SUCCESS && status != ARES_ENODATA) { goto fail; /* LCOV_EXCL_LINE: DefensiveCoding */ diff --git a/contrib/libs/c-ares/src/lib/util/ares_iface_ips.c b/contrib/libs/c-ares/src/lib/util/ares_iface_ips.c index 46cb291e30..c5f507f87e 100644 --- a/contrib/libs/c-ares/src/lib/util/ares_iface_ips.c +++ b/contrib/libs/c-ares/src/lib/util/ares_iface_ips.c @@ -431,8 +431,14 @@ static ares_status_t ares_iface_ips_enumerate(ares_iface_ips_t *ips, } status = ares_iface_ips_add(ips, addrflag, ifname, &addr, +#if _WIN32_WINNT >= 0x0600 ipaddr->OnLinkPrefixLength /* netmask */, - address->Ipv6IfIndex /* ll_scope */); +#else + ipaddr->Address.lpSockaddr->sa_family + == AF_INET?32:128, +#endif + address->Ipv6IfIndex /* ll_scope */ + ); if (status != ARES_SUCCESS) { goto done; diff --git a/contrib/libs/c-ares/src/lib/util/ares_uri.h b/contrib/libs/c-ares/src/lib/util/ares_uri.h index 6a703cba5b..2d8138fdc3 100644 --- a/contrib/libs/c-ares/src/lib/util/ares_uri.h +++ b/contrib/libs/c-ares/src/lib/util/ares_uri.h @@ -175,7 +175,7 @@ ares_status_t ares_uri_set_query_key(ares_uri_t *uri, const char *key, */ ares_status_t ares_uri_del_query_key(ares_uri_t *uri, const char *key); -/*! Retrieve the value associted with a query key. Keys are case-insensitive. +/*! Retrieve the value associated with a query key. Keys are case-insensitive. * * \param[in] uri Initialized URI object * \param[in] key Key to retrieve. diff --git a/contrib/libs/c-ares/ya.make b/contrib/libs/c-ares/ya.make index a49eb6942f..9ead6c9763 100644 --- a/contrib/libs/c-ares/ya.make +++ b/contrib/libs/c-ares/ya.make @@ -12,9 +12,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(1.34.4) +VERSION(1.34.5) -ORIGINAL_SOURCE(https://github.com/c-ares/c-ares/archive/v1.34.4.tar.gz) +ORIGINAL_SOURCE(https://github.com/c-ares/c-ares/archive/v1.34.5.tar.gz) PEERDIR( contrib/libs/libc_compat diff --git a/contrib/libs/cxxsupp/builtins/.yandex_meta/build.ym b/contrib/libs/cxxsupp/builtins/.yandex_meta/build.ym index cecee81a03..d437597c8d 100644 --- a/contrib/libs/cxxsupp/builtins/.yandex_meta/build.ym +++ b/contrib/libs/cxxsupp/builtins/.yandex_meta/build.ym @@ -1,6 +1,6 @@ {% extends '//builtin/bag.ym' %} -{% block current_version %}20.1.1{% endblock %} +{% block current_version %}20.1.2{% endblock %} {% block current_url %} https://github.com/llvm/llvm-project/releases/download/llvmorg-{{self.version().strip()}}/compiler-rt-{{self.version().strip()}}.src.tar.xz diff --git a/contrib/libs/cxxsupp/builtins/ya.make b/contrib/libs/cxxsupp/builtins/ya.make index 67e47b1a65..c6c546c341 100644 --- a/contrib/libs/cxxsupp/builtins/ya.make +++ b/contrib/libs/cxxsupp/builtins/ya.make @@ -12,9 +12,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(20.1.1) +VERSION(20.1.2) -ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.1/compiler-rt-20.1.1.src.tar.xz) +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.2/compiler-rt-20.1.2.src.tar.xz) NO_COMPILER_WARNINGS() diff --git a/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym b/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym index 85545f7c95..fc9a230e05 100644 --- a/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym +++ b/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym @@ -1,13 +1,14 @@ {% extends '//builtin/run.ym' %} -{% block current_version %}8ab82a2dc308c27fbdd0a87b5be7dddc623f1b0e{% endblock %} -{% block current_date %}2024-07-08{% endblock %} +{% block current_version %}6d66ac51a49af7ee46f1ccac45d312352d8b942e{% endblock %} +{% block current_date %}2024-09-20{% endblock %} {% block keep_sources %} .yandex_meta/scripts/sysincls.py include/__config_site include/__config_epilogue.h include/__memory/pointer_safety.h +include/__memory/allocator_const.h include/__support/win32/atomic_win32.h include/math_cuda.h include/stlfwd diff --git a/contrib/libs/cxxsupp/libcxx/.yandex_meta/devtools.licenses.report b/contrib/libs/cxxsupp/libcxx/.yandex_meta/devtools.licenses.report index e5e4fd87f4..e292435cb1 100644 --- a/contrib/libs/cxxsupp/libcxx/.yandex_meta/devtools.licenses.report +++ b/contrib/libs/cxxsupp/libcxx/.yandex_meta/devtools.licenses.report @@ -230,6 +230,7 @@ BELONGS ya.make include/__algorithm/ranges_find_first_of.h [3:4] include/__algorithm/ranges_find_if.h [3:4] include/__algorithm/ranges_find_if_not.h [3:4] + include/__algorithm/ranges_find_last.h [3:4] include/__algorithm/ranges_for_each.h [3:4] include/__algorithm/ranges_for_each_n.h [3:4] include/__algorithm/ranges_generate.h [3:4] @@ -458,6 +459,11 @@ BELONGS ya.make include/__coroutine/coroutine_traits.h [3:4] include/__coroutine/noop_coroutine_handle.h [3:4] include/__coroutine/trivial_awaitables.h [3:4] + include/__cstddef/byte.h [3:4] + include/__cstddef/max_align_t.h [3:4] + include/__cstddef/nullptr_t.h [3:4] + include/__cstddef/ptrdiff_t.h [3:4] + include/__cstddef/size_t.h [3:4] include/__debug_utils/randomize_range.h [3:4] include/__debug_utils/sanitizers.h [3:4] include/__debug_utils/strict_weak_ordering_check.h [3:4] @@ -547,11 +553,13 @@ BELONGS ya.make include/__functional/weak_result_type.h [4:5] include/__fwd/array.h [3:4] include/__fwd/bit_reference.h [3:4] + include/__fwd/byte.h [3:4] include/__fwd/complex.h [3:4] include/__fwd/deque.h [3:4] include/__fwd/format.h [4:5] include/__fwd/fstream.h [3:4] include/__fwd/functional.h [3:4] + include/__fwd/get.h [3:4] include/__fwd/ios.h [3:4] include/__fwd/istream.h [3:4] include/__fwd/mdspan.h [4:5] @@ -568,6 +576,7 @@ BELONGS ya.make include/__fwd/string_view.h [4:5] include/__fwd/subrange.h [3:4] include/__fwd/tuple.h [3:4] + include/__fwd/variant.h [3:4] include/__fwd/vector.h [3:4] include/__hash_table [4:5] include/__ios/fpos.h [4:5] @@ -643,6 +652,7 @@ BELONGS ya.make include/__math/remainder.h [3:4] include/__math/roots.h [3:4] include/__math/rounding_functions.h [3:4] + include/__math/special_functions.h [4:5] include/__math/traits.h [3:4] include/__math/trigonometric_functions.h [3:4] include/__mbstate_t.h [4:5] @@ -668,6 +678,9 @@ BELONGS ya.make include/__memory/concepts.h [4:5] include/__memory/construct_at.h [4:5] include/__memory/destruct_n.h [3:4] + include/__memory/inout_ptr.h [4:5] + include/__memory/noexcept_move_assign_container.h [3:4] + include/__memory/out_ptr.h [4:5] include/__memory/pointer_safety.h [4:5] include/__memory/pointer_traits.h [4:5] include/__memory/ranges_construct_at.h [4:5] @@ -679,6 +692,7 @@ BELONGS ya.make include/__memory/temporary_buffer.h [4:5] include/__memory/uninitialized_algorithms.h [4:5] include/__memory/unique_ptr.h [4:5] + include/__memory/unique_temporary_buffer.h [4:5] include/__memory/uses_allocator.h [4:5] include/__memory/uses_allocator_construction.h [3:4] include/__memory/voidify.h [4:5] @@ -846,6 +860,7 @@ BELONGS ya.make include/__thread/timed_backoff_policy.h [4:5] include/__tree [4:5] include/__tuple/find_index.h [3:4] + include/__tuple/ignore.h [3:4] include/__tuple/make_tuple_types.h [3:4] include/__tuple/sfinae_helpers.h [3:4] include/__tuple/tuple_element.h [3:4] @@ -912,8 +927,6 @@ BELONGS ya.make include/__type_traits/is_implicitly_default_constructible.h [3:4] include/__type_traits/is_integral.h [3:4] include/__type_traits/is_literal_type.h [3:4] - include/__type_traits/is_member_function_pointer.h [3:4] - include/__type_traits/is_member_object_pointer.h [3:4] include/__type_traits/is_member_pointer.h [3:4] include/__type_traits/is_nothrow_assignable.h [3:4] include/__type_traits/is_nothrow_constructible.h [3:4] @@ -930,7 +943,6 @@ BELONGS ya.make include/__type_traits/is_referenceable.h [3:4] include/__type_traits/is_same.h [3:4] include/__type_traits/is_scalar.h [3:4] - include/__type_traits/is_scoped_enum.h [3:4] include/__type_traits/is_signed.h [3:4] include/__type_traits/is_signed_integer.h [3:4] include/__type_traits/is_specialization.h [4:5] @@ -958,7 +970,6 @@ BELONGS ya.make include/__type_traits/maybe_const.h [3:4] include/__type_traits/nat.h [3:4] include/__type_traits/negation.h [3:4] - include/__type_traits/noexcept_move_assign_container.h [3:4] include/__type_traits/promote.h [3:4] include/__type_traits/rank.h [3:4] include/__type_traits/remove_all_extents.h [3:4] @@ -1053,7 +1064,6 @@ BELONGS ya.make include/exception [4:5] include/execution [4:5] include/expected [4:5] - include/experimental/__config [4:5] include/experimental/__simd/aligned_tag.h [4:5] include/experimental/__simd/declaration.h [4:5] include/experimental/__simd/reference.h [4:5] @@ -1360,6 +1370,7 @@ BELONGS ya.make include/__algorithm/ranges_find_first_of.h [3:4] include/__algorithm/ranges_find_if.h [3:4] include/__algorithm/ranges_find_if_not.h [3:4] + include/__algorithm/ranges_find_last.h [3:4] include/__algorithm/ranges_for_each.h [3:4] include/__algorithm/ranges_for_each_n.h [3:4] include/__algorithm/ranges_generate.h [3:4] @@ -1588,6 +1599,11 @@ BELONGS ya.make include/__coroutine/coroutine_traits.h [3:4] include/__coroutine/noop_coroutine_handle.h [3:4] include/__coroutine/trivial_awaitables.h [3:4] + include/__cstddef/byte.h [3:4] + include/__cstddef/max_align_t.h [3:4] + include/__cstddef/nullptr_t.h [3:4] + include/__cstddef/ptrdiff_t.h [3:4] + include/__cstddef/size_t.h [3:4] include/__debug_utils/randomize_range.h [3:4] include/__debug_utils/sanitizers.h [3:4] include/__debug_utils/strict_weak_ordering_check.h [3:4] @@ -1677,11 +1693,13 @@ BELONGS ya.make include/__functional/weak_result_type.h [4:5] include/__fwd/array.h [3:4] include/__fwd/bit_reference.h [3:4] + include/__fwd/byte.h [3:4] include/__fwd/complex.h [3:4] include/__fwd/deque.h [3:4] include/__fwd/format.h [4:5] include/__fwd/fstream.h [3:4] include/__fwd/functional.h [3:4] + include/__fwd/get.h [3:4] include/__fwd/ios.h [3:4] include/__fwd/istream.h [3:4] include/__fwd/mdspan.h [4:5] @@ -1698,6 +1716,7 @@ BELONGS ya.make include/__fwd/string_view.h [4:5] include/__fwd/subrange.h [3:4] include/__fwd/tuple.h [3:4] + include/__fwd/variant.h [3:4] include/__fwd/vector.h [3:4] include/__hash_table [4:5] include/__ios/fpos.h [4:5] @@ -1773,6 +1792,7 @@ BELONGS ya.make include/__math/remainder.h [3:4] include/__math/roots.h [3:4] include/__math/rounding_functions.h [3:4] + include/__math/special_functions.h [4:5] include/__math/traits.h [3:4] include/__math/trigonometric_functions.h [3:4] include/__mbstate_t.h [4:5] @@ -1798,6 +1818,9 @@ BELONGS ya.make include/__memory/concepts.h [4:5] include/__memory/construct_at.h [4:5] include/__memory/destruct_n.h [3:4] + include/__memory/inout_ptr.h [4:5] + include/__memory/noexcept_move_assign_container.h [3:4] + include/__memory/out_ptr.h [4:5] include/__memory/pointer_safety.h [4:5] include/__memory/pointer_traits.h [4:5] include/__memory/ranges_construct_at.h [4:5] @@ -1809,6 +1832,7 @@ BELONGS ya.make include/__memory/temporary_buffer.h [4:5] include/__memory/uninitialized_algorithms.h [4:5] include/__memory/unique_ptr.h [4:5] + include/__memory/unique_temporary_buffer.h [4:5] include/__memory/uses_allocator.h [4:5] include/__memory/uses_allocator_construction.h [3:4] include/__memory/voidify.h [4:5] @@ -1976,6 +2000,7 @@ BELONGS ya.make include/__thread/timed_backoff_policy.h [4:5] include/__tree [4:5] include/__tuple/find_index.h [3:4] + include/__tuple/ignore.h [3:4] include/__tuple/make_tuple_types.h [3:4] include/__tuple/sfinae_helpers.h [3:4] include/__tuple/tuple_element.h [3:4] @@ -2042,8 +2067,6 @@ BELONGS ya.make include/__type_traits/is_implicitly_default_constructible.h [3:4] include/__type_traits/is_integral.h [3:4] include/__type_traits/is_literal_type.h [3:4] - include/__type_traits/is_member_function_pointer.h [3:4] - include/__type_traits/is_member_object_pointer.h [3:4] include/__type_traits/is_member_pointer.h [3:4] include/__type_traits/is_nothrow_assignable.h [3:4] include/__type_traits/is_nothrow_constructible.h [3:4] @@ -2060,7 +2083,6 @@ BELONGS ya.make include/__type_traits/is_referenceable.h [3:4] include/__type_traits/is_same.h [3:4] include/__type_traits/is_scalar.h [3:4] - include/__type_traits/is_scoped_enum.h [3:4] include/__type_traits/is_signed.h [3:4] include/__type_traits/is_signed_integer.h [3:4] include/__type_traits/is_specialization.h [4:5] @@ -2088,7 +2110,6 @@ BELONGS ya.make include/__type_traits/maybe_const.h [3:4] include/__type_traits/nat.h [3:4] include/__type_traits/negation.h [3:4] - include/__type_traits/noexcept_move_assign_container.h [3:4] include/__type_traits/promote.h [3:4] include/__type_traits/rank.h [3:4] include/__type_traits/remove_all_extents.h [3:4] @@ -2183,7 +2204,6 @@ BELONGS ya.make include/exception [4:5] include/execution [4:5] include/expected [4:5] - include/experimental/__config [4:5] include/experimental/__simd/aligned_tag.h [4:5] include/experimental/__simd/declaration.h [4:5] include/experimental/__simd/reference.h [4:5] @@ -2412,6 +2432,18 @@ FILE_IGNORE include/exception found in files: LICENSE.TXT at line 210 Files with this license: LICENSE.TXT [208:222] +KEEP Public-Domain 89752a1567ebda554c9e4ee353430683 +BELONGS ya.make + License text: + // One-sided binary search, aka meta binary search, has been in the public domain for decades, and has the general + Scancode info: + Original SPDX id: LicenseRef-scancode-public-domain + Score : 100.00 + Match type : REFERENCE + Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE + Files with this license: + include/__algorithm/lower_bound.h [51:51] + KEEP Apache-2.0 9ac77f65a898755c7eed97099caded94 BELONGS ya.make FILE_IGNORE include/any found in files: LICENSE.TXT at line 101, LICENSE.TXT at line 104, LICENSE.TXT at line 107, LICENSE.TXT at line 111, LICENSE.TXT at line 114, LICENSE.TXT at line 130, LICENSE.TXT at line 135, LICENSE.TXT at line 137, LICENSE.TXT at line 139, LICENSE.TXT at line 151, LICENSE.TXT at line 154, LICENSE.TXT at line 160, LICENSE.TXT at line 161, LICENSE.TXT at line 162, LICENSE.TXT at line 165, LICENSE.TXT at line 175, LICENSE.TXT at line 176, LICENSE.TXT at line 178, LICENSE.TXT at line 34, LICENSE.TXT at line 44, LICENSE.TXT at line 52, LICENSE.TXT at line 53, LICENSE.TXT at line 58, LICENSE.TXT at line 66, LICENSE.TXT at line 86, LICENSE.TXT at line 89, LICENSE.TXT at line 94, LICENSE.TXT at line 98 @@ -2549,6 +2581,7 @@ BELONGS ya.make include/__algorithm/ranges_find_first_of.h [5:5] include/__algorithm/ranges_find_if.h [5:5] include/__algorithm/ranges_find_if_not.h [5:5] + include/__algorithm/ranges_find_last.h [5:5] include/__algorithm/ranges_for_each.h [5:5] include/__algorithm/ranges_for_each_n.h [5:5] include/__algorithm/ranges_generate.h [5:5] @@ -2777,6 +2810,11 @@ BELONGS ya.make include/__coroutine/coroutine_traits.h [5:5] include/__coroutine/noop_coroutine_handle.h [5:5] include/__coroutine/trivial_awaitables.h [5:5] + include/__cstddef/byte.h [5:5] + include/__cstddef/max_align_t.h [5:5] + include/__cstddef/nullptr_t.h [5:5] + include/__cstddef/ptrdiff_t.h [5:5] + include/__cstddef/size_t.h [5:5] include/__debug_utils/randomize_range.h [5:5] include/__debug_utils/sanitizers.h [5:5] include/__debug_utils/strict_weak_ordering_check.h [5:5] @@ -2866,11 +2904,13 @@ BELONGS ya.make include/__functional/weak_result_type.h [6:6] include/__fwd/array.h [5:5] include/__fwd/bit_reference.h [5:5] + include/__fwd/byte.h [5:5] include/__fwd/complex.h [5:5] include/__fwd/deque.h [5:5] include/__fwd/format.h [6:6] include/__fwd/fstream.h [5:5] include/__fwd/functional.h [5:5] + include/__fwd/get.h [5:5] include/__fwd/ios.h [5:5] include/__fwd/istream.h [5:5] include/__fwd/mdspan.h [6:6] @@ -2887,6 +2927,7 @@ BELONGS ya.make include/__fwd/string_view.h [6:6] include/__fwd/subrange.h [5:5] include/__fwd/tuple.h [5:5] + include/__fwd/variant.h [5:5] include/__fwd/vector.h [5:5] include/__hash_table [6:6] include/__ios/fpos.h [6:6] @@ -2962,6 +3003,7 @@ BELONGS ya.make include/__math/remainder.h [5:5] include/__math/roots.h [5:5] include/__math/rounding_functions.h [5:5] + include/__math/special_functions.h [6:6] include/__math/traits.h [5:5] include/__math/trigonometric_functions.h [5:5] include/__mbstate_t.h [6:6] @@ -2987,6 +3029,9 @@ BELONGS ya.make include/__memory/concepts.h [6:6] include/__memory/construct_at.h [6:6] include/__memory/destruct_n.h [5:5] + include/__memory/inout_ptr.h [6:6] + include/__memory/noexcept_move_assign_container.h [5:5] + include/__memory/out_ptr.h [6:6] include/__memory/pointer_safety.h [6:6] include/__memory/pointer_traits.h [6:6] include/__memory/ranges_construct_at.h [6:6] @@ -2998,6 +3043,7 @@ BELONGS ya.make include/__memory/temporary_buffer.h [6:6] include/__memory/uninitialized_algorithms.h [6:6] include/__memory/unique_ptr.h [6:6] + include/__memory/unique_temporary_buffer.h [6:6] include/__memory/uses_allocator.h [6:6] include/__memory/uses_allocator_construction.h [5:5] include/__memory/voidify.h [6:6] @@ -3165,6 +3211,7 @@ BELONGS ya.make include/__thread/timed_backoff_policy.h [6:6] include/__tree [6:6] include/__tuple/find_index.h [5:5] + include/__tuple/ignore.h [5:5] include/__tuple/make_tuple_types.h [5:5] include/__tuple/sfinae_helpers.h [5:5] include/__tuple/tuple_element.h [5:5] @@ -3231,8 +3278,6 @@ BELONGS ya.make include/__type_traits/is_implicitly_default_constructible.h [5:5] include/__type_traits/is_integral.h [5:5] include/__type_traits/is_literal_type.h [5:5] - include/__type_traits/is_member_function_pointer.h [5:5] - include/__type_traits/is_member_object_pointer.h [5:5] include/__type_traits/is_member_pointer.h [5:5] include/__type_traits/is_nothrow_assignable.h [5:5] include/__type_traits/is_nothrow_constructible.h [5:5] @@ -3249,7 +3294,6 @@ BELONGS ya.make include/__type_traits/is_referenceable.h [5:5] include/__type_traits/is_same.h [5:5] include/__type_traits/is_scalar.h [5:5] - include/__type_traits/is_scoped_enum.h [5:5] include/__type_traits/is_signed.h [5:5] include/__type_traits/is_signed_integer.h [5:5] include/__type_traits/is_specialization.h [6:6] @@ -3277,7 +3321,6 @@ BELONGS ya.make include/__type_traits/maybe_const.h [5:5] include/__type_traits/nat.h [5:5] include/__type_traits/negation.h [5:5] - include/__type_traits/noexcept_move_assign_container.h [5:5] include/__type_traits/promote.h [5:5] include/__type_traits/rank.h [5:5] include/__type_traits/remove_all_extents.h [5:5] @@ -3372,7 +3415,6 @@ BELONGS ya.make include/exception [6:6] include/execution [6:6] include/expected [6:6] - include/experimental/__config [6:6] include/experimental/__simd/aligned_tag.h [6:6] include/experimental/__simd/declaration.h [6:6] include/experimental/__simd/reference.h [6:6] @@ -3693,6 +3735,7 @@ BELONGS ya.make include/__algorithm/ranges_find_first_of.h [5:5] include/__algorithm/ranges_find_if.h [5:5] include/__algorithm/ranges_find_if_not.h [5:5] + include/__algorithm/ranges_find_last.h [5:5] include/__algorithm/ranges_for_each.h [5:5] include/__algorithm/ranges_for_each_n.h [5:5] include/__algorithm/ranges_generate.h [5:5] @@ -3921,6 +3964,11 @@ BELONGS ya.make include/__coroutine/coroutine_traits.h [5:5] include/__coroutine/noop_coroutine_handle.h [5:5] include/__coroutine/trivial_awaitables.h [5:5] + include/__cstddef/byte.h [5:5] + include/__cstddef/max_align_t.h [5:5] + include/__cstddef/nullptr_t.h [5:5] + include/__cstddef/ptrdiff_t.h [5:5] + include/__cstddef/size_t.h [5:5] include/__debug_utils/randomize_range.h [5:5] include/__debug_utils/sanitizers.h [5:5] include/__debug_utils/strict_weak_ordering_check.h [5:5] @@ -4010,11 +4058,13 @@ BELONGS ya.make include/__functional/weak_result_type.h [6:6] include/__fwd/array.h [5:5] include/__fwd/bit_reference.h [5:5] + include/__fwd/byte.h [5:5] include/__fwd/complex.h [5:5] include/__fwd/deque.h [5:5] include/__fwd/format.h [6:6] include/__fwd/fstream.h [5:5] include/__fwd/functional.h [5:5] + include/__fwd/get.h [5:5] include/__fwd/ios.h [5:5] include/__fwd/istream.h [5:5] include/__fwd/mdspan.h [6:6] @@ -4031,6 +4081,7 @@ BELONGS ya.make include/__fwd/string_view.h [6:6] include/__fwd/subrange.h [5:5] include/__fwd/tuple.h [5:5] + include/__fwd/variant.h [5:5] include/__fwd/vector.h [5:5] include/__hash_table [6:6] include/__ios/fpos.h [6:6] @@ -4106,6 +4157,7 @@ BELONGS ya.make include/__math/remainder.h [5:5] include/__math/roots.h [5:5] include/__math/rounding_functions.h [5:5] + include/__math/special_functions.h [6:6] include/__math/traits.h [5:5] include/__math/trigonometric_functions.h [5:5] include/__mbstate_t.h [6:6] @@ -4131,6 +4183,9 @@ BELONGS ya.make include/__memory/concepts.h [6:6] include/__memory/construct_at.h [6:6] include/__memory/destruct_n.h [5:5] + include/__memory/inout_ptr.h [6:6] + include/__memory/noexcept_move_assign_container.h [5:5] + include/__memory/out_ptr.h [6:6] include/__memory/pointer_safety.h [6:6] include/__memory/pointer_traits.h [6:6] include/__memory/ranges_construct_at.h [6:6] @@ -4142,6 +4197,7 @@ BELONGS ya.make include/__memory/temporary_buffer.h [6:6] include/__memory/uninitialized_algorithms.h [6:6] include/__memory/unique_ptr.h [6:6] + include/__memory/unique_temporary_buffer.h [6:6] include/__memory/uses_allocator.h [6:6] include/__memory/uses_allocator_construction.h [5:5] include/__memory/voidify.h [6:6] @@ -4309,6 +4365,7 @@ BELONGS ya.make include/__thread/timed_backoff_policy.h [6:6] include/__tree [6:6] include/__tuple/find_index.h [5:5] + include/__tuple/ignore.h [5:5] include/__tuple/make_tuple_types.h [5:5] include/__tuple/sfinae_helpers.h [5:5] include/__tuple/tuple_element.h [5:5] @@ -4375,8 +4432,6 @@ BELONGS ya.make include/__type_traits/is_implicitly_default_constructible.h [5:5] include/__type_traits/is_integral.h [5:5] include/__type_traits/is_literal_type.h [5:5] - include/__type_traits/is_member_function_pointer.h [5:5] - include/__type_traits/is_member_object_pointer.h [5:5] include/__type_traits/is_member_pointer.h [5:5] include/__type_traits/is_nothrow_assignable.h [5:5] include/__type_traits/is_nothrow_constructible.h [5:5] @@ -4393,7 +4448,6 @@ BELONGS ya.make include/__type_traits/is_referenceable.h [5:5] include/__type_traits/is_same.h [5:5] include/__type_traits/is_scalar.h [5:5] - include/__type_traits/is_scoped_enum.h [5:5] include/__type_traits/is_signed.h [5:5] include/__type_traits/is_signed_integer.h [5:5] include/__type_traits/is_specialization.h [6:6] @@ -4421,7 +4475,6 @@ BELONGS ya.make include/__type_traits/maybe_const.h [5:5] include/__type_traits/nat.h [5:5] include/__type_traits/negation.h [5:5] - include/__type_traits/noexcept_move_assign_container.h [5:5] include/__type_traits/promote.h [5:5] include/__type_traits/rank.h [5:5] include/__type_traits/remove_all_extents.h [5:5] @@ -4516,7 +4569,6 @@ BELONGS ya.make include/exception [6:6] include/execution [6:6] include/expected [6:6] - include/experimental/__config [6:6] include/experimental/__simd/aligned_tag.h [6:6] include/experimental/__simd/declaration.h [6:6] include/experimental/__simd/reference.h [6:6] diff --git a/contrib/libs/cxxsupp/libcxx/.yandex_meta/licenses.list.txt b/contrib/libs/cxxsupp/libcxx/.yandex_meta/licenses.list.txt index 6ffcfd8898..7a40b72ebc 100644 --- a/contrib/libs/cxxsupp/libcxx/.yandex_meta/licenses.list.txt +++ b/contrib/libs/cxxsupp/libcxx/.yandex_meta/licenses.list.txt @@ -586,6 +586,7 @@ namespace std { #include <__type_traits/aligned_storage.h> #include <__type_traits/conditional.h> #include <__type_traits/decay.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_function.h> #include <__type_traits/is_nothrow_constructible.h> @@ -622,7 +623,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { +[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { # ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw bad_any_cast(); # else @@ -1177,6 +1178,10 @@ Full text of the relevant licenses is included below. ====================Public-Domain==================== +// One-sided binary search, aka meta binary search, has been in the public domain for decades, and has the general + + +====================Public-Domain==================== // These files can be found at https://data.iana.org/time-zones/ and are in the // public domain. Information regarding the input can be found at diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/adjacent_find.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/adjacent_find.h index 6f15456e3a..f0708ebe25 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/adjacent_find.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/adjacent_find.h @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _Iter, class _Sent, class _BinaryPredicate> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { if (__first == __last) return __first; @@ -40,13 +40,13 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { } template <class _ForwardIterator, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { return std::__adjacent_find(std::move(__first), std::move(__last), __pred); } template <class _ForwardIterator> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { return std::adjacent_find(std::move(__first), std::move(__last), __equal_to()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/all_of.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/all_of.h index ec84eea759..1fcb74ffc0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/all_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/all_of.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _Predicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (!__pred(*__first)) diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/any_of.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/any_of.h index b5ff778c41..acb546bb22 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/any_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/any_of.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _Predicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (__pred(*__first)) diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/binary_search.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/binary_search.h index 6065fc3727..79a5ec089f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/binary_search.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/binary_search.h @@ -22,14 +22,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _ForwardIterator, class _Tp, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { __first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp); return __first != __last && !__comp(__value, *__first); } template <class _ForwardIterator, class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { return std::binary_search(__first, __last, __value, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/comp.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/comp.h index a0fa88d6d2..1f38f5d2d9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/comp.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/comp.h @@ -11,6 +11,7 @@ #include <__config> #include <__type_traits/desugars_to.h> +#include <__type_traits/is_integral.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -42,7 +43,7 @@ struct __less<void, void> { }; template <class _Tp> -inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true; +inline const bool __desugars_to_v<__totally_ordered_less_tag, __less<>, _Tp, _Tp> = is_integral<_Tp>::value; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h index 0890b895f5..7ae47514d6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h @@ -14,8 +14,10 @@ #include <__algorithm/iterator_operations.h> #include <__algorithm/min.h> #include <__config> +#include <__iterator/iterator_traits.h> #include <__iterator/segmented_iterator.h> #include <__type_traits/common_type.h> +#include <__type_traits/enable_if.h> #include <__utility/move.h> #include <__utility/pair.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_backward.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_backward.h index 73dc846a97..48a768f577 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_backward.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_backward.h @@ -13,8 +13,10 @@ #include <__algorithm/iterator_operations.h> #include <__algorithm/min.h> #include <__config> +#include <__iterator/iterator_traits.h> #include <__iterator/segmented_iterator.h> #include <__type_traits/common_type.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_constructible.h> #include <__utility/move.h> #include <__utility/pair.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/count.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/count.h index 1cfe7f631a..6910b4f43e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/count.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/count.h @@ -16,9 +16,10 @@ #include <__bit/popcount.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__fwd/bit_reference.h> #include <__iterator/iterator_traits.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -79,7 +80,7 @@ __count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __l } template <class _InputIterator, class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator> count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { __identity __proj; return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/count_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/count_if.h index 25782069d0..e702388960 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/count_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/count_if.h @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _Predicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename iterator_traits<_InputIterator>::difference_type count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { typename iterator_traits<_InputIterator>::difference_type __r(0); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/equal.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/equal.h index bfc8f72f6e..cd8b0673e7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/equal.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/equal.h @@ -14,12 +14,12 @@ #include <__algorithm/unwrap_iter.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__string/constexpr_c_functions.h> #include <__type_traits/desugars_to.h> #include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_constant_evaluated.h> #include <__type_traits/is_equality_comparable.h> #include <__type_traits/is_volatile.h> @@ -35,7 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate& __pred) { for (; __first1 != __last1; ++__first1, (void)++__first2) if (!__pred(*__first1, *__first2)) @@ -49,20 +49,20 @@ template <class _Tp, __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, _Tp, _Up> && !is_volatile<_Tp>::value && !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&) { return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); } template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { return std::__equal_iter_impl( std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred); } template <class _InputIterator1, class _InputIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { return std::equal(__first1, __last1, __first2, __equal_to()); } @@ -70,7 +70,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first #if _LIBCPP_STD_VER >= 14 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl( _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __comp, _Proj1& __proj1, _Proj2& __proj2) { while (__first1 != __last1 && __first2 != __last2) { if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) @@ -90,13 +90,13 @@ template <class _Tp, __is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) { return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); } template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, @@ -119,7 +119,7 @@ equal(_InputIterator1 __first1, } template <class _InputIterator1, class _InputIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { return std::equal(__first1, __last1, __first2, __last2, __equal_to()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/equal_range.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/equal_range.h index 09bbf8f006..4e74ad20aa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/equal_range.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/equal_range.h @@ -17,11 +17,11 @@ #include <__algorithm/upper_bound.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/advance.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__iterator/next.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_callable.h> #include <__type_traits/is_constructible.h> #include <__utility/move.h> @@ -60,9 +60,9 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp } template <class _ForwardIterator, class _Tp, class _Compare> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { - static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); + static_assert(__is_callable<_Compare&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible"); return std::__equal_range<_ClassicAlgPolicy>( std::move(__first), @@ -73,7 +73,7 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu } template <class _ForwardIterator, class _Tp> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { return std::equal_range(std::move(__first), std::move(__last), __value, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h index 7f58dbb13a..6f23ec3f6f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h @@ -17,10 +17,12 @@ #include <__bit/invert_if.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__fwd/bit_reference.h> #include <__iterator/segmented_iterator.h> #include <__string/constexpr_c_functions.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> +#include <__type_traits/is_equality_comparable.h> #include <__type_traits/is_integral.h> #include <__type_traits/is_same.h> #include <__type_traits/is_signed.h> @@ -167,7 +169,7 @@ struct __find_segment { // public API template <class _InputIterator, class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator find(_InputIterator __first, _InputIterator __last, const _Tp& __value) { __identity __proj; return std::__rewrap_iter( diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_end.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_end.h index 7e08e79535..08d1a295f8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_end.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_end.h @@ -15,11 +15,11 @@ #include <__algorithm/search.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/advance.h> #include <__iterator/iterator_traits.h> #include <__iterator/next.h> #include <__iterator/reverse_iterator.h> +#include <__type_traits/invoke.h> #include <__utility/pair.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -80,111 +80,8 @@ _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> } } -template < class _IterOps, - class _Pred, - class _Iter1, - class _Sent1, - class _Iter2, - class _Sent2, - class _Proj1, - class _Proj2> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter1 __find_end( - _Iter1 __first1, - _Sent1 __sent1, - _Iter2 __first2, - _Sent2 __sent2, - _Pred& __pred, - _Proj1& __proj1, - _Proj2& __proj2, - bidirectional_iterator_tag, - bidirectional_iterator_tag) { - auto __last1 = _IterOps::next(__first1, __sent1); - auto __last2 = _IterOps::next(__first2, __sent2); - // modeled after search algorithm (in reverse) - if (__first2 == __last2) - return __last1; // Everything matches an empty sequence - _Iter1 __l1 = __last1; - _Iter2 __l2 = __last2; - --__l2; - while (true) { - // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks - while (true) { - if (__first1 == __l1) // return __last1 if no element matches *__first2 - return __last1; - if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2))) - break; - } - // *__l1 matches *__l2, now match elements before here - _Iter1 __m1 = __l1; - _Iter2 __m2 = __l2; - while (true) { - if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern) - return __m1; - if (__m1 == __first1) // Otherwise if source exhaused, pattern not found - return __last1; - - // if there is a mismatch, restart with a new __l1 - if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(__proj2, *--__m2))) { - break; - } // else there is a match, check next elements - } - } -} - -template < class _AlgPolicy, - class _Pred, - class _Iter1, - class _Sent1, - class _Iter2, - class _Sent2, - class _Proj1, - class _Proj2> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter1 __find_end( - _Iter1 __first1, - _Sent1 __sent1, - _Iter2 __first2, - _Sent2 __sent2, - _Pred& __pred, - _Proj1& __proj1, - _Proj2& __proj2, - random_access_iterator_tag, - random_access_iterator_tag) { - typedef typename iterator_traits<_Iter1>::difference_type _D1; - auto __last1 = _IterOps<_AlgPolicy>::next(__first1, __sent1); - auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __sent2); - // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern - auto __len2 = __last2 - __first2; - if (__len2 == 0) - return __last1; - auto __len1 = __last1 - __first1; - if (__len1 < __len2) - return __last1; - const _Iter1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here - _Iter1 __l1 = __last1; - _Iter2 __l2 = __last2; - --__l2; - while (true) { - while (true) { - if (__s == __l1) - return __last1; - if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2))) - break; - } - _Iter1 __m1 = __l1; - _Iter2 __m2 = __l2; - while (true) { - if (__m2 == __first2) - return __m1; - // no need to check range on __m1 because __s guarantees we have enough source - if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(*--__m2))) { - break; - } - } - } -} - template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_end_classic( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_end_classic( _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, @@ -205,7 +102,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Fo } template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end( _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, @@ -215,7 +112,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Fo } template <class _ForwardIterator1, class _ForwardIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { return std::find_end(__first1, __last1, __first2, __last2, __equal_to()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_first_of.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_first_of.h index 6b99f562f8..4a240f7331 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_first_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_first_of.h @@ -35,7 +35,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_fir } template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, @@ -45,7 +45,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Fo } template <class _ForwardIterator1, class _ForwardIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_if.h index 22092d352b..fd63bcc3a5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_if.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _Predicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (__pred(*__first)) diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_if_not.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_if_not.h index cc2001967f..b4441b297c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_if_not.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_if_not.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _Predicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (!__pred(*__first)) diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/fold.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/fold.h index 255658f523..1bcb3be9aa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/fold.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/fold.h @@ -11,6 +11,7 @@ #define _LIBCPP___ALGORITHM_FOLD_H #include <__concepts/assignable.h> +#include <__concepts/constructible.h> #include <__concepts/convertible_to.h> #include <__concepts/invocable.h> #include <__concepts/movable.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/includes.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/includes.h index 62af03c374..a86102fc6d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/includes.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/includes.h @@ -13,8 +13,8 @@ #include <__algorithm/comp_ref_type.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/iterator_traits.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_callable.h> #include <__utility/move.h> @@ -47,14 +47,14 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __includes( } template <class _InputIterator1, class _InputIterator2, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { static_assert( - __is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value, "Comparator has to be callable"); + __is_callable<_Compare&, decltype(*__first1), decltype(*__first2)>::value, "The comparator has to be callable"); return std::__includes( std::move(__first1), @@ -67,7 +67,7 @@ includes(_InputIterator1 __first1, } template <class _InputIterator1, class _InputIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { return std::includes(std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/inplace_merge.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/inplace_merge.h index a6bcc66a2f..62a8bc53e2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/inplace_merge.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/inplace_merge.h @@ -24,8 +24,9 @@ #include <__iterator/iterator_traits.h> #include <__iterator/reverse_iterator.h> #include <__memory/destruct_n.h> -#include <__memory/temporary_buffer.h> #include <__memory/unique_ptr.h> +#include <__memory/unique_temporary_buffer.h> +#include <__utility/move.h> #include <__utility/pair.h> #include <new> @@ -208,16 +209,19 @@ _LIBCPP_HIDE_FROM_ABI void __inplace_merge( _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare&& __comp) { typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; - difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle); - difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last); - difference_type __buf_size = std::min(__len1, __len2); - // TODO: Remove the use of std::get_temporary_buffer - _LIBCPP_SUPPRESS_DEPRECATED_PUSH - pair<value_type*, ptrdiff_t> __buf = std::get_temporary_buffer<value_type>(__buf_size); - _LIBCPP_SUPPRESS_DEPRECATED_POP - unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first); + difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle); + difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last); + difference_type __buf_size = std::min(__len1, __len2); + __unique_temporary_buffer<value_type> __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__buf_size); return std::__inplace_merge<_AlgPolicy>( - std::move(__first), std::move(__middle), std::move(__last), __comp, __len1, __len2, __buf.first, __buf.second); + std::move(__first), + std::move(__middle), + std::move(__last), + __comp, + __len1, + __len2, + __unique_buf.get(), + __unique_buf.get_deleter().__count_); } template <class _BidirectionalIterator, class _Compare> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap.h index c589b804a5..fa668c1d04 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap.h @@ -22,13 +22,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _RandomAccessIterator, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last; } template <class _RandomAccessIterator> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { return std::is_heap(__first, __last, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap_until.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap_until.h index a174f2453c..7444d978e3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap_until.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap_until.h @@ -46,13 +46,13 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co } template <class _RandomAccessIterator, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)); } template <class _RandomAccessIterator> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) { return std::__is_heap_until(__first, __last, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_partitioned.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_partitioned.h index 1f7c8b0b26..700e452bbf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_partitioned.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_partitioned.h @@ -18,7 +18,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _Predicate> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (!__pred(*__first)) diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_permutation.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_permutation.h index 2ddfb32a21..8753e9fc13 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_permutation.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_permutation.h @@ -14,12 +14,14 @@ #include <__algorithm/iterator_operations.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/concepts.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__iterator/next.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_callable.h> +#include <__type_traits/is_same.h> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -113,7 +115,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation_impl( // 2+1 iterators, predicate. Not used by range algorithms. template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( _ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _BinaryPredicate&& __pred) { // Shorten sequences as much as possible by lopping of any equal prefix. for (; __first1 != __last1; ++__first1, (void)++__first2) { @@ -247,17 +249,17 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( // 2+1 iterators, predicate template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) { - static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, - "The predicate has to be callable"); + static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value, + "The comparator has to be callable"); return std::__is_permutation<_ClassicAlgPolicy>(std::move(__first1), std::move(__last1), std::move(__first2), __pred); } // 2+1 iterators template <class _ForwardIterator1, class _ForwardIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { return std::is_permutation(__first1, __last1, __first2, __equal_to()); } @@ -266,7 +268,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt // 2+2 iterators template <class _ForwardIterator1, class _ForwardIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { return std::__is_permutation<_ClassicAlgPolicy>( std::move(__first1), @@ -280,14 +282,14 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 boo // 2+2 iterators, predicate template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) { - static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, - "The predicate has to be callable"); + static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value, + "The comparator has to be callable"); return std::__is_permutation<_ClassicAlgPolicy>( std::move(__first1), diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted.h index 3befb1ac9c..ff61a73604 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted.h @@ -22,13 +22,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _ForwardIterator, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last; } template <class _ForwardIterator> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_sorted(_ForwardIterator __first, _ForwardIterator __last) { return std::is_sorted(__first, __last, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted_until.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted_until.h index 53a49f00de..b64fb65e84 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted_until.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted_until.h @@ -35,13 +35,13 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __ } template <class _ForwardIterator, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp); } template <class _ForwardIterator> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) { return std::is_sorted_until(__first, __last, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/iterator_operations.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/iterator_operations.h index 5cf13f0a3f..8ced989233 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/iterator_operations.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/iterator_operations.h @@ -11,6 +11,7 @@ #include <__algorithm/iter_swap.h> #include <__algorithm/ranges_iterator_concept.h> +#include <__assert> #include <__config> #include <__iterator/advance.h> #include <__iterator/distance.h> @@ -160,6 +161,59 @@ struct _IterOps<_ClassicAlgPolicy> { _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14 void __advance_to(_Iter& __first, _Iter __last) { __first = __last; } + + // advance with sentinel, a la std::ranges::advance + template <class _Iter> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_Iter> + __advance_to(_Iter& __iter, __difference_type<_Iter> __count, const _Iter& __sentinel) { + return _IterOps::__advance_to(__iter, __count, __sentinel, typename iterator_traits<_Iter>::iterator_category()); + } + +private: + // advance with sentinel, a la std::ranges::advance -- InputIterator specialization + template <class _InputIter> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_InputIter> __advance_to( + _InputIter& __iter, __difference_type<_InputIter> __count, const _InputIter& __sentinel, input_iterator_tag) { + __difference_type<_InputIter> __dist = 0; + for (; __dist < __count && __iter != __sentinel; ++__dist) + ++__iter; + return __count - __dist; + } + + // advance with sentinel, a la std::ranges::advance -- BidirectionalIterator specialization + template <class _BiDirIter> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_BiDirIter> + __advance_to(_BiDirIter& __iter, + __difference_type<_BiDirIter> __count, + const _BiDirIter& __sentinel, + bidirectional_iterator_tag) { + __difference_type<_BiDirIter> __dist = 0; + if (__count >= 0) + for (; __dist < __count && __iter != __sentinel; ++__dist) + ++__iter; + else + for (__count = -__count; __dist < __count && __iter != __sentinel; ++__dist) + --__iter; + return __count - __dist; + } + + // advance with sentinel, a la std::ranges::advance -- RandomIterator specialization + template <class _RandIter> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_RandIter> + __advance_to(_RandIter& __iter, + __difference_type<_RandIter> __count, + const _RandIter& __sentinel, + random_access_iterator_tag) { + auto __dist = _IterOps::distance(__iter, __sentinel); + _LIBCPP_ASSERT_VALID_INPUT_RANGE( + __count == 0 || (__dist < 0) == (__count < 0), "__sentinel must precede __iter when __count < 0"); + if (__count < 0) + __dist = __dist > __count ? __dist : __count; + else + __dist = __dist < __count ? __dist : __count; + __iter += __dist; + return __count - __dist; + } }; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/lexicographical_compare.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/lexicographical_compare.h index edc29e269c..1de3ca13e1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/lexicographical_compare.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/lexicographical_compare.h @@ -10,48 +10,120 @@ #define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H #include <__algorithm/comp.h> -#include <__algorithm/comp_ref_type.h> +#include <__algorithm/min.h> +#include <__algorithm/mismatch.h> +#include <__algorithm/simd_utils.h> +#include <__algorithm/unwrap_iter.h> #include <__config> +#include <__functional/identity.h> #include <__iterator/iterator_traits.h> +#include <__string/constexpr_c_functions.h> +#include <__type_traits/desugars_to.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> +#include <__type_traits/is_equality_comparable.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/is_trivially_lexicographically_comparable.h> +#include <__type_traits/is_volatile.h> + +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include <cwchar> +#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Compare, class _InputIterator1, class _InputIterator2> +template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __lexicographical_compare( - _InputIterator1 __first1, - _InputIterator1 __last1, - _InputIterator2 __first2, - _InputIterator2 __last2, - _Compare __comp) { - for (; __first2 != __last2; ++__first1, (void)++__first2) { - if (__first1 == __last1 || __comp(*__first1, *__first2)) + _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) { + while (__first2 != __last2) { + if (__first1 == __last1 || + std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) return true; - if (__comp(*__first2, *__first1)) + if (std::__invoke(__comp, std::__invoke(__proj2, *__first2), std::__invoke(__proj1, *__first1))) return false; + ++__first1; + ++__first2; } return false; } +#if _LIBCPP_STD_VER >= 14 + +// If the comparison operation is equivalent to < and that is a total order, we know that we can use equality comparison +// on that type instead to extract some information. Furthermore, if equality comparison on that type is trivial, the +// user can't observe that we're calling it. So instead of using the user-provided total order, we use std::mismatch, +// which uses equality comparison (and is vertorized). Additionally, if the type is trivially lexicographically +// comparable, we can go one step further and use std::memcmp directly instead of calling std::mismatch. +template <class _Tp, + class _Proj1, + class _Proj2, + class _Comp, + __enable_if_t<__desugars_to_v<__totally_ordered_less_tag, _Comp, _Tp, _Tp> && !is_volatile<_Tp>::value && + __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value && + __is_identity<_Proj1>::value && __is_identity<_Proj2>::value, + int> = 0> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +__lexicographical_compare(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Comp&, _Proj1&, _Proj2&) { + if constexpr (__is_trivially_lexicographically_comparable_v<_Tp, _Tp>) { + auto __res = + std::__constexpr_memcmp(__first1, __first2, __element_count(std::min(__last1 - __first1, __last2 - __first2))); + if (__res == 0) + return __last1 - __first1 < __last2 - __first2; + return __res < 0; + } +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS + else if constexpr (is_same<__remove_cv_t<_Tp>, wchar_t>::value) { + auto __res = std::__constexpr_wmemcmp(__first1, __first2, std::min(__last1 - __first1, __last2 - __first2)); + if (__res == 0) + return __last1 - __first1 < __last2 - __first2; + return __res < 0; + } +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS + else { + auto __res = std::mismatch(__first1, __last1, __first2, __last2); + if (__res.second == __last2) + return false; + if (__res.first == __last1) + return true; + return *__res.first < *__res.second; + } +} + +#endif // _LIBCPP_STD_VER >= 14 + template <class _InputIterator1, class _InputIterator2, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { - return std::__lexicographical_compare<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __comp); + __identity __proj; + return std::__lexicographical_compare( + std::__unwrap_iter(__first1), + std::__unwrap_iter(__last1), + std::__unwrap_iter(__first2), + std::__unwrap_iter(__last2), + __comp, + __proj, + __proj); } template <class _InputIterator1, class _InputIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { return std::lexicographical_compare(__first1, __last1, __first2, __last2, __less<>()); } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/lower_bound.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/lower_bound.h index 8fd355a7cf..2144ba9629 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/lower_bound.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/lower_bound.h @@ -14,10 +14,10 @@ #include <__algorithm/iterator_operations.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/advance.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_callable.h> #include <__type_traits/remove_reference.h> @@ -27,11 +27,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template <class _AlgPolicy, class _Iter, class _Sent, class _Type, class _Proj, class _Comp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter -__lower_bound(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) { - auto __len = _IterOps<_AlgPolicy>::distance(__first, __last); - +template <class _AlgPolicy, class _Iter, class _Type, class _Proj, class _Comp> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lower_bound_bisecting( + _Iter __first, + const _Type& __value, + typename iterator_traits<_Iter>::difference_type __len, + _Comp& __comp, + _Proj& __proj) { while (__len != 0) { auto __l2 = std::__half_positive(__len); _Iter __m = __first; @@ -46,16 +48,58 @@ __lower_bound(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, return __first; } +// One-sided binary search, aka meta binary search, has been in the public domain for decades, and has the general +// advantage of being \Omega(1) rather than the classic algorithm's \Omega(log(n)), with the downside of executing at +// most 2*log(n) comparisons vs the classic algorithm's exact log(n). There are two scenarios in which it really shines: +// the first one is when operating over non-random-access iterators, because the classic algorithm requires knowing the +// container's size upfront, which adds \Omega(n) iterator increments to the complexity. The second one is when you're +// traversing the container in order, trying to fast-forward to the next value: in that case, the classic algorithm +// would yield \Omega(n*log(n)) comparisons and, for non-random-access iterators, \Omega(n^2) iterator increments, +// whereas the one-sided version will yield O(n) operations on both counts, with a \Omega(log(n)) bound on the number of +// comparisons. +template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +__lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) { + // step = 0, ensuring we can always short-circuit when distance is 1 later on + if (__first == __last || !std::__invoke(__comp, std::__invoke(__proj, *__first), __value)) + return __first; + + using _Distance = typename iterator_traits<_ForwardIterator>::difference_type; + for (_Distance __step = 1; __first != __last; __step <<= 1) { + auto __it = __first; + auto __dist = __step - _IterOps<_AlgPolicy>::__advance_to(__it, __step, __last); + // once we reach the last range where needle can be we must start + // looking inwards, bisecting that range + if (__it == __last || !std::__invoke(__comp, std::__invoke(__proj, *__it), __value)) { + // we've already checked the previous value and it was less, we can save + // one comparison by skipping bisection + if (__dist == 1) + return __it; + return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj); + } + // range not found, move forward! + __first = __it; + } + return __first; +} + +template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +__lower_bound(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) { + const auto __dist = _IterOps<_AlgPolicy>::distance(__first, __last); + return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj); +} + template <class _ForwardIterator, class _Tp, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { - static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); + static_assert(__is_callable<_Compare&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); auto __proj = std::__identity(); return std::__lower_bound<_ClassicAlgPolicy>(__first, __last, __value, __comp, __proj); } template <class _ForwardIterator, class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { return std::lower_bound(__first, __last, __value, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h index 5245e523f3..22cceb4cb2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/make_projected.h @@ -16,6 +16,7 @@ #include <__type_traits/decay.h> #include <__type_traits/enable_if.h> #include <__type_traits/integral_constant.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_member_pointer.h> #include <__type_traits/is_same.h> #include <__utility/declval.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/max.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/max.h index d4c99f6f36..1673e6be91 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/max.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/max.h @@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { return __comp(__a, __b) ? __b : __a; } template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { return std::max(__a, __b, __less<>()); } @@ -39,13 +39,13 @@ max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) #ifndef _LIBCPP_CXX03_LANG template <class _Tp, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t, _Compare __comp) { return *std::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp); } template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) { return *std::max_element(__t.begin(), __t.end(), __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/max_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/max_element.h index c036726cbc..929f337fc1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/max_element.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/max_element.h @@ -13,6 +13,7 @@ #include <__algorithm/comp_ref_type.h> #include <__config> #include <__iterator/iterator_traits.h> +#include <__type_traits/is_callable.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -35,13 +36,15 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp } template <class _ForwardIterator, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { + static_assert( + __is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable"); return std::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp); } template <class _ForwardIterator> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last) { return std::max_element(__first, __last, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/min.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/min.h index 1bafad8a46..660e0b204e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/min.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/min.h @@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { return __comp(__b, __a) ? __b : __a; } template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { return std::min(__a, __b, __less<>()); } @@ -39,13 +39,13 @@ min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) #ifndef _LIBCPP_CXX03_LANG template <class _Tp, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t, _Compare __comp) { return *std::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp); } template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) { return *std::min_element(__t.begin(), __t.end(), __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/min_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/min_element.h index 65f3594d63..db996365bf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/min_element.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/min_element.h @@ -13,8 +13,8 @@ #include <__algorithm/comp_ref_type.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/iterator_traits.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_callable.h> #include <__utility/move.h> @@ -48,18 +48,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter __min_element(_Iter __ } template <class _ForwardIterator, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { static_assert( __has_forward_iterator_category<_ForwardIterator>::value, "std::min_element requires a ForwardIterator"); static_assert( - __is_callable<_Compare, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable"); + __is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable"); return std::__min_element<__comp_ref_type<_Compare> >(std::move(__first), std::move(__last), __comp); } template <class _ForwardIterator> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last) { return std::min_element(__first, __last, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax.h index 9feda2b4c0..de0bec0ef7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax.h @@ -24,13 +24,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) : pair<const _Tp&, const _Tp&>(__a, __b); } template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { return std::minmax(__a, __b, __less<>()); } @@ -38,16 +38,16 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __ #ifndef _LIBCPP_CXX03_LANG template <class _Tp, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) { - static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable"); + static_assert(__is_callable<_Compare&, _Tp, _Tp>::value, "The comparator has to be callable"); __identity __proj; auto __ret = std::__minmax_element_impl(__t.begin(), __t.end(), __comp, __proj); return pair<_Tp, _Tp>(*__ret.first, *__ret.second); } template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t) { return std::minmax(__t, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax_element.h index 43cb23347c..dc0c3a818c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax_element.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax_element.h @@ -12,8 +12,8 @@ #include <__algorithm/comp.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/iterator_traits.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_callable.h> #include <__utility/pair.h> @@ -79,18 +79,18 @@ __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) } template <class _ForwardIterator, class _Compare> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { static_assert( __has_forward_iterator_category<_ForwardIterator>::value, "std::minmax_element requires a ForwardIterator"); static_assert( - __is_callable<_Compare, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable"); + __is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable"); auto __proj = __identity(); return std::__minmax_element_impl(__first, __last, __comp, __proj); } template <class _ForwardIterator> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) { return std::minmax_element(__first, __last, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/mismatch.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/mismatch.h index 632bec0240..cb83347584 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/mismatch.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/mismatch.h @@ -17,7 +17,9 @@ #include <__config> #include <__functional/identity.h> #include <__iterator/aliasing_iterator.h> +#include <__iterator/iterator_traits.h> #include <__type_traits/desugars_to.h> +#include <__type_traits/enable_if.h> #include <__type_traits/invoke.h> #include <__type_traits/is_constant_evaluated.h> #include <__type_traits/is_equality_comparable.h> @@ -37,7 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _Iter1, class _Sent1, class _Iter2, class _Pred, class _Proj1, class _Proj2> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch_loop(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { while (__first1 != __last1) { if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) @@ -49,7 +51,7 @@ __mismatch_loop(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, } template <class _Iter1, class _Sent1, class _Iter2, class _Pred, class _Proj1, class _Proj2> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2); } @@ -57,7 +59,7 @@ __mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Pro #if _LIBCPP_VECTORIZE_ALGORITHMS template <class _Iter> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter> __mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) { using __value_type = __iter_value_type<_Iter>; constexpr size_t __unroll_count = 4; @@ -124,7 +126,7 @@ template <class _Tp, __enable_if_t<is_integral<_Tp>::value && __desugars_to_v<__equal_tag, _Pred, _Tp, _Tp> && __is_identity<_Proj1>::value && __is_identity<_Proj2>::value, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred&, _Proj1&, _Proj2&) { return std::__mismatch_vectorized(__first1, __last1, __first2); } @@ -137,7 +139,7 @@ template <class _Tp, __is_identity<_Proj1>::value && __is_identity<_Proj2>::value && __can_map_to_integer_v<_Tp> && __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { if (__libcpp_is_constant_evaluated()) { return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2); @@ -150,7 +152,7 @@ __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __ #endif // _LIBCPP_VECTORIZE_ALGORITHMS template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { __identity __proj; auto __res = std::__mismatch( @@ -159,14 +161,14 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi } template <class _InputIterator1, class _InputIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { return std::mismatch(__first1, __last1, __first2, __equal_to()); } #if _LIBCPP_STD_VER >= 14 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch( +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch( _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { while (__first1 != __last1 && __first2 != __last2) { if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) @@ -178,14 +180,14 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter } template <class _Tp, class _Pred, class _Proj1, class _Proj2> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { auto __len = std::min(__last1 - __first1, __last2 - __first2); return std::__mismatch(__first1, __first1 + __len, __first2, __pred, __proj1, __proj2); } template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, @@ -204,7 +206,7 @@ mismatch(_InputIterator1 __first1, } template <class _InputIterator1, class _InputIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { return std::mismatch(__first1, __last1, __first2, __last2, __equal_to()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h index 1716d43e2a..005099dcac 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h @@ -14,8 +14,10 @@ #include <__algorithm/iterator_operations.h> #include <__algorithm/min.h> #include <__config> +#include <__iterator/iterator_traits.h> #include <__iterator/segmented_iterator.h> #include <__type_traits/common_type.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_constructible.h> #include <__utility/move.h> #include <__utility/pair.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/move_backward.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/move_backward.h index 4beb7bdbaa..24a8d9b245 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/move_backward.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/move_backward.h @@ -13,8 +13,10 @@ #include <__algorithm/iterator_operations.h> #include <__algorithm/min.h> #include <__config> +#include <__iterator/iterator_traits.h> #include <__iterator/segmented_iterator.h> #include <__type_traits/common_type.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_constructible.h> #include <__utility/move.h> #include <__utility/pair.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/none_of.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/none_of.h index 50841ba17c..e6bd197622 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/none_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/none_of.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _Predicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) if (__pred(*__first)) diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/partial_sort_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/partial_sort_copy.h index ef7c9d34d9..172f53b290 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/partial_sort_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/partial_sort_copy.h @@ -18,8 +18,8 @@ #include <__algorithm/sort_heap.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/iterator_traits.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_callable.h> #include <__utility/move.h> #include <__utility/pair.h> @@ -76,8 +76,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) { - static_assert( - __is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value, "Comparator has to be callable"); + static_assert(__is_callable<_Compare&, decltype(*__first), decltype(*__result_first)>::value, + "The comparator has to be callable"); auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>( __first, diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/partition.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/partition.h index 824e49b9ec..669aac3b27 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/partition.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/partition.h @@ -12,6 +12,7 @@ #include <__algorithm/iterator_operations.h> #include <__config> #include <__iterator/iterator_traits.h> +#include <__type_traits/remove_cvref.h> #include <__utility/move.h> #include <__utility/pair.h> @@ -29,7 +30,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _Forw __partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag) { while (true) { if (__first == __last) - return std::make_pair(std::move(__first), std::move(__first)); + return std::make_pair(__first, __first); if (!__pred(*__first)) break; ++__first; diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl.h index 0bb052b3f9..71e7f28476 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl.h @@ -352,7 +352,7 @@ template <class _ExecutionPolicy, class _Predicate, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "is_partitioned requires ForwardIterators"); using _Implementation = __pstl::__dispatch<__pstl::__is_partitioned, __pstl::__current_configuration, _RawPolicy>; diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_adjacent_find.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_adjacent_find.h index 3c54f72331..0f2cb66699 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_adjacent_find.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_adjacent_find.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __adjacent_find { -struct __fn { +struct __adjacent_find { template <class _Iter, class _Sent, class _Proj, class _Pred> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __adjacent_find_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { @@ -67,10 +66,9 @@ struct __fn { return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __adjacent_find inline namespace __cpo { -inline constexpr auto adjacent_find = __adjacent_find::__fn{}; +inline constexpr auto adjacent_find = __adjacent_find{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_all_of.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_all_of.h index 2f603b32f3..fea0894938 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_all_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_all_of.h @@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __all_of { -struct __fn { +struct __all_of { template <class _Iter, class _Sent, class _Proj, class _Pred> _LIBCPP_HIDE_FROM_ABI constexpr static bool __all_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { for (; __first != __last; ++__first) { @@ -58,10 +57,9 @@ struct __fn { return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __all_of inline namespace __cpo { -inline constexpr auto all_of = __all_of::__fn{}; +inline constexpr auto all_of = __all_of{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_any_of.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_any_of.h index 205fcecc08..34d23b4b74 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_any_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_any_of.h @@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __any_of { -struct __fn { +struct __any_of { template <class _Iter, class _Sent, class _Proj, class _Pred> _LIBCPP_HIDE_FROM_ABI constexpr static bool __any_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { for (; __first != __last; ++__first) { @@ -58,10 +57,9 @@ struct __fn { return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __any_of inline namespace __cpo { -inline constexpr auto any_of = __any_of::__fn{}; +inline constexpr auto any_of = __any_of{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_binary_search.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_binary_search.h index 1ef2bd62b5..47bd099733 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_binary_search.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_binary_search.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __binary_search { -struct __fn { +struct __binary_search { template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, @@ -57,10 +56,9 @@ struct __fn { return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__ret)); } }; -} // namespace __binary_search inline namespace __cpo { -inline constexpr auto binary_search = __binary_search::__fn{}; +inline constexpr auto binary_search = __binary_search{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_clamp.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_clamp.h index e6181ef943..4bb3e46e73 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_clamp.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_clamp.h @@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __clamp { -struct __fn { +struct __clamp { template <class _Type, class _Proj = identity, indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> @@ -50,10 +49,9 @@ struct __fn { return __value; } }; -} // namespace __clamp inline namespace __cpo { -inline constexpr auto clamp = __clamp::__fn{}; +inline constexpr auto clamp = __clamp{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_contains.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_contains.h index 4836c3baed..88de215297 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_contains.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_contains.h @@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __contains { -struct __fn { +struct __contains { template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static @@ -50,10 +49,9 @@ struct __fn { ranges::end(__range); } }; -} // namespace __contains inline namespace __cpo { -inline constexpr auto contains = __contains::__fn{}; +inline constexpr auto contains = __contains{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_contains_subrange.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_contains_subrange.h index 4398c457fd..e8740d69db 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_contains_subrange.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_contains_subrange.h @@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __contains_subrange { -struct __fn { +struct __contains_subrange { template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1, forward_iterator _Iter2, @@ -81,10 +80,9 @@ struct __fn { return __ret.empty() == false; } }; -} // namespace __contains_subrange inline namespace __cpo { -inline constexpr auto contains_subrange = __contains_subrange::__fn{}; +inline constexpr auto contains_subrange = __contains_subrange{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy.h index e1d6d32f05..05b61c0d5d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy.h @@ -37,8 +37,7 @@ namespace ranges { template <class _InIter, class _OutIter> using copy_result = in_out_result<_InIter, _OutIter>; -namespace __copy { -struct __fn { +struct __copy { template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> requires indirectly_copyable<_InIter, _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr copy_result<_InIter, _OutIter> @@ -55,10 +54,9 @@ struct __fn { return {std::move(__ret.first), std::move(__ret.second)}; } }; -} // namespace __copy inline namespace __cpo { -inline constexpr auto copy = __copy::__fn{}; +inline constexpr auto copy = __copy{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_backward.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_backward.h index 93e3260425..81d14e465f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_backward.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_backward.h @@ -35,8 +35,7 @@ namespace ranges { template <class _Ip, class _Op> using copy_backward_result = in_out_result<_Ip, _Op>; -namespace __copy_backward { -struct __fn { +struct __copy_backward { template <bidirectional_iterator _InIter1, sentinel_for<_InIter1> _Sent1, bidirectional_iterator _InIter2> requires indirectly_copyable<_InIter1, _InIter2> _LIBCPP_HIDE_FROM_ABI constexpr copy_backward_result<_InIter1, _InIter2> @@ -53,10 +52,9 @@ struct __fn { return {std::move(__ret.first), std::move(__ret.second)}; } }; -} // namespace __copy_backward inline namespace __cpo { -inline constexpr auto copy_backward = __copy_backward::__fn{}; +inline constexpr auto copy_backward = __copy_backward{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_if.h index 4b41d2154e..1a08985fe3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_if.h @@ -36,8 +36,7 @@ namespace ranges { template <class _Ip, class _Op> using copy_if_result = in_out_result<_Ip, _Op>; -namespace __copy_if { -struct __fn { +struct __copy_if { template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred> _LIBCPP_HIDE_FROM_ABI static constexpr copy_if_result<_InIter, _OutIter> __copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) { @@ -71,10 +70,9 @@ struct __fn { return __copy_if_impl(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj); } }; -} // namespace __copy_if inline namespace __cpo { -inline constexpr auto copy_if = __copy_if::__fn{}; +inline constexpr auto copy_if = __copy_if{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_n.h index 4353fa9927..4407e07f5c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_n.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_n.h @@ -37,8 +37,7 @@ namespace ranges { template <class _Ip, class _Op> using copy_n_result = in_out_result<_Ip, _Op>; -namespace __copy_n { -struct __fn { +struct __copy_n { template <class _InIter, class _DiffType, class _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) { @@ -65,10 +64,9 @@ struct __fn { return __go(std::move(__first), __n, std::move(__result)); } }; -} // namespace __copy_n inline namespace __cpo { -inline constexpr auto copy_n = __copy_n::__fn{}; +inline constexpr auto copy_n = __copy_n{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count.h index 4f35117438..2b3969e763 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count.h @@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __count { -struct __fn { +struct __count { template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> @@ -50,10 +49,9 @@ struct __fn { return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj); } }; -} // namespace __count inline namespace __cpo { -inline constexpr auto count = __count::__fn{}; +inline constexpr auto count = __count{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count_if.h index 5f2396ff7d..2663180242 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count_if.h @@ -44,8 +44,7 @@ __count_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { return __counter; } -namespace __count_if { -struct __fn { +struct __count_if { template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, @@ -63,10 +62,9 @@ struct __fn { return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); } }; -} // namespace __count_if inline namespace __cpo { -inline constexpr auto count_if = __count_if::__fn{}; +inline constexpr auto count_if = __count_if{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_ends_with.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_ends_with.h index 06efdef36b..3621bda389 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_ends_with.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_ends_with.h @@ -22,6 +22,7 @@ #include <__iterator/reverse_iterator.h> #include <__ranges/access.h> #include <__ranges/concepts.h> +#include <__ranges/size.h> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -36,8 +37,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __ends_with { -struct __fn { +struct __ends_with { template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> _LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl_bidirectional( _Iter1 __first1, @@ -185,10 +185,9 @@ struct __fn { } } }; -} // namespace __ends_with inline namespace __cpo { -inline constexpr auto ends_with = __ends_with::__fn{}; +inline constexpr auto ends_with = __ends_with{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_equal.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_equal.h index edbd0e3641..c26d13f002 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_equal.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_equal.h @@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __equal { -struct __fn { +struct __equal { template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1, input_iterator _Iter2, @@ -93,10 +92,9 @@ struct __fn { return false; } }; -} // namespace __equal inline namespace __cpo { -inline constexpr auto equal = __equal::__fn{}; +inline constexpr auto equal = __equal{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_equal_range.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_equal_range.h index 4a308e016b..cc765f1966 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_equal_range.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_equal_range.h @@ -38,9 +38,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __equal_range { - -struct __fn { +struct __equal_range { template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Tp, @@ -64,10 +62,8 @@ struct __fn { } }; -} // namespace __equal_range - inline namespace __cpo { -inline constexpr auto equal_range = __equal_range::__fn{}; +inline constexpr auto equal_range = __equal_range{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_fill.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_fill.h index 7a177d85e9..c248009f98 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_fill.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_fill.h @@ -28,8 +28,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __fill { -struct __fn { +struct __fill { template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent> _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const { if constexpr (random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) { @@ -46,10 +45,9 @@ struct __fn { return (*this)(ranges::begin(__range), ranges::end(__range), __value); } }; -} // namespace __fill inline namespace __cpo { -inline constexpr auto fill = __fill::__fn{}; +inline constexpr auto fill = __fill{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_fill_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_fill_n.h index a6e988c008..7a33268e1d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_fill_n.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_fill_n.h @@ -25,8 +25,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __fill_n { -struct __fn { +struct __fill_n { template <class _Type, output_iterator<const _Type&> _Iter> _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, iter_difference_t<_Iter> __n, const _Type& __value) const { @@ -37,10 +36,9 @@ struct __fn { return __first; } }; -} // namespace __fill_n inline namespace __cpo { -inline constexpr auto fill_n = __fill_n::__fn{}; +inline constexpr auto fill_n = __fill_n{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h index 6b0d5efe37..1eac4cfa02 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h @@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __find { -struct __fn { +struct __find { template <class _Iter, class _Sent, class _Tp, class _Proj> _LIBCPP_HIDE_FROM_ABI static constexpr _Iter __find_unwrap(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { @@ -64,10 +63,9 @@ struct __fn { return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj); } }; -} // namespace __find inline namespace __cpo { -inline constexpr auto find = __find::__fn{}; +inline constexpr auto find = __find{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_end.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_end.h index e49e66dd4a..682724a48c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_end.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_end.h @@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __find_end { -struct __fn { +struct __find_end { template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1, forward_iterator _Iter2, @@ -87,10 +86,9 @@ struct __fn { return {__ret.first, __ret.second}; } }; -} // namespace __find_end inline namespace __cpo { -inline constexpr auto find_end = __find_end::__fn{}; +inline constexpr auto find_end = __find_end{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_first_of.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_first_of.h index d92d9686bc..102e16dd7a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_first_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_first_of.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __find_first_of { -struct __fn { +struct __find_first_of { template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter1 __find_first_of_impl( _Iter1 __first1, @@ -90,10 +89,9 @@ struct __fn { __proj2); } }; -} // namespace __find_first_of inline namespace __cpo { -inline constexpr auto find_first_of = __find_first_of::__fn{}; +inline constexpr auto find_first_of = __find_first_of{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_if.h index 888f9ec3cb..ed6406e618 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_if.h @@ -42,8 +42,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ip __find_if_impl(_Ip __first, _Sp __last, _Pre return __first; } -namespace __find_if { -struct __fn { +struct __find_if { template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity, @@ -59,10 +58,9 @@ struct __fn { return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); } }; -} // namespace __find_if inline namespace __cpo { -inline constexpr auto find_if = __find_if::__fn{}; +inline constexpr auto find_if = __find_if{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_if_not.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_if_not.h index ec19545b5a..9a359b2afd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_if_not.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_if_not.h @@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __find_if_not { -struct __fn { +struct __find_if_not { template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity, @@ -53,10 +52,9 @@ struct __fn { return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj); } }; -} // namespace __find_if_not inline namespace __cpo { -inline constexpr auto find_if_not = __find_if_not::__fn{}; +inline constexpr auto find_if_not = __find_if_not{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_last.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_last.h new file mode 100644 index 0000000000..e7dae1704c --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find_last.h @@ -0,0 +1,170 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_LAST_H +#define _LIBCPP___ALGORITHM_RANGES_FIND_LAST_H + +#include <__config> +#include <__functional/identity.h> +#include <__functional/invoke.h> +#include <__functional/ranges_operations.h> +#include <__iterator/concepts.h> +#include <__iterator/indirectly_comparable.h> +#include <__iterator/next.h> +#include <__iterator/prev.h> +#include <__iterator/projected.h> +#include <__ranges/access.h> +#include <__ranges/concepts.h> +#include <__ranges/subrange.h> +#include <__utility/forward.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +#if _LIBCPP_STD_VER >= 23 + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace ranges { + +template <class _Iter, class _Sent, class _Pred, class _Proj> +_LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> +__find_last_impl(_Iter __first, _Sent __last, _Pred __pred, _Proj& __proj) { + if (__first == __last) { + return subrange<_Iter>(__first, __first); + } + + if constexpr (bidirectional_iterator<_Iter>) { + auto __last_it = ranges::next(__first, __last); + for (auto __it = ranges::prev(__last_it); __it != __first; --__it) { + if (__pred(std::invoke(__proj, *__it))) { + return subrange<_Iter>(std::move(__it), std::move(__last_it)); + } + } + if (__pred(std::invoke(__proj, *__first))) { + return subrange<_Iter>(std::move(__first), std::move(__last_it)); + } + return subrange<_Iter>(__last_it, __last_it); + } else { + bool __found = false; + _Iter __found_it; + for (; __first != __last; ++__first) { + if (__pred(std::invoke(__proj, *__first))) { + __found = true; + __found_it = __first; + } + } + + if (__found) { + return subrange<_Iter>(std::move(__found_it), std::move(__first)); + } else { + return subrange<_Iter>(__first, __first); + } + } +} + +struct __find_last { + template <class _Type> + struct __op { + const _Type& __value; + template <class _Elem> + _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Elem&& __elem) const { + return std::forward<_Elem>(__elem) == __value; + } + }; + + template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> + requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter> + operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) { + return ranges::__find_last_impl(std::move(__first), std::move(__last), __op<_Type>{__value}, __proj); + } + + template <forward_range _Range, class _Type, class _Proj = identity> + requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static borrowed_subrange_t<_Range> + operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) { + return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Type>{__value}, __proj); + } +}; + +struct __find_last_if { + template <class _Pred> + struct __op { + _Pred& __pred; + template <class _Elem> + _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Elem&& __elem) const { + return std::invoke(__pred, std::forward<_Elem>(__elem)); + } + }; + + template <forward_iterator _Iter, + sentinel_for<_Iter> _Sent, + class _Proj = identity, + indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter> + operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) { + return ranges::__find_last_impl(std::move(__first), std::move(__last), __op<_Pred>{__pred}, __proj); + } + + template <forward_range _Range, + class _Proj = identity, + indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static borrowed_subrange_t<_Range> + operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) { + return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj); + } +}; + +struct __find_last_if_not { + template <class _Pred> + struct __op { + _Pred& __pred; + template <class _Elem> + _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Elem&& __elem) const { + return !std::invoke(__pred, std::forward<_Elem>(__elem)); + } + }; + + template <forward_iterator _Iter, + sentinel_for<_Iter> _Sent, + class _Proj = identity, + indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter> + operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) { + return ranges::__find_last_impl(std::move(__first), std::move(__last), __op<_Pred>{__pred}, __proj); + } + + template <forward_range _Range, + class _Proj = identity, + indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static borrowed_subrange_t<_Range> + operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) { + return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj); + } +}; + +inline namespace __cpo { +inline constexpr auto find_last = __find_last{}; +inline constexpr auto find_last_if = __find_last_if{}; +inline constexpr auto find_last_if_not = __find_last_if_not{}; +} // namespace __cpo +} // namespace ranges + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER >= 23 + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_RANGES_FIND_LAST_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each.h index 225dc774c8..de39bc5522 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each.h @@ -36,8 +36,7 @@ namespace ranges { template <class _Iter, class _Func> using for_each_result = in_fun_result<_Iter, _Func>; -namespace __for_each { -struct __fn { +struct __for_each { private: template <class _Iter, class _Sent, class _Proj, class _Func> _LIBCPP_HIDE_FROM_ABI constexpr static for_each_result<_Iter, _Func> @@ -65,10 +64,9 @@ public: return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj); } }; -} // namespace __for_each inline namespace __cpo { -inline constexpr auto for_each = __for_each::__fn{}; +inline constexpr auto for_each = __for_each{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each_n.h index d1fdca34cc..603cb72323 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each_n.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each_n.h @@ -36,8 +36,7 @@ namespace ranges { template <class _Iter, class _Func> using for_each_n_result = in_fun_result<_Iter, _Func>; -namespace __for_each_n { -struct __fn { +struct __for_each_n { template <input_iterator _Iter, class _Proj = identity, indirectly_unary_invocable<projected<_Iter, _Proj>> _Func> _LIBCPP_HIDE_FROM_ABI constexpr for_each_n_result<_Iter, _Func> operator()(_Iter __first, iter_difference_t<_Iter> __count, _Func __func, _Proj __proj = {}) const { @@ -48,10 +47,9 @@ struct __fn { return {std::move(__first), std::move(__func)}; } }; -} // namespace __for_each_n inline namespace __cpo { -inline constexpr auto for_each_n = __for_each_n::__fn{}; +inline constexpr auto for_each_n = __for_each_n{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_generate.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_generate.h index e6467198e6..04333b358e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_generate.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_generate.h @@ -12,12 +12,12 @@ #include <__concepts/constructible.h> #include <__concepts/invocable.h> #include <__config> -#include <__functional/invoke.h> #include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> #include <__ranges/access.h> #include <__ranges/concepts.h> #include <__ranges/dangling.h> +#include <__type_traits/invoke.h> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -32,9 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __generate { - -struct __fn { +struct __generate { template <class _OutIter, class _Sent, class _Func> _LIBCPP_HIDE_FROM_ABI constexpr static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) { for (; __first != __last; ++__first) { @@ -57,10 +55,8 @@ struct __fn { } }; -} // namespace __generate - inline namespace __cpo { -inline constexpr auto generate = __generate::__fn{}; +inline constexpr auto generate = __generate{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_generate_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_generate_n.h index cd5fd7483a..a318994d0e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_generate_n.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_generate_n.h @@ -13,12 +13,12 @@ #include <__concepts/invocable.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> #include <__iterator/iterator_traits.h> #include <__ranges/access.h> #include <__ranges/concepts.h> +#include <__type_traits/invoke.h> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -33,9 +33,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __generate_n { - -struct __fn { +struct __generate_n { template <input_or_output_iterator _OutIter, copy_constructible _Func> requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>> _LIBCPP_HIDE_FROM_ABI constexpr _OutIter @@ -49,10 +47,8 @@ struct __fn { } }; -} // namespace __generate_n - inline namespace __cpo { -inline constexpr auto generate_n = __generate_n::__fn{}; +inline constexpr auto generate_n = __generate_n{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_includes.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_includes.h index c4c3b8ed08..9145f3b556 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_includes.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_includes.h @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __includes { - -struct __fn { +struct __includes { template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1, input_iterator _Iter2, @@ -82,10 +80,8 @@ struct __fn { } }; -} // namespace __includes - inline namespace __cpo { -inline constexpr auto includes = __includes::__fn{}; +inline constexpr auto includes = __includes{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_inplace_merge.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_inplace_merge.h index d94c0ad465..5879d0e7ef 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_inplace_merge.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_inplace_merge.h @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __inplace_merge { - -struct __fn { +struct __inplace_merge { template <class _Iter, class _Sent, class _Comp, class _Proj> _LIBCPP_HIDE_FROM_ABI static constexpr auto __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) { @@ -68,10 +66,8 @@ struct __fn { } }; -} // namespace __inplace_merge - inline namespace __cpo { -inline constexpr auto inplace_merge = __inplace_merge::__fn{}; +inline constexpr auto inplace_merge = __inplace_merge{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_heap.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_heap.h index 3d9e18ce1d..b4724abfb6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_heap.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_heap.h @@ -34,9 +34,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __is_heap { - -struct __fn { +struct __is_heap { template <class _Iter, class _Sent, class _Proj, class _Comp> _LIBCPP_HIDE_FROM_ABI constexpr static bool __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -65,10 +63,8 @@ struct __fn { } }; -} // namespace __is_heap - inline namespace __cpo { -inline constexpr auto is_heap = __is_heap::__fn{}; +inline constexpr auto is_heap = __is_heap{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_heap_until.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_heap_until.h index 7a2e1fc770..25f3b484fa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_heap_until.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_heap_until.h @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __is_heap_until { - -struct __fn { +struct __is_heap_until { template <class _Iter, class _Sent, class _Proj, class _Comp> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -65,10 +63,8 @@ struct __fn { } }; -} // namespace __is_heap_until - inline namespace __cpo { -inline constexpr auto is_heap_until = __is_heap_until::__fn{}; +inline constexpr auto is_heap_until = __is_heap_until{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_partitioned.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_partitioned.h index 5be6fba46f..8092abfcd1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_partitioned.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_partitioned.h @@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __is_partitioned { -struct __fn { +struct __is_partitioned { template <class _Iter, class _Sent, class _Proj, class _Pred> _LIBCPP_HIDE_FROM_ABI constexpr static bool __is_partitioned_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { @@ -70,10 +69,9 @@ struct __fn { return __is_partitioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __is_partitioned inline namespace __cpo { -inline constexpr auto is_partitioned = __is_partitioned::__fn{}; +inline constexpr auto is_partitioned = __is_partitioned{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_permutation.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_permutation.h index 1f8d67007a..53a431d2ba 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_permutation.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_permutation.h @@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __is_permutation { -struct __fn { +struct __is_permutation { template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Pred> _LIBCPP_HIDE_FROM_ABI constexpr static bool __is_permutation_func_impl( _Iter1 __first1, @@ -91,10 +90,9 @@ struct __fn { __proj2); } }; -} // namespace __is_permutation inline namespace __cpo { -inline constexpr auto is_permutation = __is_permutation::__fn{}; +inline constexpr auto is_permutation = __is_permutation{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_sorted.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_sorted.h index 5b88d422b4..ab0670688a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_sorted.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_sorted.h @@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __is_sorted { -struct __fn { +struct __is_sorted { template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, @@ -51,10 +50,9 @@ struct __fn { return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last; } }; -} // namespace __is_sorted inline namespace __cpo { -inline constexpr auto is_sorted = __is_sorted::__fn{}; +inline constexpr auto is_sorted = __is_sorted{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_sorted_until.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_sorted_until.h index 54de530c8b..f2e51c264e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_sorted_until.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_sorted_until.h @@ -47,8 +47,7 @@ __is_sorted_until_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj return __i; } -namespace __is_sorted_until { -struct __fn { +struct __is_sorted_until { template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, @@ -66,10 +65,9 @@ struct __fn { return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); } }; -} // namespace __is_sorted_until inline namespace __cpo { -inline constexpr auto is_sorted_until = __is_sorted_until::__fn{}; +inline constexpr auto is_sorted_until = __is_sorted_until{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_lexicographical_compare.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_lexicographical_compare.h index 6d82017e30..ec12b0cc29 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_lexicographical_compare.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_lexicographical_compare.h @@ -9,6 +9,8 @@ #ifndef _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H #define _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H +#include <__algorithm/lexicographical_compare.h> +#include <__algorithm/unwrap_range.h> #include <__config> #include <__functional/identity.h> #include <__functional/invoke.h> @@ -31,10 +33,9 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __lexicographical_compare { -struct __fn { +struct __lexicographical_compare { template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp> - _LIBCPP_HIDE_FROM_ABI constexpr static bool __lexicographical_compare_impl( + static _LIBCPP_HIDE_FROM_ABI constexpr bool __lexicographical_compare_unwrap( _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, @@ -42,15 +43,16 @@ struct __fn { _Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) { - while (__first2 != __last2) { - if (__first1 == __last1 || std::invoke(__comp, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2))) - return true; - if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) - return false; - ++__first1; - ++__first2; - } - return false; + auto [__first1_un, __last1_un] = std::__unwrap_range(std::move(__first1), std::move(__last1)); + auto [__first2_un, __last2_un] = std::__unwrap_range(std::move(__first2), std::move(__last2)); + return std::__lexicographical_compare( + std::move(__first1_un), + std::move(__last1_un), + std::move(__first2_un), + std::move(__last2_un), + __comp, + __proj1, + __proj2); } template <input_iterator _Iter1, @@ -68,7 +70,7 @@ struct __fn { _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { - return __lexicographical_compare_impl( + return __lexicographical_compare_unwrap( std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __comp, __proj1, __proj2); } @@ -80,7 +82,7 @@ struct __fn { _Comp = ranges::less> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { - return __lexicographical_compare_impl( + return __lexicographical_compare_unwrap( ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), @@ -90,10 +92,9 @@ struct __fn { __proj2); } }; -} // namespace __lexicographical_compare inline namespace __cpo { -inline constexpr auto lexicographical_compare = __lexicographical_compare::__fn{}; +inline constexpr auto lexicographical_compare = __lexicographical_compare{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_lower_bound.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_lower_bound.h index 0651147e04..d1b332849b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_lower_bound.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_lower_bound.h @@ -36,8 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __lower_bound { -struct __fn { +struct __lower_bound { template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, @@ -57,10 +56,9 @@ struct __fn { return std::__lower_bound<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj); } }; -} // namespace __lower_bound inline namespace __cpo { -inline constexpr auto lower_bound = __lower_bound::__fn{}; +inline constexpr auto lower_bound = __lower_bound{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_make_heap.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_make_heap.h index fe9c024fbf..97148f77b4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_make_heap.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_make_heap.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __make_heap { - -struct __fn { +struct __make_heap { template <class _Iter, class _Sent, class _Comp, class _Proj> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __make_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -69,10 +67,8 @@ struct __fn { } }; -} // namespace __make_heap - inline namespace __cpo { -inline constexpr auto make_heap = __make_heap::__fn{}; +inline constexpr auto make_heap = __make_heap{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_max.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_max.h index d0ee6f314b..f631344422 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_max.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_max.h @@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __max { -struct __fn { +struct __max { template <class _Tp, class _Proj = identity, indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> @@ -87,10 +86,9 @@ struct __fn { } } }; -} // namespace __max inline namespace __cpo { -inline constexpr auto max = __max::__fn{}; +inline constexpr auto max = __max{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_max_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_max_element.h index c577309271..869f71ecc8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_max_element.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_max_element.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __max_element { -struct __fn { +struct __max_element { template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity, @@ -53,10 +52,9 @@ struct __fn { return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj); } }; -} // namespace __max_element inline namespace __cpo { -inline constexpr auto max_element = __max_element::__fn{}; +inline constexpr auto max_element = __max_element{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_merge.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_merge.h index bdf9a62d90..f3e0486fe4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_merge.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_merge.h @@ -39,42 +39,7 @@ namespace ranges { template <class _InIter1, class _InIter2, class _OutIter> using merge_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; -namespace __merge { - -template < class _InIter1, - class _Sent1, - class _InIter2, - class _Sent2, - class _OutIter, - class _Comp, - class _Proj1, - class _Proj2> -_LIBCPP_HIDE_FROM_ABI constexpr merge_result<__remove_cvref_t<_InIter1>, - __remove_cvref_t<_InIter2>, - __remove_cvref_t<_OutIter>> -__merge_impl(_InIter1&& __first1, - _Sent1&& __last1, - _InIter2&& __first2, - _Sent2&& __last2, - _OutIter&& __result, - _Comp&& __comp, - _Proj1&& __proj1, - _Proj2&& __proj2) { - for (; __first1 != __last1 && __first2 != __last2; ++__result) { - if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) { - *__result = *__first2; - ++__first2; - } else { - *__result = *__first1; - ++__first1; - } - } - auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result)); - auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out)); - return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)}; -} - -struct __fn { +struct __merge { template <input_iterator _InIter1, sentinel_for<_InIter1> _Sent1, input_iterator _InIter2, @@ -120,12 +85,43 @@ struct __fn { __proj1, __proj2); } -}; -} // namespace __merge + template < class _InIter1, + class _Sent1, + class _InIter2, + class _Sent2, + class _OutIter, + class _Comp, + class _Proj1, + class _Proj2> + _LIBCPP_HIDE_FROM_ABI static constexpr merge_result<__remove_cvref_t<_InIter1>, + __remove_cvref_t<_InIter2>, + __remove_cvref_t<_OutIter>> + __merge_impl(_InIter1&& __first1, + _Sent1&& __last1, + _InIter2&& __first2, + _Sent2&& __last2, + _OutIter&& __result, + _Comp&& __comp, + _Proj1&& __proj1, + _Proj2&& __proj2) { + for (; __first1 != __last1 && __first2 != __last2; ++__result) { + if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) { + *__result = *__first2; + ++__first2; + } else { + *__result = *__first1; + ++__first1; + } + } + auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result)); + auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out)); + return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)}; + } +}; inline namespace __cpo { -inline constexpr auto merge = __merge::__fn{}; +inline constexpr auto merge = __merge{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min.h index cc569d2a06..302b5d7975 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min.h @@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __min { -struct __fn { +struct __min { template <class _Tp, class _Proj = identity, indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> @@ -79,10 +78,9 @@ struct __fn { } } }; -} // namespace __min inline namespace __cpo { -inline constexpr auto min = __min::__fn{}; +inline constexpr auto min = __min{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min_element.h index 588ef258e2..fb92ae56bc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min_element.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min_element.h @@ -46,8 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ip __min_element_impl(_Ip __first, _Sp __last, return __first; } -namespace __min_element { -struct __fn { +struct __min_element { template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity, @@ -65,10 +64,9 @@ struct __fn { return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); } }; -} // namespace __min_element inline namespace __cpo { -inline constexpr auto min_element = __min_element::__fn{}; +inline constexpr auto min_element = __min_element{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h index 09cbefd91a..4f2b2bf263 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h @@ -24,6 +24,7 @@ #include <__ranges/access.h> #include <__ranges/concepts.h> #include <__type_traits/desugars_to.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_reference.h> #include <__type_traits/is_trivially_copyable.h> #include <__type_traits/remove_cvref.h> @@ -47,8 +48,7 @@ namespace ranges { template <class _T1> using minmax_result = min_max_result<_T1>; -namespace __minmax { -struct __fn { +struct __minmax { template <class _Type, class _Proj = identity, indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> @@ -89,7 +89,7 @@ struct __fn { // vectorize the code. if constexpr (contiguous_range<_Range> && is_integral_v<_ValueT> && __is_cheap_to_copy<_ValueT> & __is_identity<_Proj>::value && - __desugars_to_v<__less_tag, _Comp, _ValueT, _ValueT>) { + __desugars_to_v<__totally_ordered_less_tag, _Comp, _ValueT, _ValueT>) { minmax_result<_ValueT> __result = {__r[0], __r[0]}; for (auto __e : __r) { if (__e < __result.min) @@ -159,10 +159,9 @@ struct __fn { } } }; -} // namespace __minmax inline namespace __cpo { -inline constexpr auto minmax = __minmax::__fn{}; +inline constexpr auto minmax = __minmax{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax_element.h index 4bf6d2404e..e1a22dde09 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax_element.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax_element.h @@ -40,8 +40,7 @@ namespace ranges { template <class _T1> using minmax_element_result = min_max_result<_T1>; -namespace __minmax_element { -struct __fn { +struct __minmax_element { template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity, @@ -61,10 +60,9 @@ struct __fn { return {__ret.first, __ret.second}; } }; -} // namespace __minmax_element inline namespace __cpo { -inline constexpr auto minmax_element = __minmax_element::__fn{}; +inline constexpr auto minmax_element = __minmax_element{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_mismatch.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_mismatch.h index c4bf0022a9..b35747dfa4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_mismatch.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_mismatch.h @@ -39,8 +39,7 @@ namespace ranges { template <class _I1, class _I2> using mismatch_result = in_in_result<_I1, _I2>; -namespace __mismatch { -struct __fn { +struct __mismatch { template <class _I1, class _S1, class _I2, class _S2, class _Pred, class _Proj1, class _Proj2> static _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { @@ -84,10 +83,9 @@ struct __fn { ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), __pred, __proj1, __proj2); } }; -} // namespace __mismatch inline namespace __cpo { -constexpr inline auto mismatch = __mismatch::__fn{}; +constexpr inline auto mismatch = __mismatch{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move.h index be869f36c9..02bf7fd006 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move.h @@ -35,8 +35,7 @@ namespace ranges { template <class _InIter, class _OutIter> using move_result = in_out_result<_InIter, _OutIter>; -namespace __move { -struct __fn { +struct __move { template <class _InIter, class _Sent, class _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr static move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { @@ -58,10 +57,9 @@ struct __fn { return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result)); } }; -} // namespace __move inline namespace __cpo { -inline constexpr auto move = __move::__fn{}; +inline constexpr auto move = __move{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move_backward.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move_backward.h index 6d4071a33b..4737e6c975 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move_backward.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move_backward.h @@ -37,8 +37,7 @@ namespace ranges { template <class _InIter, class _OutIter> using move_backward_result = in_out_result<_InIter, _OutIter>; -namespace __move_backward { -struct __fn { +struct __move_backward { template <class _InIter, class _Sent, class _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr static move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) { @@ -60,10 +59,9 @@ struct __fn { return __move_backward_impl(ranges::begin(__range), ranges::end(__range), std::move(__result)); } }; -} // namespace __move_backward inline namespace __cpo { -inline constexpr auto move_backward = __move_backward::__fn{}; +inline constexpr auto move_backward = __move_backward{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_next_permutation.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_next_permutation.h index 18535e0a62..1b485423e8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_next_permutation.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_next_permutation.h @@ -40,9 +40,7 @@ namespace ranges { template <class _InIter> using next_permutation_result = in_found_result<_InIter>; -namespace __next_permutation { - -struct __fn { +struct __next_permutation { template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> requires sortable<_Iter, _Comp, _Proj> _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<_Iter> @@ -62,10 +60,8 @@ struct __fn { } }; -} // namespace __next_permutation - inline namespace __cpo { -constexpr inline auto next_permutation = __next_permutation::__fn{}; +constexpr inline auto next_permutation = __next_permutation{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_none_of.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_none_of.h index 7df3c1829f..a161282622 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_none_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_none_of.h @@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __none_of { -struct __fn { +struct __none_of { template <class _Iter, class _Sent, class _Proj, class _Pred> _LIBCPP_HIDE_FROM_ABI constexpr static bool __none_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { @@ -59,10 +58,9 @@ struct __fn { return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __none_of inline namespace __cpo { -inline constexpr auto none_of = __none_of::__fn{}; +inline constexpr auto none_of = __none_of{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_nth_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_nth_element.h index 90ade9efe1..e92c51e713 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_nth_element.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_nth_element.h @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __nth_element { - -struct __fn { +struct __nth_element { template <class _Iter, class _Sent, class _Comp, class _Proj> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -68,10 +66,8 @@ struct __fn { } }; -} // namespace __nth_element - inline namespace __cpo { -inline constexpr auto nth_element = __nth_element::__fn{}; +inline constexpr auto nth_element = __nth_element{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partial_sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partial_sort.h index c67247d2e0..fc8a1f7d93 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partial_sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partial_sort.h @@ -41,9 +41,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __partial_sort { - -struct __fn { +struct __partial_sort { template <class _Iter, class _Sent, class _Comp, class _Proj> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -66,10 +64,8 @@ struct __fn { } }; -} // namespace __partial_sort - inline namespace __cpo { -inline constexpr auto partial_sort = __partial_sort::__fn{}; +inline constexpr auto partial_sort = __partial_sort{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partial_sort_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partial_sort_copy.h index b3bdeb78fb..f221504a8c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partial_sort_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partial_sort_copy.h @@ -42,9 +42,7 @@ namespace ranges { template <class _InIter, class _OutIter> using partial_sort_copy_result = in_out_result<_InIter, _OutIter>; -namespace __partial_sort_copy { - -struct __fn { +struct __partial_sort_copy { template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1, random_access_iterator _Iter2, @@ -98,10 +96,8 @@ struct __fn { } }; -} // namespace __partial_sort_copy - inline namespace __cpo { -inline constexpr auto partial_sort_copy = __partial_sort_copy::__fn{}; +inline constexpr auto partial_sort_copy = __partial_sort_copy{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition.h index a67ac4c967..b9cc3c1893 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition.h @@ -24,6 +24,7 @@ #include <__ranges/access.h> #include <__ranges/concepts.h> #include <__ranges/subrange.h> +#include <__type_traits/remove_cvref.h> #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/pair.h> @@ -40,9 +41,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __partition { - -struct __fn { +struct __partition { template <class _Iter, class _Sent, class _Proj, class _Pred> _LIBCPP_HIDE_FROM_ABI static constexpr subrange<__remove_cvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) { @@ -72,10 +71,8 @@ struct __fn { } }; -} // namespace __partition - inline namespace __cpo { -inline constexpr auto partition = __partition::__fn{}; +inline constexpr auto partition = __partition{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition_copy.h index d60c865dd2..47878a4017 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition_copy.h @@ -38,9 +38,7 @@ namespace ranges { template <class _InIter, class _OutIter1, class _OutIter2> using partition_copy_result = in_out_out_result<_InIter, _OutIter1, _OutIter2>; -namespace __partition_copy { - -struct __fn { +struct __partition_copy { // TODO(ranges): delegate to the classic algorithm. template <class _InIter, class _Sent, class _OutIter1, class _OutIter2, class _Proj, class _Pred> _LIBCPP_HIDE_FROM_ABI constexpr static partition_copy_result<__remove_cvref_t<_InIter>, @@ -94,10 +92,8 @@ struct __fn { } }; -} // namespace __partition_copy - inline namespace __cpo { -inline constexpr auto partition_copy = __partition_copy::__fn{}; +inline constexpr auto partition_copy = __partition_copy{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition_point.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition_point.h index c5b11b5fed..324efbb86d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition_point.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_partition_point.h @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __partition_point { - -struct __fn { +struct __partition_point { // TODO(ranges): delegate to the classic algorithm. template <class _Iter, class _Sent, class _Proj, class _Pred> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter @@ -77,10 +75,8 @@ struct __fn { } }; -} // namespace __partition_point - inline namespace __cpo { -inline constexpr auto partition_point = __partition_point::__fn{}; +inline constexpr auto partition_point = __partition_point{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_pop_heap.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_pop_heap.h index 01f92c0f22..eccf54c094 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_pop_heap.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_pop_heap.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __pop_heap { - -struct __fn { +struct __pop_heap { template <class _Iter, class _Sent, class _Comp, class _Proj> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __pop_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -70,10 +68,8 @@ struct __fn { } }; -} // namespace __pop_heap - inline namespace __cpo { -inline constexpr auto pop_heap = __pop_heap::__fn{}; +inline constexpr auto pop_heap = __pop_heap{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_prev_permutation.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_prev_permutation.h index 225cee9b75..f2294b1cb0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_prev_permutation.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_prev_permutation.h @@ -40,9 +40,7 @@ namespace ranges { template <class _InIter> using prev_permutation_result = in_found_result<_InIter>; -namespace __prev_permutation { - -struct __fn { +struct __prev_permutation { template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> requires sortable<_Iter, _Comp, _Proj> _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<_Iter> @@ -62,10 +60,8 @@ struct __fn { } }; -} // namespace __prev_permutation - inline namespace __cpo { -constexpr inline auto prev_permutation = __prev_permutation::__fn{}; +constexpr inline auto prev_permutation = __prev_permutation{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_push_heap.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_push_heap.h index 9d187af38c..c5e0465bdc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_push_heap.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_push_heap.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __push_heap { - -struct __fn { +struct __push_heap { template <class _Iter, class _Sent, class _Comp, class _Proj> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -69,10 +67,8 @@ struct __fn { } }; -} // namespace __push_heap - inline namespace __cpo { -inline constexpr auto push_heap = __push_heap::__fn{}; +inline constexpr auto push_heap = __push_heap{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove.h index 17c3a2c5cd..6fbc49eba8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove.h @@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __remove { -struct __fn { +struct __remove { template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> @@ -52,10 +51,9 @@ struct __fn { return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __remove inline namespace __cpo { -inline constexpr auto remove = __remove::__fn{}; +inline constexpr auto remove = __remove{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_copy.h index 84529eceac..764c52ee16 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_copy.h @@ -38,9 +38,7 @@ namespace ranges { template <class _InIter, class _OutIter> using remove_copy_result = in_out_result<_InIter, _OutIter>; -namespace __remove_copy { - -struct __fn { +struct __remove_copy { template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, @@ -65,10 +63,8 @@ struct __fn { } }; -} // namespace __remove_copy - inline namespace __cpo { -inline constexpr auto remove_copy = __remove_copy::__fn{}; +inline constexpr auto remove_copy = __remove_copy{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_copy_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_copy_if.h index 56fe017533..87136ae825 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_copy_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_copy_if.h @@ -53,9 +53,7 @@ __remove_copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& _ return {std::move(__first), std::move(__result)}; } -namespace __remove_copy_if { - -struct __fn { +struct __remove_copy_if { template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, @@ -79,10 +77,8 @@ struct __fn { } }; -} // namespace __remove_copy_if - inline namespace __cpo { -inline constexpr auto remove_copy_if = __remove_copy_if::__fn{}; +inline constexpr auto remove_copy_if = __remove_copy_if{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_if.h index 0ea5d9a01b..384b3d41d0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_remove_if.h @@ -53,8 +53,7 @@ __remove_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { return {__new_end, __i}; } -namespace __remove_if { -struct __fn { +struct __remove_if { template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, @@ -73,10 +72,9 @@ struct __fn { return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } }; -} // namespace __remove_if inline namespace __cpo { -inline constexpr auto remove_if = __remove_if::__fn{}; +inline constexpr auto remove_if = __remove_if{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace.h index 2b88dc0329..15b1f38554 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __replace { -struct __fn { +struct __replace { template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type1, class _Type2, class _Proj = identity> requires indirectly_writable<_Iter, const _Type2&> && indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type1*> @@ -52,10 +51,9 @@ struct __fn { return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj); } }; -} // namespace __replace inline namespace __cpo { -inline constexpr auto replace = __replace::__fn{}; +inline constexpr auto replace = __replace{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_copy.h index 633f993e5c..7ab1c71543 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_copy.h @@ -38,9 +38,7 @@ namespace ranges { template <class _InIter, class _OutIter> using replace_copy_result = in_out_result<_InIter, _OutIter>; -namespace __replace_copy { - -struct __fn { +struct __replace_copy { template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _OldType, @@ -77,10 +75,8 @@ struct __fn { } }; -} // namespace __replace_copy - inline namespace __cpo { -inline constexpr auto replace_copy = __replace_copy::__fn{}; +inline constexpr auto replace_copy = __replace_copy{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_copy_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_copy_if.h index e065c3ac0a..852ec45eda 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_copy_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_copy_if.h @@ -52,9 +52,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> __repl return {std::move(__first), std::move(__result)}; } -namespace __replace_copy_if { - -struct __fn { +struct __replace_copy_if { template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type, @@ -82,10 +80,8 @@ struct __fn { } }; -} // namespace __replace_copy_if - inline namespace __cpo { -inline constexpr auto replace_copy_if = __replace_copy_if::__fn{}; +inline constexpr auto replace_copy_if = __replace_copy_if{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_if.h index 6445f42aea..baa566810b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_replace_if.h @@ -42,8 +42,7 @@ __replace_if_impl(_Iter __first, _Sent __last, _Pred& __pred, const _Type& __new return __first; } -namespace __replace_if { -struct __fn { +struct __replace_if { template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, @@ -65,10 +64,9 @@ struct __fn { return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj); } }; -} // namespace __replace_if inline namespace __cpo { -inline constexpr auto replace_if = __replace_if::__fn{}; +inline constexpr auto replace_if = __replace_if{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse.h index 9ec865995b..4e82118719 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse.h @@ -27,8 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __reverse { -struct __fn { +struct __reverse { template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent> requires permutable<_Iter> _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last) const { @@ -65,10 +64,9 @@ struct __fn { return (*this)(ranges::begin(__range), ranges::end(__range)); } }; -} // namespace __reverse inline namespace __cpo { -inline constexpr auto reverse = __reverse::__fn{}; +inline constexpr auto reverse = __reverse{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse_copy.h index 60043787a7..e5ca5cf652 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_reverse_copy.h @@ -37,8 +37,7 @@ namespace ranges { template <class _InIter, class _OutIter> using reverse_copy_result = in_out_result<_InIter, _OutIter>; -namespace __reverse_copy { -struct __fn { +struct __reverse_copy { template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> requires indirectly_copyable<_InIter, _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr reverse_copy_result<_InIter, _OutIter> @@ -54,10 +53,9 @@ struct __fn { return {ranges::next(ranges::begin(__range), ranges::end(__range)), std::move(__ret.out)}; } }; -} // namespace __reverse_copy inline namespace __cpo { -inline constexpr auto reverse_copy = __reverse_copy::__fn{}; +inline constexpr auto reverse_copy = __reverse_copy{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_rotate.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_rotate.h index 8d33a6f079..c1affc684a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_rotate.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_rotate.h @@ -33,9 +33,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __rotate { - -struct __fn { +struct __rotate { template <class _Iter, class _Sent> _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter> __rotate_fn_impl(_Iter __first, _Iter __middle, _Sent __last) { auto __ret = std::__rotate<_RangeAlgPolicy>(std::move(__first), std::move(__middle), std::move(__last)); @@ -55,10 +53,8 @@ struct __fn { } }; -} // namespace __rotate - inline namespace __cpo { -inline constexpr auto rotate = __rotate::__fn{}; +inline constexpr auto rotate = __rotate{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_rotate_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_rotate_copy.h index 26fe110b53..c0b4264a1b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_rotate_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_rotate_copy.h @@ -34,8 +34,7 @@ namespace ranges { template <class _InIter, class _OutIter> using rotate_copy_result = in_out_result<_InIter, _OutIter>; -namespace __rotate_copy { -struct __fn { +struct __rotate_copy { template <forward_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> requires indirectly_copyable<_InIter, _OutIter> _LIBCPP_HIDE_FROM_ABI constexpr rotate_copy_result<_InIter, _OutIter> @@ -52,10 +51,9 @@ struct __fn { return (*this)(ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__result)); } }; -} // namespace __rotate_copy inline namespace __cpo { -inline constexpr auto rotate_copy = __rotate_copy::__fn{}; +inline constexpr auto rotate_copy = __rotate_copy{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sample.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sample.h index e4f60a7b66..a3b2960815 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sample.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sample.h @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __sample { - -struct __fn { +struct __sample { template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Gen> requires(forward_iterator<_Iter> || random_access_iterator<_OutIter>) && indirectly_copyable<_Iter, _OutIter> && uniform_random_bit_generator<remove_reference_t<_Gen>> @@ -58,10 +56,8 @@ struct __fn { } }; -} // namespace __sample - inline namespace __cpo { -inline constexpr auto sample = __sample::__fn{}; +inline constexpr auto sample = __sample{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_search.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_search.h index 55294c6063..b711512039 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_search.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_search.h @@ -33,8 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __search { -struct __fn { +struct __search { template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_impl( _Iter1 __first1, @@ -120,10 +119,9 @@ struct __fn { __proj2); } }; -} // namespace __search inline namespace __cpo { -inline constexpr auto search = __search::__fn{}; +inline constexpr auto search = __search{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_search_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_search_n.h index 56e12755b9..81b568c096 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_search_n.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_search_n.h @@ -39,8 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __search_n { -struct __fn { +struct __search_n { template <class _Iter1, class _Sent1, class _SizeT, class _Type, class _Pred, class _Proj> _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_n_impl( _Iter1 __first, _Sent1 __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) { @@ -100,10 +99,9 @@ struct __fn { return __ranges_search_n_impl(ranges::begin(__range), ranges::end(__range), __count, __value, __pred, __proj); } }; -} // namespace __search_n inline namespace __cpo { -inline constexpr auto search_n = __search_n::__fn{}; +inline constexpr auto search_n = __search_n{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_difference.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_difference.h index 0841fb4ffd..aa36e358ef 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_difference.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_difference.h @@ -42,9 +42,7 @@ namespace ranges { template <class _InIter, class _OutIter> using set_difference_result = in_out_result<_InIter, _OutIter>; -namespace __set_difference { - -struct __fn { +struct __set_difference { template <input_iterator _InIter1, sentinel_for<_InIter1> _Sent1, input_iterator _InIter2, @@ -93,10 +91,8 @@ struct __fn { } }; -} // namespace __set_difference - inline namespace __cpo { -inline constexpr auto set_difference = __set_difference::__fn{}; +inline constexpr auto set_difference = __set_difference{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_intersection.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_intersection.h index 9427379745..068794cf1b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_intersection.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_intersection.h @@ -40,9 +40,7 @@ namespace ranges { template <class _InIter1, class _InIter2, class _OutIter> using set_intersection_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; -namespace __set_intersection { - -struct __fn { +struct __set_intersection { template <input_iterator _InIter1, sentinel_for<_InIter1> _Sent1, input_iterator _InIter2, @@ -98,10 +96,8 @@ struct __fn { } }; -} // namespace __set_intersection - inline namespace __cpo { -inline constexpr auto set_intersection = __set_intersection::__fn{}; +inline constexpr auto set_intersection = __set_intersection{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_symmetric_difference.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_symmetric_difference.h index 995eb0999d..e3b73c3eb1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_symmetric_difference.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_symmetric_difference.h @@ -40,9 +40,7 @@ namespace ranges { template <class _InIter1, class _InIter2, class _OutIter> using set_symmetric_difference_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; -namespace __set_symmetric_difference { - -struct __fn { +struct __set_symmetric_difference { template <input_iterator _InIter1, sentinel_for<_InIter1> _Sent1, input_iterator _InIter2, @@ -98,10 +96,8 @@ struct __fn { } }; -} // namespace __set_symmetric_difference - inline namespace __cpo { -inline constexpr auto set_symmetric_difference = __set_symmetric_difference::__fn{}; +inline constexpr auto set_symmetric_difference = __set_symmetric_difference{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_union.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_union.h index e870e390cc..f2e3ddb89d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_union.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_set_union.h @@ -43,9 +43,7 @@ namespace ranges { template <class _InIter1, class _InIter2, class _OutIter> using set_union_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; -namespace __set_union { - -struct __fn { +struct __set_union { template <input_iterator _InIter1, sentinel_for<_InIter1> _Sent1, input_iterator _InIter2, @@ -99,10 +97,8 @@ struct __fn { } }; -} // namespace __set_union - inline namespace __cpo { -inline constexpr auto set_union = __set_union::__fn{}; +inline constexpr auto set_union = __set_union{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_shuffle.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_shuffle.h index ab98ea22ca..87cb3685bb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_shuffle.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_shuffle.h @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __shuffle { - -struct __fn { +struct __shuffle { template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen> requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>> _LIBCPP_HIDE_FROM_ABI _Iter operator()(_Iter __first, _Sent __last, _Gen&& __gen) const { @@ -56,10 +54,8 @@ struct __fn { } }; -} // namespace __shuffle - inline namespace __cpo { -inline constexpr auto shuffle = __shuffle::__fn{}; +inline constexpr auto shuffle = __shuffle{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sort.h index 0296c146b3..2afad4c413 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sort.h @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __sort { - -struct __fn { +struct __sort { template <class _Iter, class _Sent, class _Comp, class _Proj> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -68,10 +66,8 @@ struct __fn { } }; -} // namespace __sort - inline namespace __cpo { -inline constexpr auto sort = __sort::__fn{}; +inline constexpr auto sort = __sort{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sort_heap.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sort_heap.h index bab30df170..d3e20874fa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sort_heap.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_sort_heap.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __sort_heap { - -struct __fn { +struct __sort_heap { template <class _Iter, class _Sent, class _Comp, class _Proj> _LIBCPP_HIDE_FROM_ABI constexpr static _Iter __sort_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { @@ -69,10 +67,8 @@ struct __fn { } }; -} // namespace __sort_heap - inline namespace __cpo { -inline constexpr auto sort_heap = __sort_heap::__fn{}; +inline constexpr auto sort_heap = __sort_heap{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_stable_partition.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_stable_partition.h index f34027ff77..cfc02e1e97 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_stable_partition.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_stable_partition.h @@ -42,9 +42,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __stable_partition { - -struct __fn { +struct __stable_partition { template <class _Iter, class _Sent, class _Proj, class _Pred> _LIBCPP_HIDE_FROM_ABI static subrange<__remove_cvref_t<_Iter>> __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) { @@ -76,10 +74,8 @@ struct __fn { } }; -} // namespace __stable_partition - inline namespace __cpo { -inline constexpr auto stable_partition = __stable_partition::__fn{}; +inline constexpr auto stable_partition = __stable_partition{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_stable_sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_stable_sort.h index 93909e253c..9c7df80ae9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_stable_sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_stable_sort.h @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __stable_sort { - -struct __fn { +struct __stable_sort { template <class _Iter, class _Sent, class _Comp, class _Proj> _LIBCPP_HIDE_FROM_ABI static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { auto __last_iter = ranges::next(__first, __last); @@ -66,10 +64,8 @@ struct __fn { } }; -} // namespace __stable_sort - inline namespace __cpo { -inline constexpr auto stable_sort = __stable_sort::__fn{}; +inline constexpr auto stable_sort = __stable_sort{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_starts_with.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_starts_with.h index 17084e4f24..ae145d5901 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_starts_with.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_starts_with.h @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __starts_with { -struct __fn { +struct __starts_with { template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1, input_iterator _Iter2, @@ -50,7 +49,7 @@ struct __fn { _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) { - return __mismatch::__fn::__go( + return __mismatch::__go( std::move(__first1), std::move(__last1), std::move(__first2), @@ -69,7 +68,7 @@ struct __fn { requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) { - return __mismatch::__fn::__go( + return __mismatch::__go( ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), @@ -80,9 +79,8 @@ struct __fn { .in2 == ranges::end(__range2); } }; -} // namespace __starts_with inline namespace __cpo { -inline constexpr auto starts_with = __starts_with::__fn{}; +inline constexpr auto starts_with = __starts_with{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_swap_ranges.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_swap_ranges.h index b6d9f61839..ab6db50d8a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_swap_ranges.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_swap_ranges.h @@ -36,8 +36,7 @@ namespace ranges { template <class _I1, class _I2> using swap_ranges_result = in_in_result<_I1, _I2>; -namespace __swap_ranges { -struct __fn { +struct __swap_ranges { template <input_iterator _I1, sentinel_for<_I1> _S1, input_iterator _I2, sentinel_for<_I2> _S2> requires indirectly_swappable<_I1, _I2> _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2> @@ -54,10 +53,9 @@ struct __fn { return operator()(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2)); } }; -} // namespace __swap_ranges inline namespace __cpo { -inline constexpr auto swap_ranges = __swap_ranges::__fn{}; +inline constexpr auto swap_ranges = __swap_ranges{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_transform.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_transform.h index 7850ec4f84..0913118219 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_transform.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_transform.h @@ -41,8 +41,7 @@ using unary_transform_result = in_out_result<_Ip, _Op>; template <class _I1, class _I2, class _O1> using binary_transform_result = in_in_out_result<_I1, _I2, _O1>; -namespace __transform { -struct __fn { +struct __transform { private: template <class _InIter, class _Sent, class _OutIter, class _Func, class _Proj> _LIBCPP_HIDE_FROM_ABI static constexpr unary_transform_result<_InIter, _OutIter> @@ -161,10 +160,9 @@ public: __projection2); } }; -} // namespace __transform inline namespace __cpo { -inline constexpr auto transform = __transform::__fn{}; +inline constexpr auto transform = __transform{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_unique.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_unique.h index 7a9b784321..a817359abd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_unique.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_unique.h @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __unique { - -struct __fn { +struct __unique { template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, @@ -66,10 +64,8 @@ struct __fn { } }; -} // namespace __unique - inline namespace __cpo { -inline constexpr auto unique = __unique::__fn{}; +inline constexpr auto unique = __unique{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_unique_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_unique_copy.h index 61133885ae..3b4a64e94c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_unique_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_unique_copy.h @@ -44,12 +44,10 @@ namespace ranges { template <class _InIter, class _OutIter> using unique_copy_result = in_out_result<_InIter, _OutIter>; -namespace __unique_copy { - template <class _InIter, class _OutIter> concept __can_reread_from_output = (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>); -struct __fn { +struct __unique_copy { template <class _InIter, class _OutIter> static consteval auto __get_algo_tag() { if constexpr (forward_iterator<_InIter>) { @@ -104,10 +102,8 @@ struct __fn { } }; -} // namespace __unique_copy - inline namespace __cpo { -inline constexpr auto unique_copy = __unique_copy::__fn{}; +inline constexpr auto unique_copy = __unique_copy{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_upper_bound.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_upper_bound.h index fa6fa7f70e..4b2835d4d5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_upper_bound.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_upper_bound.h @@ -30,8 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -namespace __upper_bound { -struct __fn { +struct __upper_bound { template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, @@ -60,10 +59,9 @@ struct __fn { ranges::begin(__r), ranges::end(__r), __value, __comp_lhs_rhs_swapped, __proj); } }; -} // namespace __upper_bound inline namespace __cpo { -inline constexpr auto upper_bound = __upper_bound::__fn{}; +inline constexpr auto upper_bound = __upper_bound{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/remove.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/remove.h index fd01c23cb6..b2d7023c5b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/remove.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/remove.h @@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _ForwardIterator, class _Tp> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { __first = std::find(__first, __last, __value); if (__first != __last) { diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/remove_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/remove_if.h index b14f3c0efa..56fd745569 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/remove_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/remove_if.h @@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _ForwardIterator, class _Predicate> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { __first = std::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred); if (__first != __last) { diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/search.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/search.h index b82ca78095..161fd39d86 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/search.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/search.h @@ -14,11 +14,11 @@ #include <__algorithm/iterator_operations.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/advance.h> #include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> #include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_callable.h> #include <__utility/pair.h> @@ -160,20 +160,20 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __searc } template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) { - static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, - "BinaryPredicate has to be callable"); + static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value, + "The comparator has to be callable"); auto __proj = __identity(); return std::__search_impl(__first1, __last1, __first2, __last2, __pred, __proj, __proj).first; } template <class _ForwardIterator1, class _ForwardIterator2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { return std::search(__first1, __last1, __first2, __last2, __equal_to()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/search_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/search_n.h index 771647d316..38474e1b23 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/search_n.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/search_n.h @@ -14,12 +14,13 @@ #include <__algorithm/iterator_operations.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/advance.h> #include <__iterator/concepts.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__ranges/concepts.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_callable.h> #include <__utility/convert_to_integral.h> #include <__utility/pair.h> @@ -136,16 +137,16 @@ __search_n_impl(_Iter1 __first, _Sent1 __last, _DiffT __count, const _Type& __va } template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n( +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n( _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value, _BinaryPredicate __pred) { static_assert( - __is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value, "BinaryPredicate has to be callable"); + __is_callable<_BinaryPredicate&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); auto __proj = __identity(); return std::__search_n_impl(__first, __last, std::__convert_to_integral(__count), __value, __pred, __proj).first; } template <class _ForwardIterator, class _Size, class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) { return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/set_difference.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/set_difference.h index f414bcecb5..6230b831ae 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/set_difference.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/set_difference.h @@ -15,7 +15,6 @@ #include <__algorithm/iterator_operations.h> #include <__config> #include <__functional/identity.h> -#include <__functional/invoke.h> #include <__iterator/iterator_traits.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/set_intersection.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/set_intersection.h index 73d888d1b0..6246e24b9c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/set_intersection.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/set_intersection.h @@ -12,10 +12,16 @@ #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/iterator_operations.h> +#include <__algorithm/lower_bound.h> #include <__config> +#include <__functional/identity.h> #include <__iterator/iterator_traits.h> #include <__iterator/next.h> +#include <__type_traits/is_same.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> #include <__utility/move.h> +#include <__utility/swap.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -38,10 +44,103 @@ struct __set_intersection_result { : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {} }; -template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter> +// Helper for __set_intersection() with one-sided binary search: populate result and advance input iterators if they +// are found to potentially contain the same value in two consecutive calls. This function is very intimately related to +// the way it is used and doesn't attempt to abstract that, it's not appropriate for general usage outside of its +// context. +template <class _InForwardIter1, class _InForwardIter2, class _OutIter> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_intersection_add_output_if_equal( + bool __may_be_equal, + _InForwardIter1& __first1, + _InForwardIter2& __first2, + _OutIter& __result, + bool& __prev_may_be_equal) { + if (__may_be_equal && __prev_may_be_equal) { + *__result = *__first1; + ++__result; + ++__first1; + ++__first2; + __prev_may_be_equal = false; + } else { + __prev_may_be_equal = __may_be_equal; + } +} + +// With forward iterators we can make multiple passes over the data, allowing the use of one-sided binary search to +// reduce best-case complexity to log(N). Understanding how we can use binary search and still respect complexity +// guarantees is _not_ straightforward: the guarantee is "at most 2*(N+M)-1 comparisons", and one-sided binary search +// will necessarily overshoot depending on the position of the needle in the haystack -- for instance, if we're +// searching for 3 in (1, 2, 3, 4), we'll check if 3<1, then 3<2, then 3<4, and, finally, 3<3, for a total of 4 +// comparisons, when linear search would have yielded 3. However, because we won't need to perform the intervening +// reciprocal comparisons (ie 1<3, 2<3, 4<3), that extra comparison doesn't run afoul of the guarantee. Additionally, +// this type of scenario can only happen for match distances of up to 5 elements, because 2*log2(8) is 6, and we'll +// still be worse-off at position 5 of an 8-element set. From then onwards these scenarios can't happen. TL;DR: we'll be +// 1 comparison worse-off compared to the classic linear-searching algorithm if matching position 3 of a set with 4 +// elements, or position 5 if the set has 7 or 8 elements, but we'll never exceed the complexity guarantees from the +// standard. +template <class _AlgPolicy, + class _Compare, + class _InForwardIter1, + class _Sent1, + class _InForwardIter2, + class _Sent2, + class _OutIter> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI +_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InForwardIter1, _InForwardIter2, _OutIter> __set_intersection( - _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { + _InForwardIter1 __first1, + _Sent1 __last1, + _InForwardIter2 __first2, + _Sent2 __last2, + _OutIter __result, + _Compare&& __comp, + std::forward_iterator_tag, + std::forward_iterator_tag) { + _LIBCPP_CONSTEXPR std::__identity __proj; + bool __prev_may_be_equal = false; + + while (__first2 != __last2) { + _InForwardIter1 __first1_next = + std::__lower_bound_onesided<_AlgPolicy>(__first1, __last1, *__first2, __comp, __proj); + std::swap(__first1_next, __first1); + // keeping in mind that a==b iff !(a<b) && !(b<a): + // if we can't advance __first1, that means !(*__first1 < *_first2), therefore __may_be_equal==true + std::__set_intersection_add_output_if_equal( + __first1 == __first1_next, __first1, __first2, __result, __prev_may_be_equal); + if (__first1 == __last1) + break; + + _InForwardIter2 __first2_next = + std::__lower_bound_onesided<_AlgPolicy>(__first2, __last2, *__first1, __comp, __proj); + std::swap(__first2_next, __first2); + std::__set_intersection_add_output_if_equal( + __first2 == __first2_next, __first1, __first2, __result, __prev_may_be_equal); + } + return __set_intersection_result<_InForwardIter1, _InForwardIter2, _OutIter>( + _IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)), + _IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)), + std::move(__result)); +} + +// input iterators are not suitable for multipass algorithms, so we stick to the classic single-pass version +template <class _AlgPolicy, + class _Compare, + class _InInputIter1, + class _Sent1, + class _InInputIter2, + class _Sent2, + class _OutIter> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI +_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InInputIter1, _InInputIter2, _OutIter> +__set_intersection( + _InInputIter1 __first1, + _Sent1 __last1, + _InInputIter2 __first2, + _Sent2 __last2, + _OutIter __result, + _Compare&& __comp, + std::input_iterator_tag, + std::input_iterator_tag) { while (__first1 != __last1 && __first2 != __last2) { if (__comp(*__first1, *__first2)) ++__first1; @@ -55,12 +154,28 @@ __set_intersection( } } - return __set_intersection_result<_InIter1, _InIter2, _OutIter>( + return __set_intersection_result<_InInputIter1, _InInputIter2, _OutIter>( _IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)), _IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)), std::move(__result)); } +template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI +_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter> +__set_intersection( + _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { + return std::__set_intersection<_AlgPolicy>( + std::move(__first1), + std::move(__last1), + std::move(__first2), + std::move(__last2), + std::move(__result), + std::forward<_Compare>(__comp), + typename std::_IterOps<_AlgPolicy>::template __iterator_category<_InIter1>(), + typename std::_IterOps<_AlgPolicy>::template __iterator_category<_InIter2>()); +} + template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_intersection( _InputIterator1 __first1, diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/simd_utils.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/simd_utils.h index 840400729e..fff3a086b1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/simd_utils.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/simd_utils.h @@ -110,19 +110,19 @@ using __simd_vector_underlying_type_t = decltype(std::__simd_vector_underlying_t // This isn't inlined without always_inline when loading chars. template <class _VecT, class _Iter> -_LIBCPP_NODISCARD _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT __load_vector(_Iter __iter) noexcept { +[[__nodiscard__]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT __load_vector(_Iter __iter) noexcept { return [=]<size_t... _Indices>(index_sequence<_Indices...>) _LIBCPP_ALWAYS_INLINE noexcept { return _VecT{__iter[_Indices]...}; }(make_index_sequence<__simd_vector_size_v<_VecT>>{}); } template <class _Tp, size_t _Np> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<_Tp, _Np> __vec) noexcept { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<_Tp, _Np> __vec) noexcept { return __builtin_reduce_and(__builtin_convertvector(__vec, __simd_vector<bool, _Np>)); } template <class _Tp, size_t _Np> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_Tp, _Np> __vec) noexcept { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_Tp, _Np> __vec) noexcept { using __mask_vec = __simd_vector<bool, _Np>; // This has MSan disabled du to https://github.com/llvm/llvm-project/issues/85876 @@ -151,7 +151,7 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_T } template <class _Tp, size_t _Np> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_not_set(__simd_vector<_Tp, _Np> __vec) noexcept { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_not_set(__simd_vector<_Tp, _Np> __vec) noexcept { return std::__find_first_set(~__vec); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h index 07b5814639..0b2137dee2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h @@ -28,8 +28,11 @@ #include <__iterator/iterator_traits.h> #include <__type_traits/conditional.h> #include <__type_traits/disjunction.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_arithmetic.h> #include <__type_traits/is_constant_evaluated.h> +#include <__type_traits/is_same.h> +#include <__type_traits/remove_cvref.h> #include <__utility/move.h> #include <__utility/pair.h> #include <climits> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_partition.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_partition.h index 8bb1eaf2d2..5df5e8eaf6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_partition.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_partition.h @@ -16,8 +16,9 @@ #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__memory/destruct_n.h> -#include <__memory/temporary_buffer.h> #include <__memory/unique_ptr.h> +#include <__memory/unique_temporary_buffer.h> +#include <__type_traits/remove_cvref.h> #include <__utility/move.h> #include <__utility/pair.h> #include <new> @@ -132,14 +133,12 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred // We now have a reduced range [__first, __last) // *__first is known to be false difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last); + __unique_temporary_buffer<value_type> __unique_buf; pair<value_type*, ptrdiff_t> __p(0, 0); - unique_ptr<value_type, __return_temporary_buffer> __h; if (__len >= __alloc_limit) { - // TODO: Remove the use of std::get_temporary_buffer - _LIBCPP_SUPPRESS_DEPRECATED_PUSH - __p = std::get_temporary_buffer<value_type>(__len); - _LIBCPP_SUPPRESS_DEPRECATED_POP - __h.reset(__p.first); + __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len); + __p.first = __unique_buf.get(); + __p.second = __unique_buf.get_deleter().__count_; } return std::__stable_partition_impl<_AlgPolicy, _Predicate&>( std::move(__first), std::move(__last), __pred, __len, __p, forward_iterator_tag()); @@ -272,14 +271,12 @@ _LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl( // *__last is known to be true // __len >= 2 difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last) + 1; + __unique_temporary_buffer<value_type> __unique_buf; pair<value_type*, ptrdiff_t> __p(0, 0); - unique_ptr<value_type, __return_temporary_buffer> __h; if (__len >= __alloc_limit) { - // TODO: Remove the use of std::get_temporary_buffer - _LIBCPP_SUPPRESS_DEPRECATED_PUSH - __p = std::get_temporary_buffer<value_type>(__len); - _LIBCPP_SUPPRESS_DEPRECATED_POP - __h.reset(__p.first); + __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len); + __p.first = __unique_buf.get(); + __p.second = __unique_buf.get_deleter().__count_; } return std::__stable_partition_impl<_AlgPolicy, _Predicate&>( std::move(__first), std::move(__last), __pred, __len, __p, bidirectional_iterator_tag()); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_sort.h index 726e7e16b3..ec556aad82 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_sort.h @@ -18,8 +18,8 @@ #include <__debug_utils/strict_weak_ordering_check.h> #include <__iterator/iterator_traits.h> #include <__memory/destruct_n.h> -#include <__memory/temporary_buffer.h> #include <__memory/unique_ptr.h> +#include <__memory/unique_temporary_buffer.h> #include <__type_traits/is_trivially_assignable.h> #include <__utility/move.h> #include <__utility/pair.h> @@ -241,14 +241,12 @@ __stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type; difference_type __len = __last - __first; + __unique_temporary_buffer<value_type> __unique_buf; pair<value_type*, ptrdiff_t> __buf(0, 0); - unique_ptr<value_type, __return_temporary_buffer> __h; if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value)) { - // TODO: Remove the use of std::get_temporary_buffer - _LIBCPP_SUPPRESS_DEPRECATED_PUSH - __buf = std::get_temporary_buffer<value_type>(__len); - _LIBCPP_SUPPRESS_DEPRECATED_POP - __h.reset(__buf.first); + __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len); + __buf.first = __unique_buf.get(); + __buf.second = __unique_buf.get_deleter().__count_; } std::__stable_sort<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __last, __comp, __len, __buf.first, __buf.second); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/three_way_comp_ref_type.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/three_way_comp_ref_type.h index 70c5818976..5702a1fee0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/three_way_comp_ref_type.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/three_way_comp_ref_type.h @@ -9,6 +9,7 @@ #ifndef _LIBCPP___ALGORITHM_THREE_WAY_COMP_REF_TYPE_H #define _LIBCPP___ALGORITHM_THREE_WAY_COMP_REF_TYPE_H +#include <__assert> #include <__compare/ordering.h> #include <__config> #include <__utility/declval.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h index aef0fbfb7c..bc7a8925e1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h @@ -10,7 +10,7 @@ #define _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H #include <__config> -#include <__functional/invoke.h> +#include <__type_traits/invoke.h> #include <__type_traits/remove_cvref.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/unique.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/unique.h index d597014596..1f0c4ffa82 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/unique.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/unique.h @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // unique template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter> __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { __first = std::__adjacent_find(__first, __last, __pred); if (__first != __last) { @@ -46,13 +46,13 @@ __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { } template <class _ForwardIterator, class _BinaryPredicate> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first; } template <class _ForwardIterator> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last) { return std::unique(__first, __last, __equal_to()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/upper_bound.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/upper_bound.h index c39dec2e89..d77286c9e5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/upper_bound.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/upper_bound.h @@ -18,6 +18,8 @@ #include <__iterator/advance.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> +#include <__type_traits/invoke.h> +#include <__type_traits/is_callable.h> #include <__type_traits/is_constructible.h> #include <__utility/move.h> @@ -48,15 +50,16 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp } template <class _ForwardIterator, class _Tp, class _Compare> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { + static_assert(__is_callable<_Compare&, const _Tp&, decltype(*__first)>::value, "The comparator has to be callable"); static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible"); return std::__upper_bound<_ClassicAlgPolicy>( std::move(__first), std::move(__last), __value, std::move(__comp), std::__identity()); } template <class _ForwardIterator, class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { return std::upper_bound(std::move(__first), std::move(__last), __value, __less<>()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__assert b/contrib/libs/cxxsupp/libcxx/include/__assert index 49769fb4d4..90eaa60235 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__assert +++ b/contrib/libs/cxxsupp/libcxx/include/__assert @@ -23,10 +23,10 @@ : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING( \ expression) " failed: " message "\n")) -// TODO: __builtin_assume can currently inhibit optimizations. Until this has been fixed and we can add -// assumptions without a clear optimization intent, disable that to avoid worsening the code generation. -// See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a discussion. -#if 0 && __has_builtin(__builtin_assume) +// WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear +// optimization intent. See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a +// discussion. +#if __has_builtin(__builtin_assume) # define _LIBCPP_ASSUME(expression) \ (_LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \ __builtin_assume(static_cast<bool>(expression)) _LIBCPP_DIAGNOSTIC_POP) @@ -44,18 +44,18 @@ # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) // Disabled checks. // On most modern platforms, dereferencing a null pointer does not lead to an actual memory access. -# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression) +# define _LIBCPP_ASSERT_NON_NULL(expression, message) ((void)0) // Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security // vulnerability. -# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression) +# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) ((void)0) +# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) ((void)0) +# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) ((void)0) +# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) ((void)0) +# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) ((void)0) +# define _LIBCPP_ASSERT_PEDANTIC(expression, message) ((void)0) +# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) ((void)0) +# define _LIBCPP_ASSERT_INTERNAL(expression, message) ((void)0) +# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) ((void)0) // Extensive hardening mode checks. @@ -73,8 +73,8 @@ # define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message) # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message) // Disabled checks. -# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) +# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) ((void)0) +# define _LIBCPP_ASSERT_INTERNAL(expression, message) ((void)0) // Debug hardening mode checks. @@ -99,18 +99,18 @@ #else // All checks disabled. -# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) -# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression) +# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) ((void)0) +# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) ((void)0) +# define _LIBCPP_ASSERT_NON_NULL(expression, message) ((void)0) +# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) ((void)0) +# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) ((void)0) +# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) ((void)0) +# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) ((void)0) +# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) ((void)0) +# define _LIBCPP_ASSERT_PEDANTIC(expression, message) ((void)0) +# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) ((void)0) +# define _LIBCPP_ASSERT_INTERNAL(expression, message) ((void)0) +# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) ((void)0) #endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST // clang-format on diff --git a/contrib/libs/cxxsupp/libcxx/include/__assertion_handler b/contrib/libs/cxxsupp/libcxx/include/__assertion_handler index 8bc0553c07..8f37b9089e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__assertion_handler +++ b/contrib/libs/cxxsupp/libcxx/include/__assertion_handler @@ -23,8 +23,18 @@ #else -// TODO(hardening): use `__builtin_verbose_trap(message)` once that becomes available. -# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap()) +# if __has_builtin(__builtin_verbose_trap) +// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream +// version before upstream Clang actually got the builtin. +// TODO: Remove once AppleClang supports the two-arguments version of the builtin. +# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 17000 +# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message) +# else +# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message) +# endif +# else +# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap()) +# endif #endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG diff --git a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic.h b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic.h index bd3f659c22..af6d12b5e4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic.h +++ b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic.h @@ -16,8 +16,10 @@ #include <__config> #include <__functional/operations.h> #include <__memory/addressof.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_floating_point.h> #include <__type_traits/is_function.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_same.h> #include <__type_traits/remove_const.h> #include <__type_traits/remove_pointer.h> @@ -429,6 +431,8 @@ _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit( return __o->compare_exchange_strong(*__e, __d, __s, __f); } +#if _LIBCPP_STD_VER >= 20 + // atomic_wait template <class _Tp> @@ -462,29 +466,27 @@ atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __ // atomic_notify_one template <class _Tp> -_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void -atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT { +_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT { __o->notify_one(); } template <class _Tp> -_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void -atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT { +_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT { __o->notify_one(); } // atomic_notify_all template <class _Tp> -_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void -atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT { +_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT { __o->notify_all(); } template <class _Tp> -_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void -atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT { +_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT { __o->notify_all(); } +#endif // _LIBCPP_STD_VER >= 20 + // atomic_fetch_add template <class _Tp> diff --git a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_base.h b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_base.h index 7e26434c9c..93f5c4cff0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_base.h +++ b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_base.h @@ -101,6 +101,7 @@ struct __atomic_base // false return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m); } +#if _LIBCPP_STD_VER >= 20 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT { std::__atomic_wait(*this, __v, __m); @@ -117,6 +118,7 @@ struct __atomic_base // false std::__atomic_notify_all(*this); } _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); } +#endif // _LIBCPP_STD_VER >= 20 #if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI constexpr __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {} diff --git a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_flag.h b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_flag.h index 00b157cdff..abebfc112c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_flag.h +++ b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_flag.h @@ -48,26 +48,24 @@ struct atomic_flag { __cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m); } - _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void - wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT { +#if _LIBCPP_STD_VER >= 20 + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const + volatile _NOEXCEPT { std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); } - _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); } - _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { - std::__atomic_notify_one(*this); - } - _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { std::__atomic_notify_one(*this); } + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); } _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { std::__atomic_notify_all(*this); } - _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { - std::__atomic_notify_all(*this); - } + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); } +#endif #if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI constexpr atomic_flag() _NOEXCEPT : __a_(false) {} @@ -144,45 +142,45 @@ inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_clear_explicit(atomic_flag* __o, m __o->clear(__m); } -inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void +#if _LIBCPP_STD_VER >= 20 +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT { __o->wait(__v); } -inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT { __o->wait(__v); } -inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_wait_explicit(const volatile atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { __o->wait(__v, __m); } -inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_wait_explicit(const atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { __o->wait(__v, __m); } -inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT { __o->notify_one(); } -inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void -atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT { +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT { __o->notify_one(); } -inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT { __o->notify_all(); } -inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void -atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT { +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT { __o->notify_all(); } +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_ref.h b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_ref.h index a63a95c4dd..301d42b172 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_ref.h +++ b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_ref.h @@ -20,6 +20,7 @@ #include <__assert> #include <__atomic/atomic_sync.h> #include <__atomic/check_memory_order.h> +#include <__atomic/memory_order.h> #include <__atomic/to_gcc_order.h> #include <__concepts/arithmetic.h> #include <__concepts/same_as.h> @@ -57,11 +58,6 @@ struct __get_aligner_instance { template <class _Tp> struct __atomic_ref_base { -protected: - _Tp* __ptr_; - - _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : __ptr_(std::addressof(__obj)) {} - private: _LIBCPP_HIDE_FROM_ABI static _Tp* __clear_padding(_Tp& __val) noexcept { _Tp* __ptr = std::addressof(__val); @@ -108,10 +104,14 @@ private: friend struct __atomic_waitable_traits<__atomic_ref_base<_Tp>>; + // require types that are 1, 2, 4, 8, or 16 bytes in length to be aligned to at least their size to be potentially + // used lock-free + static constexpr size_t __min_alignment = (sizeof(_Tp) & (sizeof(_Tp) - 1)) || (sizeof(_Tp) > 16) ? 0 : sizeof(_Tp); + public: using value_type = _Tp; - static constexpr size_t required_alignment = alignof(_Tp); + static constexpr size_t required_alignment = alignof(_Tp) > __min_alignment ? alignof(_Tp) : __min_alignment; // The __atomic_always_lock_free builtin takes into account the alignment of the pointer if provided, // so we create a fake pointer with a suitable alignment when querying it. Note that we are guaranteed @@ -218,6 +218,12 @@ public: } _LIBCPP_HIDE_FROM_ABI void notify_one() const noexcept { std::__atomic_notify_one(*this); } _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); } + +protected: + using _Aligned_Tp [[__gnu__::__aligned__(required_alignment)]] = _Tp; + _Aligned_Tp* __ptr_; + + _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : __ptr_(std::addressof(__obj)) {} }; template <class _Tp> diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit/bit_cast.h b/contrib/libs/cxxsupp/libcxx/include/__bit/bit_cast.h index cd04567381..735025065a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit/bit_cast.h +++ b/contrib/libs/cxxsupp/libcxx/include/__bit/bit_cast.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_CXX03_LANG template <class _ToType, class _FromType> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr _ToType __bit_cast(const _FromType& __from) noexcept { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr _ToType __bit_cast(const _FromType& __from) noexcept { return __builtin_bit_cast(_ToType, __from); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit/countl.h b/contrib/libs/cxxsupp/libcxx/include/__bit/countl.h index 998a0b44c1..bb09e8e5b5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit/countl.h +++ b/contrib/libs/cxxsupp/libcxx/include/__bit/countl.h @@ -27,15 +27,15 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned __x) _NOEXCEPT { return __builtin_clz(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long long __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit/countr.h b/contrib/libs/cxxsupp/libcxx/include/__bit/countr.h index 9e92021fba..2f7571133b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit/countr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__bit/countr.h @@ -26,20 +26,20 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned __x) _NOEXCEPT { return __builtin_ctz(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long __x) _NOEXCEPT { return __builtin_ctzl(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { return __builtin_ctzll(__x); } template <class _Tp> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT { #if __has_builtin(__builtin_ctzg) return __builtin_ctzg(__t, numeric_limits<_Tp>::digits); #else // __has_builtin(__builtin_ctzg) diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit/rotate.h b/contrib/libs/cxxsupp/libcxx/include/__bit/rotate.h index d848056c33..d79d98de29 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit/rotate.h +++ b/contrib/libs/cxxsupp/libcxx/include/__bit/rotate.h @@ -20,24 +20,37 @@ _LIBCPP_BEGIN_NAMESPACE_STD +// Writing two full functions for rotl and rotr makes it easier for the compiler +// to optimize the code. On x86 this function becomes the ROL instruction and +// the rotr function becomes the ROR instruction. template <class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __t, int __cnt) _NOEXCEPT { - static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type"); - const unsigned int __dig = numeric_limits<_Tp>::digits; - if ((__cnt % __dig) == 0) - return __t; +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT { + static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type"); + const int __n = numeric_limits<_Tp>::digits; + int __r = __s % __n; + + if (__r == 0) + return __x; - if (__cnt < 0) { - __cnt *= -1; - return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig))); // rotr with negative __cnt is similar to rotl - } + if (__r > 0) + return (__x << __r) | (__x >> (__n - __r)); - return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig))); + return (__x >> -__r) | (__x << (__n + __r)); } template <class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __t, int __cnt) _NOEXCEPT { - return std::__rotr(__t, -__cnt); +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT { + static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type"); + const int __n = numeric_limits<_Tp>::digits; + int __r = __s % __n; + + if (__r == 0) + return __x; + + if (__r > 0) + return (__x >> __r) | (__x << (__n - __r)); + + return (__x << -__r) | (__x >> (__n + __r)); } #if _LIBCPP_STD_VER >= 20 diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit_reference b/contrib/libs/cxxsupp/libcxx/include/__bit_reference index 606069d98b..22637d4397 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit_reference +++ b/contrib/libs/cxxsupp/libcxx/include/__bit_reference @@ -16,6 +16,7 @@ #include <__bit/countr.h> #include <__bit/invert_if.h> #include <__bit/popcount.h> +#include <__compare/ordering.h> #include <__config> #include <__fwd/bit_reference.h> #include <__iterator/iterator_traits.h> @@ -913,6 +914,7 @@ public: return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_; } +#if _LIBCPP_STD_VER <= 17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y) { return !(__x == __y); @@ -937,6 +939,18 @@ public: operator>=(const __bit_iterator& __x, const __bit_iterator& __y) { return !(__x < __y); } +#else // _LIBCPP_STD_VER <= 17 + _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering + operator<=>(const __bit_iterator& __x, const __bit_iterator& __y) { + if (__x.__seg_ < __y.__seg_) + return strong_ordering::less; + + if (__x.__seg_ == __y.__seg_) + return __x.__ctz_ <=> __y.__ctz_; + + return strong_ordering::greater; + } +#endif // _LIBCPP_STD_VER <= 17 private: _LIBCPP_HIDE_FROM_ABI diff --git a/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_integral.h b/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_integral.h index 0369f4dfb9..ccb5856df1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_integral.h +++ b/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_integral.h @@ -21,6 +21,7 @@ #include <__system_error/errc.h> #include <__type_traits/enable_if.h> #include <__type_traits/integral_constant.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_same.h> #include <__type_traits/make_32_64_or_128_bit.h> #include <__type_traits/make_unsigned.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/convert_to_tm.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/convert_to_tm.h index 881a497082..3a51019b80 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/convert_to_tm.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/convert_to_tm.h @@ -29,11 +29,13 @@ #include <__chrono/year_month.h> #include <__chrono/year_month_day.h> #include <__chrono/year_month_weekday.h> +#include <__chrono/zoned_time.h> #include <__concepts/same_as.h> #include <__config> #include <__format/format_error.h> #include <__memory/addressof.h> #include <__type_traits/is_convertible.h> +#include <__type_traits/is_specialization.h> #include <cstdint> #include <ctime> #include <limits> @@ -178,7 +180,13 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) { // Has no time information. } else if constexpr (same_as<_ChronoT, chrono::local_info>) { // Has no time information. -# endif +# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ + !defined(_LIBCPP_HAS_NO_LOCALIZATION) + } else if constexpr (__is_specialization_v<_ChronoT, chrono::zoned_time>) { + return std::__convert_to_tm<_Tm>( + chrono::sys_time<typename _ChronoT::duration>{__value.get_local_time().time_since_epoch()}); +# endif +# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) } else static_assert(sizeof(_ChronoT) == 0, "Add the missing type specialization"); diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/day.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/day.h index 7342084b08..f5b14689a7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/day.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/day.h @@ -11,8 +11,8 @@ #define _LIBCPP___CHRONO_DAY_H #include <__chrono/duration.h> +#include <__compare/ordering.h> #include <__config> -#include <compare> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/exception.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/exception.h index 266f8fac44..cc408d78a3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/exception.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/exception.h @@ -71,7 +71,7 @@ private: }; template <class _Duration> -_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time( +[[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time( [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) { # ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw nonexistent_local_time(__time, __info); @@ -115,7 +115,7 @@ private: }; template <class _Duration> -_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time( +[[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time( [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) { # ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw ambiguous_local_time(__time, __info); diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/formatter.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/formatter.h index e9b81c3de8..8389e2cbf9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/formatter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/formatter.h @@ -10,52 +10,59 @@ #ifndef _LIBCPP___CHRONO_FORMATTER_H #define _LIBCPP___CHRONO_FORMATTER_H -#include <__algorithm/ranges_copy.h> -#include <__chrono/calendar.h> -#include <__chrono/concepts.h> -#include <__chrono/convert_to_tm.h> -#include <__chrono/day.h> -#include <__chrono/duration.h> -#include <__chrono/file_clock.h> -#include <__chrono/hh_mm_ss.h> -#include <__chrono/local_info.h> -#include <__chrono/month.h> -#include <__chrono/month_weekday.h> -#include <__chrono/monthday.h> -#include <__chrono/ostream.h> -#include <__chrono/parser_std_format_spec.h> -#include <__chrono/statically_widen.h> -#include <__chrono/sys_info.h> -#include <__chrono/system_clock.h> -#include <__chrono/time_point.h> -#include <__chrono/weekday.h> -#include <__chrono/year.h> -#include <__chrono/year_month.h> -#include <__chrono/year_month_day.h> -#include <__chrono/year_month_weekday.h> -#include <__concepts/arithmetic.h> -#include <__concepts/same_as.h> #include <__config> -#include <__format/concepts.h> -#include <__format/format_error.h> -#include <__format/format_functions.h> -#include <__format/format_parse_context.h> -#include <__format/formatter.h> -#include <__format/parser_std_format_spec.h> -#include <__format/write_escaped.h> -#include <__memory/addressof.h> -#include <cmath> -#include <ctime> -#include <sstream> -#include <string_view> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif + +#ifndef _LIBCPP_HAS_NO_LOCALIZATION + +# include <__algorithm/ranges_copy.h> +# include <__chrono/calendar.h> +# include <__chrono/concepts.h> +# include <__chrono/convert_to_tm.h> +# include <__chrono/day.h> +# include <__chrono/duration.h> +# include <__chrono/file_clock.h> +# include <__chrono/hh_mm_ss.h> +# include <__chrono/local_info.h> +# include <__chrono/month.h> +# include <__chrono/month_weekday.h> +# include <__chrono/monthday.h> +# include <__chrono/ostream.h> +# include <__chrono/parser_std_format_spec.h> +# include <__chrono/statically_widen.h> +# include <__chrono/sys_info.h> +# include <__chrono/system_clock.h> +# include <__chrono/time_point.h> +# include <__chrono/weekday.h> +# include <__chrono/year.h> +# include <__chrono/year_month.h> +# include <__chrono/year_month_day.h> +# include <__chrono/year_month_weekday.h> +# include <__chrono/zoned_time.h> +# include <__concepts/arithmetic.h> +# include <__concepts/same_as.h> +# include <__format/concepts.h> +# include <__format/format_error.h> +# include <__format/format_functions.h> +# include <__format/format_parse_context.h> +# include <__format/formatter.h> +# include <__format/parser_std_format_spec.h> +# include <__format/write_escaped.h> +# include <__memory/addressof.h> +# include <__type_traits/is_specialization.h> +# include <cmath> +# include <ctime> +# include <limits> +# include <locale> +# include <sstream> +# include <string_view> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 namespace __formatter { @@ -136,10 +143,24 @@ __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss< __value.fractional_width); } +# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \ + !defined(_LIBCPP_HAS_NO_FILESYSTEM) +template <class _CharT, class _Duration, class _TimeZonePtr> +_LIBCPP_HIDE_FROM_ABI void +__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::zoned_time<_Duration, _TimeZonePtr>& __value) { + __formatter::__format_sub_seconds(__sstr, __value.get_local_time().time_since_epoch()); +} +# endif + template <class _Tp> consteval bool __use_fraction() { if constexpr (__is_time_point<_Tp>) return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width; +# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \ + !defined(_LIBCPP_HAS_NO_FILESYSTEM) + else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) + return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width; +# endif else if constexpr (chrono::__is_duration<_Tp>::value) return chrono::hh_mm_ss<_Tp>::fractional_width; else if constexpr (__is_hh_mm_ss<_Tp>) @@ -208,11 +229,15 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone { template <class _Tp> _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const _Tp& __value) { -# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) +# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) if constexpr (same_as<_Tp, chrono::sys_info>) return {__value.abbrev, __value.offset}; +# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) + else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) + return __formatter::__convert_to_time_zone(__value.get_info()); +# endif else -# endif +# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) return {"UTC", chrono::seconds{0}}; } @@ -319,12 +344,12 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( // // TODO FMT evaluate the comment above. -# if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32) +# if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32) case _CharT('y'): // Glibc fails for negative values, AIX for positive values too. __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), (std::abs(__t.tm_year + 1900)) % 100); break; -# endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32) +# endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32) case _CharT('Y'): // Depending on the platform's libc the range of supported years is @@ -420,12 +445,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) { return __value.weekday().ok(); else if constexpr (__is_hh_mm_ss<_Tp>) return true; -# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) +# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) else if constexpr (same_as<_Tp, chrono::sys_info>) return true; else if constexpr (same_as<_Tp, chrono::local_info>) return true; -# endif +# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) + else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) + return true; +# endif +# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) else static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); } @@ -466,12 +495,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) { return __value.weekday().ok(); else if constexpr (__is_hh_mm_ss<_Tp>) return true; -# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) +# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) else if constexpr (same_as<_Tp, chrono::sys_info>) return true; else if constexpr (same_as<_Tp, chrono::local_info>) return true; -# endif +# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) + else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) + return true; +# endif +# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) else static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); } @@ -512,12 +545,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) { return __value.ok(); else if constexpr (__is_hh_mm_ss<_Tp>) return true; -# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) +# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) else if constexpr (same_as<_Tp, chrono::sys_info>) return true; else if constexpr (same_as<_Tp, chrono::local_info>) return true; -# endif +# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) + else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) + return true; +# endif +# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) else static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); } @@ -558,12 +595,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) { return __value.month().ok(); else if constexpr (__is_hh_mm_ss<_Tp>) return true; -# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) +# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) else if constexpr (same_as<_Tp, chrono::sys_info>) return true; else if constexpr (same_as<_Tp, chrono::local_info>) return true; -# endif +# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) + else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) + return true; +# endif +# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) else static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); } @@ -589,9 +630,16 @@ __format_chrono(const _Tp& __value, __sstr << __value; else { if constexpr (chrono::__is_duration<_Tp>::value) { - if (__value < __value.zero()) - __sstr << _CharT('-'); - __formatter::__format_chrono_using_chrono_specs(__sstr, chrono::abs(__value), __chrono_specs); + // A duration can be a user defined arithmetic type. Users may specialize + // numeric_limits, but they may not specialize is_signed. + if constexpr (numeric_limits<typename _Tp::rep>::is_signed) { + if (__value < __value.zero()) { + __sstr << _CharT('-'); + __formatter::__format_chrono_using_chrono_specs(__sstr, -__value, __chrono_specs); + } else + __formatter::__format_chrono_using_chrono_specs(__sstr, __value, __chrono_specs); + } else + __formatter::__format_chrono_using_chrono_specs(__sstr, __value, __chrono_specs); // TODO FMT When keeping the precision it will truncate the string. // Note that the behaviour what the precision does isn't specified. __specs.__precision_ = -1; @@ -894,7 +942,7 @@ public: } }; -# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) +# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) template <__fmt_char_type _CharT> struct formatter<chrono::sys_info, _CharT> : public __formatter_chrono<_CharT> { public: @@ -916,10 +964,26 @@ public: return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags{}); } }; -# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) +# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) +// Note due to how libc++'s formatters are implemented there is no need to add +// the exposition only local-time-format-t abstraction. +template <class _Duration, class _TimeZonePtr, __fmt_char_type _CharT> +struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : public __formatter_chrono<_CharT> { +public: + using _Base = __formatter_chrono<_CharT>; + + template <class _ParseContext> + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock); + } +}; +# endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) +# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) -#endif // if _LIBCPP_STD_VER >= 20 +# endif // if _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD +#endif // !_LIBCPP_HAS_NO_LOCALIZATION + #endif // _LIBCPP___CHRONO_FORMATTER_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/leap_second.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/leap_second.h index 1a0e7f3107..b01d9fbca8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/leap_second.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/leap_second.h @@ -43,81 +43,86 @@ public: _LIBCPP_HIDE_FROM_ABI leap_second(const leap_second&) = default; _LIBCPP_HIDE_FROM_ABI leap_second& operator=(const leap_second&) = default; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; } private: sys_seconds __date_; seconds __value_; -}; -_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const leap_second& __x, const leap_second& __y) { - return __x.date() == __y.date(); -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const leap_second& __x, const leap_second& __y) { - return __x.date() <=> __y.date(); -} - -template <class _Duration> -_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const leap_second& __x, const sys_time<_Duration>& __y) { - return __x.date() == __y; -} - -template <class _Duration> -_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const leap_second& __x, const sys_time<_Duration>& __y) { - return __x.date() < __y; -} - -template <class _Duration> -_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const sys_time<_Duration>& __x, const leap_second& __y) { - return __x < __y.date(); -} - -template <class _Duration> -_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const leap_second& __x, const sys_time<_Duration>& __y) { - return __y < __x; -} - -template <class _Duration> -_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const sys_time<_Duration>& __x, const leap_second& __y) { - return __y < __x; -} - -template <class _Duration> -_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const leap_second& __x, const sys_time<_Duration>& __y) { - return !(__y < __x); -} - -template <class _Duration> -_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const sys_time<_Duration>& __x, const leap_second& __y) { - return !(__y < __x); -} - -template <class _Duration> -_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const leap_second& __x, const sys_time<_Duration>& __y) { - return !(__x < __y); -} - -template <class _Duration> -_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const sys_time<_Duration>& __x, const leap_second& __y) { - return !(__x < __y); -} - -# ifndef _LIBCPP_COMPILER_GCC -// This requirement cause a compilation loop in GCC-13 and running out of memory. -// TODO TZDB Test whether GCC-14 fixes this. -template <class _Duration> - requires three_way_comparable_with<sys_seconds, sys_time<_Duration>> -_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(const leap_second& __x, const sys_time<_Duration>& __y) { - return __x.date() <=> __y; -} -# endif + // The function + // template<class Duration> + // requires three_way_comparable_with<sys_seconds, sys_time<Duration>> + // constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept; + // + // Has constraints that are recursive (LWG4139). The proposed resolution is + // to make the funcion a hidden friend. For consistency make this change for + // all comparison functions. + + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const leap_second& __x, const leap_second& __y) { + return __x.date() == __y.date(); + } + + _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering operator<=>(const leap_second& __x, const leap_second& __y) { + return __x.date() <=> __y.date(); + } + + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const leap_second& __x, const sys_time<_Duration>& __y) { + return __x.date() == __y; + } + + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const leap_second& __x, const sys_time<_Duration>& __y) { + return __x.date() < __y; + } + + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const sys_time<_Duration>& __x, const leap_second& __y) { + return __x < __y.date(); + } + + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const leap_second& __x, const sys_time<_Duration>& __y) { + return __y < __x; + } + + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const sys_time<_Duration>& __x, const leap_second& __y) { + return __y < __x; + } + + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const leap_second& __x, const sys_time<_Duration>& __y) { + return !(__y < __x); + } + + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const sys_time<_Duration>& __x, const leap_second& __y) { + return !(__y < __x); + } + + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const leap_second& __x, const sys_time<_Duration>& __y) { + return !(__x < __y); + } + + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const sys_time<_Duration>& __x, const leap_second& __y) { + return !(__x < __y); + } + + template <class _Duration> + requires three_way_comparable_with<sys_seconds, sys_time<_Duration>> + _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const leap_second& __x, const sys_time<_Duration>& __y) { + return __x.date() <=> __y; + } +}; } // namespace chrono -# endif //_LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/month.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/month.h index ce5cc21aab..77c67d0954 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/month.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/month.h @@ -11,8 +11,8 @@ #define _LIBCPP___CHRONO_MONTH_H #include <__chrono/duration.h> +#include <__compare/ordering.h> #include <__config> -#include <compare> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/monthday.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/monthday.h index a89d16e518..57712cf0b6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/monthday.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/monthday.h @@ -13,8 +13,8 @@ #include <__chrono/calendar.h> #include <__chrono/day.h> #include <__chrono/month.h> +#include <__compare/ordering.h> #include <__config> -#include <compare> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/ostream.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/ostream.h index bb0341bc3e..3420fb12bc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/ostream.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/ostream.h @@ -10,36 +10,41 @@ #ifndef _LIBCPP___CHRONO_OSTREAM_H #define _LIBCPP___CHRONO_OSTREAM_H -#include <__chrono/calendar.h> -#include <__chrono/day.h> -#include <__chrono/duration.h> -#include <__chrono/file_clock.h> -#include <__chrono/hh_mm_ss.h> -#include <__chrono/local_info.h> -#include <__chrono/month.h> -#include <__chrono/month_weekday.h> -#include <__chrono/monthday.h> -#include <__chrono/statically_widen.h> -#include <__chrono/sys_info.h> -#include <__chrono/system_clock.h> -#include <__chrono/weekday.h> -#include <__chrono/year.h> -#include <__chrono/year_month.h> -#include <__chrono/year_month_day.h> -#include <__chrono/year_month_weekday.h> -#include <__concepts/same_as.h> #include <__config> -#include <__format/format_functions.h> -#include <__fwd/ostream.h> -#include <ratio> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#ifndef _LIBCPP_HAS_NO_LOCALIZATION + +# include <__chrono/calendar.h> +# include <__chrono/day.h> +# include <__chrono/duration.h> +# include <__chrono/file_clock.h> +# include <__chrono/hh_mm_ss.h> +# include <__chrono/local_info.h> +# include <__chrono/month.h> +# include <__chrono/month_weekday.h> +# include <__chrono/monthday.h> +# include <__chrono/statically_widen.h> +# include <__chrono/sys_info.h> +# include <__chrono/system_clock.h> +# include <__chrono/weekday.h> +# include <__chrono/year.h> +# include <__chrono/year_month.h> +# include <__chrono/year_month_day.h> +# include <__chrono/year_month_weekday.h> +# include <__chrono/zoned_time.h> +# include <__concepts/same_as.h> +# include <__format/format_functions.h> +# include <__fwd/ostream.h> +# include <ratio> +# include <sstream> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 namespace chrono { @@ -81,11 +86,11 @@ _LIBCPP_HIDE_FROM_ABI auto __units_suffix() { else if constexpr (same_as<typename _Period::type, nano>) return _LIBCPP_STATICALLY_WIDEN(_CharT, "ns"); else if constexpr (same_as<typename _Period::type, micro>) -# ifndef _LIBCPP_HAS_NO_UNICODE +# ifndef _LIBCPP_HAS_NO_UNICODE return _LIBCPP_STATICALLY_WIDEN(_CharT, "\u00b5s"); -# else +# else return _LIBCPP_STATICALLY_WIDEN(_CharT, "us"); -# endif +# endif else if constexpr (same_as<typename _Period::type, milli>) return _LIBCPP_STATICALLY_WIDEN(_CharT, "ms"); else if constexpr (same_as<typename _Period::type, centi>) @@ -264,7 +269,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const hh_mm_ss<_Duration> __hms return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%T}"), __hms); } -# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) +# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) template <class _CharT, class _Traits> _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& @@ -302,12 +307,21 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const local_info& __info) { _LIBCPP_STATICALLY_WIDEN(_CharT, "{}: {{{}, {}}}"), __result(), __info.first, __info.second); } -# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) +# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) +template <class _CharT, class _Traits, class _Duration, class _TimeZonePtr> +_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& +operator<<(basic_ostream<_CharT, _Traits>& __os, const zoned_time<_Duration, _TimeZonePtr>& __tp) { + return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T %Z}"), __tp); +} +# endif +# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) } // namespace chrono -#endif // if _LIBCPP_STD_VER >= 20 +# endif // if _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD +#endif // !_LIBCPP_HAS_NO_LOCALIZATION + #endif // _LIBCPP___CHRONO_OSTREAM_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/parser_std_format_spec.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/parser_std_format_spec.h index 785bbae198..c9cfcc6d57 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/parser_std_format_spec.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/parser_std_format_spec.h @@ -11,20 +11,23 @@ #define _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H #include <__config> -#include <__format/concepts.h> -#include <__format/format_error.h> -#include <__format/format_parse_context.h> -#include <__format/formatter_string.h> -#include <__format/parser_std_format_spec.h> -#include <string_view> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__format/concepts.h> +# include <__format/format_error.h> +# include <__format/format_parse_context.h> +# include <__format/formatter_string.h> +# include <__format/parser_std_format_spec.h> +# include <string_view> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 namespace __format_spec { @@ -409,8 +412,10 @@ private: } // namespace __format_spec -#endif //_LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD +#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + #endif // _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/statically_widen.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/statically_widen.h index a18c46f057..680483a59a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/statically_widen.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/statically_widen.h @@ -45,7 +45,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __s # define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str) # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/time_zone_link.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/time_zone_link.h index b2d365c5fd..7b15f6ae39 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/time_zone_link.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/time_zone_link.h @@ -68,7 +68,7 @@ operator<=>(const time_zone_link& __x, const time_zone_link& __y) noexcept { } // namespace chrono -# endif //_LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb.h index f731f8c318..dce97c3adf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb.h @@ -21,7 +21,10 @@ # include <__chrono/time_zone.h> # include <__chrono/time_zone_link.h> # include <__config> +# include <__memory/addressof.h> +# include <stdexcept> # include <string> +# include <string_view> # include <vector> # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb_list.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb_list.h index aeef4fe1ab..18446d9926 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb_list.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb_list.h @@ -21,6 +21,7 @@ # include <__config> # include <__fwd/string.h> # include <forward_list> +# include <string_view> # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/weekday.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/weekday.h index 5a7dedc6e3..86c780cc71 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/weekday.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/weekday.h @@ -79,6 +79,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const weekday& __lhs, con return __lhs.c_encoding() == __rhs.c_encoding(); } +// TODO(LLVM 20): Remove the escape hatch +# ifdef _LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<(const weekday& __lhs, const weekday& __rhs) noexcept { return __lhs.c_encoding() < __rhs.c_encoding(); } @@ -94,6 +96,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<=(const weekday& __lhs, con _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept { return !(__lhs < __rhs); } +# endif // _LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept { auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count(); diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/year.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/year.h index 1899d09f38..2ae5180cb8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/year.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/year.h @@ -11,8 +11,8 @@ #define _LIBCPP___CHRONO_YEAR_H #include <__chrono/duration.h> +#include <__compare/ordering.h> #include <__config> -#include <compare> #include <limits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/year_month.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/year_month.h index 369ea38f75..cf9234bdb4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/year_month.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/year_month.h @@ -13,8 +13,8 @@ #include <__chrono/duration.h> #include <__chrono/month.h> #include <__chrono/year.h> +#include <__compare/ordering.h> #include <__config> -#include <compare> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/year_month_day.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/year_month_day.h index 75884f3654..a0510a14f4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/year_month_day.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/year_month_day.h @@ -19,8 +19,8 @@ #include <__chrono/time_point.h> #include <__chrono/year.h> #include <__chrono/year_month.h> +#include <__compare/ordering.h> #include <__config> -#include <compare> #include <limits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -239,33 +239,11 @@ operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) n return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); } -_LIBCPP_HIDE_FROM_ABI inline constexpr bool -operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { - return !(__lhs == __rhs); -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr bool -operator<(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { - if (__lhs.year() < __rhs.year()) - return true; - if (__lhs.year() > __rhs.year()) - return false; - return __lhs.month_day_last() < __rhs.month_day_last(); -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr bool -operator>(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { - return __rhs < __lhs; -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr bool -operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { - return !(__rhs < __lhs); -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr bool -operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { - return !(__lhs < __rhs); +_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering +operator<=>(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept { + if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0) + return __c; + return __lhs.month_day_last() <=> __rhs.month_day_last(); } _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept { diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/zoned_time.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/zoned_time.h index c6084426ad..c7252cb003 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/zoned_time.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/zoned_time.h @@ -16,15 +16,28 @@ // Enable the contents of the header only when libc++ was built with experimental features enabled. #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) +# include <__chrono/calendar.h> +# include <__chrono/duration.h> +# include <__chrono/sys_info.h> +# include <__chrono/system_clock.h> # include <__chrono/time_zone.h> # include <__chrono/tzdb_list.h> +# include <__concepts/constructible.h> # include <__config> -# include <__fwd/string_view.h> +# include <__type_traits/common_type.h> +# include <__type_traits/conditional.h> +# include <__type_traits/remove_cvref.h> +# include <__utility/declval.h> +# include <__utility/move.h> +# include <string_view> # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header # endif +_LIBCPP_PUSH_MACROS +# include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ @@ -43,6 +56,165 @@ struct zoned_traits<const time_zone*> { } }; +template <class _Duration, class _TimeZonePtr = const time_zone*> +class zoned_time { + // [time.zone.zonedtime.ctor]/2 + static_assert(__is_duration<_Duration>::value, + "the program is ill-formed since _Duration is not a specialization of std::chrono::duration"); + + // The wording uses the constraints like + // constructible_from<zoned_time, decltype(__traits::locate_zone(string_view{}))> + // Using these constraints in the code causes the compiler to give an + // error that the constraint depends on itself. To avoid that issue use + // the fact it is possible to create this object from a _TimeZonePtr. + using __traits = zoned_traits<_TimeZonePtr>; + +public: + using duration = common_type_t<_Duration, seconds>; + + _LIBCPP_HIDE_FROM_ABI zoned_time() + requires requires { __traits::default_zone(); } + : __zone_{__traits::default_zone()}, __tp_{} {} + + _LIBCPP_HIDE_FROM_ABI zoned_time(const zoned_time&) = default; + _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const zoned_time&) = default; + + _LIBCPP_HIDE_FROM_ABI zoned_time(const sys_time<_Duration>& __tp) + requires requires { __traits::default_zone(); } + : __zone_{__traits::default_zone()}, __tp_{__tp} {} + + _LIBCPP_HIDE_FROM_ABI explicit zoned_time(_TimeZonePtr __zone) : __zone_{std::move(__zone)}, __tp_{} {} + + _LIBCPP_HIDE_FROM_ABI explicit zoned_time(string_view __name) + requires(requires { __traits::locate_zone(string_view{}); } && + constructible_from<_TimeZonePtr, decltype(__traits::locate_zone(string_view{}))>) + : __zone_{__traits::locate_zone(__name)}, __tp_{} {} + + template <class _Duration2> + _LIBCPP_HIDE_FROM_ABI zoned_time(const zoned_time<_Duration2, _TimeZonePtr>& __zt) + requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>> + : __zone_{__zt.get_time_zone()}, __tp_{__zt.get_sys_time()} {} + + _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const sys_time<_Duration>& __tp) + : __zone_{std::move(__zone)}, __tp_{__tp} {} + + _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const sys_time<_Duration>& __tp) + requires requires { _TimeZonePtr{__traits::locate_zone(string_view{})}; } + : zoned_time{__traits::locate_zone(__name), __tp} {} + + _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const local_time<_Duration>& __tp) + requires(is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{})), + sys_time<duration>>) + : __zone_{std::move(__zone)}, __tp_{__zone_->to_sys(__tp)} {} + + _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const local_time<_Duration>& __tp) + requires(requires { + _TimeZonePtr{__traits::locate_zone(string_view{})}; + } && is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{})), + sys_time<duration>>) + : zoned_time{__traits::locate_zone(__name), __tp} {} + + _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const local_time<_Duration>& __tp, choose __c) + requires(is_convertible_v< + decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{}, choose::earliest)), + sys_time<duration>>) + : __zone_{std::move(__zone)}, __tp_{__zone_->to_sys(__tp, __c)} {} + + _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const local_time<_Duration>& __tp, choose __c) + requires(requires { + _TimeZonePtr{__traits::locate_zone(string_view{})}; + } && is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{}, choose::earliest)), + sys_time<duration>>) + : zoned_time{__traits::locate_zone(__name), __tp, __c} {} + + template <class _Duration2, class _TimeZonePtr2> + _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const zoned_time<_Duration2, _TimeZonePtr2>& __zt) + requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>> + : __zone_{std::move(__zone)}, __tp_{__zt.get_sys_time()} {} + + // per wording choose has no effect + template <class _Duration2, class _TimeZonePtr2> + _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const zoned_time<_Duration2, _TimeZonePtr2>& __zt, choose) + requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>> + : __zone_{std::move(__zone)}, __tp_{__zt.get_sys_time()} {} + + template <class _Duration2, class _TimeZonePtr2> + _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const zoned_time<_Duration2, _TimeZonePtr2>& __zt) + requires(requires { + _TimeZonePtr{__traits::locate_zone(string_view{})}; + } && is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>) + : zoned_time{__traits::locate_zone(__name), __zt} {} + + template <class _Duration2, class _TimeZonePtr2> + _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const zoned_time<_Duration2, _TimeZonePtr2>& __zt, choose __c) + requires(requires { + _TimeZonePtr{__traits::locate_zone(string_view{})}; + } && is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>) + : zoned_time{__traits::locate_zone(__name), __zt, __c} {} + + _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) { + __tp_ = __tp; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& __tp) { + // TODO TZDB This seems wrong. + // Assigning a non-existent or ambiguous time will throw and not satisfy + // the post condition. This seems quite odd; I constructed an object with + // choose::earliest and that choice is not respected. + // what did LEWG do with this. + // MSVC STL and libstdc++ behave the same + __tp_ = __zone_->to_sys(__tp); + return *this; + } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator sys_time<duration>() const { return get_sys_time(); } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit operator local_time<duration>() const { return get_local_time(); } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _TimeZonePtr get_time_zone() const { return __zone_; } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time<duration> get_local_time() const { return __zone_->to_local(__tp_); } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time<duration> get_sys_time() const { return __tp_; } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info() const { return __zone_->get_info(__tp_); } + +private: + _TimeZonePtr __zone_; + sys_time<duration> __tp_; +}; + +zoned_time() -> zoned_time<seconds>; + +template <class _Duration> +zoned_time(sys_time<_Duration>) -> zoned_time<common_type_t<_Duration, seconds>>; + +template <class _TimeZonePtrOrName> +using __time_zone_representation = + conditional_t<is_convertible_v<_TimeZonePtrOrName, string_view>, + const time_zone*, + remove_cvref_t<_TimeZonePtrOrName>>; + +template <class _TimeZonePtrOrName> +zoned_time(_TimeZonePtrOrName&&) -> zoned_time<seconds, __time_zone_representation<_TimeZonePtrOrName>>; + +template <class _TimeZonePtrOrName, class _Duration> +zoned_time(_TimeZonePtrOrName&&, sys_time<_Duration>) + -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>; + +template <class _TimeZonePtrOrName, class _Duration> +zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>, choose = choose::earliest) + -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>; + +template <class _Duration, class _TimeZonePtrOrName, class _TimeZonePtr2> +zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, _TimeZonePtr2>, choose = choose::earliest) + -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>; + +using zoned_seconds = zoned_time<seconds>; + +template <class _Duration1, class _Duration2, class _TimeZonePtr> +_LIBCPP_HIDE_FROM_ABI bool +operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const zoned_time<_Duration2, _TimeZonePtr>& __rhs) { + return __lhs.get_time_zone() == __rhs.get_time_zone() && __lhs.get_sys_time() == __rhs.get_sys_time(); +} + } // namespace chrono # endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) @@ -50,6 +222,8 @@ struct zoned_traits<const time_zone*> { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) #endif // _LIBCPP___CHRONO_ZONED_TIME_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__compare/ordering.h b/contrib/libs/cxxsupp/libcxx/include/__compare/ordering.h index 2995d38130..297218e6f2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__compare/ordering.h +++ b/contrib/libs/cxxsupp/libcxx/include/__compare/ordering.h @@ -24,32 +24,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD // exposition only enum class _OrdResult : signed char { __less = -1, __equiv = 0, __greater = 1 }; -enum class _NCmpResult : signed char { __unordered = -127 }; +enum class _PartialOrdResult : signed char { + __less = static_cast<signed char>(_OrdResult::__less), + __equiv = static_cast<signed char>(_OrdResult::__equiv), + __greater = static_cast<signed char>(_OrdResult::__greater), + __unordered = -127, +}; class partial_ordering; class weak_ordering; class strong_ordering; -template <class _Tp, class... _Args> -inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...); - struct _CmpUnspecifiedParam { - _LIBCPP_HIDE_FROM_ABI constexpr _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {} - - template <class _Tp, class = enable_if_t<!__one_of_v<_Tp, int, partial_ordering, weak_ordering, strong_ordering>>> - _CmpUnspecifiedParam(_Tp) = delete; + // If anything other than a literal 0 is provided, the behavior is undefined by the Standard. + // + // The alternative to the `__enable_if__` attribute would be to use the fact that a pointer + // can be constructed from literal 0, but this conflicts with `-Wzero-as-null-pointer-constant`. + template <class _Tp, class = __enable_if_t<is_same_v<_Tp, int> > > + _LIBCPP_HIDE_FROM_ABI consteval _CmpUnspecifiedParam(_Tp __zero) noexcept +# if __has_attribute(__enable_if__) + __attribute__((__enable_if__( + __zero == 0, "Only literal 0 is allowed as the operand of a comparison with one of the ordering types"))) +# endif + { + (void)__zero; + } }; class partial_ordering { - using _ValueT = signed char; - - _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} - - _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering(_NCmpResult __v) noexcept : __value_(_ValueT(__v)) {} - - _LIBCPP_HIDE_FROM_ABI constexpr bool __is_ordered() const noexcept { - return __value_ != _ValueT(_NCmpResult::__unordered); - } + _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering(_PartialOrdResult __v) noexcept : __value_(__v) {} public: // valid values @@ -62,39 +65,39 @@ public: _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default; _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ == 0; + return __v.__value_ == _PartialOrdResult::__equiv; } _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ < 0; + return __v.__value_ == _PartialOrdResult::__less; } _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ <= 0; + return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__less; } _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ > 0; + return __v.__value_ == _PartialOrdResult::__greater; } _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ >= 0; + return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__greater; } _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 < __v.__value_; + return __v.__value_ == _PartialOrdResult::__greater; } _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 <= __v.__value_; + return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__greater; } _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 > __v.__value_; + return __v.__value_ == _PartialOrdResult::__less; } _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 >= __v.__value_; + return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__less; } _LIBCPP_HIDE_FROM_ABI friend constexpr partial_ordering @@ -108,13 +111,13 @@ public: } private: - _ValueT __value_; + _PartialOrdResult __value_; }; -inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less); -inline constexpr partial_ordering partial_ordering::equivalent(_OrdResult::__equiv); -inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater); -inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered); +inline constexpr partial_ordering partial_ordering::less(_PartialOrdResult::__less); +inline constexpr partial_ordering partial_ordering::equivalent(_PartialOrdResult::__equiv); +inline constexpr partial_ordering partial_ordering::greater(_PartialOrdResult::__greater); +inline constexpr partial_ordering partial_ordering::unordered(_PartialOrdResult::__unordered); class weak_ordering { using _ValueT = signed char; @@ -269,7 +272,8 @@ inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater) /// The types partial_ordering, weak_ordering, and strong_ordering are /// collectively termed the comparison category types. template <class _Tp> -concept __comparison_category = __one_of_v<_Tp, partial_ordering, weak_ordering, strong_ordering>; +concept __comparison_category = + is_same_v<_Tp, partial_ordering> || is_same_v<_Tp, weak_ordering> || is_same_v<_Tp, strong_ordering>; #endif // _LIBCPP_STD_VER >= 20 diff --git a/contrib/libs/cxxsupp/libcxx/include/__concepts/predicate.h b/contrib/libs/cxxsupp/libcxx/include/__concepts/predicate.h index 00731efc8f..e0263a878b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__concepts/predicate.h +++ b/contrib/libs/cxxsupp/libcxx/include/__concepts/predicate.h @@ -12,7 +12,7 @@ #include <__concepts/boolean_testable.h> #include <__concepts/invocable.h> #include <__config> -#include <__functional/invoke.h> +#include <__type_traits/invoke.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__config b/contrib/libs/cxxsupp/libcxx/include/__config index 8ce18c110a..8ea2c284c8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__config +++ b/contrib/libs/cxxsupp/libcxx/include/__config @@ -27,10 +27,11 @@ // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is // defined to XXYYZZ. -# define _LIBCPP_VERSION 190000 +# define _LIBCPP_VERSION 200000 # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) +# define _LIBCPP_CONCAT3(X, Y, Z) _LIBCPP_CONCAT(X, _LIBCPP_CONCAT(Y, Z)) # if __STDC_HOSTED__ == 0 # define _LIBCPP_FREESTANDING @@ -38,10 +39,10 @@ // HARDENING { -// TODO(hardening): deprecate this in LLVM 19. // This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes) -// equivalent to setting the extensive mode. +// equivalent to setting the extensive mode. This is deprecated and will be removed in LLVM 20. # ifdef _LIBCPP_ENABLE_ASSERTIONS +# warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" # if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1 # error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1" # endif @@ -162,16 +163,6 @@ _LIBCPP_HARDENING_MODE_DEBUG # define _LIBCPP_CXX03_LANG # endif -// TODO: Remove once we switch to GCC 14 -# ifndef __has_extension -# define __has_extension(__x) 0 -# endif - -// TODO: Remove once we switch to GCC 14 -# ifndef __has_feature -# define __has_feature(__x) 0 -# endif - # ifndef __has_constexpr_builtin # define __has_constexpr_builtin(x) 0 # endif @@ -201,25 +192,6 @@ _LIBCPP_HARDENING_MODE_DEBUG # error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11" # endif -// FIXME: ABI detection should be done via compiler builtin macros. This -// is just a placeholder until Clang implements such macros. For now assume -// that Windows compilers pretending to be MSVC++ target the Microsoft ABI, -// and allow the user to explicitly specify the ABI to handle cases where this -// heuristic falls short. -# if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) -# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" -# elif defined(_LIBCPP_ABI_FORCE_ITANIUM) -# define _LIBCPP_ABI_ITANIUM -# elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) -# define _LIBCPP_ABI_MICROSOFT -# else -# if defined(_WIN32) && defined(_MSC_VER) -# define _LIBCPP_ABI_MICROSOFT -# else -# define _LIBCPP_ABI_ITANIUM -# endif -# endif - # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) # define _LIBCPP_ABI_VCRUNTIME # endif @@ -234,7 +206,6 @@ _LIBCPP_HARDENING_MODE_DEBUG // easier to grep for target specific flags once the feature is complete. # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) # define _LIBCPP_HAS_NO_INCOMPLETE_PSTL -# define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN # define _LIBCPP_HAS_NO_EXPERIMENTAL_TZDB # define _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM # endif @@ -322,7 +293,6 @@ _LIBCPP_HARDENING_MODE_DEBUG # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) # define _ALIGNAS_TYPE(x) alignas(x) # define _ALIGNAS(x) alignas(x) -# define _LIBCPP_NORETURN [[noreturn]] # define _NOEXCEPT noexcept # define _NOEXCEPT_(...) noexcept(__VA_ARGS__) # define _LIBCPP_CONSTEXPR constexpr @@ -332,7 +302,6 @@ _LIBCPP_HARDENING_MODE_DEBUG # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) # define _ALIGNAS(x) __attribute__((__aligned__(x))) -# define _LIBCPP_NORETURN __attribute__((__noreturn__)) # define _LIBCPP_HAS_NO_NOEXCEPT # define nullptr __nullptr # define _NOEXCEPT throw() @@ -348,44 +317,30 @@ typedef __char32_t char32_t; # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) -# if defined(_LIBCPP_COMPILER_CLANG_BASED) - // Objective-C++ features (opt-in) -# if __has_feature(objc_arc) -# define _LIBCPP_HAS_OBJC_ARC -# endif - -# if __has_feature(objc_arc_weak) -# define _LIBCPP_HAS_OBJC_ARC_WEAK -# endif - -# if __has_extension(blocks) -# define _LIBCPP_HAS_EXTENSION_BLOCKS -# endif - -# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) -# define _LIBCPP_HAS_BLOCKS_RUNTIME -# endif - -# if !__has_feature(address_sanitizer) -# define _LIBCPP_HAS_NO_ASAN -# endif - -# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) +# if __has_feature(objc_arc) +# define _LIBCPP_HAS_OBJC_ARC +# endif -# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ +# if __has_feature(objc_arc_weak) +# define _LIBCPP_HAS_OBJC_ARC_WEAK +# endif -# elif defined(_LIBCPP_COMPILER_GCC) +# if __has_extension(blocks) +# define _LIBCPP_HAS_EXTENSION_BLOCKS +# endif -# if !defined(__SANITIZE_ADDRESS__) -# define _LIBCPP_HAS_NO_ASAN -# endif +# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) +# define _LIBCPP_HAS_BLOCKS_RUNTIME +# endif -# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) +# if !__has_feature(address_sanitizer) +# define _LIBCPP_HAS_NO_ASAN +# endif -# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ +# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) -# endif // _LIBCPP_COMPILER_[CLANG|GCC] +# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ # if defined(_LIBCPP_OBJECT_FORMAT_COFF) @@ -617,6 +572,15 @@ typedef __char32_t char32_t; inline namespace _LIBCPP_ABI_NAMESPACE { # define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_POP_EXTENSION_DIAGNOSTICS +#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental { +#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL }} + +#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 { +#define _LIBCPP_END_NAMESPACE_LFTS } _LIBCPP_END_NAMESPACE_EXPERIMENTAL + +#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 { +#define _LIBCPP_END_NAMESPACE_LFTS_V2 } _LIBCPP_END_NAMESPACE_EXPERIMENTAL + #ifdef _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD namespace filesystem { # define _LIBCPP_END_NAMESPACE_FILESYSTEM } _LIBCPP_END_NAMESPACE_STD @@ -723,14 +687,6 @@ typedef __char32_t char32_t; # define _LIBCPP_DEPRECATED_(m) # endif -# if _LIBCPP_STD_VER < 20 -# define _LIBCPP_DEPRECATED_ATOMIC_SYNC \ - _LIBCPP_DEPRECATED_("The C++20 synchronization library has been deprecated prior to C++20. Please update to " \ - "using -std=c++20 if you need to use these facilities.") -# else -# define _LIBCPP_DEPRECATED_ATOMIC_SYNC /* nothing */ -# endif - # if !defined(_LIBCPP_CXX03_LANG) # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED # else @@ -820,6 +776,12 @@ typedef __char32_t char32_t; # define _LIBCPP_CONSTEXPR_SINCE_CXX23 # endif +# if _LIBCPP_STD_VER >= 26 +# define _LIBCPP_CONSTEXPR_SINCE_CXX26 constexpr +# else +# define _LIBCPP_CONSTEXPR_SINCE_CXX26 +# endif + # ifndef _LIBCPP_WEAK # define _LIBCPP_WEAK __attribute__((__weak__)) # endif @@ -915,7 +877,7 @@ typedef __char32_t char32_t; # endif # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ - defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) + defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) || defined(__LLVM_LIBC__) # define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE # endif @@ -1024,21 +986,9 @@ typedef __char32_t char32_t; // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.) // However, MSVC implements [[msvc::no_unique_address]] which does what // [[no_unique_address]] is supposed to do, in general. - -// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or -// [[msvc::no_unique_address]] though. If/when it does implement -// [[msvc::no_unique_address]], this should be preferred though. # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] -# elif __has_cpp_attribute(no_unique_address) -# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]] # else -# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */ -// Note that this can be replaced by #error as soon as clang-cl -// implements msvc::no_unique_address, since there should be no C++20 -// compiler that doesn't support one of the two attributes at that point. -// We generally don't want to use this macro outside of C++20-only code, -// because using it conditionally in one language version only would make -// the ABI inconsistent. +# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]] # endif // c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these @@ -1149,15 +1099,6 @@ typedef __char32_t char32_t; # define _LIBCPP_USING_IF_EXISTS # endif -# if __has_cpp_attribute(__nodiscard__) -# define _LIBCPP_NODISCARD [[__nodiscard__]] -# else -// We can't use GCC's [[gnu::warn_unused_result]] and -// __attribute__((warn_unused_result)), because GCC does not silence them via -// (void) cast. -# define _LIBCPP_NODISCARD -# endif - # if __has_attribute(__no_destroy__) # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) # else diff --git a/contrib/libs/cxxsupp/libcxx/include/__config_site b/contrib/libs/cxxsupp/libcxx/include/__config_site index ecd7ae4d27..61cf47ac44 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__config_site +++ b/contrib/libs/cxxsupp/libcxx/include/__config_site @@ -51,6 +51,8 @@ #define _LIBCPP_ENABLE_CXX20_REMOVED_SHARED_PTR_UNIQUE +#define _LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS + #ifdef _musl_ # define _LIBCPP_HAS_MUSL_LIBC #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/__config_site.in b/contrib/libs/cxxsupp/libcxx/include/__config_site.in index 67022146c9..bf2d31d8ee 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__config_site.in +++ b/contrib/libs/cxxsupp/libcxx/include/__config_site.in @@ -15,6 +15,7 @@ #cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT #cmakedefine _LIBCPP_HAS_NO_THREADS #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK +#cmakedefine _LIBCPP_HAS_NO_TERMINAL #cmakedefine _LIBCPP_HAS_MUSL_LIBC #cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD #cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL diff --git a/contrib/libs/cxxsupp/libcxx/include/__configuration/abi.h b/contrib/libs/cxxsupp/libcxx/include/__configuration/abi.h index c31fbbae1a..1e4c9cf3a3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__configuration/abi.h +++ b/contrib/libs/cxxsupp/libcxx/include/__configuration/abi.h @@ -18,6 +18,25 @@ # pragma GCC system_header #endif +// FIXME: ABI detection should be done via compiler builtin macros. This +// is just a placeholder until Clang implements such macros. For now assume +// that Windows compilers pretending to be MSVC++ target the Microsoft ABI, +// and allow the user to explicitly specify the ABI to handle cases where this +// heuristic falls short. +#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) +# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" +#elif defined(_LIBCPP_ABI_FORCE_ITANIUM) +# define _LIBCPP_ABI_ITANIUM +#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) +# define _LIBCPP_ABI_MICROSOFT +#else +# if defined(_WIN32) && defined(_MSC_VER) +# define _LIBCPP_ABI_MICROSOFT +# else +# define _LIBCPP_ABI_ITANIUM +# endif +#endif + #if _LIBCPP_ABI_VERSION >= 2 // Change short string representation so that string data starts at offset 0, // improving its alignment in some cases. @@ -96,6 +115,20 @@ # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW // Dont' add an inline namespace for `std::filesystem` # define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE +// std::basic_ios uses WEOF to indicate that the fill value is +// uninitialized. However, on platforms where the size of char_type is +// equal to or greater than the size of int_type and char_type is unsigned, +// std::char_traits<char_type>::eq_int_type() cannot distinguish between WEOF +// and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill +// value has been initialized using a separate boolean, which changes the ABI. +# define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE +// Historically, libc++ used a type called `__compressed_pair` to reduce storage needs in cases of empty types (e.g. an +// empty allocator in std::vector). We switched to using `[[no_unique_address]]`. However, for ABI compatibility reasons +// we had to add artificial padding in a few places. +// +// This setting disables the addition of such artificial padding, leading to a more optimal +// representation for several types. +# define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING #elif _LIBCPP_ABI_VERSION == 1 # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) // Enable compiling copies of now inline methods into the dylib to support @@ -135,6 +168,24 @@ // - `string_view`. // #define _LIBCPP_ABI_BOUNDED_ITERATORS +// Changes the iterator type of `basic_string` to a bounded iterator that keeps track of whether it's within the bounds +// of the original container and asserts it on every dereference and when performing iterator arithmetics. +// +// ABI impact: changes the iterator type of `basic_string` and its specializations, such as `string` and `wstring`. +// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING + +// Changes the iterator type of `vector` to a bounded iterator that keeps track of whether it's within the bounds of the +// original container and asserts it on every dereference and when performing iterator arithmetics. Note: this doesn't +// yet affect `vector<bool>`. +// +// ABI impact: changes the iterator type of `vector` (except `vector<bool>`). +// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR + +// [[msvc::no_unique_address]] seems to mostly affect empty classes, so the padding scheme for Itanium doesn't work. +#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING) +# define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING +#endif + #if defined(_LIBCPP_COMPILER_CLANG_BASED) # if defined(__APPLE__) # if defined(__i386__) || defined(__x86_64__) diff --git a/contrib/libs/cxxsupp/libcxx/include/__configuration/platform.h b/contrib/libs/cxxsupp/libcxx/include/__configuration/platform.h index 6d5b95164e..78ad402a68 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__configuration/platform.h +++ b/contrib/libs/cxxsupp/libcxx/include/__configuration/platform.h @@ -30,15 +30,18 @@ // ... add new file formats here ... #endif -// Need to detect which libc we're using if we're on Linux. -#if defined(__linux__) +// To detect which libc we're using +#if __has_include(<features.h>) # include <features.h> +#endif + +#if defined(__linux__) # if defined(__GLIBC_PREREQ) # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) # else # define _LIBCPP_GLIBC_PREREQ(a, b) 0 # endif // defined(__GLIBC_PREREQ) -#endif // defined(__linux__) +#endif #ifndef __BYTE_ORDER__ # error \ diff --git a/contrib/libs/cxxsupp/libcxx/include/__cstddef/byte.h b/contrib/libs/cxxsupp/libcxx/include/__cstddef/byte.h new file mode 100644 index 0000000000..09e1d75e0b --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__cstddef/byte.h @@ -0,0 +1,85 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___CSTDDEF_BYTE_H +#define _LIBCPP___CSTDDEF_BYTE_H + +#include <__config> +#include <__fwd/byte.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 17 +namespace std { // purposefully not versioned + +enum class byte : unsigned char {}; + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept { + return static_cast<byte>( + static_cast<unsigned char>(static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs))); +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept { + return __lhs = __lhs | __rhs; +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept { + return static_cast<byte>( + static_cast<unsigned char>(static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs))); +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept { + return __lhs = __lhs & __rhs; +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept { + return static_cast<byte>( + static_cast<unsigned char>(static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs))); +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept { + return __lhs = __lhs ^ __rhs; +} + +_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept { + return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(__b))); +} + +template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept { + return __lhs = __lhs << __shift; +} + +template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept { + return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); +} + +template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept { + return __lhs = __lhs >> __shift; +} + +template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept { + return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); +} + +template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept { + return static_cast<_Integer>(__b); +} + +} // namespace std +#endif // _LIBCPP_STD_VER >= 17 + +#endif // _LIBCPP___CSTDDEF_BYTE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__cstddef/max_align_t.h b/contrib/libs/cxxsupp/libcxx/include/__cstddef/max_align_t.h new file mode 100644 index 0000000000..7c09c7e7f3 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__cstddef/max_align_t.h @@ -0,0 +1,27 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___CSTDDEF_MAX_ALIGN_T_H +#define _LIBCPP___CSTDDEF_MAX_ALIGN_T_H + +#include <__config> +#include <stddef.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_CXX03_LANG) +using ::max_align_t _LIBCPP_USING_IF_EXISTS; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_MAX_ALIGN_T_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__cstddef/nullptr_t.h b/contrib/libs/cxxsupp/libcxx/include/__cstddef/nullptr_t.h new file mode 100644 index 0000000000..de3f7d4ab5 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__cstddef/nullptr_t.h @@ -0,0 +1,25 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___CSTDDEF_NULLPTR_T_H +#define _LIBCPP___CSTDDEF_NULLPTR_T_H + +#include <__config> +#include <stddef.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +using ::nullptr_t; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_NULLPTR_T_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__cstddef/ptrdiff_t.h b/contrib/libs/cxxsupp/libcxx/include/__cstddef/ptrdiff_t.h new file mode 100644 index 0000000000..f8b5cdaaff --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__cstddef/ptrdiff_t.h @@ -0,0 +1,25 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___CSTDDEF_PTRDIFF_T_H +#define _LIBCPP___CSTDDEF_PTRDIFF_T_H + +#include <__config> +#include <stddef.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_PTRDIFF_T_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__cstddef/size_t.h b/contrib/libs/cxxsupp/libcxx/include/__cstddef/size_t.h new file mode 100644 index 0000000000..91abbf0131 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__cstddef/size_t.h @@ -0,0 +1,25 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___CSTDDEF_SIZE_T_H +#define _LIBCPP___CSTDDEF_SIZE_T_H + +#include <__config> +#include <stddef.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +using ::size_t _LIBCPP_USING_IF_EXISTS; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___CSTDDEF_SIZE_T_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__exception/exception_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__exception/exception_ptr.h index e9316f31c2..fcf907411b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__exception/exception_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__exception/exception_ptr.h @@ -138,7 +138,7 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { #else // _LIBCPP_ABI_MICROSOFT -_LIBCPP_HIDE_FROM_ABI exception_ptr __copy_exception_ptr(void* __exception, const void* __ptr); +_LIBCPP_EXPORTED_FROM_ABI exception_ptr __copy_exception_ptr(void* __except, const void* __ptr); // This is a built-in template function which automagically extracts the required // information. diff --git a/contrib/libs/cxxsupp/libcxx/include/__exception/nested_exception.h b/contrib/libs/cxxsupp/libcxx/include/__exception/nested_exception.h index feb489f87f..8e817e1c06 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__exception/nested_exception.h +++ b/contrib/libs/cxxsupp/libcxx/include/__exception/nested_exception.h @@ -13,6 +13,8 @@ #include <__exception/exception_ptr.h> #include <__memory/addressof.h> #include <__type_traits/decay.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_base_of.h> #include <__type_traits/is_class.h> #include <__type_traits/is_constructible.h> @@ -38,7 +40,7 @@ public: virtual ~nested_exception() _NOEXCEPT; // access functions - _LIBCPP_NORETURN void rethrow_nested() const; + [[__noreturn__]] void rethrow_nested() const; _LIBCPP_HIDE_FROM_ABI exception_ptr nested_ptr() const _NOEXCEPT { return __ptr_; } }; @@ -53,19 +55,19 @@ struct __throw_with_nested; template <class _Tp, class _Up> struct __throw_with_nested<_Tp, _Up, true> { - _LIBCPP_NORETURN static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { + [[__noreturn__]] static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { throw __nested<_Up>(std::forward<_Tp>(__t)); } }; template <class _Tp, class _Up> struct __throw_with_nested<_Tp, _Up, false> { - _LIBCPP_NORETURN static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { throw std::forward<_Tp>(__t); } + [[__noreturn__]] static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { throw std::forward<_Tp>(__t); } }; #endif template <class _Tp> -_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void throw_with_nested(_Tp&& __t) { +[[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void throw_with_nested(_Tp&& __t) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS using _Up = __decay_t<_Tp>; static_assert(is_copy_constructible<_Up>::value, "type thrown must be CopyConstructible"); diff --git a/contrib/libs/cxxsupp/libcxx/include/__exception/operations.h b/contrib/libs/cxxsupp/libcxx/include/__exception/operations.h index 0a9c7a7c7f..c8744eb297 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__exception/operations.h +++ b/contrib/libs/cxxsupp/libcxx/include/__exception/operations.h @@ -22,20 +22,22 @@ namespace std { // purposefully not using versioning namespace using unexpected_handler = void (*)(); _LIBCPP_EXPORTED_FROM_ABI unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT; _LIBCPP_EXPORTED_FROM_ABI unexpected_handler get_unexpected() _NOEXCEPT; -_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void unexpected(); +[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void unexpected(); #endif using terminate_handler = void (*)(); _LIBCPP_EXPORTED_FROM_ABI terminate_handler set_terminate(terminate_handler) _NOEXCEPT; _LIBCPP_EXPORTED_FROM_ABI terminate_handler get_terminate() _NOEXCEPT; -_LIBCPP_EXPORTED_FROM_ABI bool uncaught_exception() _NOEXCEPT; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION) +_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 bool uncaught_exception() _NOEXCEPT; +#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION) _LIBCPP_EXPORTED_FROM_ABI int uncaught_exceptions() _NOEXCEPT; class _LIBCPP_EXPORTED_FROM_ABI exception_ptr; _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT; -_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); +[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); } // namespace std #endif // _LIBCPP___EXCEPTION_OPERATIONS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__exception/terminate.h b/contrib/libs/cxxsupp/libcxx/include/__exception/terminate.h index e672471dc5..0bfc3506d3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__exception/terminate.h +++ b/contrib/libs/cxxsupp/libcxx/include/__exception/terminate.h @@ -16,7 +16,7 @@ #endif namespace std { // purposefully not using versioning namespace -_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT; +[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT; } // namespace std #endif // _LIBCPP___EXCEPTION_TERMINATE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h b/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h index d08222f7bc..6e5745c744 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h +++ b/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h @@ -17,9 +17,11 @@ #include <__functional/invoke.h> #include <__memory/addressof.h> #include <__memory/construct_at.h> +#include <__type_traits/conditional.h> #include <__type_traits/conjunction.h> #include <__type_traits/disjunction.h> #include <__type_traits/integral_constant.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_convertible.h> @@ -503,25 +505,24 @@ public: private: template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual> - using __can_convert = - _And< is_constructible<_Tp, _UfQual>, - is_constructible<_Err, _OtherErrQual>, - _If<_Not<is_same<remove_cv_t<_Tp>, bool>>::value, - _And< - _Not<_And<is_same<_Tp, _Up>, is_same<_Err, _OtherErr>>>, // use the copy constructor instead, see #92676 - _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>, - _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>, - _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>, - _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>, - _Not<is_convertible<expected<_Up, _OtherErr>&, _Tp>>, - _Not<is_convertible<expected<_Up, _OtherErr>&&, _Tp>>, - _Not<is_convertible<const expected<_Up, _OtherErr>&, _Tp>>, - _Not<is_convertible<const expected<_Up, _OtherErr>&&, _Tp>>>, - true_type>, - _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>, - _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>, - _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>, - _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>> >; + using __can_convert = _And< + is_constructible<_Tp, _UfQual>, + is_constructible<_Err, _OtherErrQual>, + _If<_Not<is_same<remove_cv_t<_Tp>, bool>>::value, + _And< _Not<_And<is_same<_Tp, _Up>, is_same<_Err, _OtherErr>>>, // use the copy constructor instead, see #92676 + _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>, + _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>, + _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>, + _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>, + _Not<is_convertible<expected<_Up, _OtherErr>&, _Tp>>, + _Not<is_convertible<expected<_Up, _OtherErr>&&, _Tp>>, + _Not<is_convertible<const expected<_Up, _OtherErr>&, _Tp>>, + _Not<is_convertible<const expected<_Up, _OtherErr>&&, _Tp>>>, + true_type>, + _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>, + _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>, + _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>, + _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>> >; template <class _Func, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr explicit expected( @@ -918,9 +919,9 @@ public: requires is_constructible_v<_Err, _Err&> _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & { using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>; - static_assert(__is_std_expected<_Up>::value, "The result of f(**this) must be a specialization of std::expected"); + static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected"); static_assert(is_same_v<typename _Up::error_type, _Err>, - "The result of f(**this) must have the same error_type as this expected"); + "The result of f(value()) must have the same error_type as this expected"); if (has_value()) { return std::invoke(std::forward<_Func>(__f), this->__val()); } @@ -931,9 +932,9 @@ public: requires is_constructible_v<_Err, const _Err&> _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& { using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&>>; - static_assert(__is_std_expected<_Up>::value, "The result of f(**this) must be a specialization of std::expected"); + static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected"); static_assert(is_same_v<typename _Up::error_type, _Err>, - "The result of f(**this) must have the same error_type as this expected"); + "The result of f(value()) must have the same error_type as this expected"); if (has_value()) { return std::invoke(std::forward<_Func>(__f), this->__val()); } @@ -945,9 +946,9 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && { using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&&>>; static_assert( - __is_std_expected<_Up>::value, "The result of f(std::move(**this)) must be a specialization of std::expected"); + __is_std_expected<_Up>::value, "The result of f(std::move(value())) must be a specialization of std::expected"); static_assert(is_same_v<typename _Up::error_type, _Err>, - "The result of f(std::move(**this)) must have the same error_type as this expected"); + "The result of f(std::move(value())) must have the same error_type as this expected"); if (has_value()) { return std::invoke(std::forward<_Func>(__f), std::move(this->__val())); } @@ -959,9 +960,9 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& { using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&&>>; static_assert( - __is_std_expected<_Up>::value, "The result of f(std::move(**this)) must be a specialization of std::expected"); + __is_std_expected<_Up>::value, "The result of f(std::move(value())) must be a specialization of std::expected"); static_assert(is_same_v<typename _Up::error_type, _Err>, - "The result of f(std::move(**this)) must have the same error_type as this expected"); + "The result of f(std::move(value())) must have the same error_type as this expected"); if (has_value()) { return std::invoke(std::forward<_Func>(__f), std::move(this->__val())); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__filesystem/directory_entry.h b/contrib/libs/cxxsupp/libcxx/include/__filesystem/directory_entry.h index c40b5d7233..d5daa3fefc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__filesystem/directory_entry.h +++ b/contrib/libs/cxxsupp/libcxx/include/__filesystem/directory_entry.h @@ -20,6 +20,7 @@ #include <__filesystem/operations.h> #include <__filesystem/path.h> #include <__filesystem/perms.h> +#include <__fwd/ostream.h> #include <__system_error/errc.h> #include <__system_error/error_code.h> #include <__utility/move.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__filesystem/filesystem_error.h b/contrib/libs/cxxsupp/libcxx/include/__filesystem/filesystem_error.h index 80a11e3b19..f43568c200 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__filesystem/filesystem_error.h +++ b/contrib/libs/cxxsupp/libcxx/include/__filesystem/filesystem_error.h @@ -69,13 +69,13 @@ private: # ifndef _LIBCPP_HAS_NO_EXCEPTIONS template <class... _Args> -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void __throw_filesystem_error(_Args&&... __args) { throw filesystem_error(std::forward<_Args>(__args)...); } # else template <class... _Args> -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void __throw_filesystem_error(_Args&&...) { _LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode"); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__filesystem/path.h b/contrib/libs/cxxsupp/libcxx/include/__filesystem/path.h index ff468d5177..f0d3968043 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__filesystem/path.h +++ b/contrib/libs/cxxsupp/libcxx/include/__filesystem/path.h @@ -21,6 +21,7 @@ #include <__type_traits/is_pointer.h> #include <__type_traits/remove_const.h> #include <__type_traits/remove_pointer.h> +#include <__utility/move.h> #include <cstddef> #include <string> #include <string_view> @@ -811,7 +812,7 @@ public: _LIBCPP_HIDE_FROM_ABI path extension() const { return string_type(__extension()); } // query - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); } _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { return !__root_name().empty(); } _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { return !__root_directory().empty(); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h b/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h index 8598f0a1c0..ce9ac0c81e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h @@ -646,7 +646,7 @@ private: } // namespace __format -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/concepts.h b/contrib/libs/cxxsupp/libcxx/include/__format/concepts.h index 13380e9b91..737783ed4b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/concepts.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/concepts.h @@ -75,8 +75,8 @@ template <class _Tp> concept __fmt_pair_like = __is_specialization_v<_Tp, pair> || (__is_specialization_v<_Tp, tuple> && tuple_size_v<_Tp> == 2); -# endif //_LIBCPP_STD_VER >= 23 -#endif //_LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/container_adaptor.h b/contrib/libs/cxxsupp/libcxx/include/__format/container_adaptor.h index 9f49ca03bf..d3be2e1895 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/container_adaptor.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/container_adaptor.h @@ -66,7 +66,7 @@ template <class _CharT, class _Tp, formattable<_CharT> _Container> struct _LIBCPP_TEMPLATE_VIS formatter<stack<_Tp, _Container>, _CharT> : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {}; -#endif //_LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/enable_insertable.h b/contrib/libs/cxxsupp/libcxx/include/__format/enable_insertable.h index 86ef94a325..29fe566ff0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/enable_insertable.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/enable_insertable.h @@ -28,7 +28,7 @@ inline constexpr bool __enable_insertable = false; } // namespace __format -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/escaped_output_table.h b/contrib/libs/cxxsupp/libcxx/include/__format/escaped_output_table.h index f7be2dc61f..bdf86cb6f9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/escaped_output_table.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/escaped_output_table.h @@ -856,7 +856,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { // clang-format on } // namespace __escaped_output_table -#endif //_LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/extended_grapheme_cluster_table.h b/contrib/libs/cxxsupp/libcxx/include/__format/extended_grapheme_cluster_table.h index 48581d8a5d..7dbc239f5f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/extended_grapheme_cluster_table.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/extended_grapheme_cluster_table.h @@ -1656,7 +1656,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { } // namespace __extended_grapheme_custer_property_boundary -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h index aa02f81dc4..d1ce055874 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h @@ -392,7 +392,7 @@ _LIBCPP_DEPRECATED_IN_CXX26 } } -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_arg_store.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_arg_store.h index 23a599e995..68e936acec 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_arg_store.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_arg_store.h @@ -22,6 +22,7 @@ #include <__type_traits/conditional.h> #include <__type_traits/extent.h> #include <__type_traits/remove_const.h> +#include <cstdint> #include <string> #include <string_view> @@ -259,7 +260,7 @@ struct _LIBCPP_TEMPLATE_VIS __format_arg_store { _Storage __storage; }; -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_args.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_args.h index a5fde36a29..e19b4458e4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_args.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_args.h @@ -28,8 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Context> class _LIBCPP_TEMPLATE_VIS basic_format_args { public: - basic_format_args() noexcept = default; - template <class... _Args> _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept : __size_(sizeof...(_Args)) { @@ -73,7 +71,7 @@ private: template <class _Context, class... _Args> basic_format_args(__format_arg_store<_Context, _Args...>) -> basic_format_args<_Context>; -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_context.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_context.h index 087d4bf289..a9be17b855 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_context.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_context.h @@ -131,6 +131,10 @@ private: _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(_OutIt __out_it, basic_format_args<basic_format_context> __args) : __out_it_(std::move(__out_it)), __args_(__args) {} # endif + +public: + basic_format_context(const basic_format_context&) = delete; + basic_format_context& operator=(const basic_format_context&) = delete; }; // A specialization for __retarget_buffer @@ -208,7 +212,7 @@ private: }; _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_context); -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_error.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_error.h index ed40e395d6..1df7dbff2b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_error.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_error.h @@ -35,7 +35,7 @@ public: }; _LIBCPP_DIAGNOSTIC_POP -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) { +[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) { # ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw format_error(__s); # else @@ -43,7 +43,7 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const ch # endif } -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_functions.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_functions.h index d14b49aff1..1518ab5768 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_functions.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_functions.h @@ -360,7 +360,7 @@ _LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<wchar_t> runtime_format(wst return __fmt; } # endif -# endif //_LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 template <class _CharT, class... _Args> struct _LIBCPP_TEMPLATE_VIS basic_format_string { @@ -671,7 +671,7 @@ formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) # endif // _LIBCPP_HAS_NO_LOCALIZATION -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_parse_context.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_parse_context.h index aefcd5497f..54c23014e7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_parse_context.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_parse_context.h @@ -98,7 +98,7 @@ using format_parse_context = basic_format_parse_context<char>; using wformat_parse_context = basic_format_parse_context<wchar_t>; # endif -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_string.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_string.h index bdf3cff7f4..a499afee88 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_string.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_string.h @@ -153,7 +153,7 @@ __parse_arg_id(_Iterator __begin, _Iterator __end, auto& __parse_ctx) { } // namespace __format -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_to_n_result.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_to_n_result.h index 6f30546dec..344299e32f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_to_n_result.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_to_n_result.h @@ -28,7 +28,7 @@ struct _LIBCPP_TEMPLATE_VIS format_to_n_result { }; _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(format_to_n_result); -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter.h index e2f418f936..39c2670dd8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter.h @@ -40,6 +40,9 @@ struct _LIBCPP_TEMPLATE_VIS formatter { # if _LIBCPP_STD_VER >= 23 template <class _Tp> +constexpr bool enable_nonlocking_formatter_optimization = false; + +template <class _Tp> _LIBCPP_HIDE_FROM_ABI constexpr void __set_debug_format(_Tp& __formatter) { if constexpr (requires { __formatter.set_debug_format(); }) __formatter.set_debug_format(); diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_bool.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_bool.h index 17dc69541e..a43eba53c9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_bool.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_bool.h @@ -69,7 +69,11 @@ public: __format_spec::__parser<_CharT> __parser_; }; -#endif //_LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<bool> = true; +# endif // _LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_char.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_char.h index d33e84368a..a96acba08d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_char.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_char.h @@ -83,10 +83,18 @@ struct _LIBCPP_TEMPLATE_VIS formatter<char, wchar_t> : public __formatter_char<w template <> struct _LIBCPP_TEMPLATE_VIS formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {}; - # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS -#endif //_LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<char> = true; +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<wchar_t> = true; +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_STD_VER >= 23 + +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_floating_point.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_floating_point.h index fa42ba203b..fc95dd3f22 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_floating_point.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_floating_point.h @@ -774,7 +774,15 @@ struct _LIBCPP_TEMPLATE_VIS formatter<double, _CharT> : public __formatter_float template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter<long double, _CharT> : public __formatter_floating_point<_CharT> {}; -#endif //_LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<float> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<double> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<long double> = true; +# endif // _LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integer.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integer.h index 41400f0047..b7f46014c5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integer.h @@ -88,7 +88,38 @@ template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter<__uint128_t, _CharT> : public __formatter_integer<_CharT> {}; # endif -#endif //_LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<signed char> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<short> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<int> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<long> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<long long> = true; +# ifndef _LIBCPP_HAS_NO_INT128 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<__int128_t> = true; +# endif + +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<unsigned char> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<unsigned short> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<unsigned> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<unsigned long> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<unsigned long long> = true; +# ifndef _LIBCPP_HAS_NO_INT128 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<__uint128_t> = true; +# endif +# endif // _LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integral.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integral.h index eca966f888..beed3ab8d9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integral.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integral.h @@ -436,7 +436,7 @@ __format_bool(bool __value, _FormatContext& __ctx, __format_spec::__parsed_speci } // namespace __formatter -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_output.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_output.h index 1498f64c4a..34c4c87313 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_output.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_output.h @@ -326,7 +326,7 @@ _LIBCPP_HIDE_FROM_ABI int __truncate(basic_string_view<_CharT>& __str, int __pre } // namespace __formatter -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_pointer.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_pointer.h index 6941343efd..6e0fa9a1b4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_pointer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_pointer.h @@ -65,7 +65,15 @@ struct _LIBCPP_TEMPLATE_VIS formatter<void*, _CharT> : public __formatter_pointe template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter<const void*, _CharT> : public __formatter_pointer<_CharT> {}; -#endif //_LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<nullptr_t> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<void*> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<const void*> = true; +# endif // _LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h index 347439fc8d..b29e97847f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h @@ -143,7 +143,32 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT } }; -#endif //_LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 23 +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<char*> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<const char*> = true; +template <size_t _Size> +inline constexpr bool enable_nonlocking_formatter_optimization<char[_Size]> = true; +template <class _Traits, class _Allocator> +inline constexpr bool enable_nonlocking_formatter_optimization<basic_string<char, _Traits, _Allocator>> = true; +template <class _Traits> +inline constexpr bool enable_nonlocking_formatter_optimization<basic_string_view<char, _Traits>> = true; + +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<wchar_t*> = true; +template <> +inline constexpr bool enable_nonlocking_formatter_optimization<const wchar_t*> = true; +template <size_t _Size> +inline constexpr bool enable_nonlocking_formatter_optimization<wchar_t[_Size]> = true; +template <class _Traits, class _Allocator> +inline constexpr bool enable_nonlocking_formatter_optimization<basic_string<wchar_t, _Traits, _Allocator>> = true; +template <class _Traits> +inline constexpr bool enable_nonlocking_formatter_optimization<basic_string_view<wchar_t, _Traits>> = true; +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_tuple.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_tuple.h index 030097a879..bb841ef114 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_tuple.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_tuple.h @@ -143,7 +143,7 @@ template <__fmt_char_type _CharT, formattable<_CharT>... _Args> struct _LIBCPP_TEMPLATE_VIS formatter<tuple<_Args...>, _CharT> : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {}; -#endif //_LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/indic_conjunct_break_table.h b/contrib/libs/cxxsupp/libcxx/include/__format/indic_conjunct_break_table.h index 44521d2749..39dd45da77 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/indic_conjunct_break_table.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/indic_conjunct_break_table.h @@ -343,7 +343,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { } // namespace __indic_conjunct_break -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h b/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h index 150bdde89f..6bdf8e319b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h @@ -52,13 +52,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace __format_spec { -_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void +[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void __throw_invalid_option_format_error(const char* __id, const char* __option) { std::__throw_format_error( (string("The format specifier for ") + __id + " does not allow the " + __option + " option").c_str()); } -_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __throw_invalid_type_format_error(const char* __id) { +[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void __throw_invalid_type_format_error(const char* __id) { std::__throw_format_error( (string("The type option contains an invalid value for ") + __id + " formatting argument").c_str()); } @@ -1163,7 +1163,7 @@ __estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __col } // namespace __format_spec -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/range_default_formatter.h b/contrib/libs/cxxsupp/libcxx/include/__format/range_default_formatter.h index b35223ae93..fb21b0f8be 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/range_default_formatter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/range_default_formatter.h @@ -207,7 +207,7 @@ template <ranges::input_range _Rp, class _CharT> requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>) struct _LIBCPP_TEMPLATE_VIS formatter<_Rp, _CharT> : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {}; -#endif //_LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/range_formatter.h b/contrib/libs/cxxsupp/libcxx/include/__format/range_formatter.h index 6915630743..def55c86ce 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/range_formatter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/range_formatter.h @@ -257,7 +257,7 @@ private: basic_string_view<_CharT> __closing_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "]"); }; -#endif //_LIBCPP_STD_VER >= 23 +#endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/unicode.h b/contrib/libs/cxxsupp/libcxx/include/__format/unicode.h index de7d0fea1d..ce6d55ae34 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/unicode.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/unicode.h @@ -595,7 +595,7 @@ private: } // namespace __unicode -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/width_estimation_table.h b/contrib/libs/cxxsupp/libcxx/include/__format/width_estimation_table.h index 11f61dea18..23a08746b9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/width_estimation_table.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/width_estimation_table.h @@ -263,7 +263,7 @@ inline constexpr uint32_t __table_upper_bound = 0x0003fffd; } // namespace __width_estimation_table -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/write_escaped.h b/contrib/libs/cxxsupp/libcxx/include/__format/write_escaped.h index 052ea98c3c..9c288a84d0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/write_escaped.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/write_escaped.h @@ -16,6 +16,7 @@ #include <__charconv/to_chars_result.h> #include <__chrono/statically_widen.h> #include <__format/escaped_output_table.h> +#include <__format/extended_grapheme_cluster_table.h> #include <__format/formatter_output.h> #include <__format/parser_std_format_spec.h> #include <__format/unicode.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h b/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h index 3996460c52..c1af67f2ad 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h @@ -11,10 +11,10 @@ #define _LIBCPP___FUNCTIONAL_BIND_H #include <__config> -#include <__functional/invoke.h> #include <__functional/weak_result_type.h> #include <__fwd/functional.h> #include <__type_traits/decay.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_reference_wrapper.h> #include <__type_traits/is_void.h> #include <cstddef> diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/function.h b/contrib/libs/cxxsupp/libcxx/include/__functional/function.h index c7b98035e3..0d95c9a6ef 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/function.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/function.h @@ -78,7 +78,7 @@ public: }; _LIBCPP_DIAGNOSTIC_POP -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_function_call() { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_function_call() { # ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw bad_function_call(); # else @@ -143,45 +143,46 @@ class __default_alloc_func; template <class _Fp, class _Ap, class _Rp, class... _ArgTypes> class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> { - __compressed_pair<_Fp, _Ap> __f_; + _LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Ap, __alloc_); public: typedef _LIBCPP_NODEBUG _Fp _Target; typedef _LIBCPP_NODEBUG _Ap _Alloc; - _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __f_.first(); } + _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __func_; } // WIN32 APIs may define __allocator, so use __get_allocator instead. - _LIBCPP_HIDE_FROM_ABI const _Alloc& __get_allocator() const { return __f_.second(); } + _LIBCPP_HIDE_FROM_ABI const _Alloc& __get_allocator() const { return __alloc_; } - _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f) - : __f_(piecewise_construct, std::forward_as_tuple(std::move(__f)), std::forward_as_tuple()) {} + _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f) : __func_(std::move(__f)), __alloc_() {} - _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, const _Alloc& __a) - : __f_(piecewise_construct, std::forward_as_tuple(__f), std::forward_as_tuple(__a)) {} + _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, const _Alloc& __a) : __func_(__f), __alloc_(__a) {} _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, _Alloc&& __a) - : __f_(piecewise_construct, std::forward_as_tuple(__f), std::forward_as_tuple(std::move(__a))) {} + : __func_(__f), __alloc_(std::move(__a)) {} _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f, _Alloc&& __a) - : __f_(piecewise_construct, std::forward_as_tuple(std::move(__f)), std::forward_as_tuple(std::move(__a))) {} + : __func_(std::move(__f)), __alloc_(std::move(__a)) {} _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) { typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(__f_.first(), std::forward<_ArgTypes>(__arg)...); + return _Invoker::__call(__func_, std::forward<_ArgTypes>(__arg)...); } _LIBCPP_HIDE_FROM_ABI __alloc_func* __clone() const { typedef allocator_traits<_Alloc> __alloc_traits; typedef __rebind_alloc<__alloc_traits, __alloc_func> _AA; - _AA __a(__f_.second()); + _AA __a(__alloc_); typedef __allocator_destructor<_AA> _Dp; unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new ((void*)__hold.get()) __alloc_func(__f_.first(), _Alloc(__a)); + ::new ((void*)__hold.get()) __alloc_func(__func_, _Alloc(__a)); return __hold.release(); } - _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT { __f_.~__compressed_pair<_Target, _Alloc>(); } + _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT { + __func_.~_Fp(); + __alloc_.~_Alloc(); + } _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__alloc_func* __f) { typedef allocator_traits<_Alloc> __alloc_traits; diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h b/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h index a9e450edd3..59dce7ac9c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h @@ -13,6 +13,7 @@ #include <__functional/unary_function.h> #include <__fwd/functional.h> #include <__type_traits/conjunction.h> +#include <__type_traits/enable_if.h> #include <__type_traits/invoke.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_enum.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/identity.h b/contrib/libs/cxxsupp/libcxx/include/__functional/identity.h index 8468de3dae..1b1c6cf73c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/identity.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/identity.h @@ -26,7 +26,7 @@ struct __is_identity : false_type {}; struct __identity { template <class _Tp> - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT { return std::forward<_Tp>(__t); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/invoke.h b/contrib/libs/cxxsupp/libcxx/include/__functional/invoke.h index ef4bf25f07..ab201e9420 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/invoke.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/invoke.h @@ -12,6 +12,7 @@ #include <__config> #include <__type_traits/invoke.h> +#include <__type_traits/is_void.h> #include <__utility/forward.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fn.h b/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fn.h index ee07a71774..58dbdf871d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fn.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fn.h @@ -12,8 +12,8 @@ #include <__config> #include <__functional/binary_function.h> -#include <__functional/invoke.h> #include <__functional/weak_result_type.h> +#include <__type_traits/invoke.h> #include <__utility/forward.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/operations.h b/contrib/libs/cxxsupp/libcxx/include/__functional/operations.h index 0a6320f19d..6022bd679e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/operations.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/operations.h @@ -14,6 +14,7 @@ #include <__functional/binary_function.h> #include <__functional/unary_function.h> #include <__type_traits/desugars_to.h> +#include <__type_traits/is_integral.h> #include <__utility/forward.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -362,7 +363,7 @@ struct _LIBCPP_TEMPLATE_VIS less : __binary_function<_Tp, _Tp, bool> { _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less); template <class _Tp> -inline const bool __desugars_to_v<__less_tag, less<_Tp>, _Tp, _Tp> = true; +inline const bool __desugars_to_v<__totally_ordered_less_tag, less<_Tp>, _Tp, _Tp> = is_integral<_Tp>::value; #if _LIBCPP_STD_VER >= 14 template <> @@ -377,7 +378,7 @@ struct _LIBCPP_TEMPLATE_VIS less<void> { }; template <class _Tp> -inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Tp> = true; +inline const bool __desugars_to_v<__totally_ordered_less_tag, less<>, _Tp, _Tp> = is_integral<_Tp>::value; #endif #if _LIBCPP_STD_VER >= 14 diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/perfect_forward.h b/contrib/libs/cxxsupp/libcxx/include/__functional/perfect_forward.h index 74177c789b..8fd68db3d6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/perfect_forward.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/perfect_forward.h @@ -11,6 +11,7 @@ #define _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/enable_if.h> #include <__type_traits/invoke.h> #include <__type_traits/is_constructible.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/ranges_operations.h b/contrib/libs/cxxsupp/libcxx/include/__functional/ranges_operations.h index 27f06eadd0..f023d765a6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/ranges_operations.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/ranges_operations.h @@ -100,7 +100,7 @@ template <class _Tp, class _Up> inline const bool __desugars_to_v<__equal_tag, ranges::equal_to, _Tp, _Up> = true; template <class _Tp, class _Up> -inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true; +inline const bool __desugars_to_v<__totally_ordered_less_tag, ranges::less, _Tp, _Up> = true; #endif // _LIBCPP_STD_VER >= 20 diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/reference_wrapper.h b/contrib/libs/cxxsupp/libcxx/include/__functional/reference_wrapper.h index 3570e2673c..a4a66a50cf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/reference_wrapper.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/reference_wrapper.h @@ -13,10 +13,10 @@ #include <__compare/synth_three_way.h> #include <__concepts/boolean_testable.h> #include <__config> -#include <__functional/invoke.h> #include <__functional/weak_result_type.h> #include <__memory/addressof.h> #include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_const.h> #include <__type_traits/remove_cvref.h> #include <__type_traits/void_t.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/weak_result_type.h b/contrib/libs/cxxsupp/libcxx/include/__functional/weak_result_type.h index ad7a839518..793775a290 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/weak_result_type.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/weak_result_type.h @@ -12,9 +12,9 @@ #include <__config> #include <__functional/binary_function.h> -#include <__functional/invoke.h> #include <__functional/unary_function.h> #include <__type_traits/integral_constant.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_same.h> #include <__utility/declval.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/array.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/array.h index b429d0c5a9..794779ae46 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__fwd/array.h +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/array.h @@ -10,7 +10,8 @@ #define _LIBCPP___FWD_ARRAY_H #include <__config> -#include <cstddef> +#include <__cstddef/size_t.h> +#include <__type_traits/integral_constant.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -35,11 +36,11 @@ template <size_t _Ip, class _Tp, size_t _Size> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT; #endif -template <class> -struct __is_std_array : false_type {}; +template <class _Tp> +inline const bool __is_std_array_v = false; template <class _Tp, size_t _Size> -struct __is_std_array<array<_Tp, _Size> > : true_type {}; +inline const bool __is_std_array_v<array<_Tp, _Size> > = true; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/byte.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/byte.h new file mode 100644 index 0000000000..0301833d93 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/byte.h @@ -0,0 +1,26 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_BYTE_H +#define _LIBCPP___FWD_BYTE_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 17 +namespace std { // purposefully not versioned + +enum class byte : unsigned char; + +} // namespace std +#endif // _LIBCPP_STD_VER >= 17 + +#endif // _LIBCPP___FWD_BYTE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/complex.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/complex.h index 22c78c5cc3..092d2e10b1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__fwd/complex.h +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/complex.h @@ -10,7 +10,7 @@ #define _LIBCPP___FWD_COMPLEX_H #include <__config> -#include <cstddef> +#include <__cstddef/size_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/format.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/format.h index b30c220f8a..815e3e1922 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__fwd/format.h +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/format.h @@ -31,7 +31,7 @@ class _LIBCPP_TEMPLATE_VIS basic_format_context; template <class _Tp, class _CharT = char> struct _LIBCPP_TEMPLATE_VIS formatter; -#endif //_LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/get.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/get.h new file mode 100644 index 0000000000..6121ed0efd --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/get.h @@ -0,0 +1,24 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_GET_H +#define _LIBCPP___FWD_GET_H + +#include <__config> +#include <__fwd/array.h> +#include <__fwd/complex.h> +#include <__fwd/pair.h> +#include <__fwd/subrange.h> +#include <__fwd/tuple.h> +#include <__fwd/variant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#endif // _LIBCPP___FWD_GET_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/pair.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/pair.h index af32628fe1..b8ba2b7e92 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__fwd/pair.h +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/pair.h @@ -10,8 +10,8 @@ #define _LIBCPP___FWD_PAIR_H #include <__config> +#include <__cstddef/size_t.h> #include <__fwd/tuple.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/span.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/span.h index 8dafa742c1..5d473ee51c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__fwd/span.h +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/span.h @@ -11,7 +11,7 @@ #define _LIBCPP___FWD_SPAN_H #include <__config> -#include <cstddef> +#include <__cstddef/size_t.h> #include <limits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/subrange.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/subrange.h index 60a41da23d..5b3a07e553 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__fwd/subrange.h +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/subrange.h @@ -11,8 +11,8 @@ #include <__concepts/copyable.h> #include <__config> +#include <__cstddef/size_t.h> #include <__iterator/concepts.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/tuple.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/tuple.h index 902770c295..2ed32bc0df 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__fwd/tuple.h +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/tuple.h @@ -10,7 +10,7 @@ #define _LIBCPP___FWD_TUPLE_H #include <__config> -#include <cstddef> +#include <__cstddef/size_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/variant.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/variant.h new file mode 100644 index 0000000000..71c792f46a --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/variant.h @@ -0,0 +1,77 @@ +//===---------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_VARIANT_H +#define _LIBCPP___FWD_VARIANT_H + +#include <__config> +#include <__cstddef/size_t.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 17 + +template <class... _Types> +class _LIBCPP_TEMPLATE_VIS variant; + +template <class _Tp> +struct _LIBCPP_TEMPLATE_VIS variant_size; + +template <class _Tp> +inline constexpr size_t variant_size_v = variant_size<_Tp>::value; + +template <size_t _Ip, class _Tp> +struct _LIBCPP_TEMPLATE_VIS variant_alternative; + +template <size_t _Ip, class _Tp> +using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type; + +inline constexpr size_t variant_npos = static_cast<size_t>(-1); + +template <size_t _Ip, class... _Types> +_LIBCPP_HIDE_FROM_ABI +_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>& +get(variant<_Types...>&); + +template <size_t _Ip, class... _Types> +_LIBCPP_HIDE_FROM_ABI +_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&& +get(variant<_Types...>&&); + +template <size_t _Ip, class... _Types> +_LIBCPP_HIDE_FROM_ABI +_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>& +get(const variant<_Types...>&); + +template <size_t _Ip, class... _Types> +_LIBCPP_HIDE_FROM_ABI +_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& +get(const variant<_Types...>&&); + +template <class _Tp, class... _Types> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp& get(variant<_Types...>&); + +template <class _Tp, class... _Types> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp&& get(variant<_Types...>&&); + +template <class _Tp, class... _Types> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp& get(const variant<_Types...>&); + +template <class _Tp, class... _Types> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&& +get(const variant<_Types...>&&); + +#endif // _LIBCPP_STD_VER >= 17 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_VARIANT_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__hash_table b/contrib/libs/cxxsupp/libcxx/include/__hash_table index 0257585285..821d4edd8d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__hash_table +++ b/contrib/libs/cxxsupp/libcxx/include/__hash_table @@ -16,8 +16,8 @@ #include <__bit/countl.h> #include <__config> #include <__functional/hash.h> -#include <__functional/invoke.h> #include <__iterator/iterator_traits.h> +#include <__math/rounding_functions.h> #include <__memory/addressof.h> #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> @@ -27,6 +27,8 @@ #include <__memory/unique_ptr.h> #include <__type_traits/can_extract_key.h> #include <__type_traits/conditional.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_const.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_nothrow_assignable.h> @@ -40,9 +42,8 @@ #include <__utility/move.h> #include <__utility/pair.h> #include <__utility/swap.h> -#include <cmath> #include <cstring> -#include <initializer_list> +#include <limits> #include <new> // __launder #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -77,11 +78,18 @@ struct __hash_node_base { typedef __hash_node_base __first_node; typedef __rebind_pointer_t<_NodePtr, __first_node> __node_base_pointer; typedef _NodePtr __node_pointer; - -#if defined(_LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB) typedef __node_base_pointer __next_pointer; -#else - typedef __conditional_t<is_pointer<__node_pointer>::value, __node_base_pointer, __node_pointer> __next_pointer; + +// TODO(LLVM 22): Remove this check +#ifndef _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB + static_assert(sizeof(__node_base_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) == + _LIBCPP_ALIGNOF(__node_pointer), + "It looks like you are using std::__hash_table (an implementation detail for the unordered containers) " + "with a fancy pointer type that thas a different representation depending on whether it points to a " + "__hash_table base pointer or a __hash_table node pointer (both of which are implementation details of " + "the standard library). This means that your ABI is being broken between LLVM 19 and LLVM 20. If you " + "don't care about your ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to " + "silence this diagnostic."); #endif __next_pointer __next_; @@ -554,29 +562,29 @@ class __bucket_list_deallocator { typedef allocator_traits<allocator_type> __alloc_traits; typedef typename __alloc_traits::size_type size_type; - __compressed_pair<size_type, allocator_type> __data_; + _LIBCPP_COMPRESSED_PAIR(size_type, __size_, allocator_type, __alloc_); public: typedef typename __alloc_traits::pointer pointer; _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) - : __data_(0, __default_init_tag()) {} + : __size_(0) {} _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(const allocator_type& __a, size_type __size) _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) - : __data_(__size, __a) {} + : __size_(__size), __alloc_(__a) {} _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(__bucket_list_deallocator&& __x) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) - : __data_(std::move(__x.__data_)) { + : __size_(std::move(__x.__size_)), __alloc_(std::move(__x.__alloc_)) { __x.size() = 0; } - _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __data_.first(); } - _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __data_.first(); } + _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; } + _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; } - _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __data_.second(); } - _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __data_.second(); } + _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __alloc_; } + _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __alloc_; } _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { __alloc_traits::deallocate(__alloc(), __p, size()); } }; @@ -716,27 +724,27 @@ private: // --- Member data begin --- __bucket_list __bucket_list_; - __compressed_pair<__first_node, __node_allocator> __p1_; - __compressed_pair<size_type, hasher> __p2_; - __compressed_pair<float, key_equal> __p3_; + _LIBCPP_COMPRESSED_PAIR(__first_node, __first_node_, __node_allocator, __node_alloc_); + _LIBCPP_COMPRESSED_PAIR(size_type, __size_, hasher, __hasher_); + _LIBCPP_COMPRESSED_PAIR(float, __max_load_factor_, key_equal, __key_eq_); // --- Member data end --- - _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __p2_.first(); } + _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; } public: - _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __p2_.first(); } + _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; } - _LIBCPP_HIDE_FROM_ABI hasher& hash_function() _NOEXCEPT { return __p2_.second(); } - _LIBCPP_HIDE_FROM_ABI const hasher& hash_function() const _NOEXCEPT { return __p2_.second(); } + _LIBCPP_HIDE_FROM_ABI hasher& hash_function() _NOEXCEPT { return __hasher_; } + _LIBCPP_HIDE_FROM_ABI const hasher& hash_function() const _NOEXCEPT { return __hasher_; } - _LIBCPP_HIDE_FROM_ABI float& max_load_factor() _NOEXCEPT { return __p3_.first(); } - _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __p3_.first(); } + _LIBCPP_HIDE_FROM_ABI float& max_load_factor() _NOEXCEPT { return __max_load_factor_; } + _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __max_load_factor_; } - _LIBCPP_HIDE_FROM_ABI key_equal& key_eq() _NOEXCEPT { return __p3_.second(); } - _LIBCPP_HIDE_FROM_ABI const key_equal& key_eq() const _NOEXCEPT { return __p3_.second(); } + _LIBCPP_HIDE_FROM_ABI key_equal& key_eq() _NOEXCEPT { return __key_eq_; } + _LIBCPP_HIDE_FROM_ABI const key_equal& key_eq() const _NOEXCEPT { return __key_eq_; } - _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __p1_.second(); } - _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __p1_.second(); } + _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; } + _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; } public: typedef __hash_iterator<__node_pointer> iterator; @@ -875,10 +883,10 @@ public: _LIBCPP_HIDE_FROM_ABI void __rehash_unique(size_type __n) { __rehash<true>(__n); } _LIBCPP_HIDE_FROM_ABI void __rehash_multi(size_type __n) { __rehash<false>(__n); } _LIBCPP_HIDE_FROM_ABI void __reserve_unique(size_type __n) { - __rehash_unique(static_cast<size_type>(std::ceil(__n / max_load_factor()))); + __rehash_unique(static_cast<size_type>(__math::ceil(__n / max_load_factor()))); } _LIBCPP_HIDE_FROM_ABI void __reserve_multi(size_type __n) { - __rehash_multi(static_cast<size_type>(std::ceil(__n / max_load_factor()))); + __rehash_multi(static_cast<size_type>(__math::ceil(__n / max_load_factor()))); } _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __bucket_list_.get_deleter().size(); } @@ -1022,26 +1030,34 @@ inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() _NOEXCEPT_( is_nothrow_default_constructible<__bucket_list>::value&& is_nothrow_default_constructible<__first_node>::value&& is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_default_constructible<hasher>::value&& is_nothrow_default_constructible<key_equal>::value) - : __p2_(0, __default_init_tag()), __p3_(1.0f, __default_init_tag()) {} + : __size_(0), __max_load_factor_(1.0f) {} template <class _Tp, class _Hash, class _Equal, class _Alloc> inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, const key_equal& __eql) - : __bucket_list_(nullptr, __bucket_list_deleter()), __p1_(), __p2_(0, __hf), __p3_(1.0f, __eql) {} + : __bucket_list_(nullptr, __bucket_list_deleter()), + __first_node_(), + __node_alloc_(), + __size_(0), + __hasher_(__hf), + __max_load_factor_(1.0f), + __key_eq_(__eql) {} template <class _Tp, class _Hash, class _Equal, class _Alloc> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table( const hasher& __hf, const key_equal& __eql, const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__default_init_tag(), __node_allocator(__a)), - __p2_(0, __hf), - __p3_(1.0f, __eql) {} + __node_alloc_(__node_allocator(__a)), + __size_(0), + __hasher_(__hf), + __max_load_factor_(1.0f), + __key_eq_(__eql) {} template <class _Tp, class _Hash, class _Equal, class _Alloc> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__default_init_tag(), __node_allocator(__a)), - __p2_(0, __default_init_tag()), - __p3_(1.0f, __default_init_tag()) {} + __node_alloc_(__node_allocator(__a)), + __size_(0), + __max_load_factor_(1.0f) {} template <class _Tp, class _Hash, class _Equal, class _Alloc> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u) @@ -1049,17 +1065,20 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u) __bucket_list_deleter(allocator_traits<__pointer_allocator>::select_on_container_copy_construction( __u.__bucket_list_.get_deleter().__alloc()), 0)), - __p1_(__default_init_tag(), - allocator_traits<__node_allocator>::select_on_container_copy_construction(__u.__node_alloc())), - __p2_(0, __u.hash_function()), - __p3_(__u.__p3_) {} + __node_alloc_(allocator_traits<__node_allocator>::select_on_container_copy_construction(__u.__node_alloc())), + __size_(0), + __hasher_(__u.hash_function()), + __max_load_factor_(__u.__max_load_factor_), + __key_eq_(__u.__key_eq_) {} template <class _Tp, class _Hash, class _Equal, class _Alloc> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__default_init_tag(), __node_allocator(__a)), - __p2_(0, __u.hash_function()), - __p3_(__u.__p3_) {} + __node_alloc_(__node_allocator(__a)), + __size_(0), + __hasher_(__u.hash_function()), + __max_load_factor_(__u.__max_load_factor_), + __key_eq_(__u.__key_eq_) {} template <class _Tp, class _Hash, class _Equal, class _Alloc> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEXCEPT_( @@ -1067,12 +1086,15 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEX is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<hasher>::value&& is_nothrow_move_constructible<key_equal>::value) : __bucket_list_(std::move(__u.__bucket_list_)), - __p1_(std::move(__u.__p1_)), - __p2_(std::move(__u.__p2_)), - __p3_(std::move(__u.__p3_)) { + __first_node_(std::move(__u.__first_node_)), + __node_alloc_(std::move(__u.__node_alloc_)), + __size_(std::move(__u.__size_)), + __hasher_(std::move(__u.__hasher_)), + __max_load_factor_(__u.__max_load_factor_), + __key_eq_(std::move(__u.__key_eq_)) { if (size() > 0) { - __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr(); - __u.__p1_.first().__next_ = nullptr; + __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr(); + __u.__first_node_.__next_ = nullptr; __u.size() = 0; } } @@ -1080,17 +1102,19 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEX template <class _Tp, class _Hash, class _Equal, class _Alloc> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__default_init_tag(), __node_allocator(__a)), - __p2_(0, std::move(__u.hash_function())), - __p3_(std::move(__u.__p3_)) { + __node_alloc_(__node_allocator(__a)), + __size_(0), + __hasher_(std::move(__u.__hasher_)), + __max_load_factor_(__u.__max_load_factor_), + __key_eq_(std::move(__u.__key_eq_)) { if (__a == allocator_type(__u.__node_alloc())) { __bucket_list_.reset(__u.__bucket_list_.release()); __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size(); __u.__bucket_list_.get_deleter().size() = 0; if (__u.size() > 0) { - __p1_.first().__next_ = __u.__p1_.first().__next_; - __u.__p1_.first().__next_ = nullptr; - __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr(); + __first_node_.__next_ = __u.__first_node_.__next_; + __u.__first_node_.__next_ = nullptr; + __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr(); size() = __u.size(); __u.size() = 0; } @@ -1104,7 +1128,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() { static_assert(is_copy_constructible<hasher>::value, "Hasher must be copy-constructible."); #endif - __deallocate_node(__p1_.first().__next_); + __deallocate_node(__first_node_.__next_); } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -1150,8 +1174,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT { for (size_type __i = 0; __i < __bc; ++__i) __bucket_list_[__i] = nullptr; size() = 0; - __next_pointer __cache = __p1_.first().__next_; - __p1_.first().__next_ = nullptr; + __next_pointer __cache = __first_node_.__next_; + __first_node_.__next_ = nullptr; return __cache; } @@ -1168,10 +1192,10 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, hash_function() = std::move(__u.hash_function()); max_load_factor() = __u.max_load_factor(); key_eq() = std::move(__u.key_eq()); - __p1_.first().__next_ = __u.__p1_.first().__next_; + __first_node_.__next_ = __u.__first_node_.__next_; if (size() > 0) { - __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr(); - __u.__p1_.first().__next_ = nullptr; + __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr(); + __u.__first_node_.__next_ = nullptr; __u.size() = 0; } } @@ -1288,7 +1312,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f template <class _Tp, class _Hash, class _Equal, class _Alloc> inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT { - return iterator(__p1_.first().__next_); + return iterator(__first_node_.__next_); } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -1300,7 +1324,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT { template <class _Tp, class _Hash, class _Equal, class _Alloc> inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT { - return const_iterator(__p1_.first().__next_); + return const_iterator(__first_node_.__next_); } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -1312,8 +1336,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT { template <class _Tp, class _Hash, class _Equal, class _Alloc> void __hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT { if (size() > 0) { - __deallocate_node(__p1_.first().__next_); - __p1_.first().__next_ = nullptr; + __deallocate_node(__first_node_.__next_); + __first_node_.__next_ = nullptr; size_type __bc = bucket_count(); for (size_type __i = 0; __i < __bc; ++__i) __bucket_list_[__i] = nullptr; @@ -1348,7 +1372,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(size_t __ } if (size() + 1 > __bc * max_load_factor() || __bc == 0) { __rehash_unique(std::max<size_type>( - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); } return nullptr; } @@ -1365,7 +1389,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(__node_po // insert_after __bucket_list_[__chash], or __first_node if bucket is null __next_pointer __pn = __bucket_list_[__chash]; if (__pn == nullptr) { - __pn = __p1_.first().__ptr(); + __pn = __first_node_.__ptr(); __nd->__next_ = __pn->__next_; __pn->__next_ = __nd->__ptr(); // fix up __bucket_list_ @@ -1408,7 +1432,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(size_t __c size_type __bc = bucket_count(); if (size() + 1 > __bc * max_load_factor() || __bc == 0) { __rehash_multi(std::max<size_type>( - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); } size_t __chash = std::__constrain_hash(__cp_hash, __bc); @@ -1445,7 +1469,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform( size_type __bc = bucket_count(); size_t __chash = std::__constrain_hash(__cp->__hash_, __bc); if (__pn == nullptr) { - __pn = __p1_.first().__ptr(); + __pn = __first_node_.__ptr(); __cp->__next_ = __pn->__next_; __pn->__next_ = __cp->__ptr(); // fix up __bucket_list_ @@ -1483,7 +1507,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(const_iterator __p size_type __bc = bucket_count(); if (size() + 1 > __bc * max_load_factor() || __bc == 0) { __rehash_multi(std::max<size_type>( - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); } size_t __chash = std::__constrain_hash(__cp->__hash_, __bc); @@ -1523,14 +1547,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args)...); if (size() + 1 > __bc * max_load_factor() || __bc == 0) { __rehash_unique(std::max<size_type>( - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); __chash = std::__constrain_hash(__hash, __bc); } // insert_after __bucket_list_[__chash], or __first_node if bucket is null __next_pointer __pn = __bucket_list_[__chash]; if (__pn == nullptr) { - __pn = __p1_.first().__ptr(); + __pn = __first_node_.__ptr(); __h->__next_ = __pn->__next_; __pn->__next_ = __h.get()->__ptr(); // fix up __bucket_list_ @@ -1692,8 +1716,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_D else if (__n < __bc) { __n = std::max<size_type>( __n, - std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(std::ceil(float(size()) / max_load_factor()))) - : std::__next_prime(size_t(std::ceil(float(size()) / max_load_factor())))); + std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(__math::ceil(float(size()) / max_load_factor()))) + : std::__next_prime(size_t(__math::ceil(float(size()) / max_load_factor())))); if (__n < __bc) __do_rehash<_UniqueKeys>(__n); } @@ -1708,7 +1732,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc) { if (__nbc > 0) { for (size_type __i = 0; __i < __nbc; ++__i) __bucket_list_[__i] = nullptr; - __next_pointer __pp = __p1_.first().__ptr(); + __next_pointer __pp = __first_node_.__ptr(); __next_pointer __cp = __pp->__next_; if (__cp != nullptr) { size_type __chash = std::__constrain_hash(__cp->__hash(), __nbc); @@ -1885,7 +1909,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT { // Fix up __bucket_list_ // if __pn is not in same bucket (before begin is not in same bucket) && // if __cn->__next_ is not in same bucket (nullptr is not in same bucket) - if (__pn == __p1_.first().__ptr() || std::__constrain_hash(__pn->__hash(), __bc) != __chash) { + if (__pn == __first_node_.__ptr() || std::__constrain_hash(__pn->__hash(), __bc) != __chash) { if (__cn->__next_ == nullptr || std::__constrain_hash(__cn->__next_->__hash(), __bc) != __chash) __bucket_list_[__chash] = nullptr; } @@ -2004,14 +2028,17 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) std::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size()); std::__swap_allocator(__bucket_list_.get_deleter().__alloc(), __u.__bucket_list_.get_deleter().__alloc()); std::__swap_allocator(__node_alloc(), __u.__node_alloc()); - std::swap(__p1_.first().__next_, __u.__p1_.first().__next_); - __p2_.swap(__u.__p2_); - __p3_.swap(__u.__p3_); + std::swap(__first_node_.__next_, __u.__first_node_.__next_); + using std::swap; + swap(__size_, __u.__size_); + swap(__hasher_, __u.__hasher_); + swap(__max_load_factor_, __u.__max_load_factor_); + swap(__key_eq_, __u.__key_eq_); if (size() > 0) - __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr(); + __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr(); if (__u.size() > 0) - __u.__bucket_list_[std::__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] = - __u.__p1_.first().__ptr(); + __u.__bucket_list_[std::__constrain_hash(__u.__first_node_.__next_->__hash(), __u.bucket_count())] = + __u.__first_node_.__ptr(); } template <class _Tp, class _Hash, class _Equal, class _Alloc> diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h index 4c51bdefd8..62e89c5478 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h @@ -76,9 +76,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i // [range.iter.op.advance] namespace ranges { -namespace __advance { - -struct __fn { +struct __advance { private: template <class _Ip> _LIBCPP_HIDE_FROM_ABI static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) { @@ -189,10 +187,8 @@ public: } }; -} // namespace __advance - inline namespace __cpo { -inline constexpr auto advance = __advance::__fn{}; +inline constexpr auto advance = __advance{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/bounded_iter.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/bounded_iter.h index b5dcfe515c..2a5322b5d2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/bounded_iter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/bounded_iter.h @@ -11,6 +11,8 @@ #define _LIBCPP___ITERATOR_BOUNDED_ITER_H #include <__assert> +#include <__compare/ordering.h> +#include <__compare/three_way_comparable.h> #include <__config> #include <__iterator/iterator_traits.h> #include <__memory/pointer_traits.h> @@ -201,10 +203,13 @@ public: operator==(___bounded_iter const& __x, ___bounded_iter const& __y) _NOEXCEPT { return __x.__current_ == __y.__current_; } + +#if _LIBCPP_STD_VER <= 17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool operator!=(___bounded_iter const& __x, ___bounded_iter const& __y) _NOEXCEPT { return __x.__current_ != __y.__current_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool operator<(___bounded_iter const& __x, ___bounded_iter const& __y) _NOEXCEPT { return __x.__current_ < __y.__current_; @@ -222,9 +227,28 @@ public: return __x.__current_ >= __y.__current_; } +#else + _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering + operator<=>(___bounded_iter const& __x, ___bounded_iter const& __y) noexcept { + if constexpr (three_way_comparable<_Iterator, strong_ordering>) { + return __x.__current_ <=> __y.__current_; + } else { + if (__x.__current_ < __y.__current_) + return strong_ordering::less; + + if (__x.__current_ == __y.__current_) + return strong_ordering::equal; + + return strong_ordering::greater; + } + } +#endif // _LIBCPP_STD_VER >= 20 + private: template <class> friend struct pointer_traits; + template <class, class> + friend struct ___bounded_iter; _Iterator __current_; // current iterator _Iterator __begin_, __end_; // valid range represented as [begin, end] }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/common_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/common_iterator.h index 199de2cc73..31fc8267e5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/common_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/common_iterator.h @@ -26,6 +26,7 @@ #include <__iterator/iterator_traits.h> #include <__iterator/readable_traits.h> #include <__memory/addressof.h> +#include <__type_traits/conditional.h> #include <__type_traits/is_pointer.h> #include <__utility/declval.h> #include <variant> @@ -235,7 +236,7 @@ public: return std::__unchecked_get<_Sent>(__x.__hold_) - std::__unchecked_get<_I2>(__y.__hold_); } - _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> + _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) iter_move(const common_iterator& __i) noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>()))) requires input_iterator<_Iter> { diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h index afb7b821a9..1c227933a4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h @@ -26,7 +26,6 @@ #include <__concepts/semiregular.h> #include <__concepts/totally_ordered.h> #include <__config> -#include <__functional/invoke.h> #include <__iterator/incrementable_traits.h> #include <__iterator/iter_move.h> #include <__iterator/iterator_traits.h> @@ -34,7 +33,10 @@ #include <__memory/pointer_traits.h> #include <__type_traits/add_pointer.h> #include <__type_traits/common_reference.h> +#include <__type_traits/integral_constant.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_pointer.h> +#include <__type_traits/is_primary_template.h> #include <__type_traits/is_reference.h> #include <__type_traits/remove_cv.h> #include <__type_traits/remove_cvref.h> @@ -64,8 +66,33 @@ concept __indirectly_readable_impl = template <class _In> concept indirectly_readable = __indirectly_readable_impl<remove_cvref_t<_In>>; +template <class _Tp> +using __projected_iterator_t = typename _Tp::__projected_iterator; + +template <class _Tp> +using __projected_projection_t = typename _Tp::__projected_projection; + +template <class _Tp> +concept __specialization_of_projected = requires { + typename __projected_iterator_t<_Tp>; + typename __projected_projection_t<_Tp>; +} && __is_primary_template<_Tp>::value; + +template <class _Tp> +struct __indirect_value_t_impl { + using type = iter_value_t<_Tp>&; +}; +template <__specialization_of_projected _Tp> +struct __indirect_value_t_impl<_Tp> { + using type = invoke_result_t<__projected_projection_t<_Tp>&, + typename __indirect_value_t_impl<__projected_iterator_t<_Tp>>::type>; +}; + +template <indirectly_readable _Tp> +using __indirect_value_t = typename __indirect_value_t_impl<_Tp>::type; + template <indirectly_readable _Tp> -using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, iter_value_t<_Tp>&>; +using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, __indirect_value_t<_Tp>>; // [iterator.concept.writable] template <class _Out, class _Tp> @@ -176,47 +203,46 @@ concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip // [indirectcallable.indirectinvocable] template <class _Fp, class _It> concept indirectly_unary_invocable = - indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, iter_value_t<_It>&> && - invocable<_Fp&, iter_reference_t<_It>> && invocable<_Fp&, iter_common_reference_t<_It>> && - common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>; + indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, __indirect_value_t<_It>> && + invocable<_Fp&, iter_reference_t<_It>> && + common_reference_with< invoke_result_t<_Fp&, __indirect_value_t<_It>>, + invoke_result_t<_Fp&, iter_reference_t<_It>>>; template <class _Fp, class _It> concept indirectly_regular_unary_invocable = - indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, iter_value_t<_It>&> && - regular_invocable<_Fp&, iter_reference_t<_It>> && regular_invocable<_Fp&, iter_common_reference_t<_It>> && - common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>; + indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, __indirect_value_t<_It>> && + regular_invocable<_Fp&, iter_reference_t<_It>> && + common_reference_with< invoke_result_t<_Fp&, __indirect_value_t<_It>>, + invoke_result_t<_Fp&, iter_reference_t<_It>>>; template <class _Fp, class _It> concept indirect_unary_predicate = - indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, iter_value_t<_It>&> && - predicate<_Fp&, iter_reference_t<_It>> && predicate<_Fp&, iter_common_reference_t<_It>>; + indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, __indirect_value_t<_It>> && + predicate<_Fp&, iter_reference_t<_It>>; template <class _Fp, class _It1, class _It2> concept indirect_binary_predicate = indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> && - predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && - predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && - predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && - predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && - predicate<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; + predicate<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> && + predicate<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> && + predicate<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> && + predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>; template <class _Fp, class _It1, class _It2 = _It1> concept indirect_equivalence_relation = indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> && - equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && - equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && - equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && - equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && - equivalence_relation<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; + equivalence_relation<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> && + equivalence_relation<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> && + equivalence_relation<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> && + equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>; template <class _Fp, class _It1, class _It2 = _It1> concept indirect_strict_weak_order = indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> && - strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && - strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && - strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && - strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && - strict_weak_order<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; + strict_weak_order<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> && + strict_weak_order<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> && + strict_weak_order<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> && + strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>; template <class _Fp, class... _Its> requires(indirectly_readable<_Its> && ...) && invocable<_Fp, iter_reference_t<_Its>...> diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/counted_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/counted_iterator.h index ea2832e3b9..d461427cce 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/counted_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/counted_iterator.h @@ -11,6 +11,7 @@ #define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H #include <__assert> +#include <__compare/ordering.h> #include <__concepts/assignable.h> #include <__concepts/common_with.h> #include <__concepts/constructible.h> @@ -28,7 +29,6 @@ #include <__type_traits/add_pointer.h> #include <__type_traits/conditional.h> #include <__utility/move.h> -#include <compare> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -249,7 +249,7 @@ public: return __rhs.__count_ <=> __lhs.__count_; } - _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> + _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) iter_move(const counted_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__current_))) requires input_iterator<_Iter> { diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/distance.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/distance.h index 75bd49c9ae..1732aa527f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/distance.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/distance.h @@ -52,9 +52,7 @@ distance(_InputIter __first, _InputIter __last) { // [range.iter.op.distance] namespace ranges { -namespace __distance { - -struct __fn { +struct __distance { template <class _Ip, sentinel_for<_Ip> _Sp> requires(!sized_sentinel_for<_Sp, _Ip>) _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const { @@ -85,10 +83,8 @@ struct __fn { } }; -} // namespace __distance - inline namespace __cpo { -inline constexpr auto distance = __distance::__fn{}; +inline constexpr auto distance = __distance{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator_traits.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator_traits.h index 11af9e3018..4d9ad480cc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/iterator_traits.h @@ -24,6 +24,8 @@ #include <__type_traits/common_reference.h> #include <__type_traits/conditional.h> #include <__type_traits/disjunction.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_convertible.h> #include <__type_traits/is_object.h> #include <__type_traits/is_primary_template.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h index 5d9095622f..0ee3b300b1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h @@ -41,9 +41,7 @@ next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = // [range.iter.op.next] namespace ranges { -namespace __next { - -struct __fn { +struct __next { template <input_or_output_iterator _Ip> _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const { ++__x; @@ -69,10 +67,8 @@ struct __fn { } }; -} // namespace __next - inline namespace __cpo { -inline constexpr auto next = __next::__fn{}; +inline constexpr auto next = __next{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/ostreambuf_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/ostreambuf_iterator.h index dda0094dc3..401b6f3f23 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/ostreambuf_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/ostreambuf_iterator.h @@ -11,10 +11,13 @@ #define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H #include <__config> +#include <__fwd/ios.h> +#include <__fwd/ostream.h> +#include <__fwd/streambuf.h> #include <__iterator/iterator.h> #include <__iterator/iterator_traits.h> #include <cstddef> -#include <iosfwd> // for forward declaration of basic_streambuf +#include <iosfwd> // for forward declaration of ostreambuf_iterator #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h index 333939c091..9a38b67b85 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h @@ -40,9 +40,7 @@ prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = // [range.iter.op.prev] namespace ranges { -namespace __prev { - -struct __fn { +struct __prev { template <bidirectional_iterator _Ip> _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const { --__x; @@ -62,10 +60,8 @@ struct __fn { } }; -} // namespace __prev - inline namespace __cpo { -inline constexpr auto prev = __prev::__fn{}; +inline constexpr auto prev = __prev{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h index 463d07b0d3..1c560ec055 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h @@ -26,6 +26,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _It, class _Proj> struct __projected_impl { struct __type { + using __primary_template = __type; + using __projected_iterator = _It; + using __projected_projection = _Proj; + using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>; indirect_result_t<_Proj&, _It> operator*() const; // not defined }; @@ -34,6 +38,10 @@ struct __projected_impl { template <weakly_incrementable _It, class _Proj> struct __projected_impl<_It, _Proj> { struct __type { + using __primary_template = __type; + using __projected_iterator = _It; + using __projected_projection = _Proj; + using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>; using difference_type = iter_difference_t<_It>; indirect_result_t<_Proj&, _It> operator*() const; // not defined diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h index 252d13b26c..549d8ff2db 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h @@ -10,11 +10,14 @@ #ifndef _LIBCPP___ITERATOR_WRAP_ITER_H #define _LIBCPP___ITERATOR_WRAP_ITER_H +#include <__compare/ordering.h> +#include <__compare/three_way_comparable.h> #include <__config> #include <__iterator/iterator_traits.h> #include <__memory/addressof.h> #include <__memory/pointer_traits.h> #include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_convertible.h> #include <cstddef> @@ -131,6 +134,7 @@ operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC return __x.base() < __y.base(); } +#if _LIBCPP_STD_VER <= 17 template <class _Iter1> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { @@ -142,7 +146,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { return !(__x == __y); } - template <class _Iter1> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { @@ -179,6 +182,24 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX return !(__y < __x); } +#else +template <class _Iter1, class _Iter2> +_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering +operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept { + if constexpr (three_way_comparable_with<_Iter1, _Iter2, strong_ordering>) { + return __x.base() <=> __y.base(); + } else { + if (__x.base() < __y.base()) + return strong_ordering::less; + + if (__x.base() == __y.base()) + return strong_ordering::equal; + + return strong_ordering::greater; + } +} +#endif // _LIBCPP_STD_VER >= 20 + template <class _Iter1, class _Iter2> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 #ifndef _LIBCPP_CXX03_LANG diff --git a/contrib/libs/cxxsupp/libcxx/include/__locale_dir/locale_base_api/ibm.h b/contrib/libs/cxxsupp/libcxx/include/__locale_dir/locale_base_api/ibm.h index 01af201944..fa3bc1c363 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__locale_dir/locale_base_api/ibm.h +++ b/contrib/libs/cxxsupp/libcxx/include/__locale_dir/locale_base_api/ibm.h @@ -82,7 +82,7 @@ strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) { inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) { const size_t buff_size = 256; - if ((*strp = (char*)malloc(buff_size)) == NULL) { + if ((*strp = (char*)malloc(buff_size)) == nullptr) { return -1; } @@ -97,7 +97,7 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char va_end(ap_copy); if ((size_t)str_size >= buff_size) { - if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) { + if ((*strp = (char*)realloc(*strp, str_size + 1)) == nullptr) { return -1; } str_size = vsnprintf(*strp, str_size + 1, fmt, ap); diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/abs.h b/contrib/libs/cxxsupp/libcxx/include/__math/abs.h index ab82a2800f..fc3bf3a2c7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__math/abs.h +++ b/contrib/libs/cxxsupp/libcxx/include/__math/abs.h @@ -23,19 +23,19 @@ namespace __math { // fabs -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { return __builtin_fabs(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT { return __builtin_fabsl(__x); } template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT { return __builtin_fabs((double)__x); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/copysign.h b/contrib/libs/cxxsupp/libcxx/include/__math/copysign.h index b38690bb58..c3ca6a3b03 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__math/copysign.h +++ b/contrib/libs/cxxsupp/libcxx/include/__math/copysign.h @@ -13,7 +13,6 @@ #include <__type_traits/enable_if.h> #include <__type_traits/is_arithmetic.h> #include <__type_traits/promote.h> -#include <limits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -25,16 +24,16 @@ namespace __math { // copysign -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { return ::__builtin_copysignf(__x, __y); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { return ::__builtin_copysignl(__x, __y); } template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type copysign(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type copysign(_A1 __x, _A2 __y) _NOEXCEPT { return ::__builtin_copysign(__x, __y); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/hypot.h b/contrib/libs/cxxsupp/libcxx/include/__math/hypot.h index 1bf193a9ab..b2bf8e11c8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__math/hypot.h +++ b/contrib/libs/cxxsupp/libcxx/include/__math/hypot.h @@ -10,15 +10,23 @@ #define _LIBCPP___MATH_HYPOT_H #include <__config> +#include <__math/abs.h> +#include <__math/exponential_functions.h> +#include <__math/min_max.h> +#include <__math/roots.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_arithmetic.h> #include <__type_traits/is_same.h> #include <__type_traits/promote.h> +#include <limits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD namespace __math { @@ -41,8 +49,60 @@ inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type hypot(_A1 __x, _ return __math::hypot((__result_type)__x, (__result_type)__y); } +#if _LIBCPP_STD_VER >= 17 +// Computes the three-dimensional hypotenuse: `std::hypot(x,y,z)`. +// The naive implementation might over-/underflow which is why this implementation is more involved: +// If the square of an argument might run into issues, we scale the arguments appropriately. +// See https://github.com/llvm/llvm-project/issues/92782 for a detailed discussion and summary. +template <class _Real> +_LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) { + // Factors needed to determine if over-/underflow might happen + constexpr int __exp = std::numeric_limits<_Real>::max_exponent / 2; + const _Real __overflow_threshold = __math::ldexp(_Real(1), __exp); + const _Real __overflow_scale = __math::ldexp(_Real(1), -(__exp + 20)); + + // Scale arguments depending on their size + const _Real __max_abs = __math::fmax(__math::fabs(__x), __math::fmax(__math::fabs(__y), __math::fabs(__z))); + _Real __scale; + if (__max_abs > __overflow_threshold) { // x*x + y*y + z*z might overflow + __scale = __overflow_scale; + } else if (__max_abs < 1 / __overflow_threshold) { // x*x + y*y + z*z might underflow + __scale = 1 / __overflow_scale; + } else { + __scale = 1; + } + __x *= __scale; + __y *= __scale; + __z *= __scale; + + // Compute hypot of scaled arguments and undo scaling + return __math::sqrt(__x * __x + __y * __y + __z * __z) / __scale; +} + +inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y, float __z) { return __math::__hypot(__x, __y, __z); } + +inline _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y, double __z) { return __math::__hypot(__x, __y, __z); } + +inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y, long double __z) { + return __math::__hypot(__x, __y, __z); +} + +template <class _A1, + class _A2, + class _A3, + std::enable_if_t< is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>, int> = 0 > +_LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type hypot(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2, _A3>::type; + static_assert(!( + std::is_same_v<_A1, __result_type> && std::is_same_v<_A2, __result_type> && std::is_same_v<_A3, __result_type>)); + return __math::__hypot( + static_cast<__result_type>(__x), static_cast<__result_type>(__y), static_cast<__result_type>(__z)); +} +#endif + } // namespace __math _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS #endif // _LIBCPP___MATH_HYPOT_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/min_max.h b/contrib/libs/cxxsupp/libcxx/include/__math/min_max.h index 27997b4491..db900c849e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__math/min_max.h +++ b/contrib/libs/cxxsupp/libcxx/include/__math/min_max.h @@ -25,21 +25,21 @@ namespace __math { // fmax -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { return __builtin_fmaxf(__x, __y); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { return __builtin_fmax(__x, __y); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT { return __builtin_fmaxl(__x, __y); } template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT { using __result_type = typename __promote<_A1, _A2>::type; static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); return __math::fmax((__result_type)__x, (__result_type)__y); @@ -47,21 +47,21 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::typ // fmin -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT { return __builtin_fminf(__x, __y); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { return __builtin_fmin(__x, __y); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT { return __builtin_fminl(__x, __y); } template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT { using __result_type = typename __promote<_A1, _A2>::type; static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); return __math::fmin((__result_type)__x, (__result_type)__y); diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/remainder.h b/contrib/libs/cxxsupp/libcxx/include/__math/remainder.h index 0fbf0b8ef9..0adb7f3af5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__math/remainder.h +++ b/contrib/libs/cxxsupp/libcxx/include/__math/remainder.h @@ -14,7 +14,6 @@ #include <__type_traits/is_arithmetic.h> #include <__type_traits/is_same.h> #include <__type_traits/promote.h> -#include <limits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/roots.h b/contrib/libs/cxxsupp/libcxx/include/__math/roots.h index 359fd747cf..cef376fb00 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__math/roots.h +++ b/contrib/libs/cxxsupp/libcxx/include/__math/roots.h @@ -39,19 +39,19 @@ inline _LIBCPP_HIDE_FROM_ABI double sqrt(_A1 __x) _NOEXCEPT { // cbrt -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { return __builtin_cbrt(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT { return __builtin_cbrtl(__x); } template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT { return __builtin_cbrt((double)__x); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/rounding_functions.h b/contrib/libs/cxxsupp/libcxx/include/__math/rounding_functions.h index f7246ba7fe..474f585a62 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__math/rounding_functions.h +++ b/contrib/libs/cxxsupp/libcxx/include/__math/rounding_functions.h @@ -26,37 +26,37 @@ namespace __math { // ceil -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { return __builtin_ceil(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT { return __builtin_ceill(__x); } template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT { return __builtin_ceil((double)__x); } // floor -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { return __builtin_floor(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT { return __builtin_floorl(__x); } template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT { return __builtin_floor((double)__x); } @@ -126,21 +126,21 @@ inline _LIBCPP_HIDE_FROM_ABI long lround(_A1 __x) _NOEXCEPT { // nearbyint -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT { return __builtin_nearbyintf(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { return __builtin_nearbyint(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT { return __builtin_nearbyintl(__x); } template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT { return __builtin_nearbyint((double)__x); } @@ -186,55 +186,55 @@ inline _LIBCPP_HIDE_FROM_ABI double nexttoward(_A1 __x, long double __y) _NOEXCE // rint -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { return __builtin_rint(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT { return __builtin_rintl(__x); } template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT { return __builtin_rint((double)__x); } // round -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { return __builtin_round(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT { return __builtin_roundl(__x); } template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT { return __builtin_round((double)__x); } // trunc -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_trunc(__x); } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_trunc(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { return __builtin_trunc(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT { return __builtin_truncl(__x); } template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT { return __builtin_trunc((double)__x); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/special_functions.h b/contrib/libs/cxxsupp/libcxx/include/__math/special_functions.h new file mode 100644 index 0000000000..0b1c753a65 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/special_functions.h @@ -0,0 +1,84 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_SPECIAL_FUNCTIONS_H +#define _LIBCPP___MATH_SPECIAL_FUNCTIONS_H + +#include <__config> +#include <__math/copysign.h> +#include <__math/traits.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> +#include <limits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 17 + +template <class _Real> +_LIBCPP_HIDE_FROM_ABI _Real __hermite(unsigned __n, _Real __x) { + // The Hermite polynomial H_n(x). + // The implementation is based on the recurrence formula: H_{n+1}(x) = 2x H_n(x) - 2n H_{n-1}. + // Press, William H., et al. Numerical recipes 3rd edition: The art of scientific computing. + // Cambridge university press, 2007, p. 183. + + // NOLINTBEGIN(readability-identifier-naming) + if (__math::isnan(__x)) + return __x; + + _Real __H_0{1}; + if (__n == 0) + return __H_0; + + _Real __H_n_prev = __H_0; + _Real __H_n = 2 * __x; + for (unsigned __i = 1; __i < __n; ++__i) { + _Real __H_n_next = 2 * (__x * __H_n - __i * __H_n_prev); + __H_n_prev = __H_n; + __H_n = __H_n_next; + } + + if (!__math::isfinite(__H_n)) { + // Overflow occured. Two possible cases: + // n is odd: return infinity of the same sign as x. + // n is even: return +Inf + _Real __inf = std::numeric_limits<_Real>::infinity(); + return (__n & 1) ? __math::copysign(__inf, __x) : __inf; + } + return __H_n; + // NOLINTEND(readability-identifier-naming) +} + +inline _LIBCPP_HIDE_FROM_ABI double hermite(unsigned __n, double __x) { return std::__hermite(__n, __x); } + +inline _LIBCPP_HIDE_FROM_ABI float hermite(unsigned __n, float __x) { + // use double internally -- float is too prone to overflow! + return static_cast<float>(std::hermite(__n, static_cast<double>(__x))); +} + +inline _LIBCPP_HIDE_FROM_ABI long double hermite(unsigned __n, long double __x) { return std::__hermite(__n, __x); } + +inline _LIBCPP_HIDE_FROM_ABI float hermitef(unsigned __n, float __x) { return std::hermite(__n, __x); } + +inline _LIBCPP_HIDE_FROM_ABI long double hermitel(unsigned __n, long double __x) { return std::hermite(__n, __x); } + +template <class _Integer, std::enable_if_t<std::is_integral_v<_Integer>, int> = 0> +_LIBCPP_HIDE_FROM_ABI double hermite(unsigned __n, _Integer __x) { + return std::hermite(__n, static_cast<double>(__x)); +} + +#endif // _LIBCPP_STD_VER >= 17 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_SPECIAL_FUNCTIONS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/traits.h b/contrib/libs/cxxsupp/libcxx/include/__math/traits.h index 9fdf4096b2..4ce554ddbe 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__math/traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__math/traits.h @@ -12,11 +12,9 @@ #include <__config> #include <__type_traits/enable_if.h> #include <__type_traits/is_arithmetic.h> -#include <__type_traits/is_floating_point.h> #include <__type_traits/is_integral.h> #include <__type_traits/is_signed.h> #include <__type_traits/promote.h> -#include <limits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -28,103 +26,131 @@ namespace __math { // signbit -template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { +// TODO(LLVM 22): Remove conditional once support for Clang 19 is dropped. +#if defined(_LIBCPP_COMPILER_GCC) || __has_constexpr_builtin(__builtin_signbit) +# define _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_CONSTEXPR_SINCE_CXX23 +#else +# define _LIBCPP_SIGNBIT_CONSTEXPR +#endif + +// The universal C runtime (UCRT) in the WinSDK provides floating point overloads +// for std::signbit(). By defining our overloads as templates, we can work around +// this issue as templates are less preferred than non-template functions. +template <class = void> +[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(float __x) _NOEXCEPT { + return __builtin_signbit(__x); +} + +template <class = void> +[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(double __x) _NOEXCEPT { + return __builtin_signbit(__x); +} + +template <class = void> +[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(long double __x) _NOEXCEPT { return __builtin_signbit(__x); } template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { return __x < 0; } template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { return false; } // isfinite -template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT { - return __builtin_isfinite((typename __promote<_A1>::type)__x); +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { + return true; } -template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { - return true; +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(float __x) _NOEXCEPT { + return __builtin_isfinite(__x); } -// isinf +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(double __x) _NOEXCEPT { + return __builtin_isfinite(__x); +} -template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT { - return __builtin_isinf((typename __promote<_A1>::type)__x); +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(long double __x) _NOEXCEPT { + return __builtin_isfinite(__x); } -template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT { +// isinf + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT { return false; } -#ifdef _LIBCPP_PREFERRED_OVERLOAD && !defined(__CUDACC__) -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { return __builtin_isinf(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool -isinf(double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI +#ifdef _LIBCPP_PREFERRED_OVERLOAD && !defined(__CUDACC__) +_LIBCPP_PREFERRED_OVERLOAD +#endif + bool + isinf(double __x) _NOEXCEPT { return __builtin_isinf(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __builtin_isinf(__x); } -#endif // isnan -template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT { - return __builtin_isnan(__x); -} - template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { return false; } -#ifdef _LIBCPP_PREFERRED_OVERLOAD && !defined(__CUDACC__) -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { return __builtin_isnan(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool -isnan(double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI +#ifdef _LIBCPP_PREFERRED_OVERLOAD && !defined(__CUDACC__) +_LIBCPP_PREFERRED_OVERLOAD +#endif + bool + isnan(double __x) _NOEXCEPT { return __builtin_isnan(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __builtin_isnan(__x); } -#endif // isnormal -template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { + return __x != 0; +} + +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(float __x) _NOEXCEPT { return __builtin_isnormal(__x); } -template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { - return __x != 0; +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(double __x) _NOEXCEPT { + return __builtin_isnormal(__x); +} + +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(long double __x) _NOEXCEPT { + return __builtin_isnormal(__x); } // isgreater template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { using type = typename __promote<_A1, _A2>::type; return __builtin_isgreater((type)__x, (type)__y); } @@ -132,7 +158,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) // isgreaterequal template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { using type = typename __promote<_A1, _A2>::type; return __builtin_isgreaterequal((type)__x, (type)__y); } @@ -140,7 +166,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 // isless template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { using type = typename __promote<_A1, _A2>::type; return __builtin_isless((type)__x, (type)__y); } @@ -148,7 +174,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NO // islessequal template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { using type = typename __promote<_A1, _A2>::type; return __builtin_islessequal((type)__x, (type)__y); } @@ -156,7 +182,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y // islessgreater template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { using type = typename __promote<_A1, _A2>::type; return __builtin_islessgreater((type)__x, (type)__y); } @@ -164,7 +190,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 _ // isunordered template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { using type = typename __promote<_A1, _A2>::type; return __builtin_isunordered((type)__x, (type)__y); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__mdspan/extents.h b/contrib/libs/cxxsupp/libcxx/include/__mdspan/extents.h index fea0decd8c..3d2c2771a8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__mdspan/extents.h +++ b/contrib/libs/cxxsupp/libcxx/include/__mdspan/extents.h @@ -19,6 +19,8 @@ #include <__assert> #include <__config> + +#include <__concepts/arithmetic.h> #include <__type_traits/common_type.h> #include <__type_traits/is_convertible.h> #include <__type_traits/is_nothrow_constructible.h> @@ -282,8 +284,7 @@ public: using size_type = make_unsigned_t<index_type>; using rank_type = size_t; - static_assert(is_integral<index_type>::value && !is_same<index_type, bool>::value, - "extents::index_type must be a signed or unsigned integer type"); + static_assert(__libcpp_integer<index_type>, "extents::index_type must be a signed or unsigned integer type"); static_assert(((__mdspan_detail::__is_representable_as<index_type>(_Extents) || (_Extents == dynamic_extent)) && ...), "extents ctor: arguments must be representable as index_type and nonnegative"); @@ -448,12 +449,18 @@ struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> { using type = extents<_IndexType, _ExtentsPack...>; }; -} // end namespace __mdspan_detail +} // namespace __mdspan_detail // [mdspan.extents.dextents], alias template template <class _IndexType, size_t _Rank> using dextents = typename __mdspan_detail::__make_dextents<_IndexType, _Rank>::type; +# if _LIBCPP_STD_VER >= 26 +// [mdspan.extents.dims], alias template `dims` +template <size_t _Rank, class _IndexType = size_t> +using dims = dextents<_IndexType, _Rank>; +# endif + // Deduction guide for extents # if _LIBCPP_STD_VER >= 26 template <class... _IndexTypes> diff --git a/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_left.h b/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_left.h index d058cbccff..59574e83b0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_left.h +++ b/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_left.h @@ -21,6 +21,7 @@ #include <__config> #include <__fwd/mdspan.h> #include <__mdspan/extents.h> +#include <__type_traits/common_type.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_convertible.h> #include <__type_traits/is_nothrow_constructible.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_right.h b/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_right.h index 6842e9dc37..d1acdb4123 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_right.h +++ b/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_right.h @@ -21,6 +21,7 @@ #include <__config> #include <__fwd/mdspan.h> #include <__mdspan/extents.h> +#include <__type_traits/common_type.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_convertible.h> #include <__type_traits/is_nothrow_constructible.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_stride.h b/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_stride.h index 86148ac849..c57f596431 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_stride.h +++ b/contrib/libs/cxxsupp/libcxx/include/__mdspan/layout_stride.h @@ -18,12 +18,16 @@ #define _LIBCPP___MDSPAN_LAYOUT_STRIDE_H #include <__assert> +#include <__concepts/same_as.h> #include <__config> #include <__fwd/mdspan.h> #include <__mdspan/extents.h> +#include <__type_traits/common_type.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_convertible.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/is_same.h> #include <__utility/as_const.h> #include <__utility/integer_sequence.h> #include <__utility/swap.h> @@ -31,6 +35,7 @@ #include <cinttypes> #include <cstddef> #include <limits> +#include <span> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocate_at_least.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocate_at_least.h index df73d9a2e9..a10e4fbaea 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocate_at_least.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocate_at_least.h @@ -35,7 +35,7 @@ struct __allocation_result { }; template <class _Alloc> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __allocation_result<typename allocator_traits<_Alloc>::pointer> __allocate_at_least(_Alloc& __alloc, size_t __n) { return {__alloc.allocate(__n), __n}; diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h index c276b4542e..e100e45633 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h @@ -47,23 +47,7 @@ public: typedef allocator<_Up> other; }; }; - -// TODO(LLVM 20): Remove the escape hatch -# ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST -template <> -class _LIBCPP_TEMPLATE_VIS allocator<const void> { -public: - _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer; - _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; - _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type; - - template <class _Up> - struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { - typedef allocator<_Up> other; - }; -}; -# endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST -#endif // _LIBCPP_STD_VER <= 17 +#endif // _LIBCPP_STD_VER <= 17 // This class provides a non-trivial default constructor to the class that derives from it // if the condition is satisfied. @@ -109,7 +93,8 @@ public: template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {} - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) { + static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type"); if (__n > allocator_traits<allocator>::max_size(*this)) __throw_bad_array_new_length(); if (__libcpp_is_constant_evaluated()) { @@ -121,6 +106,7 @@ public: #if _LIBCPP_STD_VER >= 23 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<_Tp*> allocate_at_least(size_t __n) { + static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type"); return {allocate(__n), __n}; } #endif @@ -152,7 +138,7 @@ public: return std::addressof(__x); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 _Tp* allocate(size_t __n, const void*) { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 _Tp* allocate(size_t __n, const void*) { return allocate(__n); } @@ -169,85 +155,6 @@ public: #endif }; -// TODO(LLVM 20): Remove the escape hatch -#ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST -template <class _Tp> -class _LIBCPP_TEMPLATE_VIS allocator<const _Tp> - : private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> > { - static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); - -public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef const _Tp value_type; - typedef true_type propagate_on_container_move_assignment; -# if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS) - _LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal; -# endif - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default; - - template <class _Up> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {} - - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const _Tp* allocate(size_t __n) { - if (__n > allocator_traits<allocator>::max_size(*this)) - __throw_bad_array_new_length(); - if (__libcpp_is_constant_evaluated()) { - return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp))); - } else { - return static_cast<const _Tp*>(std::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); - } - } - -# if _LIBCPP_STD_VER >= 23 - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<const _Tp*> allocate_at_least(size_t __n) { - return {allocate(__n), __n}; - } -# endif - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void deallocate(const _Tp* __p, size_t __n) { - if (__libcpp_is_constant_evaluated()) { - ::operator delete(const_cast<_Tp*>(__p)); - } else { - std::__libcpp_deallocate((void*)const_cast<_Tp*>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); - } - } - - // C++20 Removed members -# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer; - _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; - _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference; - _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference; - - template <class _Up> - struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { - typedef allocator<_Up> other; - }; - - _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI const_pointer address(const_reference __x) const _NOEXCEPT { - return std::addressof(__x); - } - - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 const _Tp* allocate(size_t __n, const void*) { - return allocate(__n); - } - - _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { - return size_type(~0) / sizeof(_Tp); - } - - template <class _Up, class... _Args> - _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void construct(_Up* __p, _Args&&... __args) { - ::new ((void*)__p) _Up(std::forward<_Args>(__args)...); - } - - _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void destroy(pointer __p) { __p->~_Tp(); } -# endif -}; -#endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST - template <class _Tp, class _Up> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT { @@ -263,6 +170,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const allocator<_Tp>&, const alloca #endif +#include <__memory/allocator_const.h> + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___MEMORY_ALLOCATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_const.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_const.h new file mode 100644 index 0000000000..e8fa49fd18 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_const.h @@ -0,0 +1,79 @@ +// kept old implementation + +#ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST +template <class _Tp> +class _LIBCPP_TEMPLATE_VIS allocator<const _Tp> + : private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> > { + static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); + +public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef const _Tp value_type; + typedef true_type propagate_on_container_move_assignment; +# if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS) + _LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal; +# endif + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default; + + template <class _Up> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {} + + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const _Tp* allocate(size_t __n) { + if (__n > allocator_traits<allocator>::max_size(*this)) + __throw_bad_array_new_length(); + if (__libcpp_is_constant_evaluated()) { + return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp))); + } else { + return static_cast<const _Tp*>(std::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); + } + } + +# if _LIBCPP_STD_VER >= 23 + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<const _Tp*> allocate_at_least(size_t __n) { + return {allocate(__n), __n}; + } +# endif + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void deallocate(const _Tp* __p, size_t __n) { + if (__libcpp_is_constant_evaluated()) { + ::operator delete(const_cast<_Tp*>(__p)); + } else { + std::__libcpp_deallocate((void*)const_cast<_Tp*>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); + } + } + + // C++20 Removed members +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference; + + template <class _Up> + struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { + typedef allocator<_Up> other; + }; + + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI const_pointer address(const_reference __x) const _NOEXCEPT { + return std::addressof(__x); + } + + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 const _Tp* allocate(size_t __n, const void*) { + return allocate(__n); + } + + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { + return size_type(~0) / sizeof(_Tp); + } + + template <class _Up, class... _Args> + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void construct(_Up* __p, _Args&&... __args) { + ::new ((void*)__p) _Up(std::forward<_Args>(__args)...); + } + + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void destroy(pointer __p) { __p->~_Tp(); } +# endif +}; +#endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
\ No newline at end of file diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h index ac564f0e6f..f4d9679807 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h @@ -11,6 +11,7 @@ #define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H #include <__config> +#include <__fwd/memory.h> #include <__memory/construct_at.h> #include <__memory/pointer_traits.h> #include <__type_traits/enable_if.h> @@ -41,7 +42,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD struct NAME<_Tp, __void_t<typename _Tp::PROPERTY > > : true_type {} // __pointer -_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_pointer, pointer); template <class _Tp, class _Alloc, class _RawAlloc = __libcpp_remove_reference_t<_Alloc>, @@ -276,13 +276,13 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { }; #endif // _LIBCPP_CXX03_LANG - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer allocate(allocator_type& __a, size_type __n) { return __a.allocate(__n); } template <class _Ap = _Alloc, __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0> - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) { _LIBCPP_SUPPRESS_DEPRECATED_PUSH return __a.allocate(__n, __hint); @@ -291,7 +291,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { template <class _Ap = _Alloc, class = void, __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0> - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer) { return __a.allocate(__n); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/array_cookie.h b/contrib/libs/cxxsupp/libcxx/include/__memory/array_cookie.h new file mode 100644 index 0000000000..34eec64320 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/array_cookie.h @@ -0,0 +1,55 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MEMORY_ARRAY_COOKIE_H +#define _LIBCPP___MEMORY_ARRAY_COOKIE_H + +#include <__config> +#include <__configuration/abi.h> +#include <__type_traits/integral_constant.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__type_traits/negation.h> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// Trait representing whether a type requires an array cookie at the start of its allocation when +// allocated as `new T[n]` and deallocated as `delete array`. +// +// Under the Itanium C++ ABI [1], we know that an array cookie is available unless `T` is trivially +// destructible and the call to `operator delete[]` is not a sized operator delete. Under ABIs other +// than the Itanium ABI, we assume there are no array cookies. +// +// [1]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#array-cookies +#ifdef _LIBCPP_ABI_ITANIUM +// TODO: Use a builtin instead +// TODO: We should factor in the choice of the usual deallocation function in this determination. +template <class _Tp> +struct __has_array_cookie : _Not<is_trivially_destructible<_Tp> > {}; +#else +template <class _Tp> +struct __has_array_cookie : false_type {}; +#endif + +template <class _Tp> +// Avoid failures when -fsanitize-address-poison-custom-array-cookie is enabled +_LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") size_t __get_array_cookie(_Tp const* __ptr) { + static_assert( + __has_array_cookie<_Tp>::value, "Trying to access the array cookie of a type that is not guaranteed to have one"); + size_t const* __cookie = reinterpret_cast<size_t const*>(__ptr) - 1; // TODO: Use a builtin instead + return *__cookie; +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MEMORY_ARRAY_COOKIE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h b/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h index 526eb3334f..c7ba2a99c7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <size_t _Np, class _Tp> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __assume_aligned(_Tp* __ptr) { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __assume_aligned(_Tp* __ptr) { static_assert(_Np != 0 && (_Np & (_Np - 1)) == 0, "std::assume_aligned<N>(p) requires N to be a power of two"); if (__libcpp_is_constant_evaluated()) { diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/compressed_pair.h b/contrib/libs/cxxsupp/libcxx/include/__memory/compressed_pair.h index 40e5cfc35f..629e3ad884 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/compressed_pair.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/compressed_pair.h @@ -11,161 +11,80 @@ #define _LIBCPP___MEMORY_COMPRESSED_PAIR_H #include <__config> -#include <__fwd/tuple.h> -#include <__tuple/tuple_indices.h> -#include <__type_traits/decay.h> -#include <__type_traits/dependent_type.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_constructible.h> +#include <__type_traits/datasizeof.h> #include <__type_traits/is_empty.h> #include <__type_traits/is_final.h> -#include <__type_traits/is_same.h> -#include <__type_traits/is_swappable.h> -#include <__utility/forward.h> -#include <__utility/move.h> -#include <__utility/piecewise_construct.h> -#include <cstddef> +#include <__type_traits/is_reference.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - _LIBCPP_BEGIN_NAMESPACE_STD -// Tag used to default initialize one or both of the pair's elements. -struct __default_init_tag {}; -struct __value_init_tag {}; - -template <class _Tp, int _Idx, bool _CanBeEmptyBase = is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value> -struct __compressed_pair_elem { - using _ParamT = _Tp; - using reference = _Tp&; - using const_reference = const _Tp&; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_() {} - - template <class _Up, __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) - : __value_(std::forward<_Up>(__u)) {} - -#ifndef _LIBCPP_CXX03_LANG - template <class... _Args, size_t... _Indices> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit __compressed_pair_elem( - piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>) - : __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {} -#endif - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference __get() _NOEXCEPT { return __value_; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; } - -private: - _Tp __value_; -}; - -template <class _Tp, int _Idx> -struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { - using _ParamT = _Tp; - using reference = _Tp&; - using const_reference = const _Tp&; - using __value_type = _Tp; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem() = default; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_type() {} - - template <class _Up, __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) - : __value_type(std::forward<_Up>(__u)) {} - -#ifndef _LIBCPP_CXX03_LANG - template <class... _Args, size_t... _Indices> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 - __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>) - : __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {} -#endif - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference __get() _NOEXCEPT { return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; } -}; +// ================================================================================================================== // +// The utilites here are for staying ABI compatible with the legacy `__compressed_pair`. They should not be used // +// for new data structures. Use `_LIBCPP_NO_UNIQUE_ADDRESS` for new data structures instead (but make sure you // +// understand how it works). // +// ================================================================================================================== // -template <class _T1, class _T2> -class __compressed_pair : private __compressed_pair_elem<_T1, 0>, private __compressed_pair_elem<_T2, 1> { -public: - // NOTE: This static assert should never fire because __compressed_pair - // is *almost never* used in a scenario where it's possible for T1 == T2. - // (The exception is std::function where it is possible that the function - // object and the allocator have the same type). - static_assert( - (!is_same<_T1, _T2>::value), - "__compressed_pair cannot be instantiated when T1 and T2 are the same type; " - "The current implementation is NOT ABI-compatible with the previous implementation for this configuration"); - - using _Base1 _LIBCPP_NODEBUG = __compressed_pair_elem<_T1, 0>; - using _Base2 _LIBCPP_NODEBUG = __compressed_pair_elem<_T2, 1>; - - template <bool _Dummy = true, - __enable_if_t< __dependent_type<is_default_constructible<_T1>, _Dummy>::value && - __dependent_type<is_default_constructible<_T2>, _Dummy>::value, - int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair() - : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} - - template <class _U1, class _U2> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair(_U1&& __t1, _U2&& __t2) - : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {} - -#ifndef _LIBCPP_CXX03_LANG - template <class... _Args1, class... _Args2> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit __compressed_pair( - piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) - : _Base1(__pc, std::move(__first_args), typename __make_tuple_indices<sizeof...(_Args1)>::type()), - _Base2(__pc, std::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {} -#endif - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename _Base1::reference first() _NOEXCEPT { - return static_cast<_Base1&>(*this).__get(); - } - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename _Base1::const_reference first() const _NOEXCEPT { - return static_cast<_Base1 const&>(*this).__get(); - } - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename _Base2::reference second() _NOEXCEPT { - return static_cast<_Base2&>(*this).__get(); - } - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename _Base2::const_reference second() const _NOEXCEPT { - return static_cast<_Base2 const&>(*this).__get(); - } - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT { - return static_cast<_Base1*>(__pair); - } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT { - return static_cast<_Base2*>(__pair); - } - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(__compressed_pair& __x) - _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) { - using std::swap; - swap(first(), __x.first()); - swap(second(), __x.second()); - } +// The first member is aligned to the alignment of the second member to force padding in front of the compressed pair +// in case there are members before it. +// +// For example: +// (assuming x86-64 linux) +// class SomeClass { +// uint32_t member1; +// _LIBCPP_COMPRESSED_PAIR(uint32_t, member2, uint64_t, member3); +// } +// +// The layout with __compressed_pair is: +// member1 - offset: 0, size: 4 +// padding - offset: 4, size: 4 +// member2 - offset: 8, size: 4 +// padding - offset: 12, size: 4 +// member3 - offset: 16, size: 8 +// +// If the [[gnu::aligned]] wasn't there, the layout would instead be: +// member1 - offset: 0, size: 4 +// member2 - offset: 4, size: 4 +// member3 - offset: 8, size: 8 + +#ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING + +template <class _ToPad> +class __compressed_pair_padding { + char __padding_[((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || is_reference<_ToPad>::value) + ? 0 + : sizeof(_ToPad) - __datasizeof_v<_ToPad>]; }; -template <class _T1, class _T2> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void -swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) - _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) { - __x.swap(__y); -} +# define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ + _LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(_LIBCPP_ALIGNOF(T2)))) T1 Initializer1; \ + _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ + _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ + _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _) + +# define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \ + _LIBCPP_NO_UNIQUE_ADDRESS \ + __attribute__((__aligned__(_LIBCPP_ALIGNOF(T2)), __aligned__(_LIBCPP_ALIGNOF(T3)))) T1 Initializer1; \ + _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ + _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ + _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \ + _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \ + _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _) + +#else +# define _LIBCPP_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ + _LIBCPP_NO_UNIQUE_ADDRESS T1 Name1; \ + _LIBCPP_NO_UNIQUE_ADDRESS T2 Name2 + +# define _LIBCPP_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3) \ + _LIBCPP_NO_UNIQUE_ADDRESS T1 Name1; \ + _LIBCPP_NO_UNIQUE_ADDRESS T2 Name2; \ + _LIBCPP_NO_UNIQUE_ADDRESS T3 Name3 +#endif // _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING _LIBCPP_END_NAMESPACE_STD -_LIBCPP_POP_MACROS - #endif // _LIBCPP___MEMORY_COMPRESSED_PAIR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/inout_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/inout_ptr.h new file mode 100644 index 0000000000..b0e7593792 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/inout_ptr.h @@ -0,0 +1,110 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___INOUT_PTR_H +#define _LIBCPP___INOUT_PTR_H + +#include <__config> +#include <__memory/addressof.h> +#include <__memory/pointer_traits.h> +#include <__memory/shared_ptr.h> +#include <__memory/unique_ptr.h> +#include <__type_traits/is_pointer.h> +#include <__type_traits/is_same.h> +#include <__type_traits/is_specialization.h> +#include <__type_traits/is_void.h> +#include <__utility/forward.h> +#include <__utility/move.h> +#include <tuple> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 23 + +template <class _Smart, class _Pointer, class... _Args> +class _LIBCPP_TEMPLATE_VIS inout_ptr_t { + static_assert(!__is_specialization_v<_Smart, shared_ptr>, "std::shared_ptr<> is not supported with std::inout_ptr."); + +public: + _LIBCPP_HIDE_FROM_ABI explicit inout_ptr_t(_Smart& __smart, _Args... __args) + : __s_(__smart), __a_(std::forward<_Args>(__args)...), __p_([&__smart] { + if constexpr (is_pointer_v<_Smart>) { + return __smart; + } else { + return __smart.get(); + } + }()) { + if constexpr (requires { __s_.release(); }) { + __s_.release(); + } else { + __s_ = _Smart(); + } + } + + _LIBCPP_HIDE_FROM_ABI inout_ptr_t(const inout_ptr_t&) = delete; + + _LIBCPP_HIDE_FROM_ABI ~inout_ptr_t() { + // LWG-3897 inout_ptr will not update raw pointer to null + if constexpr (!is_pointer_v<_Smart>) { + if (!__p_) { + return; + } + } + + using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>; + if constexpr (is_pointer_v<_Smart>) { + std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); }, + std::move(__a_)); + } else if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) { + std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); }, + std::move(__a_)); + } else { + static_assert(is_constructible_v<_Smart, _SmartPtr, _Args...>, + "The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args..."); + std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); }, + std::move(__a_)); + } + } + + _LIBCPP_HIDE_FROM_ABI operator _Pointer*() const noexcept { return std::addressof(const_cast<_Pointer&>(__p_)); } + + _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept + requires(!is_same_v<_Pointer, void*>) + { + static_assert(is_pointer_v<_Pointer>, "The conversion to void** requires _Pointer to be a raw pointer."); + + return reinterpret_cast<void**>(static_cast<_Pointer*>(*this)); + } + +private: + _Smart& __s_; + tuple<_Args...> __a_; + _Pointer __p_; +}; + +template <class _Pointer = void, class _Smart, class... _Args> +_LIBCPP_HIDE_FROM_ABI auto inout_ptr(_Smart& __s, _Args&&... __args) { + using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>; + return std::inout_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...); +} + +#endif // _LIBCPP_STD_VER >= 23 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___INOUT_PTR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/noexcept_move_assign_container.h b/contrib/libs/cxxsupp/libcxx/include/__memory/noexcept_move_assign_container.h index baaf36d998..b0063516aa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/noexcept_move_assign_container.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/noexcept_move_assign_container.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H -#define _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H +#ifndef _LIBCPP___MEMORY_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H +#define _LIBCPP___MEMORY_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H #include <__config> #include <__memory/allocator_traits.h> @@ -34,4 +34,4 @@ struct __noexcept_move_assign_container _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H +#endif // _LIBCPP___MEMORY_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/out_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/out_ptr.h new file mode 100644 index 0000000000..030a4c3b0e --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/out_ptr.h @@ -0,0 +1,102 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___OUT_PTR_H +#define _LIBCPP___OUT_PTR_H + +#include <__config> +#include <__memory/addressof.h> +#include <__memory/pointer_traits.h> +#include <__memory/shared_ptr.h> +#include <__memory/unique_ptr.h> +#include <__type_traits/is_pointer.h> +#include <__type_traits/is_specialization.h> +#include <__type_traits/is_void.h> +#include <__utility/forward.h> +#include <__utility/move.h> +#include <tuple> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 23 + +template <class _Smart, class _Pointer, class... _Args> +class _LIBCPP_TEMPLATE_VIS out_ptr_t { + static_assert(!__is_specialization_v<_Smart, shared_ptr> || sizeof...(_Args) > 0, + "Using std::shared_ptr<> without a deleter in std::out_ptr is not supported."); + +public: + _LIBCPP_HIDE_FROM_ABI explicit out_ptr_t(_Smart& __smart, _Args... __args) + : __s_(__smart), __a_(std::forward<_Args>(__args)...), __p_() { + using _Ptr = decltype(__smart); + if constexpr (__resettable_smart_pointer<_Ptr>) { + __s_.reset(); + } else if constexpr (is_constructible_v<_Smart>) { + __s_ = _Smart(); + } else { + static_assert(__resettable_smart_pointer<_Ptr> || is_constructible_v<_Smart>, + "The adapted pointer type must have a reset() member function or be default constructible."); + } + } + + _LIBCPP_HIDE_FROM_ABI out_ptr_t(const out_ptr_t&) = delete; + + _LIBCPP_HIDE_FROM_ABI ~out_ptr_t() { + if (!__p_) { + return; + } + + using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>; + if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) { + std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); }, + std::move(__a_)); + } else { + static_assert(is_constructible_v<_Smart, _SmartPtr, _Args...>, + "The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args..."); + std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); }, + std::move(__a_)); + } + } + + _LIBCPP_HIDE_FROM_ABI operator _Pointer*() const noexcept { return std::addressof(const_cast<_Pointer&>(__p_)); } + + _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept + requires(!is_same_v<_Pointer, void*>) + { + static_assert(is_pointer_v<_Pointer>, "The conversion to void** requires _Pointer to be a raw pointer."); + + return reinterpret_cast<void**>(static_cast<_Pointer*>(*this)); + } + +private: + _Smart& __s_; + tuple<_Args...> __a_; + _Pointer __p_ = _Pointer(); +}; + +template <class _Pointer = void, class _Smart, class... _Args> +_LIBCPP_HIDE_FROM_ABI auto out_ptr(_Smart& __s, _Args&&... __args) { + using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>; + return std::out_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...); +} + +#endif // _LIBCPP_STD_VER >= 23 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___OUT_PTR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h b/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h index fcd2c3edd9..98961ddf97 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h @@ -15,24 +15,35 @@ #include <__type_traits/conditional.h> #include <__type_traits/conjunction.h> #include <__type_traits/decay.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_class.h> #include <__type_traits/is_function.h> #include <__type_traits/is_void.h> #include <__type_traits/void_t.h> #include <__utility/declval.h> +#include <__utility/forward.h> #include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Tp, class = void> -struct __has_element_type : false_type {}; +// clang-format off +#define _LIBCPP_CLASS_TRAITS_HAS_XXX(NAME, PROPERTY) \ + template <class _Tp, class = void> \ + struct NAME : false_type {}; \ + template <class _Tp> \ + struct NAME<_Tp, __void_t<typename _Tp::PROPERTY> > : true_type {} +// clang-format on -template <class _Tp> -struct __has_element_type<_Tp, __void_t<typename _Tp::element_type> > : true_type {}; +_LIBCPP_CLASS_TRAITS_HAS_XXX(__has_pointer, pointer); +_LIBCPP_CLASS_TRAITS_HAS_XXX(__has_element_type, element_type); template <class _Ptr, bool = __has_element_type<_Ptr>::value> struct __pointer_traits_element_type {}; @@ -240,6 +251,59 @@ to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) { } #endif +#if _LIBCPP_STD_VER >= 23 + +template <class _Tp> +struct __pointer_of {}; + +template <class _Tp> + requires(__has_pointer<_Tp>::value) +struct __pointer_of<_Tp> { + using type = typename _Tp::pointer; +}; + +template <class _Tp> + requires(!__has_pointer<_Tp>::value && __has_element_type<_Tp>::value) +struct __pointer_of<_Tp> { + using type = typename _Tp::element_type*; +}; + +template <class _Tp> + requires(!__has_pointer<_Tp>::value && !__has_element_type<_Tp>::value && + __has_element_type<pointer_traits<_Tp>>::value) +struct __pointer_of<_Tp> { + using type = typename pointer_traits<_Tp>::element_type*; +}; + +template <typename _Tp> +using __pointer_of_t = typename __pointer_of<_Tp>::type; + +template <class _Tp, class _Up> +struct __pointer_of_or { + using type _LIBCPP_NODEBUG = _Up; +}; + +template <class _Tp, class _Up> + requires requires { typename __pointer_of_t<_Tp>; } +struct __pointer_of_or<_Tp, _Up> { + using type _LIBCPP_NODEBUG = __pointer_of_t<_Tp>; +}; + +template <typename _Tp, typename _Up> +using __pointer_of_or_t = typename __pointer_of_or<_Tp, _Up>::type; + +template <class _Smart> +concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); }; + +template <class _Smart, class _Pointer, class... _Args> +concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p, _Args... __args) { + __s.reset(static_cast<__pointer_of_or_t<_Smart, _Pointer>>(__p), std::forward<_Args>(__args)...); +}; + +#endif + _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MEMORY_POINTER_TRAITS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_construct_at.h b/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_construct_at.h index f731e75e7b..b7523d4ba4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_construct_at.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_construct_at.h @@ -38,43 +38,33 @@ namespace ranges { // construct_at -namespace __construct_at { - -struct __fn { +struct __construct_at { template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))> _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator()(_Tp* __location, _Args&&... __args) const { return std::construct_at(__location, std::forward<_Args>(__args)...); } }; -} // namespace __construct_at - inline namespace __cpo { -inline constexpr auto construct_at = __construct_at::__fn{}; +inline constexpr auto construct_at = __construct_at{}; } // namespace __cpo // destroy_at -namespace __destroy_at { - -struct __fn { +struct __destroy_at { template <destructible _Tp> _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Tp* __location) const noexcept { std::destroy_at(__location); } }; -} // namespace __destroy_at - inline namespace __cpo { -inline constexpr auto destroy_at = __destroy_at::__fn{}; +inline constexpr auto destroy_at = __destroy_at{}; } // namespace __cpo // destroy -namespace __destroy { - -struct __fn { +struct __destroy { template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel> requires destructible<iter_value_t<_InputIterator>> _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept { @@ -88,17 +78,13 @@ struct __fn { } }; -} // namespace __destroy - inline namespace __cpo { -inline constexpr auto destroy = __destroy::__fn{}; +inline constexpr auto destroy = __destroy{}; } // namespace __cpo // destroy_n -namespace __destroy_n { - -struct __fn { +struct __destroy_n { template <__nothrow_input_iterator _InputIterator> requires destructible<iter_value_t<_InputIterator>> _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator @@ -107,10 +93,8 @@ struct __fn { } }; -} // namespace __destroy_n - inline namespace __cpo { -inline constexpr auto destroy_n = __destroy_n::__fn{}; +inline constexpr auto destroy_n = __destroy_n{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_uninitialized_algorithms.h b/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_uninitialized_algorithms.h index 90090055bb..4815ac6e5d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_uninitialized_algorithms.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_uninitialized_algorithms.h @@ -42,9 +42,7 @@ namespace ranges { // uninitialized_default_construct -namespace __uninitialized_default_construct { - -struct __fn { +struct __uninitialized_default_construct { template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel> requires default_initializable<iter_value_t<_ForwardIterator>> _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { @@ -59,17 +57,13 @@ struct __fn { } }; -} // namespace __uninitialized_default_construct - inline namespace __cpo { -inline constexpr auto uninitialized_default_construct = __uninitialized_default_construct::__fn{}; +inline constexpr auto uninitialized_default_construct = __uninitialized_default_construct{}; } // namespace __cpo // uninitialized_default_construct_n -namespace __uninitialized_default_construct_n { - -struct __fn { +struct __uninitialized_default_construct_n { template <__nothrow_forward_iterator _ForwardIterator> requires default_initializable<iter_value_t<_ForwardIterator>> _LIBCPP_HIDE_FROM_ABI _ForwardIterator @@ -79,17 +73,13 @@ struct __fn { } }; -} // namespace __uninitialized_default_construct_n - inline namespace __cpo { -inline constexpr auto uninitialized_default_construct_n = __uninitialized_default_construct_n::__fn{}; +inline constexpr auto uninitialized_default_construct_n = __uninitialized_default_construct_n{}; } // namespace __cpo // uninitialized_value_construct -namespace __uninitialized_value_construct { - -struct __fn { +struct __uninitialized_value_construct { template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel> requires default_initializable<iter_value_t<_ForwardIterator>> _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { @@ -104,17 +94,13 @@ struct __fn { } }; -} // namespace __uninitialized_value_construct - inline namespace __cpo { -inline constexpr auto uninitialized_value_construct = __uninitialized_value_construct::__fn{}; +inline constexpr auto uninitialized_value_construct = __uninitialized_value_construct{}; } // namespace __cpo // uninitialized_value_construct_n -namespace __uninitialized_value_construct_n { - -struct __fn { +struct __uninitialized_value_construct_n { template <__nothrow_forward_iterator _ForwardIterator> requires default_initializable<iter_value_t<_ForwardIterator>> _LIBCPP_HIDE_FROM_ABI _ForwardIterator @@ -124,17 +110,13 @@ struct __fn { } }; -} // namespace __uninitialized_value_construct_n - inline namespace __cpo { -inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_construct_n::__fn{}; +inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_construct_n{}; } // namespace __cpo // uninitialized_fill -namespace __uninitialized_fill { - -struct __fn { +struct __uninitialized_fill { template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel, class _Tp> requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&> _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const { @@ -149,17 +131,13 @@ struct __fn { } }; -} // namespace __uninitialized_fill - inline namespace __cpo { -inline constexpr auto uninitialized_fill = __uninitialized_fill::__fn{}; +inline constexpr auto uninitialized_fill = __uninitialized_fill{}; } // namespace __cpo // uninitialized_fill_n -namespace __uninitialized_fill_n { - -struct __fn { +struct __uninitialized_fill_n { template <__nothrow_forward_iterator _ForwardIterator, class _Tp> requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&> _LIBCPP_HIDE_FROM_ABI _ForwardIterator @@ -169,10 +147,8 @@ struct __fn { } }; -} // namespace __uninitialized_fill_n - inline namespace __cpo { -inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{}; +inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n{}; } // namespace __cpo // uninitialized_copy @@ -180,9 +156,7 @@ inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{}; template <class _InputIterator, class _OutputIterator> using uninitialized_copy_result = in_out_result<_InputIterator, _OutputIterator>; -namespace __uninitialized_copy { - -struct __fn { +struct __uninitialized_copy { template <input_iterator _InputIterator, sentinel_for<_InputIterator> _Sentinel1, __nothrow_forward_iterator _OutputIterator, @@ -207,10 +181,8 @@ struct __fn { } }; -} // namespace __uninitialized_copy - inline namespace __cpo { -inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{}; +inline constexpr auto uninitialized_copy = __uninitialized_copy{}; } // namespace __cpo // uninitialized_copy_n @@ -218,9 +190,7 @@ inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{}; template <class _InputIterator, class _OutputIterator> using uninitialized_copy_n_result = in_out_result<_InputIterator, _OutputIterator>; -namespace __uninitialized_copy_n { - -struct __fn { +struct __uninitialized_copy_n { template <input_iterator _InputIterator, __nothrow_forward_iterator _OutputIterator, __nothrow_sentinel_for<_OutputIterator> _Sentinel> @@ -238,10 +208,8 @@ struct __fn { } }; -} // namespace __uninitialized_copy_n - inline namespace __cpo { -inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{}; +inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n{}; } // namespace __cpo // uninitialized_move @@ -249,9 +217,7 @@ inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{}; template <class _InputIterator, class _OutputIterator> using uninitialized_move_result = in_out_result<_InputIterator, _OutputIterator>; -namespace __uninitialized_move { - -struct __fn { +struct __uninitialized_move { template <input_iterator _InputIterator, sentinel_for<_InputIterator> _Sentinel1, __nothrow_forward_iterator _OutputIterator, @@ -276,10 +242,8 @@ struct __fn { } }; -} // namespace __uninitialized_move - inline namespace __cpo { -inline constexpr auto uninitialized_move = __uninitialized_move::__fn{}; +inline constexpr auto uninitialized_move = __uninitialized_move{}; } // namespace __cpo // uninitialized_move_n @@ -287,9 +251,7 @@ inline constexpr auto uninitialized_move = __uninitialized_move::__fn{}; template <class _InputIterator, class _OutputIterator> using uninitialized_move_n_result = in_out_result<_InputIterator, _OutputIterator>; -namespace __uninitialized_move_n { - -struct __fn { +struct __uninitialized_move_n { template <input_iterator _InputIterator, __nothrow_forward_iterator _OutputIterator, __nothrow_sentinel_for<_OutputIterator> _Sentinel> @@ -308,10 +270,8 @@ struct __fn { } }; -} // namespace __uninitialized_move_n - inline namespace __cpo { -inline constexpr auto uninitialized_move_n = __uninitialized_move_n::__fn{}; +inline constexpr auto uninitialized_move_n = __uninitialized_move_n{}; } // namespace __cpo } // namespace ranges diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h index 146b2059e8..0c622cd918 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h @@ -34,6 +34,8 @@ #include <__type_traits/conditional.h> #include <__type_traits/conjunction.h> #include <__type_traits/disjunction.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_array.h> #include <__type_traits/is_bounded_array.h> #include <__type_traits/is_constructible.h> @@ -121,7 +123,7 @@ public: const char* what() const _NOEXCEPT override; }; -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw bad_weak_ptr(); #else @@ -230,11 +232,11 @@ private: template <class _Tp, class _Dp, class _Alloc> class __shared_ptr_pointer : public __shared_weak_count { - __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; + _LIBCPP_COMPRESSED_TRIPLE(_Tp, __ptr_, _Dp, __deleter_, _Alloc, __alloc_); public: _LIBCPP_HIDE_FROM_ABI __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) - : __data_(__compressed_pair<_Tp, _Dp>(__p, std::move(__d)), std::move(__a)) {} + : __ptr_(__p), __deleter_(std::move(__d)), __alloc_(std::move(__a)) {} #ifndef _LIBCPP_HAS_NO_RTTI _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* __get_deleter(const type_info&) const _NOEXCEPT override; @@ -249,15 +251,15 @@ private: template <class _Tp, class _Dp, class _Alloc> const void* __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT { - return __t == typeid(_Dp) ? std::addressof(__data_.first().second()) : nullptr; + return __t == typeid(_Dp) ? std::addressof(__deleter_) : nullptr; } #endif // _LIBCPP_HAS_NO_RTTI template <class _Tp, class _Dp, class _Alloc> void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT { - __data_.first().second()(__data_.first().first()); - __data_.first().second().~_Dp(); + __deleter_(__ptr_); + __deleter_.~_Dp(); } template <class _Tp, class _Dp, class _Alloc> @@ -266,8 +268,8 @@ void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT { typedef allocator_traits<_Al> _ATraits; typedef pointer_traits<typename _ATraits::pointer> _PTraits; - _Al __a(__data_.second()); - __data_.second().~_Alloc(); + _Al __a(__alloc_); + __alloc_.~_Alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } @@ -325,36 +327,28 @@ private: allocator_traits<_ControlBlockAlloc>::deallocate(__tmp, pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1); } + // TODO: It should be possible to refactor this to remove `_Storage` entirely. // This class implements the control block for non-array shared pointers created // through `std::allocate_shared` and `std::make_shared`. - // - // In previous versions of the library, we used a compressed pair to store - // both the _Alloc and the _Tp. This implies using EBO, which is incompatible - // with Allocator construction for _Tp. To allow implementing P0674 in C++20, - // we now use a properly aligned char buffer while making sure that we maintain - // the same layout that we had when we used a compressed pair. - using _CompressedPair = __compressed_pair<_Alloc, _Tp>; - struct _ALIGNAS_TYPE(_CompressedPair) _Storage { - char __blob_[sizeof(_CompressedPair)]; + struct _Storage { + struct _Data { + _LIBCPP_COMPRESSED_PAIR(_Alloc, __alloc_, _Tp, __elem_); + }; + + _ALIGNAS_TYPE(_Data) char __buffer_[sizeof(_Data)]; _LIBCPP_HIDE_FROM_ABI explicit _Storage(_Alloc&& __a) { ::new ((void*)__get_alloc()) _Alloc(std::move(__a)); } _LIBCPP_HIDE_FROM_ABI ~_Storage() { __get_alloc()->~_Alloc(); } + _LIBCPP_HIDE_FROM_ABI _Alloc* __get_alloc() _NOEXCEPT { - _CompressedPair* __as_pair = reinterpret_cast<_CompressedPair*>(__blob_); - typename _CompressedPair::_Base1* __first = _CompressedPair::__get_first_base(__as_pair); - _Alloc* __alloc = reinterpret_cast<_Alloc*>(__first); - return __alloc; + return std::addressof(reinterpret_cast<_Data*>(__buffer_)->__alloc_); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp* __get_elem() _NOEXCEPT { - _CompressedPair* __as_pair = reinterpret_cast<_CompressedPair*>(__blob_); - typename _CompressedPair::_Base2* __second = _CompressedPair::__get_second_base(__as_pair); - _Tp* __elem = reinterpret_cast<_Tp*>(__second); - return __elem; + return std::addressof(reinterpret_cast<_Data*>(__buffer_)->__elem_); } }; - static_assert(_LIBCPP_ALIGNOF(_Storage) == _LIBCPP_ALIGNOF(_CompressedPair), ""); - static_assert(sizeof(_Storage) == sizeof(_CompressedPair), ""); _Storage __storage_; }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/temporary_buffer.h b/contrib/libs/cxxsupp/libcxx/include/__memory/temporary_buffer.h index 88799ca95c..219e03f99b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/temporary_buffer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/temporary_buffer.h @@ -11,6 +11,7 @@ #define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H #include <__config> +#include <__memory/unique_temporary_buffer.h> #include <__utility/pair.h> #include <cstddef> #include <new> @@ -19,57 +20,27 @@ # pragma GCC system_header #endif +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER) + _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT { - pair<_Tp*, ptrdiff_t> __r(0, 0); - const ptrdiff_t __m = - (~ptrdiff_t(0) ^ ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) / sizeof(_Tp); - if (__n > __m) - __n = __m; - while (__n > 0) { -#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) - if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) { - align_val_t __al = align_val_t(_LIBCPP_ALIGNOF(_Tp)); - __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), __al, nothrow)); - } else { - __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); - } -#else - if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) { - // Since aligned operator new is unavailable, return an empty - // buffer rather than one with invalid alignment. - return __r; - } - - __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); -#endif - - if (__r.first) { - __r.second = __n; - break; - } - __n /= 2; - } - return __r; + __unique_temporary_buffer<_Tp> __unique_buf = std::__allocate_unique_temporary_buffer<_Tp>(__n); + pair<_Tp*, ptrdiff_t> __result(__unique_buf.get(), __unique_buf.get_deleter().__count_); + __unique_buf.release(); + return __result; } template <class _Tp> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 void return_temporary_buffer(_Tp* __p) _NOEXCEPT { - std::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp)); + __unique_temporary_buffer<_Tp> __unique_buf(__p); + (void)__unique_buf; } -struct __return_temporary_buffer { - _LIBCPP_SUPPRESS_DEPRECATED_PUSH - template <class _Tp> - _LIBCPP_HIDE_FROM_ABI void operator()(_Tp* __p) const { - std::return_temporary_buffer(__p); - } - _LIBCPP_SUPPRESS_DEPRECATED_POP -}; - _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER) + #endif // _LIBCPP___MEMORY_TEMPORARY_BUFFER_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/uninitialized_algorithms.h b/contrib/libs/cxxsupp/libcxx/include/__memory/uninitialized_algorithms.h index 7475ef5cf8..a8dbde0b1c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/uninitialized_algorithms.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/uninitialized_algorithms.h @@ -22,6 +22,7 @@ #include <__memory/construct_at.h> #include <__memory/pointer_traits.h> #include <__memory/voidify.h> +#include <__type_traits/enable_if.h> #include <__type_traits/extent.h> #include <__type_traits/is_array.h> #include <__type_traits/is_constant_evaluated.h> @@ -564,15 +565,12 @@ template <class _Alloc, class _In, class _RawTypeIn = __remove_const_t<_In>, class _Out, - __enable_if_t< - // using _RawTypeIn because of the allocator<T const> extension - is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value && - is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value && - __allocator_has_trivial_copy_construct<_Alloc, _RawTypeIn>::value, - int> = 0> + __enable_if_t<is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value && + is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value && + __allocator_has_trivial_copy_construct<_Alloc, _In>::value, + int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out* __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) { - // TODO: Remove the const_cast once we drop support for std::allocator<T const> if (__libcpp_is_constant_evaluated()) { while (__first1 != __last1) { std::__construct_at(std::__to_address(__first2), *__first1); @@ -581,7 +579,11 @@ __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* } return __first2; } else { +#ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST return std::copy(__first1, __last1, const_cast<_RawTypeIn*>(__first2)); +#else + return std::copy(__first1, __last1, __first2); +#endif } } @@ -642,7 +644,11 @@ __uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _ __guard.__complete(); std::__allocator_destroy(__alloc, __first, __last); } else { +#ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST __builtin_memcpy(const_cast<__remove_const_t<_Tp>*>(__result), __first, sizeof(_Tp) * (__last - __first)); +#else + __builtin_memcpy(__result, __first, sizeof(_Tp) * (__last - __first)); +#endif } } diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h index 8dd000ba0c..73e2f37c12 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h @@ -23,6 +23,7 @@ #include <__type_traits/common_type.h> #include <__type_traits/conditional.h> #include <__type_traits/dependent_type.h> +#include <__type_traits/enable_if.h> #include <__type_traits/integral_constant.h> #include <__type_traits/is_array.h> #include <__type_traits/is_assignable.h> @@ -37,6 +38,7 @@ #include <__type_traits/is_void.h> #include <__type_traits/remove_extent.h> #include <__type_traits/type_identity.h> +#include <__utility/declval.h> #include <__utility/forward.h> #include <__utility/move.h> #include <cstddef> @@ -143,7 +145,7 @@ public: void>; private: - __compressed_pair<pointer, deleter_type> __ptr_; + _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_); typedef _LIBCPP_NODEBUG __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE; @@ -177,23 +179,25 @@ private: public: template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(), __deleter_() {} template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT - : __ptr_(__value_init_tag(), __value_init_tag()) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(), __deleter_() {} template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > - _LIBCPP_HIDE_FROM_ABI - _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT + : __ptr_(__p), + __deleter_() {} template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT - : __ptr_(__p, __d) {} + : __ptr_(__p), + __deleter_(__d) {} template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT - : __ptr_(__p, std::move(__d)) { + : __ptr_(__p), + __deleter_(std::move(__d)) { static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); } @@ -201,24 +205,26 @@ public: _LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT - : __ptr_(__u.release(), std::forward<deleter_type>(__u.get_deleter())) {} + : __ptr_(__u.release()), + __deleter_(std::forward<deleter_type>(__u.get_deleter())) {} template <class _Up, class _Ep, class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>, class = _EnableIfDeleterConvertible<_Ep> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT - : __ptr_(__u.release(), std::forward<_Ep>(__u.get_deleter())) {} + : __ptr_(__u.release()), + __deleter_(std::forward<_Ep>(__u.get_deleter())) {} #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release(), __value_init_tag()) {} + _LIBCPP_HIDE_FROM_ABI unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release()), __deleter_() {} #endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT { reset(__u.release()); - __ptr_.second() = std::forward<deleter_type>(__u.get_deleter()); + __deleter_ = std::forward<deleter_type>(__u.get_deleter()); return *this; } @@ -228,7 +234,7 @@ public: class = _EnableIfDeleterAssignable<_Ep> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT { reset(__u.release()); - __ptr_.second() = std::forward<_Ep>(__u.get_deleter()); + __deleter_ = std::forward<_Ep>(__u.get_deleter()); return *this; } @@ -253,33 +259,38 @@ public: return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const { - return *__ptr_.first(); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const + _NOEXCEPT_(_NOEXCEPT_(*std::declval<pointer>())) { + return *__ptr_; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_.first(); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __ptr_.second(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT { - return __ptr_.second(); + return __deleter_; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT { - return __ptr_.first() != nullptr; + return __ptr_ != nullptr; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT { - pointer __t = __ptr_.first(); - __ptr_.first() = pointer(); + pointer __t = __ptr_; + __ptr_ = pointer(); return __t; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(pointer __p = pointer()) _NOEXCEPT { - pointer __tmp = __ptr_.first(); - __ptr_.first() = __p; + pointer __tmp = __ptr_; + __ptr_ = __p; if (__tmp) - __ptr_.second()(__tmp); + __deleter_(__tmp); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { + using std::swap; + swap(__ptr_, __u.__ptr_); + swap(__deleter_, __u.__deleter_); + } }; template <class _Tp, class _Dp> @@ -301,7 +312,7 @@ public: void>; private: - __compressed_pair<pointer, deleter_type> __ptr_; + _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_); template <class _From> struct _CheckArrayPointerConversion : is_same<_From, pointer> {}; @@ -350,42 +361,46 @@ private: public: template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(), __deleter_() {} template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT - : __ptr_(__value_init_tag(), __value_init_tag()) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(), __deleter_() {} template <class _Pp, bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy>, class = _EnableIfPointerConvertible<_Pp> > - _LIBCPP_HIDE_FROM_ABI - _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __p) _NOEXCEPT + : __ptr_(__p), + __deleter_() {} template <class _Pp, bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >, class = _EnableIfPointerConvertible<_Pp> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) _NOEXCEPT - : __ptr_(__p, __d) {} + : __ptr_(__p), + __deleter_(__d) {} template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) _NOEXCEPT - : __ptr_(nullptr, __d) {} + : __ptr_(nullptr), + __deleter_(__d) {} template <class _Pp, bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >, class = _EnableIfPointerConvertible<_Pp> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT - : __ptr_(__p, std::move(__d)) { + : __ptr_(__p), + __deleter_(std::move(__d)) { static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); } template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT - : __ptr_(nullptr, std::move(__d)) { + : __ptr_(nullptr), + __deleter_(std::move(__d)) { static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); } @@ -396,11 +411,12 @@ public: _LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT - : __ptr_(__u.release(), std::forward<deleter_type>(__u.get_deleter())) {} + : __ptr_(__u.release()), + __deleter_(std::forward<deleter_type>(__u.get_deleter())) {} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT { reset(__u.release()); - __ptr_.second() = std::forward<deleter_type>(__u.get_deleter()); + __deleter_ = std::forward<deleter_type>(__u.get_deleter()); return *this; } @@ -409,7 +425,8 @@ public: class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>, class = _EnableIfDeleterConvertible<_Ep> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT - : __ptr_(__u.release(), std::forward<_Ep>(__u.get_deleter())) {} + : __ptr_(__u.release()), + __deleter_(std::forward<_Ep>(__u.get_deleter())) {} template <class _Up, class _Ep, @@ -417,7 +434,7 @@ public: class = _EnableIfDeleterAssignable<_Ep> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT { reset(__u.release()); - __ptr_.second() = std::forward<_Ep>(__u.get_deleter()); + __deleter_ = std::forward<_Ep>(__u.get_deleter()); return *this; } @@ -435,41 +452,45 @@ public: } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator[](size_t __i) const { - return __ptr_.first()[__i]; + return __ptr_[__i]; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __ptr_.second(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT { - return __ptr_.second(); + return __deleter_; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT { - return __ptr_.first() != nullptr; + return __ptr_ != nullptr; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT { - pointer __t = __ptr_.first(); - __ptr_.first() = pointer(); + pointer __t = __ptr_; + __ptr_ = pointer(); return __t; } template <class _Pp, __enable_if_t<_CheckArrayPointerConversion<_Pp>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(_Pp __p) _NOEXCEPT { - pointer __tmp = __ptr_.first(); - __ptr_.first() = __p; + pointer __tmp = __ptr_; + __ptr_ = __p; if (__tmp) - __ptr_.second()(__tmp); + __deleter_(__tmp); } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(nullptr_t = nullptr) _NOEXCEPT { - pointer __tmp = __ptr_.first(); - __ptr_.first() = nullptr; + pointer __tmp = __ptr_; + __ptr_ = nullptr; if (__tmp) - __ptr_.second()(__tmp); + __deleter_(__tmp); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { + using std::swap; + swap(__ptr_, __u.__ptr_); + swap(__deleter_, __u.__deleter_); + } }; template <class _Tp, class _Dp, __enable_if_t<__is_swappable_v<_Dp>, int> = 0> diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/unique_temporary_buffer.h b/contrib/libs/cxxsupp/libcxx/include/__memory/unique_temporary_buffer.h new file mode 100644 index 0000000000..b9e2a47332 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/unique_temporary_buffer.h @@ -0,0 +1,92 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H +#define _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H + +#include <__assert> +#include <__config> + +#include <__memory/allocator.h> +#include <__memory/unique_ptr.h> +#include <__type_traits/is_constant_evaluated.h> +#include <cstddef> +#include <new> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +struct __temporary_buffer_deleter { + ptrdiff_t __count_; // ignored in non-constant evaluation + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __temporary_buffer_deleter() _NOEXCEPT : __count_(0) {} + _LIBCPP_HIDE_FROM_ABI + _LIBCPP_CONSTEXPR explicit __temporary_buffer_deleter(ptrdiff_t __count) _NOEXCEPT : __count_(__count) {} + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) _NOEXCEPT { + if (__libcpp_is_constant_evaluated()) { + allocator<_Tp>().deallocate(__ptr, __count_); + return; + } + + std::__libcpp_deallocate_unsized((void*)__ptr, _LIBCPP_ALIGNOF(_Tp)); + } +}; + +template <class _Tp> +using __unique_temporary_buffer = unique_ptr<_Tp, __temporary_buffer_deleter<_Tp> >; + +template <class _Tp> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __unique_temporary_buffer<_Tp> +__allocate_unique_temporary_buffer(ptrdiff_t __count) { + using __deleter_type = __temporary_buffer_deleter<_Tp>; + using __unique_buffer_type = __unique_temporary_buffer<_Tp>; + + if (__libcpp_is_constant_evaluated()) { + return __unique_buffer_type(allocator<_Tp>().allocate(__count), __deleter_type(__count)); + } + + _Tp* __ptr = nullptr; + const ptrdiff_t __max_count = + (~ptrdiff_t(0) ^ ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) / sizeof(_Tp); + if (__count > __max_count) + __count = __max_count; + while (__count > 0) { +#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) + if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) { + align_val_t __al = align_val_t(_LIBCPP_ALIGNOF(_Tp)); + __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), __al, nothrow)); + } else { + __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), nothrow)); + } +#else + if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) { + // Since aligned operator new is unavailable, constructs an empty buffer rather than one with invalid alignment. + return __unique_buffer_type(); + } + + __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), nothrow)); +#endif + + if (__ptr) { + break; + } + __count /= 2; + } + + return __unique_buffer_type(__ptr, __deleter_type(__count)); +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator.h b/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator.h index 84310c3fa5..16504e8b2a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator.h @@ -11,6 +11,7 @@ #define _LIBCPP___MEMORY_USES_ALLOCATOR_H #include <__config> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_convertible.h> #include <cstddef> diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h b/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h index 5e5819d4c2..955879ffc5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h @@ -40,104 +40,8 @@ inline constexpr bool __is_std_pair<pair<_Type1, _Type2>> = true; template <class _Tp> inline constexpr bool __is_cv_std_pair = __is_std_pair<remove_cv_t<_Tp>>; -template <class _Type, class _Alloc, class... _Args, __enable_if_t<!__is_cv_std_pair<_Type>, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr auto -__uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept { - if constexpr (!uses_allocator_v<remove_cv_t<_Type>, _Alloc> && is_constructible_v<_Type, _Args...>) { - return std::forward_as_tuple(std::forward<_Args>(__args)...); - } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> && - is_constructible_v<_Type, allocator_arg_t, const _Alloc&, _Args...>) { - return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(allocator_arg, __alloc, std::forward<_Args>(__args)...); - } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> && - is_constructible_v<_Type, _Args..., const _Alloc&>) { - return std::forward_as_tuple(std::forward<_Args>(__args)..., __alloc); - } else { - static_assert( - sizeof(_Type) + 1 == 0, "If uses_allocator_v<Type> is true, the type has to be allocator-constructible"); - } -} - -template <class _Pair, class _Alloc, class _Tuple1, class _Tuple2, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args( - const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept { - return std::make_tuple( - piecewise_construct, - std::apply( - [&__alloc](auto&&... __args1) { - return std::__uses_allocator_construction_args<typename _Pair::first_type>( - __alloc, std::forward<decltype(__args1)>(__args1)...); - }, - std::forward<_Tuple1>(__x)), - std::apply( - [&__alloc](auto&&... __args2) { - return std::__uses_allocator_construction_args<typename _Pair::second_type>( - __alloc, std::forward<decltype(__args2)>(__args2)...); - }, - std::forward<_Tuple2>(__y))); -} - -template <class _Pair, class _Alloc, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc) noexcept { - return std::__uses_allocator_construction_args<_Pair>(__alloc, piecewise_construct, tuple<>{}, tuple<>{}); -} - -template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr auto -__uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept { - return std::__uses_allocator_construction_args<_Pair>( - __alloc, - piecewise_construct, - std::forward_as_tuple(std::forward<_Up>(__u)), - std::forward_as_tuple(std::forward<_Vp>(__v))); -} - -# if _LIBCPP_STD_VER >= 23 -template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr auto -__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept { - return std::__uses_allocator_construction_args<_Pair>( - __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second)); -} -# endif - -template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr auto -__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept { - return std::__uses_allocator_construction_args<_Pair>( - __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second)); -} - -template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr auto -__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept { - return std::__uses_allocator_construction_args<_Pair>( - __alloc, - piecewise_construct, - std::forward_as_tuple(std::get<0>(std::move(__pair))), - std::forward_as_tuple(std::get<1>(std::move(__pair)))); -} - -# if _LIBCPP_STD_VER >= 23 -template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr auto -__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept { - return std::__uses_allocator_construction_args<_Pair>( - __alloc, - piecewise_construct, - std::forward_as_tuple(std::get<0>(std::move(__pair))), - std::forward_as_tuple(std::get<1>(std::move(__pair)))); -} - -template <class _Pair, class _Alloc, __pair_like_no_subrange _PairLike, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr auto -__uses_allocator_construction_args(const _Alloc& __alloc, _PairLike&& __p) noexcept { - return std::__uses_allocator_construction_args<_Pair>( - __alloc, - piecewise_construct, - std::forward_as_tuple(std::get<0>(std::forward<_PairLike>(__p))), - std::forward_as_tuple(std::get<1>(std::forward<_PairLike>(__p)))); -} -# endif +template <class _Tp, class = void> +struct __uses_allocator_construction_args; namespace __uses_allocator_detail { @@ -165,46 +69,135 @@ inline constexpr bool __uses_allocator_constraints = __is_cv_std_pair<_Tp> && !_ } // namespace __uses_allocator_detail -template < class _Pair, - class _Alloc, - class _Type, - __enable_if_t<__uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr auto -__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept; - template <class _Type, class _Alloc, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args); -template < class _Pair, - class _Alloc, - class _Type, - __enable_if_t< __uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int>> -_LIBCPP_HIDE_FROM_ABI constexpr auto -__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept { - struct __pair_constructor { - using _PairMutable = remove_cv_t<_Pair>; +template <class _Pair> +struct __uses_allocator_construction_args<_Pair, __enable_if_t<__is_cv_std_pair<_Pair>>> { + template <class _Alloc, class _Tuple1, class _Tuple2> + static _LIBCPP_HIDE_FROM_ABI constexpr auto + __apply(const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept { + return std::make_tuple( + piecewise_construct, + std::apply( + [&__alloc](auto&&... __args1) { + return __uses_allocator_construction_args<typename _Pair::first_type>::__apply( + __alloc, std::forward<decltype(__args1)>(__args1)...); + }, + std::forward<_Tuple1>(__x)), + std::apply( + [&__alloc](auto&&... __args2) { + return __uses_allocator_construction_args<typename _Pair::second_type>::__apply( + __alloc, std::forward<decltype(__args2)>(__args2)...); + }, + std::forward<_Tuple2>(__y))); + } - _LIBCPP_HIDDEN constexpr auto __do_construct(const _PairMutable& __pair) const { - return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair); - } + template <class _Alloc> + static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc) noexcept { + return __uses_allocator_construction_args<_Pair>::__apply(__alloc, piecewise_construct, tuple<>{}, tuple<>{}); + } - _LIBCPP_HIDDEN constexpr auto __do_construct(_PairMutable&& __pair) const { - return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair)); - } + template <class _Alloc, class _Up, class _Vp> + static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept { + return __uses_allocator_construction_args<_Pair>::__apply( + __alloc, + piecewise_construct, + std::forward_as_tuple(std::forward<_Up>(__u)), + std::forward_as_tuple(std::forward<_Vp>(__v))); + } - const _Alloc& __alloc_; - _Type& __value_; +# if _LIBCPP_STD_VER >= 23 + template <class _Alloc, class _Up, class _Vp> + static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept { + return __uses_allocator_construction_args<_Pair>::__apply( + __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second)); + } +# endif - _LIBCPP_HIDDEN constexpr operator _PairMutable() const { return __do_construct(std::forward<_Type>(__value_)); } - }; + template <class _Alloc, class _Up, class _Vp> + static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept { + return __uses_allocator_construction_args<_Pair>::__apply( + __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second)); + } - return std::make_tuple(__pair_constructor{__alloc, __value}); -} + template <class _Alloc, class _Up, class _Vp> + static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept { + return __uses_allocator_construction_args<_Pair>::__apply( + __alloc, + piecewise_construct, + std::forward_as_tuple(std::get<0>(std::move(__pair))), + std::forward_as_tuple(std::get<1>(std::move(__pair)))); + } + +# if _LIBCPP_STD_VER >= 23 + template <class _Alloc, class _Up, class _Vp> + static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept { + return __uses_allocator_construction_args<_Pair>::__apply( + __alloc, + piecewise_construct, + std::forward_as_tuple(std::get<0>(std::move(__pair))), + std::forward_as_tuple(std::get<1>(std::move(__pair)))); + } + + template < class _Alloc, __pair_like_no_subrange _PairLike> + static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _PairLike&& __p) noexcept { + return __uses_allocator_construction_args<_Pair>::__apply( + __alloc, + piecewise_construct, + std::forward_as_tuple(std::get<0>(std::forward<_PairLike>(__p))), + std::forward_as_tuple(std::get<1>(std::forward<_PairLike>(__p)))); + } +# endif + + template <class _Alloc, + class _Type, + __enable_if_t<__uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int> = 0> + static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _Type&& __value) noexcept { + struct __pair_constructor { + using _PairMutable = remove_cv_t<_Pair>; + + _LIBCPP_HIDDEN constexpr auto __do_construct(const _PairMutable& __pair) const { + return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair); + } + + _LIBCPP_HIDDEN constexpr auto __do_construct(_PairMutable&& __pair) const { + return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair)); + } + + const _Alloc& __alloc_; + _Type& __value_; + + _LIBCPP_HIDDEN constexpr operator _PairMutable() const { return __do_construct(std::forward<_Type>(__value_)); } + }; + + return std::make_tuple(__pair_constructor{__alloc, __value}); + } +}; + +template <class _Type> +struct __uses_allocator_construction_args<_Type, __enable_if_t<!__is_cv_std_pair<_Type>>> { + template <class _Alloc, class... _Args> + static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _Args&&... __args) noexcept { + if constexpr (!uses_allocator_v<remove_cv_t<_Type>, _Alloc> && is_constructible_v<_Type, _Args...>) { + return std::forward_as_tuple(std::forward<_Args>(__args)...); + } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> && + is_constructible_v<_Type, allocator_arg_t, const _Alloc&, _Args...>) { + return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(allocator_arg, __alloc, std::forward<_Args>(__args)...); + } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> && + is_constructible_v<_Type, _Args..., const _Alloc&>) { + return std::forward_as_tuple(std::forward<_Args>(__args)..., __alloc); + } else { + static_assert( + sizeof(_Type) + 1 == 0, "If uses_allocator_v<Type> is true, the type has to be allocator-constructible"); + } + } +}; template <class _Type, class _Alloc, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args) { return std::make_from_tuple<_Type>( - std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...)); + __uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...)); } template <class _Type, class _Alloc, class... _Args> @@ -212,7 +205,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Type* __uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Args&&... __args) { return std::apply( [&__ptr](auto&&... __xs) { return std::__construct_at(__ptr, std::forward<decltype(__xs)>(__xs)...); }, - std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...)); + __uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...)); } #endif // _LIBCPP_STD_VER >= 17 @@ -221,8 +214,8 @@ __uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _ template <class _Type, class _Alloc, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr auto uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept - -> decltype(std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...)) { - return /*--*/ std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...); + -> decltype(__uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...)) { + return /*--*/ __uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...); } template <class _Type, class _Alloc, class... _Args> diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory_resource/polymorphic_allocator.h b/contrib/libs/cxxsupp/libcxx/include/__memory_resource/polymorphic_allocator.h index a71096d3e4..fb36d5cad7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory_resource/polymorphic_allocator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory_resource/polymorphic_allocator.h @@ -174,6 +174,19 @@ public: _LIBCPP_HIDE_FROM_ABI memory_resource* resource() const noexcept { return __res_; } + _LIBCPP_HIDE_FROM_ABI friend bool + operator==(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept { + return *__lhs.resource() == *__rhs.resource(); + } + +# if _LIBCPP_STD_VER <= 17 + // This overload is not specified, it was added due to LWG3683. + _LIBCPP_HIDE_FROM_ABI friend bool + operator!=(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept { + return *__lhs.resource() != *__rhs.resource(); + } +# endif + private: template <class... _Args, size_t... _Is> _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...> diff --git a/contrib/libs/cxxsupp/libcxx/include/__mutex/lock_guard.h b/contrib/libs/cxxsupp/libcxx/include/__mutex/lock_guard.h index 8340b9bbd4..50765cdd04 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__mutex/lock_guard.h +++ b/contrib/libs/cxxsupp/libcxx/include/__mutex/lock_guard.h @@ -16,8 +16,6 @@ # pragma GCC system_header #endif -#ifndef _LIBCPP_HAS_NO_THREADS - _LIBCPP_BEGIN_NAMESPACE_STD template <class _Mutex> @@ -29,13 +27,13 @@ private: mutex_type& __m_; public: - _LIBCPP_NODISCARD + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) : __m_(__m) { __m_.lock(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t) + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) : __m_(__m) {} _LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); } @@ -47,6 +45,4 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(lock_guard); _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_HAS_NO_THREADS - #endif // _LIBCPP___MUTEX_LOCK_GUARD_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__mutex/tag_types.h b/contrib/libs/cxxsupp/libcxx/include/__mutex/tag_types.h index 05ccb8b23a..2b2dd58ee4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__mutex/tag_types.h +++ b/contrib/libs/cxxsupp/libcxx/include/__mutex/tag_types.h @@ -15,8 +15,6 @@ # pragma GCC system_header #endif -#ifndef _LIBCPP_HAS_NO_THREADS - _LIBCPP_BEGIN_NAMESPACE_STD struct _LIBCPP_EXPORTED_FROM_ABI defer_lock_t { @@ -31,18 +29,16 @@ struct _LIBCPP_EXPORTED_FROM_ABI adopt_lock_t { explicit adopt_lock_t() = default; }; -# if _LIBCPP_STD_VER >= 17 +#if _LIBCPP_STD_VER >= 17 inline constexpr defer_lock_t defer_lock = defer_lock_t(); inline constexpr try_to_lock_t try_to_lock = try_to_lock_t(); inline constexpr adopt_lock_t adopt_lock = adopt_lock_t(); -# elif !defined(_LIBCPP_CXX03_LANG) +#elif !defined(_LIBCPP_CXX03_LANG) constexpr defer_lock_t defer_lock = defer_lock_t(); constexpr try_to_lock_t try_to_lock = try_to_lock_t(); constexpr adopt_lock_t adopt_lock = adopt_lock_t(); -# endif +#endif _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_HAS_NO_THREADS - #endif // _LIBCPP___MUTEX_TAG_TYPES_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__mutex/unique_lock.h b/contrib/libs/cxxsupp/libcxx/include/__mutex/unique_lock.h index 4a616ba51e..c404921070 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__mutex/unique_lock.h +++ b/contrib/libs/cxxsupp/libcxx/include/__mutex/unique_lock.h @@ -22,8 +22,6 @@ # pragma GCC system_header #endif -#ifndef _LIBCPP_HAS_NO_THREADS - _LIBCPP_BEGIN_NAMESPACE_STD template <class _Mutex> @@ -36,28 +34,28 @@ private: bool __owns_; public: - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {} - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI explicit unique_lock(mutex_type& __m) + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {} + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI explicit unique_lock(mutex_type& __m) : __m_(std::addressof(__m)), __owns_(true) { __m_->lock(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT : __m_(std::addressof(__m)), __owns_(false) {} - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, try_to_lock_t) + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, try_to_lock_t) : __m_(std::addressof(__m)), __owns_(__m.try_lock()) {} - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, adopt_lock_t) + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, adopt_lock_t) : __m_(std::addressof(__m)), __owns_(true) {} template <class _Clock, class _Duration> - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t) + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t) : __m_(std::addressof(__m)), __owns_(__m.try_lock_until(__t)) {} template <class _Rep, class _Period> - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d) + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d) : __m_(std::addressof(__m)), __owns_(__m.try_lock_for(__d)) {} _LIBCPP_HIDE_FROM_ABI ~unique_lock() { @@ -68,7 +66,7 @@ public: unique_lock(unique_lock const&) = delete; unique_lock& operator=(unique_lock const&) = delete; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(unique_lock&& __u) _NOEXCEPT + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(unique_lock&& __u) _NOEXCEPT : __m_(__u.__m_), __owns_(__u.__owns_) { __u.__m_ = nullptr; @@ -86,16 +84,16 @@ public: return *this; } - void lock(); - bool try_lock(); + _LIBCPP_HIDE_FROM_ABI void lock(); + _LIBCPP_HIDE_FROM_ABI bool try_lock(); template <class _Rep, class _Period> - bool try_lock_for(const chrono::duration<_Rep, _Period>& __d); + _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d); template <class _Clock, class _Duration> - bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); + _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); - void unlock(); + _LIBCPP_HIDE_FROM_ABI void unlock(); _LIBCPP_HIDE_FROM_ABI void swap(unique_lock& __u) _NOEXCEPT { std::swap(__m_, __u.__m_); @@ -116,7 +114,7 @@ public: _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock); template <class _Mutex> -void unique_lock<_Mutex>::lock() { +_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() { if (__m_ == nullptr) __throw_system_error(EPERM, "unique_lock::lock: references null mutex"); if (__owns_) @@ -126,7 +124,7 @@ void unique_lock<_Mutex>::lock() { } template <class _Mutex> -bool unique_lock<_Mutex>::try_lock() { +_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock() { if (__m_ == nullptr) __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex"); if (__owns_) @@ -137,7 +135,7 @@ bool unique_lock<_Mutex>::try_lock() { template <class _Mutex> template <class _Rep, class _Period> -bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) { +_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) { if (__m_ == nullptr) __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex"); if (__owns_) @@ -148,7 +146,7 @@ bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __ template <class _Mutex> template <class _Clock, class _Duration> -bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { +_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { if (__m_ == nullptr) __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex"); if (__owns_) @@ -158,7 +156,7 @@ bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Durat } template <class _Mutex> -void unique_lock<_Mutex>::unlock() { +_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::unlock() { if (!__owns_) __throw_system_error(EPERM, "unique_lock::unlock: not locked"); __m_->unlock(); @@ -172,6 +170,4 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(unique_lock<_Mutex>& __x, unique_lock<_Mu _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_HAS_NO_THREADS - #endif // _LIBCPP___MUTEX_UNIQUE_LOCK_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ostream/basic_ostream.h b/contrib/libs/cxxsupp/libcxx/include/__ostream/basic_ostream.h index 4f7e9cfe1c..3aadf6735e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ostream/basic_ostream.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ostream/basic_ostream.h @@ -10,29 +10,32 @@ #define _LIBCPP___OSTREAM_BASIC_OSTREAM_H #include <__config> -#include <__exception/operations.h> -#include <__memory/shared_ptr.h> -#include <__memory/unique_ptr.h> -#include <__system_error/error_code.h> -#include <__type_traits/conjunction.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_base_of.h> -#include <__type_traits/void_t.h> -#include <__utility/declval.h> -#include <bitset> -#include <cstddef> -#include <ios> -#include <locale> -#include <new> // for __throw_bad_alloc -#include <streambuf> -#include <string_view> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif + +#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__exception/operations.h> +# include <__memory/shared_ptr.h> +# include <__memory/unique_ptr.h> +# include <__system_error/error_code.h> +# include <__type_traits/conjunction.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_base_of.h> +# include <__type_traits/void_t.h> +# include <__utility/declval.h> +# include <bitset> +# include <cstddef> +# include <ios> +# include <locale> +# include <new> // for __throw_bad_alloc +# include <streambuf> +# include <string_view> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -99,19 +102,19 @@ public: basic_ostream& operator<<(long double __f); basic_ostream& operator<<(const void* __p); -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(const volatile void* __p) { return operator<<(const_cast<const void*>(__p)); } -#endif +# endif basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb); -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 // LWG 2221 - nullptr. This is not backported to older standards modes. // See https://reviews.llvm.org/D127033 for more info on the rationale. _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(nullptr_t) { return *this << "nullptr"; } -#endif +# endif // 27.7.2.7 Unformatted output: basic_ostream& put(char_type __c); @@ -152,16 +155,16 @@ basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& _ template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>::sentry::~sentry() { - if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && !uncaught_exception()) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS + if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && uncaught_exceptions() == 0) { +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS if (__os_.rdbuf()->pubsync() == -1) __os_.setstate(ios_base::badbit); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -182,15 +185,15 @@ basic_ostream<_CharT, _Traits>::~basic_ostream() {} template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { if (__sb) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef istreambuf_iterator<_CharT, _Traits> _Ip; typedef ostreambuf_iterator<_CharT, _Traits> _Op; _Ip __i(__sb); @@ -204,27 +207,27 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_typ } if (__c == 0) this->setstate(ios_base::failbit); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_failbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } else this->setstate(ios_base::badbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -232,19 +235,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; @@ -259,19 +262,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short .failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -279,19 +282,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; @@ -306,19 +309,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int _ .failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -326,19 +329,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -346,19 +349,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -366,19 +369,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long long __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -386,19 +389,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -406,19 +409,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -426,19 +429,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -446,19 +449,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(doubl if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -466,19 +469,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp; @@ -486,20 +489,20 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& __put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str, size_t __len) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Ip; @@ -513,11 +516,11 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __s .failed()) __os.setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return __os; } @@ -528,9 +531,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_ template <class _CharT, class _Traits> _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { _CharT __c = __os.widen(__cn); @@ -545,11 +548,11 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_ .failed()) __os.setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return __os; } @@ -577,9 +580,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) { template <class _CharT, class _Traits> _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Ip; @@ -606,11 +609,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) { .failed()) __os.setstate(ios_base::badbit | ios_base::failbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return __os; } @@ -635,9 +638,9 @@ operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) { template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Op; @@ -646,37 +649,37 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __ if (__o.failed()) this->setstate(ios_base::badbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS sentry __sen(*this); if (__sen && __n) { if (this->rdbuf()->sputn(__s, __n) != __n) this->setstate(ios_base::badbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } template <class _CharT, class _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS if (this->rdbuf()) { sentry __s(*this); if (__s) { @@ -684,11 +687,11 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() { this->setstate(ios_base::badbit); } } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return *this; } @@ -797,9 +800,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) { std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); } -#if 0 && _LIBCPP_STD_VER >= 20 +# if 0 && _LIBCPP_STD_VER >= 20 -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <class _Traits> basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete; @@ -818,9 +821,9 @@ basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, co template <class _Traits> basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete; -# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# ifndef _LIBCPP_HAS_NO_CHAR8_T template <class _Traits> basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete; @@ -832,7 +835,7 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const ch template <class _Traits> basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete; -# endif +# endif template <class _Traits> basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete; @@ -846,15 +849,17 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const ch template <class _Traits> basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete; -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>; -#endif +# endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS +#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + #endif // _LIBCPP___OSTREAM_BASIC_OSTREAM_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ostream/print.h b/contrib/libs/cxxsupp/libcxx/include/__ostream/print.h index 8265ac0077..6c82b11e1d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ostream/print.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ostream/print.h @@ -10,21 +10,24 @@ #define _LIBCPP___OSTREAM_PRINT_H #include <__config> -#include <__fwd/ostream.h> -#include <__iterator/ostreambuf_iterator.h> -#include <__ostream/basic_ostream.h> -#include <format> -#include <ios> -#include <locale> -#include <print> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif + +#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__fwd/ostream.h> +# include <__iterator/ostreambuf_iterator.h> +# include <__ostream/basic_ostream.h> +# include <format> +# include <ios> +# include <locale> +# include <print> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). _LIBCPP_HIDE_FROM_ABI inline void @@ -49,9 +52,9 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _ const char* __str = __o.data(); size_t __len = __o.size(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef ostreambuf_iterator<char> _Ip; if (std::__pad_and_output( _Ip(__os), @@ -63,11 +66,11 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _ .failed()) __os.setstate(ios_base::badbit | ios_base::failbit); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } } @@ -91,12 +94,12 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view _ // is determined in the same way as the print(FILE*, ...) overloads. _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os); -# ifndef _LIBCPP_HAS_NO_UNICODE +# ifndef _LIBCPP_HAS_NO_UNICODE template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) { -# if _LIBCPP_AVAILABILITY_HAS_PRINT == 0 +# if _LIBCPP_AVAILABILITY_HAS_PRINT == 0 return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl); -# else +# else FILE* __file = std::__get_ostream_file(__os); if (!__file || !__print::__is_terminal(__file)) return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl); @@ -112,49 +115,49 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo // This is the path for the native API, start with flushing. __os.flush(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS ostream::sentry __s(__os); if (__s) { -# ifndef _LIBCPP_WIN32API +# ifndef _LIBCPP_WIN32API __print::__vprint_unicode_posix(__file, __fmt, __args, __write_nl, true); -# elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) +# elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) __print::__vprint_unicode_windows(__file, __fmt, __args, __write_nl, true); -# else -# error "Windows builds with wchar_t disabled are not supported." -# endif +# else +# error "Windows builds with wchar_t disabled are not supported." +# endif } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS -# endif // _LIBCPP_AVAILABILITY_HAS_PRINT +# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_AVAILABILITY_HAS_PRINT } template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(ostream& __os, string_view __fmt, format_args __args) { std::__vprint_unicode(__os, __fmt, __args, false); } -# endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_HAS_NO_UNICODE template <class... _Args> _LIBCPP_HIDE_FROM_ABI void print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) { -# ifndef _LIBCPP_HAS_NO_UNICODE +# ifndef _LIBCPP_HAS_NO_UNICODE if constexpr (__print::__use_unicode_execution_charset) std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), false); else std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false); -# else // _LIBCPP_HAS_NO_UNICODE +# else // _LIBCPP_HAS_NO_UNICODE std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false); -# endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_HAS_NO_UNICODE } template <class... _Args> _LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) { -# ifndef _LIBCPP_HAS_NO_UNICODE +# ifndef _LIBCPP_HAS_NO_UNICODE // Note the wording in the Standard is inefficient. The output of // std::format is a std::string which is then copied. This solution // just appends a newline at the end of the output. @@ -162,9 +165,9 @@ _LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt, std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), true); else std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true); -# else // _LIBCPP_HAS_NO_UNICODE +# else // _LIBCPP_HAS_NO_UNICODE std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true); -# endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_HAS_NO_UNICODE } template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). @@ -172,8 +175,10 @@ _LIBCPP_HIDE_FROM_ABI inline void println(ostream& __os) { std::print(__os, "\n"); } -#endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD +#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + #endif // _LIBCPP___OSTREAM_PRINT_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/backend.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/backend.h index 86d9f28c77..5980b0708c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/backend.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/backend.h @@ -19,16 +19,20 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> -#if defined(_LIBCPP_PSTL_BACKEND_SERIAL) -# include <__pstl/backends/default.h> -# include <__pstl/backends/serial.h> -#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD) -# include <__pstl/backends/default.h> -# include <__pstl/backends/std_thread.h> -#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH) -# include <__pstl/backends/default.h> -# include <__pstl/backends/libdispatch.h> -#endif +#if _LIBCPP_STD_VER >= 17 + +# if defined(_LIBCPP_PSTL_BACKEND_SERIAL) +# include <__pstl/backends/default.h> +# include <__pstl/backends/serial.h> +# elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD) +# include <__pstl/backends/default.h> +# include <__pstl/backends/std_thread.h> +# elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH) +# include <__pstl/backends/default.h> +# include <__pstl/backends/libdispatch.h> +# endif + +#endif // _LIBCPP_STD_VER >= 17 _LIBCPP_POP_MACROS diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/backend_fwd.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/backend_fwd.h index 32c5da576f..2132e8dbce 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/backend_fwd.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/backend_fwd.h @@ -39,6 +39,8 @@ _LIBCPP_PUSH_MACROS // the user. // +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -50,18 +52,18 @@ struct __libdispatch_backend_tag; struct __serial_backend_tag; struct __std_thread_backend_tag; -#if defined(_LIBCPP_PSTL_BACKEND_SERIAL) +# if defined(_LIBCPP_PSTL_BACKEND_SERIAL) using __current_configuration = __backend_configuration<__serial_backend_tag, __default_backend_tag>; -#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD) +# elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD) using __current_configuration = __backend_configuration<__std_thread_backend_tag, __default_backend_tag>; -#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH) +# elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH) using __current_configuration = __backend_configuration<__libdispatch_backend_tag, __default_backend_tag>; -#else +# else // ...New vendors can add parallel backends here... -# error "Invalid PSTL backend configuration" -#endif +# error "Invalid PSTL backend configuration" +# endif template <class _Backend, class _ExecutionPolicy> struct __find_if; @@ -296,6 +298,8 @@ struct __reduce; } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_BACKEND_FWD_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/default.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/default.h index 61a128805f..3672bbf60a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/default.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/default.h @@ -33,6 +33,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -163,7 +165,7 @@ struct __is_partitioned<__default_backend_tag, _ExecutionPolicy> { [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept { using _FindIfNot = __dispatch<__find_if_not, __current_configuration, _ExecutionPolicy>; - auto __maybe_first = _FindIfNot()(__policy, std::move(__first), std::move(__last), __pred); + auto __maybe_first = _FindIfNot()(__policy, std::move(__first), __last, __pred); if (__maybe_first == nullopt) return nullopt; @@ -498,6 +500,8 @@ struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_BACKENDS_DEFAULT_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/libdispatch.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/libdispatch.h index a0c3ad980e..2d6ab49c8f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/libdispatch.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/libdispatch.h @@ -44,6 +44,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -140,15 +142,15 @@ struct __cpu_traits<__libdispatch_backend_tag> { unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges( [&]() -> __merge_range_t* { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif +# endif return std::allocator<__merge_range_t>().allocate(__n_ranges); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (const std::bad_alloc&) { return nullptr; } -#endif +# endif }(), __destroy); @@ -392,6 +394,8 @@ struct __fill<__libdispatch_backend_tag, _ExecutionPolicy> } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/serial.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/serial.h index 5f24499899..f4142016cc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/serial.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/serial.h @@ -30,6 +30,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -176,6 +178,8 @@ struct __transform_reduce_binary<__serial_backend_tag, _ExecutionPolicy> { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/std_thread.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/std_thread.h index 49570bd30b..19b985f860 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/std_thread.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/backends/std_thread.h @@ -32,6 +32,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -131,6 +133,8 @@ struct __fill<__std_thread_backend_tag, _ExecutionPolicy> } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/any_of.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/any_of.h index b33c787a29..803db7974e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/any_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/any_of.h @@ -26,6 +26,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -94,6 +96,8 @@ struct __cpu_parallel_any_of { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/cpu_traits.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/cpu_traits.h index 0483d6918f..5e59752fa5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/cpu_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/cpu_traits.h @@ -19,6 +19,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -81,6 +83,8 @@ struct __cpu_traits; } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/fill.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/fill.h index 4e6d29b30c..3e5936589a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/fill.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/fill.h @@ -23,6 +23,8 @@ # pragma GCC system_header #endif +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -63,4 +65,6 @@ struct __cpu_parallel_fill { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + #endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/find_if.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/find_if.h index 12b2e88971..cd92e5a99f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/find_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/find_if.h @@ -31,6 +31,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -132,6 +134,8 @@ struct __cpu_parallel_find_if { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/for_each.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/for_each.h index d4d7862135..cec719bc47 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/for_each.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/for_each.h @@ -23,6 +23,8 @@ # pragma GCC system_header #endif +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -63,4 +65,6 @@ struct __cpu_parallel_for_each { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + #endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/merge.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/merge.h index dfa4cbf69b..a9069ca51d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/merge.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/merge.h @@ -26,6 +26,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -80,6 +82,8 @@ struct __cpu_parallel_merge { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/stable_sort.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/stable_sort.h index 8e64f3e537..5afdd3fd62 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/stable_sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/stable_sort.h @@ -21,6 +21,8 @@ # pragma GCC system_header #endif +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -44,4 +46,6 @@ struct __cpu_parallel_stable_sort { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + #endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/transform.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/transform.h index 27ce8e27b2..979121be8c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/transform.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/transform.h @@ -27,6 +27,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -148,6 +150,8 @@ struct __cpu_parallel_transform_binary { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/transform_reduce.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/transform_reduce.h index 36ac1a9072..aafbf1ca96 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/transform_reduce.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/cpu_algos/transform_reduce.h @@ -31,6 +31,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -211,6 +213,8 @@ struct __cpu_parallel_transform_reduce { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/dispatch.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/dispatch.h index 5e903f7524..ea40fa79eb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/dispatch.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/dispatch.h @@ -23,6 +23,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -61,6 +63,8 @@ using __dispatch = typename __find_first_implemented<_Algorithm, _BackendConfigu } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_DISPATCH_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__pstl/handle_exception.h b/contrib/libs/cxxsupp/libcxx/include/__pstl/handle_exception.h index d6270958c3..57dfcfde45 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__pstl/handle_exception.h +++ b/contrib/libs/cxxsupp/libcxx/include/__pstl/handle_exception.h @@ -22,6 +22,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_BEGIN_NAMESPACE_STD namespace __pstl { @@ -52,6 +54,8 @@ _LIBCPP_HIDE_FROM_ABI auto __handle_exception(_Args&&... __args) { } // namespace __pstl _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER >= 17 + _LIBCPP_POP_MACROS #endif // _LIBCPP___PSTL_HANDLE_EXCEPTION_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/binomial_distribution.h b/contrib/libs/cxxsupp/libcxx/include/__random/binomial_distribution.h index 54f321af63..3f19746bae 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/binomial_distribution.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/binomial_distribution.h @@ -97,6 +97,11 @@ public: } }; +// The LLVM C library provides this with conflicting `noexcept` attributes. +#if !defined(_LIBCPP_MSVCRT_LIKE) && !defined(__LLVM_LIBC__) +extern "C" double lgamma_r(double, int*); +#endif + inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) { #if defined(_LIBCPP_MSVCRT_LIKE) return lgamma(__d); diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/mersenne_twister_engine.h b/contrib/libs/cxxsupp/libcxx/include/__random/mersenne_twister_engine.h index 65280d7c55..1f50e608ce 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/mersenne_twister_engine.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/mersenne_twister_engine.h @@ -13,6 +13,7 @@ #include <__algorithm/min.h> #include <__config> #include <__random/is_seed_sequence.h> +#include <__type_traits/enable_if.h> #include <cstddef> #include <cstdint> #include <iosfwd> diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/seed_seq.h b/contrib/libs/cxxsupp/libcxx/include/__random/seed_seq.h index 5cf84aeb8a..c1a320a75c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/seed_seq.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/seed_seq.h @@ -14,6 +14,8 @@ #include <__algorithm/max.h> #include <__config> #include <__iterator/iterator_traits.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_unsigned.h> #include <cstdint> #include <initializer_list> diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/subtract_with_carry_engine.h b/contrib/libs/cxxsupp/libcxx/include/__random/subtract_with_carry_engine.h index ec25fed49f..926333cdda 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/subtract_with_carry_engine.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/subtract_with_carry_engine.h @@ -14,6 +14,7 @@ #include <__config> #include <__random/is_seed_sequence.h> #include <__random/linear_congruential_engine.h> +#include <__type_traits/enable_if.h> #include <cstddef> #include <cstdint> #include <iosfwd> diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/uniform_random_bit_generator.h b/contrib/libs/cxxsupp/libcxx/include/__random/uniform_random_bit_generator.h index 4076f19b2c..75ffc27f9f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/uniform_random_bit_generator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/uniform_random_bit_generator.h @@ -13,8 +13,8 @@ #include <__concepts/invocable.h> #include <__concepts/same_as.h> #include <__config> -#include <__functional/invoke.h> #include <__type_traits/integral_constant.h> +#include <__type_traits/invoke.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/elements_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/elements_view.h index f159f53dc0..ac0d8dbbd5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/elements_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/elements_view.h @@ -16,7 +16,7 @@ #include <__concepts/derived_from.h> #include <__concepts/equality_comparable.h> #include <__config> -#include <__fwd/complex.h> +#include <__fwd/get.h> #include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> #include <__ranges/access.h> @@ -38,6 +38,7 @@ #include <__utility/forward.h> #include <__utility/move.h> #include <cstddef> +#include <tuple> // std::get #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h index c0f5ed936a..b2fa958a0f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h @@ -344,6 +344,8 @@ public: return __iterator{__bound_sentinel_}; } + _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const { return __value_ == __bound_sentinel_; } + _LIBCPP_HIDE_FROM_ABI constexpr auto size() const requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) || (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start> diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/range_adaptor.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/range_adaptor.h index 2da246f24e..b20165319b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/range_adaptor.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/range_adaptor.h @@ -19,8 +19,10 @@ #include <__functional/invoke.h> #include <__ranges/concepts.h> #include <__type_traits/decay.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_class.h> #include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/remove_cv.h> #include <__type_traits/remove_cvref.h> #include <__utility/forward.h> #include <__utility/move.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h index f91c7c3526..45244f3499 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h @@ -70,6 +70,8 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* end() const noexcept { return data() + 1; } + _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return false; } + _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 1; } _LIBCPP_HIDE_FROM_ABI constexpr _Tp* data() noexcept { return __value_.operator->(); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h index aba584ef93..144746babb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h @@ -33,6 +33,7 @@ #include <__tuple/tuple_size.h> #include <__type_traits/conditional.h> #include <__type_traits/decay.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_pointer.h> #include <__type_traits/is_reference.h> #include <__type_traits/make_unsigned.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/transform_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/transform_view.h index dc3aaa59ed..42e9a131f7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/transform_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/transform_view.h @@ -34,6 +34,7 @@ #include <__ranges/view_interface.h> #include <__type_traits/conditional.h> #include <__type_traits/decay.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_nothrow_constructible.h> #include <__type_traits/is_object.h> #include <__type_traits/is_reference.h> @@ -173,7 +174,8 @@ template <input_range _View, copy_constructible _Fn> # endif requires __transform_view_constraints<_View, _Fn> template <bool _Const> -class transform_view<_View, _Fn>::__iterator : public __transform_view_iterator_category_base<_View, _Fn> { +class transform_view<_View, _Fn>::__iterator + : public __transform_view_iterator_category_base<_View, __maybe_const<_Const, _Fn>> { using _Parent = __maybe_const<_Const, transform_view>; using _Base = __maybe_const<_Const, _View>; @@ -190,7 +192,7 @@ public: iterator_t<_Base> __current_ = iterator_t<_Base>(); using iterator_concept = typename __transform_view_iterator_concept<_View>::type; - using value_type = remove_cvref_t<invoke_result_t<_Fn&, range_reference_t<_Base>>>; + using value_type = remove_cvref_t<invoke_result_t<__maybe_const<_Const, _Fn>&, range_reference_t<_Base>>>; using difference_type = range_difference_t<_Base>; _LIBCPP_HIDE_FROM_ABI __iterator() @@ -326,13 +328,6 @@ public: { return __x.__current_ - __y.__current_; } - - _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) iter_move(const __iterator& __i) noexcept(noexcept(*__i)) { - if constexpr (is_lvalue_reference_v<decltype(*__i)>) - return std::move(*__i); - else - return *__i; - } }; # if _LIBCPP_STD_VER >= 23 diff --git a/contrib/libs/cxxsupp/libcxx/include/__split_buffer b/contrib/libs/cxxsupp/libcxx/include/__split_buffer index 2725b7d436..5da7a1f74a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__split_buffer +++ b/contrib/libs/cxxsupp/libcxx/include/__split_buffer @@ -78,7 +78,7 @@ public: pointer __first_; pointer __begin_; pointer __end_; - __compressed_pair<pointer, allocator_type> __end_cap_; + _LIBCPP_COMPRESSED_PAIR(pointer, __end_cap_, allocator_type, __alloc_); using __alloc_ref = __add_lvalue_reference_t<allocator_type>; using __alloc_const_ref = __add_lvalue_reference_t<allocator_type>; @@ -88,13 +88,13 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) - : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __default_init_tag()) {} + : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) {} _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(__alloc_rr& __a) - : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) {} + : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr), __alloc_(__a) {} _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(const __alloc_rr& __a) - : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) {} + : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr), __alloc_(__a) {} _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); @@ -111,15 +111,11 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer(); - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __alloc_rr& __alloc() _NOEXCEPT { return __end_cap_.second(); } - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const __alloc_rr& __alloc() const _NOEXCEPT { - return __end_cap_.second(); - } + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __alloc_rr& __alloc() _NOEXCEPT { return __alloc_; } + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const __alloc_rr& __alloc() const _NOEXCEPT { return __alloc_; } - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT { return __end_cap_.first(); } - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT { - return __end_cap_.first(); - } + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT { return __end_cap_; } + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT { return __end_cap_; } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __begin_; } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __begin_; } @@ -351,7 +347,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a) - : __end_cap_(nullptr, __a) { + : __end_cap_(nullptr), __alloc_(__a) { if (__cap == 0) { __first_ = nullptr; } else { @@ -376,7 +372,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(__ : __first_(std::move(__c.__first_)), __begin_(std::move(__c.__begin_)), __end_(std::move(__c.__end_)), - __end_cap_(std::move(__c.__end_cap_)) { + __end_cap_(std::move(__c.__end_cap_)), + __alloc_(std::move(__c.__alloc_)) { __c.__first_ = nullptr; __c.__begin_ = nullptr; __c.__end_ = nullptr; @@ -386,7 +383,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(__ template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a) - : __end_cap_(nullptr, __a) { + : __end_cap_(nullptr), __alloc_(__a) { if (__a == __c.__alloc()) { __first_ = __c.__first_; __begin_ = __c.__begin_; diff --git a/contrib/libs/cxxsupp/libcxx/include/__std_clang_module b/contrib/libs/cxxsupp/libcxx/include/__std_clang_module index 18d6ce6b46..a21ed26add 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__std_clang_module +++ b/contrib/libs/cxxsupp/libcxx/include/__std_clang_module @@ -33,9 +33,7 @@ #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) # include <atomic> #endif -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include <barrier> -#endif +#include <barrier> #include <bit> #include <bitset> #include <cassert> @@ -75,12 +73,8 @@ #include <ctime> #include <ctype.h> #include <cuchar> -#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) -# include <cwchar> -#endif -#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) -# include <cwctype> -#endif +#include <cwchar> +#include <cwctype> #include <deque> #include <errno.h> #include <exception> @@ -101,9 +95,7 @@ # include <fstream> #endif #include <functional> -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include <future> -#endif +#include <future> #include <initializer_list> #include <inttypes.h> #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) @@ -120,9 +112,7 @@ # include <istream> #endif #include <iterator> -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include <latch> -#endif +#include <latch> #include <limits> #include <list> #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) @@ -153,13 +143,9 @@ # include <regex> #endif #include <scoped_allocator> -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include <semaphore> -#endif +#include <semaphore> #include <set> -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include <shared_mutex> -#endif +#include <shared_mutex> #include <source_location> #include <span> #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) @@ -175,9 +161,7 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include <stop_token> -#endif +#include <stop_token> #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) # include <streambuf> #endif @@ -192,9 +176,7 @@ #endif #include <system_error> #include <tgmath.h> -#if !defined(_LIBCPP_HAS_NO_THREADS) -# include <thread> -#endif +#include <thread> #include <tuple> #include <type_traits> #include <typeindex> @@ -207,9 +189,5 @@ #include <variant> #include <vector> #include <version> -#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) -# include <wchar.h> -#endif -#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) -# include <wctype.h> -#endif +#include <wchar.h> +#include <wctype.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__stop_token/atomic_unique_lock.h b/contrib/libs/cxxsupp/libcxx/include/__stop_token/atomic_unique_lock.h index 13e59f9f0d..8fb70a4bfb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__stop_token/atomic_unique_lock.h +++ b/contrib/libs/cxxsupp/libcxx/include/__stop_token/atomic_unique_lock.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H -#define _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H +#ifndef _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H +#define _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H #include <__bit/popcount.h> #include <__config> @@ -133,8 +133,8 @@ private: _LIBCPP_HIDE_FROM_ABI static constexpr auto __set_locked_bit = [](_State __state) { return __state | _LockedBit; }; }; -#endif // _LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H +#endif // _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_callback.h b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_callback.h index 760cf2bb55..8d7167a5f0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_callback.h +++ b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_callback.h @@ -31,7 +31,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) +#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) template <class _Callback> class _LIBCPP_AVAILABILITY_SYNC stop_callback : private __stop_callback_base { @@ -93,10 +93,10 @@ private: template <class _Callback> _LIBCPP_AVAILABILITY_SYNC stop_callback(stop_token, _Callback) -> stop_callback<_Callback>; -#endif // _LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) +#endif // _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_source.h b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_source.h index 7069746278..7243856ecd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_source.h +++ b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_source.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) +#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) struct nostopstate_t { explicit nostopstate_t() = default; @@ -84,8 +84,8 @@ private: __intrusive_shared_ptr<__stop_state> __state_; }; -#endif // _LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) +#endif // _LIBCPP___STOP_TOKEN_STOP_SOURCE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_token.h b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_token.h index 1bd75cbbf6..b256973889 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_token.h +++ b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_token.h @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) +#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) class _LIBCPP_AVAILABILITY_SYNC stop_token { public: @@ -56,7 +56,7 @@ private: _LIBCPP_HIDE_FROM_ABI explicit stop_token(const __intrusive_shared_ptr<__stop_state>& __state) : __state_(__state) {} }; -#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__string/char_traits.h b/contrib/libs/cxxsupp/libcxx/include/__string/char_traits.h index 44b46ebb94..39accc6928 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__string/char_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__string/char_traits.h @@ -20,6 +20,7 @@ #include <__functional/hash.h> #include <__functional/identity.h> #include <__iterator/iterator_traits.h> +#include <__std_mbstate_t.h> #include <__string/constexpr_c_functions.h> #include <__type_traits/is_constant_evaluated.h> #include <__utility/is_pointer_in_range.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__string/constexpr_c_functions.h b/contrib/libs/cxxsupp/libcxx/include/__string/constexpr_c_functions.h index a978f816f1..9b8871e2e7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__string/constexpr_c_functions.h +++ b/contrib/libs/cxxsupp/libcxx/include/__string/constexpr_c_functions.h @@ -13,11 +13,13 @@ #include <__memory/addressof.h> #include <__memory/construct_at.h> #include <__type_traits/datasizeof.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_always_bitcastable.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_constant_evaluated.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_equality_comparable.h> +#include <__type_traits/is_integral.h> #include <__type_traits/is_same.h> #include <__type_traits/is_trivially_copyable.h> #include <__type_traits/is_trivially_lexicographically_comparable.h> @@ -64,13 +66,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_st return __builtin_strlen(reinterpret_cast<const char*>(__str)); } -// Because of __libcpp_is_trivially_lexicographically_comparable we know that comparing the object representations is +// Because of __is_trivially_lexicographically_comparable_v we know that comparing the object representations is // equivalent to a std::memcmp. Since we have multiple objects contiguously in memory, we can call memcmp once instead // of invoking it on every object individually. template <class _Tp, class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __constexpr_memcmp(const _Tp* __lhs, const _Up* __rhs, __element_count __n) { - static_assert(__libcpp_is_trivially_lexicographically_comparable<_Tp, _Up>::value, + static_assert(__is_trivially_lexicographically_comparable_v<_Tp, _Up>, "_Tp and _Up have to be trivially lexicographically comparable"); auto __count = static_cast<size_t>(__n); diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__nop_locale_mgmt.h b/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__nop_locale_mgmt.h index b9ffcbe162..5aaf3eaa64 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__nop_locale_mgmt.h +++ b/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__nop_locale_mgmt.h @@ -15,13 +15,13 @@ // Patch over lack of extended locale support typedef void* locale_t; -inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return NULL; } +inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return nullptr; } inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {} -inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return NULL; } +inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return nullptr; } -inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return NULL; } +inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return nullptr; } #define LC_COLLATE_MASK (1 << LC_COLLATE) #define LC_CTYPE_MASK (1 << LC_CTYPE) diff --git a/contrib/libs/cxxsupp/libcxx/include/__system_error/system_error.h b/contrib/libs/cxxsupp/libcxx/include/__system_error/system_error.h index 362e675056..3ffa1029ca 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__system_error/system_error.h +++ b/contrib/libs/cxxsupp/libcxx/include/__system_error/system_error.h @@ -39,8 +39,8 @@ public: _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } }; -_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg); -_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) { +[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg); +[[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw system_error(__ec, __what_arg); #else diff --git a/contrib/libs/cxxsupp/libcxx/include/__thread/jthread.h b/contrib/libs/cxxsupp/libcxx/include/__thread/jthread.h index b3d5c25fb7..9f3d41d391 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__thread/jthread.h +++ b/contrib/libs/cxxsupp/libcxx/include/__thread/jthread.h @@ -11,17 +11,19 @@ #define _LIBCPP___THREAD_JTHREAD_H #include <__config> -#include <__functional/invoke.h> #include <__stop_token/stop_source.h> #include <__stop_token/stop_token.h> +#include <__thread/id.h> #include <__thread/support.h> #include <__thread/thread.h> #include <__type_traits/decay.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_same.h> #include <__type_traits/remove_cvref.h> #include <__utility/forward.h> #include <__utility/move.h> +#include <__utility/swap.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -30,7 +32,7 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> -#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) +#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) _LIBCPP_BEGIN_NAMESPACE_STD @@ -127,7 +129,7 @@ private: _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) _LIBCPP_POP_MACROS diff --git a/contrib/libs/cxxsupp/libcxx/include/__thread/this_thread.h b/contrib/libs/cxxsupp/libcxx/include/__thread/this_thread.h index de7eea282c..c7521c90ed 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__thread/this_thread.h +++ b/contrib/libs/cxxsupp/libcxx/include/__thread/this_thread.h @@ -10,6 +10,7 @@ #ifndef _LIBCPP___THREAD_THIS_THREAD_H #define _LIBCPP___THREAD_THIS_THREAD_H +#include <__chrono/duration.h> #include <__chrono/steady_clock.h> #include <__chrono/time_point.h> #include <__condition_variable/condition_variable.h> @@ -29,6 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace this_thread { +#ifndef _LIBCPP_HAS_NO_THREADS + _LIBCPP_EXPORTED_FROM_ABI void sleep_for(const chrono::nanoseconds& __ns); template <class _Rep, class _Period> @@ -65,6 +68,8 @@ inline _LIBCPP_HIDE_FROM_ABI void sleep_until(const chrono::time_point<chrono::s inline _LIBCPP_HIDE_FROM_ABI void yield() _NOEXCEPT { __libcpp_thread_yield(); } +#endif // !_LIBCPP_HAS_NO_THREADS + } // namespace this_thread _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__thread/thread.h b/contrib/libs/cxxsupp/libcxx/include/__thread/thread.h index d2254a695f..481a3f38b8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__thread/thread.h +++ b/contrib/libs/cxxsupp/libcxx/include/__thread/thread.h @@ -10,6 +10,7 @@ #ifndef _LIBCPP___THREAD_THREAD_H #define _LIBCPP___THREAD_THREAD_H +#include <__assert> #include <__condition_variable/condition_variable.h> #include <__config> #include <__exception/terminate.h> @@ -20,6 +21,7 @@ #include <__system_error/system_error.h> #include <__thread/id.h> #include <__thread/support.h> +#include <__type_traits/decay.h> #include <__utility/forward.h> #include <tuple> @@ -37,6 +39,8 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD +#if !defined(_LIBCPP_HAS_NO_THREADS) + template <class _Tp> class __thread_specific_ptr; class _LIBCPP_EXPORTED_FROM_ABI __thread_struct; @@ -117,7 +121,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> : public __unary_function<__thread } }; -#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# ifndef _LIBCPP_HAS_NO_LOCALIZATION template <class _CharT, class _Traits> _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) { @@ -142,7 +146,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) { __sstr << __id.__id_; return __os << __sstr.str(); } -#endif // _LIBCPP_HAS_NO_LOCALIZATION +# endif // _LIBCPP_HAS_NO_LOCALIZATION class _LIBCPP_EXPORTED_FROM_ABI thread { __libcpp_thread_t __t_; @@ -155,13 +159,13 @@ public: typedef __libcpp_thread_t native_handle_type; _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {} -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args); -#else // _LIBCPP_CXX03_LANG +# else // _LIBCPP_CXX03_LANG template <class _Fp> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp __f); -#endif +# endif ~thread(); _LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { __t.__t_ = _LIBCPP_NULL_THREAD; } @@ -185,7 +189,7 @@ public: static unsigned hardware_concurrency() _NOEXCEPT; }; -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template <class _TSp, class _Fp, class... _Args, size_t... _Indices> inline _LIBCPP_HIDE_FROM_ABI void __thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>) { @@ -215,7 +219,7 @@ thread::thread(_Fp&& __f, _Args&&... __args) { __throw_system_error(__ec, "thread constructor failed"); } -#else // _LIBCPP_CXX03_LANG +# else // _LIBCPP_CXX03_LANG template <class _Fp> struct __thread_invoke_pair { @@ -247,10 +251,12 @@ thread::thread(_Fp __f) { __throw_system_error(__ec, "thread constructor failed"); } -#endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); } +#endif // !defined(_LIBCPP_HAS_NO_THREADS) + _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS diff --git a/contrib/libs/cxxsupp/libcxx/include/__tree b/contrib/libs/cxxsupp/libcxx/include/__tree index 1990fa602d..f6ef21cdaa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tree +++ b/contrib/libs/cxxsupp/libcxx/include/__tree @@ -13,7 +13,6 @@ #include <__algorithm/min.h> #include <__assert> #include <__config> -#include <__functional/invoke.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__iterator/next.h> @@ -25,6 +24,8 @@ #include <__memory/unique_ptr.h> #include <__type_traits/can_extract_key.h> #include <__type_traits/conditional.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_const.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_nothrow_assignable.h> @@ -566,11 +567,18 @@ struct __tree_node_base_types { typedef __tree_end_node<__node_base_pointer> __end_node_type; typedef __rebind_pointer_t<_VoidPtr, __end_node_type> __end_node_pointer; -#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB) typedef __end_node_pointer __parent_pointer; -#else - typedef __conditional_t< is_pointer<__end_node_pointer>::value, __end_node_pointer, __node_base_pointer> - __parent_pointer; + +// TODO(LLVM 22): Remove this check +#ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB + static_assert(sizeof(__node_base_pointer) == sizeof(__end_node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) == + _LIBCPP_ALIGNOF(__end_node_pointer), + "It looks like you are using std::__tree (an implementation detail for (multi)map/set) with a fancy " + "pointer type that thas a different representation depending on whether it points to a __tree base " + "pointer or a __tree node pointer (both of which are implementation details of the standard library). " + "This means that your ABI is being broken between LLVM 19 and LLVM 20. If you don't care about your " + "ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to silence this " + "diagnostic."); #endif private: @@ -605,12 +613,7 @@ public: typedef _Tp __node_value_type; typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer; typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer; -#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB) typedef typename __base::__end_node_pointer __iter_pointer; -#else - typedef __conditional_t< is_pointer<__node_pointer>::value, typename __base::__end_node_pointer, __node_pointer> - __iter_pointer; -#endif private: static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const"); @@ -932,21 +935,21 @@ private: private: __iter_pointer __begin_node_; - __compressed_pair<__end_node_t, __node_allocator> __pair1_; - __compressed_pair<size_type, value_compare> __pair3_; + _LIBCPP_COMPRESSED_PAIR(__end_node_t, __end_node_, __node_allocator, __node_alloc_); + _LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_); public: _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() _NOEXCEPT { - return static_cast<__iter_pointer>(pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first())); + return static_cast<__iter_pointer>(pointer_traits<__end_node_ptr>::pointer_to(__end_node_)); } _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() const _NOEXCEPT { return static_cast<__iter_pointer>( - pointer_traits<__end_node_ptr>::pointer_to(const_cast<__end_node_t&>(__pair1_.first()))); + pointer_traits<__end_node_ptr>::pointer_to(const_cast<__end_node_t&>(__end_node_))); } - _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __pair1_.second(); } + _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; } private: - _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __pair1_.second(); } + _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; } _LIBCPP_HIDE_FROM_ABI __iter_pointer& __begin_node() _NOEXCEPT { return __begin_node_; } _LIBCPP_HIDE_FROM_ABI const __iter_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; } @@ -954,12 +957,12 @@ public: _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); } private: - _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __pair3_.first(); } + _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; } public: - _LIBCPP_HIDE_FROM_ABI const size_type& size() const _NOEXCEPT { return __pair3_.first(); } - _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __pair3_.second(); } - _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __pair3_.second(); } + _LIBCPP_HIDE_FROM_ABI const size_type& size() const _NOEXCEPT { return __size_; } + _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __value_comp_; } + _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __value_comp_; } public: _LIBCPP_HIDE_FROM_ABI __node_pointer __root() const _NOEXCEPT { @@ -1324,21 +1327,19 @@ private: template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_( is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value) - : __pair3_(0, __comp) { + : __size_(0), __value_comp_(__comp) { __begin_node() = __end_node(); } template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) - : __begin_node_(__iter_pointer()), - __pair1_(__default_init_tag(), __node_allocator(__a)), - __pair3_(0, __default_init_tag()) { + : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0) { __begin_node() = __end_node(); } template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) - : __begin_node_(__iter_pointer()), __pair1_(__default_init_tag(), __node_allocator(__a)), __pair3_(0, __comp) { + : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) { __begin_node() = __end_node(); } @@ -1437,8 +1438,9 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _ template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) : __begin_node_(__iter_pointer()), - __pair1_(__default_init_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())), - __pair3_(0, __t.value_comp()) { + __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())), + __size_(0), + __value_comp_(__t.value_comp()) { __begin_node() = __end_node(); } @@ -1446,8 +1448,10 @@ template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_( is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value) : __begin_node_(std::move(__t.__begin_node_)), - __pair1_(std::move(__t.__pair1_)), - __pair3_(std::move(__t.__pair3_)) { + __end_node_(std::move(__t.__end_node_)), + __node_alloc_(std::move(__t.__node_alloc_)), + __size_(__t.__size_), + __value_comp_(std::move(__t.__value_comp_)) { if (size() == 0) __begin_node() = __end_node(); else { @@ -1460,7 +1464,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_( template <class _Tp, class _Compare, class _Allocator> __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a) - : __pair1_(__default_init_tag(), __node_allocator(__a)), __pair3_(0, std::move(__t.value_comp())) { + : __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(std::move(__t.value_comp())) { if (__a == __t.__alloc()) { if (__t.size() == 0) __begin_node() = __end_node(); @@ -1482,10 +1486,11 @@ template <class _Tp, class _Compare, class _Allocator> void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value) { destroy(static_cast<__node_pointer>(__end_node()->__left_)); - __begin_node_ = __t.__begin_node_; - __pair1_.first() = __t.__pair1_.first(); + __begin_node_ = __t.__begin_node_; + __end_node_ = __t.__end_node_; __move_assign_alloc(__t); - __pair3_ = std::move(__t.__pair3_); + __size_ = __t.__size_; + __value_comp_ = std::move(__t.__value_comp_); if (size() == 0) __begin_node() = __end_node(); else { @@ -1554,9 +1559,10 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) { using std::swap; swap(__begin_node_, __t.__begin_node_); - swap(__pair1_.first(), __t.__pair1_.first()); + swap(__end_node_, __t.__end_node_); std::__swap_allocator(__node_alloc(), __t.__node_alloc()); - __pair3_.swap(__t.__pair3_); + swap(__size_, __t.__size_); + swap(__value_comp_, __t.__value_comp_); if (size() == 0) __begin_node() = __end_node(); else diff --git a/contrib/libs/cxxsupp/libcxx/include/__tuple/find_index.h b/contrib/libs/cxxsupp/libcxx/include/__tuple/find_index.h index 133b00419d..cc7329d3e8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tuple/find_index.h +++ b/contrib/libs/cxxsupp/libcxx/include/__tuple/find_index.h @@ -10,8 +10,8 @@ #define _LIBCPP___TUPLE_FIND_INDEX_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/is_same.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__tuple/ignore.h b/contrib/libs/cxxsupp/libcxx/include/__tuple/ignore.h new file mode 100644 index 0000000000..43cce53874 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__tuple/ignore.h @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___TUPLE_IGNORE_H +#define _LIBCPP___TUPLE_IGNORE_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_CXX03_LANG + +_LIBCPP_BEGIN_NAMESPACE_STD + +struct __ignore_type { + template <class _Tp> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const __ignore_type& operator=(const _Tp&) const noexcept { + return *this; + } +}; + +# if _LIBCPP_STD_VER >= 17 +inline constexpr __ignore_type ignore; +# else +constexpr __ignore_type ignore; +# endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_CXX03_LANG + +#endif // _LIBCPP___TUPLE_IGNORE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__tuple/make_tuple_types.h b/contrib/libs/cxxsupp/libcxx/include/__tuple/make_tuple_types.h index 9e0fefae2f..53e98c3d6e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tuple/make_tuple_types.h +++ b/contrib/libs/cxxsupp/libcxx/include/__tuple/make_tuple_types.h @@ -10,6 +10,7 @@ #define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H #include <__config> +#include <__cstddef/size_t.h> #include <__fwd/array.h> #include <__fwd/tuple.h> #include <__tuple/tuple_element.h> @@ -19,7 +20,6 @@ #include <__type_traits/copy_cvref.h> #include <__type_traits/remove_cv.h> #include <__type_traits/remove_reference.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__tuple/sfinae_helpers.h b/contrib/libs/cxxsupp/libcxx/include/__tuple/sfinae_helpers.h index 7db5eeb1dd..4a6ff1fd2d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tuple/sfinae_helpers.h +++ b/contrib/libs/cxxsupp/libcxx/include/__tuple/sfinae_helpers.h @@ -10,6 +10,7 @@ #define _LIBCPP___TUPLE_SFINAE_HELPERS_H #include <__config> +#include <__cstddef/size_t.h> #include <__fwd/tuple.h> #include <__tuple/make_tuple_types.h> #include <__tuple/tuple_element.h> @@ -23,7 +24,6 @@ #include <__type_traits/is_same.h> #include <__type_traits/remove_cvref.h> #include <__type_traits/remove_reference.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_element.h b/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_element.h index 55b3b47619..1404460e74 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_element.h +++ b/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_element.h @@ -10,9 +10,9 @@ #define _LIBCPP___TUPLE_TUPLE_ELEMENT_H #include <__config> +#include <__cstddef/size_t.h> #include <__tuple/tuple_indices.h> #include <__tuple/tuple_types.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -40,32 +40,6 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> { #ifndef _LIBCPP_CXX03_LANG -# if !__has_builtin(__type_pack_element) - -namespace __indexer_detail { - -template <size_t _Idx, class _Tp> -struct __indexed { - using type _LIBCPP_NODEBUG = _Tp; -}; - -template <class _Types, class _Indexes> -struct __indexer; - -template <class... _Types, size_t... _Idx> -struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>> : __indexed<_Idx, _Types>... {}; - -template <size_t _Idx, class _Tp> -__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&); - -} // namespace __indexer_detail - -template <size_t _Idx, class... _Types> -using __type_pack_element _LIBCPP_NODEBUG = typename decltype(__indexer_detail::__at_index<_Idx>( - __indexer_detail::__indexer< __tuple_types<_Types...>, - typename __make_tuple_indices<sizeof...(_Types)>::type >{}))::type; -# endif - template <size_t _Ip, class... _Types> struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > { static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range"); diff --git a/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_indices.h b/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_indices.h index 501e711255..25dc9ec685 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_indices.h +++ b/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_indices.h @@ -10,8 +10,8 @@ #define _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H #include <__config> +#include <__cstddef/size_t.h> #include <__utility/integer_sequence.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_like_ext.h b/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_like_ext.h index 0cc21e0b75..45c0e65d62 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_like_ext.h +++ b/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_like_ext.h @@ -10,12 +10,12 @@ #define _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H #include <__config> +#include <__cstddef/size_t.h> #include <__fwd/array.h> #include <__fwd/pair.h> #include <__fwd/tuple.h> #include <__tuple/tuple_types.h> #include <__type_traits/integral_constant.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_like_no_subrange.h b/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_like_no_subrange.h index 274b0bf188..30018d6a05 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_like_no_subrange.h +++ b/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_like_no_subrange.h @@ -10,13 +10,13 @@ #define _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H #include <__config> +#include <__cstddef/size_t.h> #include <__fwd/array.h> #include <__fwd/complex.h> #include <__fwd/pair.h> #include <__fwd/tuple.h> #include <__tuple/tuple_size.h> #include <__type_traits/remove_cvref.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_size.h b/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_size.h index 18a17fd4d5..b970280fe3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_size.h +++ b/contrib/libs/cxxsupp/libcxx/include/__tuple/tuple_size.h @@ -10,11 +10,13 @@ #define _LIBCPP___TUPLE_TUPLE_SIZE_H #include <__config> +#include <__cstddef/size_t.h> #include <__fwd/tuple.h> #include <__tuple/tuple_types.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_const.h> #include <__type_traits/is_volatile.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/add_pointer.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/add_pointer.h index 358e3cbd23..5aac7d5cfa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/add_pointer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/add_pointer.h @@ -11,9 +11,7 @@ #include <__config> #include <__type_traits/is_referenceable.h> -#include <__type_traits/is_same.h> #include <__type_traits/is_void.h> -#include <__type_traits/remove_cv.h> #include <__type_traits/remove_reference.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/aligned_storage.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/aligned_storage.h index 46aae12832..49b4e971bb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/aligned_storage.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/aligned_storage.h @@ -10,11 +10,11 @@ #define _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/conditional.h> #include <__type_traits/integral_constant.h> #include <__type_traits/nat.h> #include <__type_traits/type_list.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/aligned_union.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/aligned_union.h index 005ed9a096..de62a4b1c2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/aligned_union.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/aligned_union.h @@ -10,9 +10,9 @@ #define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/aligned_storage.h> #include <__type_traits/integral_constant.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/alignment_of.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/alignment_of.h index f2d069bf24..8871c8ce11 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/alignment_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/alignment_of.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/datasizeof.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/datasizeof.h index b4cbd1ddfa..0c1ed94f84 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/datasizeof.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/datasizeof.h @@ -10,9 +10,9 @@ #define _LIBCPP___TYPE_TRAITS_DATASIZEOF_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/is_class.h> #include <__type_traits/is_final.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -37,15 +37,15 @@ struct _FirstPaddingByte { char __first_padding_byte_; }; -// _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow -// the use as an extension. +// _FirstPaddingByte<> is sometimes non-standard layout. +// It is conditionally-supported to use __builtin_offsetof in that case, but GCC and Clang allow it. _LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof") _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Winvalid-offsetof") template <class _Tp> -inline const size_t __datasizeof_v = offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_); +inline const size_t __datasizeof_v = __builtin_offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_); _LIBCPP_DIAGNOSTIC_POP -#endif // __has_extension(datasizeof) +#endif // __has_extension(datasizeof) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/desugars_to.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/desugars_to.h index 97a2ee5448..b0ce7c414e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/desugars_to.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/desugars_to.h @@ -17,10 +17,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD -// Tags to represent the canonical operations +// Tags to represent the canonical operations. + +// syntactically, the operation is equivalent to calling `a == b` struct __equal_tag {}; + +// syntactically, the operation is equivalent to calling `a + b` struct __plus_tag {}; -struct __less_tag {}; + +// syntactically, the operation is equivalent to calling `a < b`, and these expressions +// have to be true for any `a` and `b`: +// - `(a < b) == (b > a)` +// - `(!(a < b) && !(b < a)) == (a == b)` +// For example, this is satisfied for std::less on integral types, but also for ranges::less on all types due to +// additional semantic requirements on that operation. +struct __totally_ordered_less_tag {}; // This class template is used to determine whether an operation "desugars" // (or boils down) to a given canonical operation. diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/extent.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/extent.h index 8f281b36f7..9d52032c0a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/extent.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/extent.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_EXTENT_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/invoke.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/invoke.h index a0281f5b20..71db32ae6a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/invoke.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/invoke.h @@ -17,8 +17,7 @@ #include <__type_traits/integral_constant.h> #include <__type_traits/is_base_of.h> #include <__type_traits/is_core_convertible.h> -#include <__type_traits/is_member_function_pointer.h> -#include <__type_traits/is_member_object_pointer.h> +#include <__type_traits/is_member_pointer.h> #include <__type_traits/is_reference_wrapper.h> #include <__type_traits/is_same.h> #include <__type_traits/is_void.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_allocator.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_allocator.h index 144ffac4d7..191eeb9a1f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_allocator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_allocator.h @@ -10,10 +10,10 @@ #define _LIBCPP___TYPE_IS_ALLOCATOR_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> #include <__type_traits/void_t.h> #include <__utility/declval.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_array.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_array.h index dc23de28d2..f34204e19e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_array.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_array.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_base_of.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_base_of.h index 090abeeb54..488b63719e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_base_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_base_of.h @@ -26,6 +26,18 @@ template <class _Bp, class _Dp> inline constexpr bool is_base_of_v = __is_base_of(_Bp, _Dp); #endif +#if _LIBCPP_STD_VER >= 26 +# if __has_builtin(__builtin_is_virtual_base_of) + +template <class _Base, class _Derived> +struct _LIBCPP_TEMPLATE_VIS is_virtual_base_of : public bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)> {}; + +template <class _Base, class _Derived> +inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived); + +# endif +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___TYPE_TRAITS_IS_BASE_OF_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_bounded_array.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_bounded_array.h index 211403d638..a78b52e706 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_bounded_array.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_bounded_array.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_enum.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_enum.h index 77ca3ea108..2fab6db2c8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_enum.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_enum.h @@ -26,6 +26,16 @@ template <class _Tp> inline constexpr bool is_enum_v = __is_enum(_Tp); #endif +#if _LIBCPP_STD_VER >= 23 + +template <class _Tp> +struct _LIBCPP_TEMPLATE_VIS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {}; + +template <class _Tp> +inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp); + +#endif // _LIBCPP_STD_VER >= 23 + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___TYPE_TRAITS_IS_ENUM_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_function.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_function.h index 580d1b6b7d..98fedd0ad9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_function.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_function.h @@ -11,8 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_const.h> -#include <__type_traits/is_reference.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -20,22 +18,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if __has_builtin(__is_function) && !defined(__CUDACC__) - template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {}; -#else - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_function - : public integral_constant<bool, !(is_reference<_Tp>::value || is_const<const _Tp>::value)> {}; - -#endif // __has_builtin(__is_function) - #if _LIBCPP_STD_VER >= 17 template <class _Tp> -inline constexpr bool is_function_v = is_function<_Tp>::value; +inline constexpr bool is_function_v = __is_function(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_fundamental.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_fundamental.h index 417739f9dc..a1211bca4f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_fundamental.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_fundamental.h @@ -34,7 +34,7 @@ inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental - : public integral_constant<bool, is_void<_Tp>::value || __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; + : public integral_constant<bool, is_void<_Tp>::value || __is_null_pointer_v<_Tp> || is_arithmetic<_Tp>::value> {}; # if _LIBCPP_STD_VER >= 17 template <class _Tp> diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_member_function_pointer.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_member_function_pointer.h deleted file mode 100644 index af2c3e2d83..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_member_function_pointer.h +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H -#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H - -#include <__config> -#include <__type_traits/integral_constant.h> -#include <__type_traits/is_function.h> -#include <__type_traits/remove_cv.h> -#include <cstddef> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _Tp> -struct __libcpp_is_member_pointer { - enum { __is_member = false, __is_func = false, __is_obj = false }; -}; -template <class _Tp, class _Up> -struct __libcpp_is_member_pointer<_Tp _Up::*> { - enum { - __is_member = true, - __is_func = is_function<_Tp>::value, - __is_obj = !__is_func, - }; -}; - -#if __has_builtin(__is_member_function_pointer) && !defined(__CUDACC__) - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {}; - -# if _LIBCPP_STD_VER >= 17 -template <class _Tp> -inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); -# endif - -#else // __has_builtin(__is_member_function_pointer) - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer - : public _BoolConstant<__libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_func> {}; - -# if _LIBCPP_STD_VER >= 17 -template <class _Tp> -inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; -# endif - -#endif // __has_builtin(__is_member_function_pointer) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_member_object_pointer.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_member_object_pointer.h deleted file mode 100644 index 645488edeb..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_member_object_pointer.h +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H -#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H - -#include <__config> -#include <__type_traits/integral_constant.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if __has_builtin(__is_member_object_pointer) && !defined(__CUDACC__) - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {}; - -# if _LIBCPP_STD_VER >= 17 -template <class _Tp> -inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); -# endif - -#else // __has_builtin(__is_member_object_pointer) - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer - : public _BoolConstant<__libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_obj> {}; - -# if _LIBCPP_STD_VER >= 17 -template <class _Tp> -inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; -# endif - -#endif // __has_builtin(__is_member_object_pointer) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_member_pointer.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_member_pointer.h index 429f2affcb..3e2753ac42 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_member_pointer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_member_pointer.h @@ -11,7 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_member_function_pointer.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -19,28 +18,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if __has_builtin(__is_member_pointer) && !defined(__CUDACC__) - template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {}; -# if _LIBCPP_STD_VER >= 17 template <class _Tp> -inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); -# endif +struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {}; -#else // __has_builtin(__is_member_pointer) +template <class _Tp> +struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {}; +#if _LIBCPP_STD_VER >= 17 template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_member_pointer - : public _BoolConstant<__libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_member> {}; +inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); -# if _LIBCPP_STD_VER >= 17 template <class _Tp> -inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; -# endif +inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); -#endif // __has_builtin(__is_member_pointer) +template <class _Tp> +inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); +#endif _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_nothrow_constructible.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_nothrow_constructible.h index 678debb455..58d2b24751 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_nothrow_constructible.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_nothrow_constructible.h @@ -13,10 +13,6 @@ #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/add_rvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_constructible.h> -#include <__type_traits/is_reference.h> -#include <__utility/declval.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -24,85 +20,28 @@ _LIBCPP_BEGIN_NAMESPACE_STD -// GCC is disabled due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 -#if __has_builtin(__is_nothrow_constructible) && !defined(_LIBCPP_COMPILER_GCC) && !defined(__CUDACC__) - template < class _Tp, class... _Args> struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {}; -#else - -template <bool, bool, class _Tp, class... _Args> -struct __libcpp_is_nothrow_constructible; - -template <class _Tp, class... _Args> -struct __libcpp_is_nothrow_constructible</*is constructible*/ true, /*is reference*/ false, _Tp, _Args...> - : public integral_constant<bool, noexcept(_Tp(std::declval<_Args>()...))> {}; - -template <class _Tp> -void __implicit_conversion_to(_Tp) noexcept {} - -template <class _Tp, class _Arg> -struct __libcpp_is_nothrow_constructible</*is constructible*/ true, /*is reference*/ true, _Tp, _Arg> - : public integral_constant<bool, noexcept(std::__implicit_conversion_to<_Tp>(std::declval<_Arg>()))> {}; - -template <class _Tp, bool _IsReference, class... _Args> -struct __libcpp_is_nothrow_constructible</*is constructible*/ false, _IsReference, _Tp, _Args...> : public false_type { -}; - -template <class _Tp, class... _Args> -struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible - : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, - is_reference<_Tp>::value, - _Tp, - _Args...> {}; - -template <class _Tp, size_t _Ns> -struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]> - : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp> {}; - -#endif // __has_builtin(__is_nothrow_constructible) #if _LIBCPP_STD_VER >= 17 template <class _Tp, class... _Args> inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value; #endif -// TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed -#ifdef _LIBCPP_COMPILER_GCC - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible - : public is_nothrow_constructible<_Tp, __add_lvalue_reference_t<const _Tp> > {}; - -#else // _LIBCPP_COMPILER_GCC - template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible : public integral_constant< bool, __is_nothrow_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; -#endif // _LIBCPP_COMPILER_GCC - #if _LIBCPP_STD_VER >= 17 template <class _Tp> inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; #endif -// TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed -#ifndef _LIBCPP_COMPILER_GCC - template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; -#else // _LIBCPP_COMPILER_GCC - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible - : public is_nothrow_constructible<_Tp, __add_rvalue_reference_t<_Tp> > {}; - -#endif // _LIBCPP_COMPILER_GCC - #if _LIBCPP_STD_VER >= 17 template <class _Tp> inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_nothrow_destructible.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_nothrow_destructible.h index c2d5ca8723..41271a38f3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_nothrow_destructible.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_nothrow_destructible.h @@ -10,10 +10,10 @@ #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> #include <__type_traits/is_destructible.h> #include <__utility/declval.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_null_pointer.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_null_pointer.h index c666f5f247..302b2f8903 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_null_pointer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_null_pointer.h @@ -10,9 +10,9 @@ #define _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H #include <__config> +#include <__cstddef/nullptr_t.h> #include <__type_traits/integral_constant.h> #include <__type_traits/remove_cv.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -21,20 +21,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> -struct __is_nullptr_t_impl : public false_type {}; -template <> -struct __is_nullptr_t_impl<nullptr_t> : public true_type {}; - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {}; +#if __has_builtin(__remove_cv) +inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t); +#else +inline const bool __is_null_pointer_v = __is_same(__remove_cv_t<_Tp>, nullptr_t); +#endif #if _LIBCPP_STD_VER >= 14 template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_null_pointer : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {}; +struct _LIBCPP_TEMPLATE_VIS is_null_pointer : integral_constant<bool, __is_null_pointer_v<_Tp>> {}; # if _LIBCPP_STD_VER >= 17 template <class _Tp> -inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; +inline constexpr bool is_null_pointer_v = __is_null_pointer_v<_Tp>; # endif #endif // _LIBCPP_STD_VER >= 14 diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_object.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_object.h index cdfe4838e6..ec04508402 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_object.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_object.h @@ -11,10 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_array.h> -#include <__type_traits/is_class.h> -#include <__type_traits/is_scalar.h> -#include <__type_traits/is_union.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -22,30 +18,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if __has_builtin(__is_object) && !defined(__CUDACC__) - template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> {}; -# if _LIBCPP_STD_VER >= 17 +#if _LIBCPP_STD_VER >= 17 template <class _Tp> inline constexpr bool is_object_v = __is_object(_Tp); -# endif - -#else // __has_builtin(__is_object) - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_object - : public integral_constant<bool, - is_scalar<_Tp>::value || is_array<_Tp>::value || is_union<_Tp>::value || - is_class<_Tp>::value > {}; - -# if _LIBCPP_STD_VER >= 17 -template <class _Tp> -inline constexpr bool is_object_v = is_object<_Tp>::value; -# endif - -#endif // __has_builtin(__is_object) +#endif _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_reference.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_reference.h index 9d8564679b..cc157a438e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_reference.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_reference.h @@ -18,28 +18,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) && __has_builtin(__is_reference) && \ - !defined(__CUDACC__) +template <class _Tp> +struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> {}; +#if _LIBCPP_STD_VER >= 17 template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {}; +inline constexpr bool is_reference_v = __is_reference(_Tp); +#endif + +#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {}; +struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {}; template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> {}; +struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {}; # if _LIBCPP_STD_VER >= 17 template <class _Tp> -inline constexpr bool is_reference_v = __is_reference(_Tp); -template <class _Tp> inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); template <class _Tp> inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); # endif -#else // __has_builtin(__is_lvalue_reference) && etc... +#else // __has_builtin(__is_lvalue_reference) template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; @@ -51,25 +53,15 @@ struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; - # if _LIBCPP_STD_VER >= 17 template <class _Tp> -inline constexpr bool is_reference_v = is_reference<_Tp>::value; - -template <class _Tp> inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; template <class _Tp> inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; # endif -#endif // __has_builtin(__is_lvalue_reference) && etc... +#endif // __has_builtin(__is_lvalue_reference) _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_scalar.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_scalar.h index e6f8e87f18..09117928a9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_scalar.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_scalar.h @@ -49,7 +49,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar bool, is_arithmetic<_Tp>::value || is_member_pointer<_Tp>::value || is_pointer<_Tp>::value || - __is_nullptr_t<_Tp>::value || + __is_null_pointer_v<_Tp> || __is_block<_Tp>::value || is_enum<_Tp>::value> {}; // clang-format on diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_scoped_enum.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_scoped_enum.h deleted file mode 100644 index 1db88e1335..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_scoped_enum.h +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H -#define _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H - -#include <__config> -#include <__type_traits/integral_constant.h> -#include <__type_traits/is_convertible.h> -#include <__type_traits/is_enum.h> -#include <__type_traits/underlying_type.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER >= 23 - -// TODO: GCC and Clang both have this builtin. Remove the false case once we've updated to GCC 14. -# if __has_builtin(__is_scoped_enum) - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {}; - -template <class _Tp> -inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp); - -# else - -template <class _Tp, bool = is_enum_v<_Tp> > -struct __is_scoped_enum_helper : false_type {}; - -template <class _Tp> -struct __is_scoped_enum_helper<_Tp, true> : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {}; - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_scoped_enum : public __is_scoped_enum_helper<_Tp> {}; - -template <class _Tp> -inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; - -# endif // __has_builtin(__is_scoped_enum) - -#endif // _LIBCPP_STD_VER >= 23 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_swappable.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_swappable.h index 0b817e6509..221f017700 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_swappable.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_swappable.h @@ -10,15 +10,16 @@ #define _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/enable_if.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_nothrow_assignable.h> #include <__type_traits/is_nothrow_constructible.h> #include <__type_traits/void_t.h> #include <__utility/declval.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_trivially_lexicographically_comparable.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_trivially_lexicographically_comparable.h index a310ea1b87..15dda5824a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_trivially_lexicographically_comparable.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_trivially_lexicographically_comparable.h @@ -10,6 +10,7 @@ #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_LEXICOGRAPHICALLY_COMPARABLE_H #include <__config> +#include <__fwd/byte.h> #include <__type_traits/integral_constant.h> #include <__type_traits/is_same.h> #include <__type_traits/is_unsigned.h> @@ -40,13 +41,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD // unsigned integer types with sizeof(T) > 1: depending on the endianness, the LSB might be the first byte to be // compared. This means that when comparing unsigned(129) and unsigned(2) // using memcmp(), the result would be that 2 > 129. -// TODO: Do we want to enable this on big-endian systems? + +template <class _Tp> +inline const bool __is_std_byte_v = false; + +#if _LIBCPP_STD_VER >= 17 +template <> +inline const bool __is_std_byte_v<byte> = true; +#endif template <class _Tp, class _Up> -struct __libcpp_is_trivially_lexicographically_comparable - : integral_constant<bool, - is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value && sizeof(_Tp) == 1 && - is_unsigned<_Tp>::value> {}; +inline const bool __is_trivially_lexicographically_comparable_v = + is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value && +#ifdef _LIBCPP_LITTLE_ENDIAN + sizeof(_Tp) == 1 && +#endif + (is_unsigned<_Tp>::value || __is_std_byte_v<_Tp>); _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_void.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_void.h index 69eea76488..813bf45dc0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_void.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_void.h @@ -11,7 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_same.h> #include <__type_traits/remove_cv.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -20,27 +19,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if __has_builtin(__is_void) && !defined(__CUDACC__) - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> {}; - -# if _LIBCPP_STD_VER >= 17 template <class _Tp> -inline constexpr bool is_void_v = __is_void(_Tp); -# endif - +#if __has_builtin(__remove_cv) +struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {}; #else +struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_same(__remove_cv_t<_Tp>, void)> {}; +#endif +#if _LIBCPP_STD_VER >= 17 template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS is_void : public is_same<__remove_cv_t<_Tp>, void> {}; - -# if _LIBCPP_STD_VER >= 17 -template <class _Tp> -inline constexpr bool is_void_v = is_void<_Tp>::value; -# endif - -#endif // __has_builtin(__is_void) +# if __has_builtin(__remove_cv) +inline constexpr bool is_void_v = __is_same(__remove_cv(_Tp), void); +# else +inline constexpr bool is_void_v = __is_same(__remove_cv_t<_Tp>, void); +# endif +#endif _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/make_signed.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/make_signed.h index c1fc009d9b..d09d6ed4a1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/make_signed.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/make_signed.h @@ -10,6 +10,7 @@ #define _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H #include <__config> +#include <__type_traits/copy_cv.h> #include <__type_traits/is_enum.h> #include <__type_traits/is_integral.h> #include <__type_traits/nat.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/make_unsigned.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/make_unsigned.h index 282cd2d911..8757f451eb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/make_unsigned.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/make_unsigned.h @@ -86,12 +86,10 @@ template <class _Tp> using make_unsigned_t = __make_unsigned_t<_Tp>; #endif -#ifndef _LIBCPP_CXX03_LANG template <class _Tp> -_LIBCPP_HIDE_FROM_ABI constexpr __make_unsigned_t<_Tp> __to_unsigned_like(_Tp __x) noexcept { +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __make_unsigned_t<_Tp> __to_unsigned_like(_Tp __x) _NOEXCEPT { return static_cast<__make_unsigned_t<_Tp> >(__x); } -#endif template <class _Tp, class _Up> using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, __make_unsigned_t<_Up>, _Up>; diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/rank.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/rank.h index 7f6fad1c54..aeeedec40d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/rank.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/rank.h @@ -10,8 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_RANK_H #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/integral_constant.h> -#include <cstddef> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_all_extents.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_all_extents.h index d5373b51f5..db7dab4a6c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_all_extents.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_all_extents.h @@ -10,7 +10,7 @@ #define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H #include <__config> -#include <cstddef> +#include <__cstddef/size_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_cv.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_cv.h index 639a9c4fb6..e09cfd7723 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_cv.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_cv.h @@ -34,7 +34,7 @@ using __remove_cv_t = typename remove_cv<_Tp>::type; #else template <class _Tp> using __remove_cv_t = __remove_cv(_Tp); -#endif // __has_builtin(__remove_cv) +#endif #if _LIBCPP_STD_VER >= 14 template <class _Tp> diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_extent.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_extent.h index fe37b5c726..aceeb47069 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_extent.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/remove_extent.h @@ -10,7 +10,7 @@ #define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H #include <__config> -#include <cstddef> +#include <__cstddef/size_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/result_of.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/result_of.h index f00fa8e9be..73a1944752 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/result_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/result_of.h @@ -10,7 +10,7 @@ #define _LIBCPP___TYPE_TRAITS_RESULT_OF_H #include <__config> -#include <__functional/invoke.h> +#include <__type_traits/invoke.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/type_list.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/type_list.h index 02905707ee..0d9ca98958 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/type_list.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/type_list.h @@ -10,7 +10,7 @@ #define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H #include <__config> -#include <cstddef> +#include <__cstddef/size_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/forward.h b/contrib/libs/cxxsupp/libcxx/include/__utility/forward.h index d5275dcbd0..6674066447 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/forward.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/forward.h @@ -21,13 +21,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>& __t) _NOEXCEPT { return static_cast<_Tp&&>(__t); } template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>&& __t) _NOEXCEPT { static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue"); return static_cast<_Tp&&>(__t); diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/in_place.h b/contrib/libs/cxxsupp/libcxx/include/__utility/in_place.h index fa7a2f4bfd..459b271675 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/in_place.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/in_place.h @@ -10,6 +10,7 @@ #define _LIBCPP___UTILITY_IN_PLACE_H #include <__config> +#include <__type_traits/integral_constant.h> #include <__type_traits/remove_cvref.h> #include <cstddef> diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/move.h b/contrib/libs/cxxsupp/libcxx/include/__utility/move.h index b6a42db054..66aec5aa26 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/move.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/move.h @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&& +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&& move(_LIBCPP_LIFETIMEBOUND _Tp&& __t) _NOEXCEPT { typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up; return static_cast<_Up&&>(__t); @@ -37,7 +37,7 @@ using __move_if_noexcept_result_t = __conditional_t<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, _Tp&&>; template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp> move_if_noexcept(_LIBCPP_LIFETIMEBOUND _Tp& __x) _NOEXCEPT { return std::move(__x); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h b/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h index 0afbebcdc9..78534a3f39 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h @@ -25,6 +25,7 @@ #include <__type_traits/common_type.h> #include <__type_traits/conditional.h> #include <__type_traits/decay.h> +#include <__type_traits/enable_if.h> #include <__type_traits/integral_constant.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_constructible.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/rel_ops.h b/contrib/libs/cxxsupp/libcxx/include/__utility/rel_ops.h index ee8657196d..a8caf5bdea 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/rel_ops.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/rel_ops.h @@ -20,22 +20,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace rel_ops { template <class _Tp> -inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const _Tp& __y) { +inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const _Tp& __y) { return !(__x == __y); } template <class _Tp> -inline _LIBCPP_HIDE_FROM_ABI bool operator>(const _Tp& __x, const _Tp& __y) { +inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator>(const _Tp& __x, const _Tp& __y) { return __y < __x; } template <class _Tp> -inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const _Tp& __x, const _Tp& __y) { +inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator<=(const _Tp& __x, const _Tp& __y) { return !(__y < __x); } template <class _Tp> -inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const _Tp& __x, const _Tp& __y) { +inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator>=(const _Tp& __x, const _Tp& __y) { return !(__x < __y); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/swap.h b/contrib/libs/cxxsupp/libcxx/include/__utility/swap.h index ab88b8e0a0..ecfbdec75a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/swap.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/swap.h @@ -10,6 +10,7 @@ #define _LIBCPP___UTILITY_SWAP_H #include <__config> +#include <__type_traits/enable_if.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_nothrow_assignable.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/unreachable.h b/contrib/libs/cxxsupp/libcxx/include/__utility/unreachable.h index d833f74c2e..5525452aa5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/unreachable.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/unreachable.h @@ -18,7 +18,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() { +[[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() { _LIBCPP_ASSERT_INTERNAL(false, "std::unreachable() was reached"); __builtin_unreachable(); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__verbose_abort b/contrib/libs/cxxsupp/libcxx/include/__verbose_abort index 195ce65b72..244278aec6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__verbose_abort +++ b/contrib/libs/cxxsupp/libcxx/include/__verbose_abort @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // This function should never be called directly from the code -- it should only be called through // the _LIBCPP_VERBOSE_ABORT macro. -_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS +[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...); // _LIBCPP_VERBOSE_ABORT(format, args...) diff --git a/contrib/libs/cxxsupp/libcxx/include/algorithm b/contrib/libs/cxxsupp/libcxx/include/algorithm index a522a60f1b..36fd035b7e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/algorithm +++ b/contrib/libs/cxxsupp/libcxx/include/algorithm @@ -102,6 +102,31 @@ namespace ranges { constexpr borrowed_iterator_t<R> find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20 + template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity> + requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*> + constexpr subrange<I> find_last(I first, S last, const T& value, Proj proj = {}); // since C++23 + + template<forward_range R, class T, class Proj = identity> + requires + indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*> + constexpr borrowed_subrange_t<R> find_last(R&& r, const T& value, Proj proj = {}); // since C++23 + + template<forward_iterator I, sentinel_for<I> S, class Proj = identity, + indirect_unary_predicate<projected<I, Proj>> Pred> + constexpr subrange<I> find_last_if(I first, S last, Pred pred, Proj proj = {}); // since C++23 + + template<forward_range R, class Proj = identity, + indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> + constexpr borrowed_subrange_t<R> find_last_if(R&& r, Pred pred, Proj proj = {}); // since C++23 + + template<forward_iterator I, sentinel_for<I> S, class Proj = identity, + indirect_unary_predicate<projected<I, Proj>> Pred> + constexpr subrange<I> find_last_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++23 + + template<forward_range R, class Proj = identity, + indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> + constexpr borrowed_subrange_t<R> find_last_if_not(R&& r, Pred pred, Proj proj = {}); // since C++23 + template<class T, class Proj = identity, indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 @@ -288,6 +313,9 @@ namespace ranges { template<class I, class F> using for_each_result = in_fun_result<I, F>; // since C++20 + template<class I, class F> + using for_each_n_result = in_fun_result<I, F>; // since C++20 + template<input_iterator I, sentinel_for<I> S, class Proj = identity, indirectly_unary_invocable<projected<I, Proj>> Fun> constexpr ranges::for_each_result<I, Fun> @@ -675,6 +703,12 @@ namespace ranges { ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 + template<class I, class O> + using move_result = in_out_result<I, O>; // since C++20 + + template<class I, class O> + using move_backward_result = in_out_result<I, O>; // since C++20 + template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2> requires indirectly_movable<I1, I2> constexpr ranges::move_backward_result<I1, I2> @@ -1989,6 +2023,7 @@ template <class BidirectionalIterator, class Compare> # include <__algorithm/fold.h> # include <__algorithm/ranges_contains_subrange.h> # include <__algorithm/ranges_ends_with.h> +# include <__algorithm/ranges_find_last.h> # include <__algorithm/ranges_starts_with.h> #endif // _LIBCPP_STD_VER >= 23 diff --git a/contrib/libs/cxxsupp/libcxx/include/any b/contrib/libs/cxxsupp/libcxx/include/any index 5def14dc87..6e4ff31ff9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/any +++ b/contrib/libs/cxxsupp/libcxx/include/any @@ -90,6 +90,7 @@ namespace std { #include <__type_traits/aligned_storage.h> #include <__type_traits/conditional.h> #include <__type_traits/decay.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_function.h> #include <__type_traits/is_nothrow_constructible.h> @@ -126,7 +127,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { +[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { # ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw bad_any_cast(); # else diff --git a/contrib/libs/cxxsupp/libcxx/include/array b/contrib/libs/cxxsupp/libcxx/include/array index 6ffde852f4..0e9af41986 100644 --- a/contrib/libs/cxxsupp/libcxx/include/array +++ b/contrib/libs/cxxsupp/libcxx/include/array @@ -19,17 +19,17 @@ template <class T, size_t N > struct array { // types: - typedef T & reference; - typedef const T & const_reference; - typedef implementation defined iterator; - typedef implementation defined const_iterator; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef T value_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + using value_type = T; + using pointer = T*; + using const_pointer = const T*; + using reference = T&; + using const_reference = const T&; + using size_type = size_t; + using difference_type = ptrdiff_t; + using iterator = implementation-defined; + using const_iterator = implementation-defined; + using reverse_iterator = std::reverse_iterator<iterator>; + using const_reverse_iterator = std::reverse_iterator<const_iterator>; // No explicit construct/copy/destroy for aggregate type void fill(const T& u); // constexpr in C++20 @@ -124,6 +124,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce #include <__tuple/sfinae_helpers.h> #include <__type_traits/conditional.h> #include <__type_traits/conjunction.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_array.h> #include <__type_traits/is_const.h> #include <__type_traits/is_constructible.h> @@ -232,7 +233,7 @@ struct _LIBCPP_TEMPLATE_VIS array { // capacity: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; } // element access: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT { @@ -270,20 +271,25 @@ struct _LIBCPP_TEMPLATE_VIS array { template <class _Tp> struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { // types: - typedef array __self; - typedef _Tp value_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef value_type* iterator; - typedef const value_type* const_iterator; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - - typedef __conditional_t<is_const<_Tp>::value, const __empty, __empty> _EmptyType; + using __self = array; + using value_type = _Tp; + using reference = value_type&; + using const_reference = const value_type&; + using pointer = value_type*; + using const_pointer = const value_type*; +#if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY) + using iterator = __wrap_iter<pointer>; + using const_iterator = __wrap_iter<const_pointer>; +#else + using iterator = pointer; + using const_iterator = const_pointer; +#endif + using size_type = size_t; + using difference_type = ptrdiff_t; + using reverse_iterator = std::reverse_iterator<iterator>; + using const_reverse_iterator = std::reverse_iterator<const_iterator>; + + using _EmptyType = __conditional_t<is_const<_Tp>::value, const __empty, __empty>; struct _ArrayInStructT { _Tp __data_[1]; @@ -335,7 +341,7 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { // capacity: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; } // element access: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT { @@ -422,8 +428,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const array<_Tp, _Size>& __x, const template <class _Tp, size_t _Size> _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { - return std::lexicographical_compare_three_way( - __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } #endif // _LIBCPP_STD_VER <= 17 @@ -440,7 +445,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_con template <size_t _Ip, class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > { static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)"); - typedef _Tp type; + using type = _Tp; }; template <size_t _Ip, class _Tp, size_t _Size> diff --git a/contrib/libs/cxxsupp/libcxx/include/atomic b/contrib/libs/cxxsupp/libcxx/include/atomic index 80a0f9ee37..bf65750672 100644 --- a/contrib/libs/cxxsupp/libcxx/include/atomic +++ b/contrib/libs/cxxsupp/libcxx/include/atomic @@ -101,12 +101,12 @@ struct atomic bool compare_exchange_strong(T& expc, T desr, memory_order m = memory_order_seq_cst) noexcept; - void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept; - void wait(T, memory_order = memory_order::seq_cst) const noexcept; - void notify_one() volatile noexcept; - void notify_one() noexcept; - void notify_all() volatile noexcept; - void notify_all() noexcept; + void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20 + void wait(T, memory_order = memory_order::seq_cst) const noexcept; // since C++20 + void notify_one() volatile noexcept; // since C++20 + void notify_one() noexcept; // since C++20 + void notify_all() volatile noexcept; // since C++20 + void notify_all() noexcept; // since C++20 }; template <> @@ -184,12 +184,12 @@ struct atomic<integral> integral operator^=(integral op) volatile noexcept; integral operator^=(integral op) noexcept; - void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept; - void wait(integral, memory_order = memory_order::seq_cst) const noexcept; - void notify_one() volatile noexcept; - void notify_one() noexcept; - void notify_all() volatile noexcept; - void notify_all() noexcept; + void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20 + void wait(integral, memory_order = memory_order::seq_cst) const noexcept; // since C++20 + void notify_one() volatile noexcept; // since C++20 + void notify_one() noexcept; // since C++20 + void notify_all() volatile noexcept; // since C++20 + void notify_all() noexcept; // since C++20 }; template <class T> @@ -254,12 +254,12 @@ struct atomic<T*> T* operator-=(ptrdiff_t op) volatile noexcept; T* operator-=(ptrdiff_t op) noexcept; - void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept; - void wait(T*, memory_order = memory_order::seq_cst) const noexcept; - void notify_one() volatile noexcept; - void notify_one() noexcept; - void notify_all() volatile noexcept; - void notify_all() noexcept; + void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20 + void wait(T*, memory_order = memory_order::seq_cst) const noexcept; // since C++20 + void notify_one() volatile noexcept; // since C++20 + void notify_one() noexcept; // since C++20 + void notify_all() volatile noexcept; // since C++20 + void notify_all() noexcept; // since C++20 }; template<> @@ -321,12 +321,12 @@ struct atomic<floating-point-type> { // since C++20 floating-point-type operator-=(floating-point-type) volatile noexcept; floating-point-type operator-=(floating-point-type) noexcept; - void wait(floating-point-type, memory_order = memory_order::seq_cst) const volatile noexcept; - void wait(floating-point-type, memory_order = memory_order::seq_cst) const noexcept; - void notify_one() volatile noexcept; - void notify_one() noexcept; - void notify_all() volatile noexcept; - void notify_all() noexcept; + void wait(floating-point-type, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20 + void wait(floating-point-type, memory_order = memory_order::seq_cst) const noexcept; // since C++20 + void notify_one() volatile noexcept; // since C++20 + void notify_one() noexcept; // since C++20 + void notify_all() volatile noexcept; // since C++20 + void notify_all() noexcept; // since C++20 }; // [atomics.nonmembers], non-member functions @@ -443,23 +443,23 @@ template<class T> memory_order) noexcept; template<class T> - void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept; + void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept; // since C++20 template<class T> - void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept; + void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept; // since C++20 template<class T> - void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type, + void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type, // since C++20 memory_order) noexcept; template<class T> - void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type, + void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type, // since C++20 memory_order) noexcept; template<class T> - void atomic_notify_one(volatile atomic<T>*) noexcept; + void atomic_notify_one(volatile atomic<T>*) noexcept; // since C++20 template<class T> - void atomic_notify_one(atomic<T>*) noexcept; + void atomic_notify_one(atomic<T>*) noexcept; // since C++20 template<class T> - void atomic_notify_all(volatile atomic<T>*) noexcept; + void atomic_notify_all(volatile atomic<T>*) noexcept; // since C++20 template<class T> - void atomic_notify_all(atomic<T>*) noexcept; + void atomic_notify_all(atomic<T>*) noexcept; // since C++20 // Atomics for standard typedef types @@ -534,12 +534,12 @@ typedef struct atomic_flag void clear(memory_order m = memory_order_seq_cst) volatile noexcept; void clear(memory_order m = memory_order_seq_cst) noexcept; - void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept; - void wait(bool, memory_order = memory_order::seq_cst) const noexcept; - void notify_one() volatile noexcept; - void notify_one() noexcept; - void notify_all() volatile noexcept; - void notify_all() noexcept; + void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20 + void wait(bool, memory_order = memory_order::seq_cst) const noexcept; // since C++20 + void notify_one() volatile noexcept; // since C++20 + void notify_one() noexcept; // since C++20 + void notify_all() volatile noexcept; // since C++20 + void notify_all() noexcept; // since C++20 } atomic_flag; bool atomic_flag_test(volatile atomic_flag* obj) noexcept; @@ -557,14 +557,14 @@ void atomic_flag_clear(atomic_flag* obj) noexcept; void atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; void atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; -void atomic_wait(const volatile atomic_flag* obj, T old) noexcept; -void atomic_wait(const atomic_flag* obj, T old) noexcept; -void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept; -void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept; -void atomic_one(volatile atomic_flag* obj) noexcept; -void atomic_one(atomic_flag* obj) noexcept; -void atomic_all(volatile atomic_flag* obj) noexcept; -void atomic_all(atomic_flag* obj) noexcept; +void atomic_wait(const volatile atomic_flag* obj, T old) noexcept; // since C++20 +void atomic_wait(const atomic_flag* obj, T old) noexcept; // since C++20 +void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept; // since C++20 +void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept; // since C++20 +void atomic_one(volatile atomic_flag* obj) noexcept; // since C++20 +void atomic_one(atomic_flag* obj) noexcept; // since C++20 +void atomic_all(volatile atomic_flag* obj) noexcept; // since C++20 +void atomic_all(atomic_flag* obj) noexcept; // since C++20 // fences @@ -589,17 +589,12 @@ template <class T> #include <__config> -#if _LIBCPP_STD_VER < 23 && defined(_LIBCPP_STDATOMIC_H) -# error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23. -#endif - #include <__atomic/aliases.h> #include <__atomic/atomic.h> #include <__atomic/atomic_base.h> #include <__atomic/atomic_flag.h> #include <__atomic/atomic_init.h> #include <__atomic/atomic_lock_free.h> -#include <__atomic/atomic_ref.h> #include <__atomic/atomic_sync.h> #include <__atomic/check_memory_order.h> #include <__atomic/contention_t.h> @@ -610,6 +605,10 @@ template <class T> #include <__atomic/memory_order.h> #include <version> +#if _LIBCPP_STD_VER >= 20 +# include <__atomic/atomic_ref.h> +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/barrier b/contrib/libs/cxxsupp/libcxx/include/barrier index 12608e17d8..abc014e8aa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/barrier +++ b/contrib/libs/cxxsupp/libcxx/include/barrier @@ -17,7 +17,7 @@ namespace std { template<class CompletionFunction = see below> - class barrier + class barrier // since C++20 { public: using arrival_token = see below; @@ -47,30 +47,28 @@ namespace std #include <__config> -#ifdef _LIBCPP_HAS_NO_THREADS -# error "<barrier> is not supported since libc++ has been configured without support for threads." -#endif +#if !defined(_LIBCPP_HAS_NO_THREADS) -#include <__assert> -#include <__atomic/atomic_base.h> -#include <__atomic/memory_order.h> -#include <__memory/unique_ptr.h> -#include <__thread/poll_with_backoff.h> -#include <__thread/timed_backoff_policy.h> -#include <__utility/move.h> -#include <cstddef> -#include <cstdint> -#include <limits> -#include <version> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# include <__assert> +# include <__atomic/atomic_base.h> +# include <__atomic/memory_order.h> +# include <__memory/unique_ptr.h> +# include <__thread/poll_with_backoff.h> +# include <__thread/timed_backoff_policy.h> +# include <__utility/move.h> +# include <cstddef> +# include <cstdint> +# include <limits> +# include <version> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_BEGIN_NAMESPACE_STD @@ -78,7 +76,7 @@ struct __empty_completion { inline _LIBCPP_HIDE_FROM_ABI void operator()() noexcept {} }; -# ifndef _LIBCPP_HAS_NO_TREE_BARRIER +# ifndef _LIBCPP_HAS_NO_TREE_BARRIER /* @@ -127,7 +125,7 @@ public: __expected_adjustment_(0), __completion_(std::move(__completion)), __phase_(0) {} - _LIBCPP_NODISCARD _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) { + [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) { _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( __update <= __expected_, "update is greater than the expected count for the current barrier phase"); @@ -152,7 +150,7 @@ public: } }; -# else +# else /* @@ -253,10 +251,10 @@ public: } }; -# endif // !_LIBCPP_HAS_NO_TREE_BARRIER +# endif // !_LIBCPP_HAS_NO_TREE_BARRIER template <class _CompletionF = __empty_completion> -class _LIBCPP_DEPRECATED_ATOMIC_SYNC barrier { +class barrier { __barrier_base<_CompletionF> __b_; public: @@ -265,7 +263,7 @@ public: static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return __barrier_base<_CompletionF>::max(); } _LIBCPP_AVAILABILITY_SYNC - _LIBCPP_HIDE_FROM_ABI explicit barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF()) + _LIBCPP_HIDE_FROM_ABI explicit barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF()) : __b_(__count, std::move(__completion)) { _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( __count >= 0, @@ -279,7 +277,7 @@ public: barrier(barrier const&) = delete; barrier& operator=(barrier const&) = delete; - _LIBCPP_NODISCARD _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) { + [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) { _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update > 0, "barrier:arrive must be called with a value greater than 0"); return __b_.arrive(__update); } @@ -292,10 +290,12 @@ public: _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_STD_VER >= 14 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_POP_MACROS +#endif // !defined(_LIBCPP_HAS_NO_THREADS) + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <atomic> # include <concepts> @@ -305,4 +305,4 @@ _LIBCPP_POP_MACROS # include <variant> #endif -#endif //_LIBCPP_BARRIER +#endif // _LIBCPP_BARRIER diff --git a/contrib/libs/cxxsupp/libcxx/include/bitset b/contrib/libs/cxxsupp/libcxx/include/bitset index 6bd7bfe585..ce23d52216 100644 --- a/contrib/libs/cxxsupp/libcxx/include/bitset +++ b/contrib/libs/cxxsupp/libcxx/include/bitset @@ -128,6 +128,7 @@ template <size_t N> struct hash<std::bitset<N>>; #include <__algorithm/count.h> #include <__algorithm/fill.h> +#include <__algorithm/fill_n.h> #include <__algorithm/find.h> #include <__bit_reference> #include <__config> diff --git a/contrib/libs/cxxsupp/libcxx/include/chrono b/contrib/libs/cxxsupp/libcxx/include/chrono index 23441ddb23..7bec5e5a26 100644 --- a/contrib/libs/cxxsupp/libcxx/include/chrono +++ b/contrib/libs/cxxsupp/libcxx/include/chrono @@ -789,6 +789,21 @@ strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept; // [time.zone.zonedtraits], class template zoned_traits template<class T> struct zoned_traits; // C++20 +// [time.zone.zonedtime], class template zoned_time +template<class Duration, class TimeZonePtr = const time_zone*> // C++20 +class zoned_time; + +using zoned_seconds = zoned_time<seconds>; // C++20 + +template<class Duration1, class Duration2, class TimeZonePtr> // C++20 + bool operator==(const zoned_time<Duration1, TimeZonePtr>& x, + const zoned_time<Duration2, TimeZonePtr>& y); + +template<class charT, class traits, class Duration, class TimeZonePtr> // C++20 + basic_ostream<charT, traits>& + operator<<(basic_ostream<charT, traits>& os, + const zoned_time<Duration, TimeZonePtr>& t); + // [time.zone.leap], leap second support class leap_second { // C++20 public: @@ -871,6 +886,8 @@ namespace std { struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>; // C++20 template<class charT> struct formatter<chrono::sys_info, charT>; // C++20 template<class charT> struct formatter<chrono::local_info, charT>; // C++20 + template<class Duration, class TimeZonePtr, class charT> // C++20 + struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>; } // namespace std namespace chrono { @@ -998,8 +1015,8 @@ constexpr chrono::year operator ""y(unsigned lo # include <charconv> # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) # include <locale> +# include <ostream> # endif -# include <ostream> #endif #endif // _LIBCPP_CHRONO diff --git a/contrib/libs/cxxsupp/libcxx/include/cmath b/contrib/libs/cxxsupp/libcxx/include/cmath index 7a87e35c84..5d30b15187 100644 --- a/contrib/libs/cxxsupp/libcxx/include/cmath +++ b/contrib/libs/cxxsupp/libcxx/include/cmath @@ -204,6 +204,14 @@ floating_point fmin (arithmetic x, arithmetic y); float fminf(float x, float y); long double fminl(long double x, long double y); +double hermite(unsigned n, double x); // C++17 +float hermite(unsigned n, float x); // C++17 +long double hermite(unsigned n, long double x); // C++17 +float hermitef(unsigned n, float x); // C++17 +long double hermitel(unsigned n, long double x); // C++17 +template <class Integer> +double hermite(unsigned n, Integer x); // C++17 + floating_point hypot (arithmetic x, arithmetic y); float hypotf(float x, float y); long double hypotl(long double x, long double y); @@ -305,6 +313,7 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept */ #include <__config> +#include <__math/hypot.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_arithmetic.h> #include <__type_traits/is_constant_evaluated.h> @@ -315,6 +324,7 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept #include <limits> #include <version> +#include <__math/special_functions.h> #include <math.h> #ifndef _LIBCPP_MATH_H @@ -544,44 +554,6 @@ using ::scalbnl _LIBCPP_USING_IF_EXISTS; using ::tgammal _LIBCPP_USING_IF_EXISTS; using ::truncl _LIBCPP_USING_IF_EXISTS; -#if _LIBCPP_STD_VER >= 17 -inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y, float __z) { - return sqrt(__x * __x + __y * __y + __z * __z); -} -inline _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y, double __z) { - return sqrt(__x * __x + __y * __y + __z * __z); -} -inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y, long double __z) { - return sqrt(__x * __x + __y * __y + __z * __z); -} - -template <class _A1, class _A2, class _A3> -inline _LIBCPP_HIDE_FROM_ABI -typename enable_if_t< is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, - __promote<_A1, _A2, _A3> >::type -hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT { - typedef typename __promote<_A1, _A2, _A3>::type __result_type; - static_assert( - !(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value && is_same<_A3, __result_type>::value), - ""); - return std::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); -} -#endif - -template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT { -#if __has_builtin(__builtin_isnan) - return __builtin_isnan(__lcpp_x); -#else - return isnan(__lcpp_x); -#endif -} - -template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT { - return std::isnan(__lcpp_x); -} - template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isinf) @@ -596,20 +568,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NO return std::isinf(__lcpp_x); } -template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT { -#if __has_builtin(__builtin_isfinite) - return __builtin_isfinite(__lcpp_x); -#else - return isfinite(__lcpp_x); -#endif -} - -template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT { - return __builtin_isfinite(__lcpp_x); -} - #if _LIBCPP_STD_VER >= 20 template <typename _Fp> _LIBCPP_HIDE_FROM_ABI constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept { diff --git a/contrib/libs/cxxsupp/libcxx/include/complex b/contrib/libs/cxxsupp/libcxx/include/complex index bfe61c506e..80471d903f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/complex +++ b/contrib/libs/cxxsupp/libcxx/include/complex @@ -421,7 +421,8 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f) : __re_(__re), __im_(__im) {} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(__from_builtin_tag, _Complex float __v) + template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex float __v) : __re_(__real__ __v), __im_(__imag__ __v) {} _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c); @@ -517,7 +518,8 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0) : __re_(__re), __im_(__im) {} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(__from_builtin_tag, _Complex double __v) + template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex double __v) : __re_(__real__ __v), __im_(__imag__ __v) {} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c); @@ -617,7 +619,8 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L) : __re_(__re), __im_(__im) {} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(__from_builtin_tag, _Complex long double __v) + template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex long double __v) : __re_(__real__ __v), __im_(__imag__ __v) {} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c); @@ -994,14 +997,14 @@ conj(_Tp __re) { template <class _Tp> inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) { complex<_Tp> __r = __c; - if (std::__constexpr_isinf(__c.real()) || std::__constexpr_isinf(__c.imag())) + if (std::isinf(__c.real()) || std::isinf(__c.imag())) __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag())); return __r; } template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) { - if (std::__constexpr_isinf(__re)) + if (std::isinf(__re)) __re = std::abs(__re); return complex<_Tp>(__re); } @@ -1016,23 +1019,23 @@ inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_Co template <class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = _Tp()) { - if (std::__constexpr_isnan(__rho) || std::signbit(__rho)) + if (std::isnan(__rho) || std::signbit(__rho)) return complex<_Tp>(_Tp(NAN), _Tp(NAN)); - if (std::__constexpr_isnan(__theta)) { - if (std::__constexpr_isinf(__rho)) + if (std::isnan(__theta)) { + if (std::isinf(__rho)) return complex<_Tp>(__rho, __theta); return complex<_Tp>(__theta, __theta); } - if (std::__constexpr_isinf(__theta)) { - if (std::__constexpr_isinf(__rho)) + if (std::isinf(__theta)) { + if (std::isinf(__rho)) return complex<_Tp>(__rho, _Tp(NAN)); return complex<_Tp>(_Tp(NAN), _Tp(NAN)); } _Tp __x = __rho * std::cos(__theta); - if (std::__constexpr_isnan(__x)) + if (std::isnan(__x)) __x = 0; _Tp __y = __rho * std::sin(__theta); - if (std::__constexpr_isnan(__y)) + if (std::isnan(__y)) __y = 0; return complex<_Tp>(__x, __y); } @@ -1055,14 +1058,12 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) { template <class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) { - if (std::__constexpr_isinf(__x.imag())) + if (std::isinf(__x.imag())) return complex<_Tp>(_Tp(INFINITY), __x.imag()); - if (std::__constexpr_isinf(__x.real())) { + if (std::isinf(__x.real())) { if (__x.real() > _Tp(0)) - return complex<_Tp>( - __x.real(), std::__constexpr_isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag())); - return complex<_Tp>( - std::__constexpr_isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag())); + return complex<_Tp>(__x.real(), std::isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag())); + return complex<_Tp>(std::isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag())); } return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2)); } @@ -1075,12 +1076,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) { if (__i == 0) { return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag())); } - if (std::__constexpr_isinf(__x.real())) { + if (std::isinf(__x.real())) { if (__x.real() < _Tp(0)) { - if (!std::__constexpr_isfinite(__i)) + if (!std::isfinite(__i)) __i = _Tp(1); - } else if (__i == 0 || !std::__constexpr_isfinite(__i)) { - if (std::__constexpr_isinf(__i)) + } else if (__i == 0 || !std::isfinite(__i)) { + if (std::isinf(__i)) __i = _Tp(NAN); return complex<_Tp>(__x.real(), __i); } @@ -1127,21 +1128,21 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> __sqr(const complex<_Tp>& __x) { template <class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) { const _Tp __pi(atan2(+0., -0.)); - if (std::__constexpr_isinf(__x.real())) { - if (std::__constexpr_isnan(__x.imag())) + if (std::isinf(__x.real())) { + if (std::isnan(__x.imag())) return __x; - if (std::__constexpr_isinf(__x.imag())) + if (std::isinf(__x.imag())) return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag())); return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag())); } - if (std::__constexpr_isnan(__x.real())) { - if (std::__constexpr_isinf(__x.imag())) + if (std::isnan(__x.real())) { + if (std::isinf(__x.imag())) return complex<_Tp>(__x.imag(), __x.real()); if (__x.imag() == 0) return __x; return complex<_Tp>(__x.real(), __x.real()); } - if (std::__constexpr_isinf(__x.imag())) + if (std::isinf(__x.imag())) return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1))); return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag())); @@ -1152,10 +1153,10 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) { template <class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { const _Tp __pi(atan2(+0., -0.)); - if (std::__constexpr_isinf(__x.real())) { - if (std::__constexpr_isnan(__x.imag())) + if (std::isinf(__x.real())) { + if (std::isnan(__x.imag())) return complex<_Tp>(std::abs(__x.real()), __x.imag()); - if (std::__constexpr_isinf(__x.imag())) { + if (std::isinf(__x.imag())) { if (__x.real() > 0) return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag())); else @@ -1165,12 +1166,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { return complex<_Tp>(-__x.real(), std::copysign(__pi, __x.imag())); return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag())); } - if (std::__constexpr_isnan(__x.real())) { - if (std::__constexpr_isinf(__x.imag())) + if (std::isnan(__x.real())) { + if (std::isinf(__x.imag())) return complex<_Tp>(std::abs(__x.imag()), __x.real()); return complex<_Tp>(__x.real(), __x.real()); } - if (std::__constexpr_isinf(__x.imag())) + if (std::isinf(__x.imag())) return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi / _Tp(2), __x.imag())); complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1))); return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag())); @@ -1181,18 +1182,18 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { template <class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) { const _Tp __pi(atan2(+0., -0.)); - if (std::__constexpr_isinf(__x.imag())) { + if (std::isinf(__x.imag())) { return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); } - if (std::__constexpr_isnan(__x.imag())) { - if (std::__constexpr_isinf(__x.real()) || __x.real() == 0) + if (std::isnan(__x.imag())) { + if (std::isinf(__x.real()) || __x.real() == 0) return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag()); return complex<_Tp>(__x.imag(), __x.imag()); } - if (std::__constexpr_isnan(__x.real())) { + if (std::isnan(__x.real())) { return complex<_Tp>(__x.real(), __x.real()); } - if (std::__constexpr_isinf(__x.real())) { + if (std::isinf(__x.real())) { return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); } if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0)) { @@ -1206,11 +1207,11 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) { template <class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) { - if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag())) + if (std::isinf(__x.real()) && !std::isfinite(__x.imag())) return complex<_Tp>(__x.real(), _Tp(NAN)); - if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag())) + if (__x.real() == 0 && !std::isfinite(__x.imag())) return complex<_Tp>(__x.real(), _Tp(NAN)); - if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real())) + if (__x.imag() == 0 && !std::isfinite(__x.real())) return __x; return complex<_Tp>(std::sinh(__x.real()) * std::cos(__x.imag()), std::cosh(__x.real()) * std::sin(__x.imag())); } @@ -1219,13 +1220,13 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) { template <class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) { - if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag())) + if (std::isinf(__x.real()) && !std::isfinite(__x.imag())) return complex<_Tp>(std::abs(__x.real()), _Tp(NAN)); - if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag())) + if (__x.real() == 0 && !std::isfinite(__x.imag())) return complex<_Tp>(_Tp(NAN), __x.real()); if (__x.real() == 0 && __x.imag() == 0) return complex<_Tp>(_Tp(1), __x.imag()); - if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real())) + if (__x.imag() == 0 && !std::isfinite(__x.real())) return complex<_Tp>(std::abs(__x.real()), __x.imag()); return complex<_Tp>(std::cosh(__x.real()) * std::cos(__x.imag()), std::sinh(__x.real()) * std::sin(__x.imag())); } @@ -1234,18 +1235,18 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) { template <class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) { - if (std::__constexpr_isinf(__x.real())) { - if (!std::__constexpr_isfinite(__x.imag())) + if (std::isinf(__x.real())) { + if (!std::isfinite(__x.imag())) return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0)); return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag()))); } - if (std::__constexpr_isnan(__x.real()) && __x.imag() == 0) + if (std::isnan(__x.real()) && __x.imag() == 0) return __x; _Tp __2r(_Tp(2) * __x.real()); _Tp __2i(_Tp(2) * __x.imag()); _Tp __d(std::cosh(__2r) + std::cos(__2i)); _Tp __2rsh(std::sinh(__2r)); - if (std::__constexpr_isinf(__2rsh) && std::__constexpr_isinf(__d)) + if (std::isinf(__2rsh) && std::isinf(__d)) return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), __2i > _Tp(0) ? _Tp(0) : _Tp(-0.)); return complex<_Tp>(__2rsh / __d, std::sin(__2i) / __d); } @@ -1263,10 +1264,10 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) { template <class _Tp> _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) { const _Tp __pi(atan2(+0., -0.)); - if (std::__constexpr_isinf(__x.real())) { - if (std::__constexpr_isnan(__x.imag())) + if (std::isinf(__x.real())) { + if (std::isnan(__x.imag())) return complex<_Tp>(__x.imag(), __x.real()); - if (std::__constexpr_isinf(__x.imag())) { + if (std::isinf(__x.imag())) { if (__x.real() < _Tp(0)) return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag()); return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag()); @@ -1275,12 +1276,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) { return complex<_Tp>(__pi, std::signbit(__x.imag()) ? -__x.real() : __x.real()); return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real()); } - if (std::__constexpr_isnan(__x.real())) { - if (std::__constexpr_isinf(__x.imag())) + if (std::isnan(__x.real())) { + if (std::isinf(__x.imag())) return complex<_Tp>(__x.real(), -__x.imag()); return complex<_Tp>(__x.real(), __x.real()); } - if (std::__constexpr_isinf(__x.imag())) + if (std::isinf(__x.imag())) return complex<_Tp>(__pi / _Tp(2), -__x.imag()); if (__x.real() == 0 && (__x.imag() == 0 || std::isnan(__x.imag()))) return complex<_Tp>(__pi / _Tp(2), -__x.imag()); diff --git a/contrib/libs/cxxsupp/libcxx/include/condition_variable b/contrib/libs/cxxsupp/libcxx/include/condition_variable index 5195cd6057..229a2ce103 100644 --- a/contrib/libs/cxxsupp/libcxx/include/condition_variable +++ b/contrib/libs/cxxsupp/libcxx/include/condition_variable @@ -173,7 +173,7 @@ public: template <class _Lock, class _Rep, class _Period, class _Predicate> bool _LIBCPP_HIDE_FROM_ABI wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); -# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) +# if _LIBCPP_STD_VER >= 20 template <class _Lock, class _Predicate> _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait(_Lock& __lock, stop_token __stoken, _Predicate __pred); @@ -186,7 +186,7 @@ public: _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait_for(_Lock& __lock, stop_token __stoken, const chrono::duration<_Rep, _Period>& __rel_time, _Predicate __pred); -# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) +# endif // _LIBCPP_STD_VER >= 20 }; inline condition_variable_any::condition_variable_any() : __mut_(make_shared<mutex>()) {} @@ -260,7 +260,7 @@ condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Pe return wait_until(__lock, chrono::steady_clock::now() + __d, std::move(__pred)); } -# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) +# if _LIBCPP_STD_VER >= 20 template <class _Lock, class _Predicate> bool condition_variable_any::wait(_Lock& __user_lock, stop_token __stoken, _Predicate __pred) { @@ -341,7 +341,7 @@ bool condition_variable_any::wait_for( return wait_until(__lock, std::move(__stoken), chrono::steady_clock::now() + __rel_time, std::move(__pred)); } -# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_EXPORTED_FROM_ABI void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>); diff --git a/contrib/libs/cxxsupp/libcxx/include/cstddef b/contrib/libs/cxxsupp/libcxx/include/cstddef index 1a4049e4d3..2b138d9690 100644 --- a/contrib/libs/cxxsupp/libcxx/include/cstddef +++ b/contrib/libs/cxxsupp/libcxx/include/cstddef @@ -34,9 +34,6 @@ Types: */ #include <__config> -#include <__type_traits/enable_if.h> -#include <__type_traits/integral_constant.h> -#include <__type_traits/is_integral.h> #include <version> #include <stddef.h> @@ -53,81 +50,10 @@ Types: # pragma GCC system_header #endif -_LIBCPP_BEGIN_NAMESPACE_STD - -using ::nullptr_t; -using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS; -using ::size_t _LIBCPP_USING_IF_EXISTS; - -#if !defined(_LIBCPP_CXX03_LANG) -using ::max_align_t _LIBCPP_USING_IF_EXISTS; -#endif - -_LIBCPP_END_NAMESPACE_STD - -#if _LIBCPP_STD_VER >= 17 -namespace std // purposefully not versioned -{ -enum class byte : unsigned char {}; - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept { - return static_cast<byte>( - static_cast<unsigned char>(static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs))); -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept { - return __lhs = __lhs | __rhs; -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept { - return static_cast<byte>( - static_cast<unsigned char>(static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs))); -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept { - return __lhs = __lhs & __rhs; -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept { - return static_cast<byte>( - static_cast<unsigned char>(static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs))); -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept { - return __lhs = __lhs ^ __rhs; -} - -_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept { - return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(__b))); -} - -template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept { - return __lhs = __lhs << __shift; -} - -template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept { - return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); -} - -template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept { - return __lhs = __lhs >> __shift; -} - -template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept { - return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); -} - -template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> -[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept { - return static_cast<_Integer>(__b); -} - -} // namespace std - -#endif +#include <__cstddef/byte.h> +#include <__cstddef/max_align_t.h> +#include <__cstddef/nullptr_t.h> +#include <__cstddef/ptrdiff_t.h> +#include <__cstddef/size_t.h> #endif // _LIBCPP_CSTDDEF diff --git a/contrib/libs/cxxsupp/libcxx/include/cstdio b/contrib/libs/cxxsupp/libcxx/include/cstdio index 7f94371081..a461c24dcc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/cstdio +++ b/contrib/libs/cxxsupp/libcxx/include/cstdio @@ -96,6 +96,7 @@ void perror(const char* s); */ #include <__config> +#include <__cstddef/size_t.h> #include <stdio.h> @@ -115,7 +116,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD using ::FILE _LIBCPP_USING_IF_EXISTS; using ::fpos_t _LIBCPP_USING_IF_EXISTS; -using ::size_t _LIBCPP_USING_IF_EXISTS; using ::fclose _LIBCPP_USING_IF_EXISTS; using ::fflush _LIBCPP_USING_IF_EXISTS; diff --git a/contrib/libs/cxxsupp/libcxx/include/cstdlib b/contrib/libs/cxxsupp/libcxx/include/cstdlib index 25a829bb05..02ee3a25b9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/cstdlib +++ b/contrib/libs/cxxsupp/libcxx/include/cstdlib @@ -82,6 +82,7 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 */ #include <__config> +#include <__cstddef/size_t.h> #include <stdlib.h> @@ -99,7 +100,6 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 _LIBCPP_BEGIN_NAMESPACE_STD -using ::size_t _LIBCPP_USING_IF_EXISTS; using ::div_t _LIBCPP_USING_IF_EXISTS; using ::ldiv_t _LIBCPP_USING_IF_EXISTS; using ::lldiv_t _LIBCPP_USING_IF_EXISTS; diff --git a/contrib/libs/cxxsupp/libcxx/include/cstring b/contrib/libs/cxxsupp/libcxx/include/cstring index c2c92b02e7..5bb6e3e106 100644 --- a/contrib/libs/cxxsupp/libcxx/include/cstring +++ b/contrib/libs/cxxsupp/libcxx/include/cstring @@ -57,6 +57,7 @@ size_t strlen(const char* s); */ #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/is_constant_evaluated.h> #include <string.h> @@ -75,7 +76,6 @@ size_t strlen(const char* s); _LIBCPP_BEGIN_NAMESPACE_STD -using ::size_t _LIBCPP_USING_IF_EXISTS; using ::memcpy _LIBCPP_USING_IF_EXISTS; using ::memmove _LIBCPP_USING_IF_EXISTS; using ::strcpy _LIBCPP_USING_IF_EXISTS; diff --git a/contrib/libs/cxxsupp/libcxx/include/ctime b/contrib/libs/cxxsupp/libcxx/include/ctime index cad942e610..2df861c0de 100644 --- a/contrib/libs/cxxsupp/libcxx/include/ctime +++ b/contrib/libs/cxxsupp/libcxx/include/ctime @@ -46,6 +46,7 @@ int timespec_get( struct timespec *ts, int base); // C++17 */ #include <__config> +#include <__cstddef/size_t.h> // <time.h> is not provided by libc++ #if __has_include(<time.h>) @@ -62,7 +63,6 @@ int timespec_get( struct timespec *ts, int base); // C++17 _LIBCPP_BEGIN_NAMESPACE_STD using ::clock_t _LIBCPP_USING_IF_EXISTS; -using ::size_t _LIBCPP_USING_IF_EXISTS; using ::time_t _LIBCPP_USING_IF_EXISTS; using ::tm _LIBCPP_USING_IF_EXISTS; #if _LIBCPP_STD_VER >= 17 && __has_attribute(using_if_exists) diff --git a/contrib/libs/cxxsupp/libcxx/include/cuchar b/contrib/libs/cxxsupp/libcxx/include/cuchar index f0015be275..bfc26f03aa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/cuchar +++ b/contrib/libs/cxxsupp/libcxx/include/cuchar @@ -37,6 +37,7 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps); */ #include <__config> +#include <__cstddef/size_t.h> #include <uchar.h> @@ -57,7 +58,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if !defined(_LIBCPP_CXX03_LANG) using ::mbstate_t _LIBCPP_USING_IF_EXISTS; -using ::size_t _LIBCPP_USING_IF_EXISTS; # if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8) using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS; diff --git a/contrib/libs/cxxsupp/libcxx/include/cwchar b/contrib/libs/cxxsupp/libcxx/include/cwchar index 08cfac58c8..f5a26664c1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/cwchar +++ b/contrib/libs/cxxsupp/libcxx/include/cwchar @@ -103,6 +103,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, */ #include <__config> +#include <__cstddef/size_t.h> #include <__type_traits/copy_cv.h> #include <__type_traits/is_constant_evaluated.h> #include <__type_traits/is_equality_comparable.h> @@ -127,7 +128,6 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, _LIBCPP_BEGIN_NAMESPACE_STD using ::mbstate_t _LIBCPP_USING_IF_EXISTS; -using ::size_t _LIBCPP_USING_IF_EXISTS; using ::tm _LIBCPP_USING_IF_EXISTS; using ::wint_t _LIBCPP_USING_IF_EXISTS; using ::FILE _LIBCPP_USING_IF_EXISTS; diff --git a/contrib/libs/cxxsupp/libcxx/include/deque b/contrib/libs/cxxsupp/libcxx/include/deque index fc0e1adfc1..f6c748a4bf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/deque +++ b/contrib/libs/cxxsupp/libcxx/include/deque @@ -184,7 +184,10 @@ template <class T, class Allocator, class Predicate> #include <__algorithm/fill_n.h> #include <__algorithm/lexicographical_compare.h> #include <__algorithm/lexicographical_compare_three_way.h> +#include <__algorithm/max.h> #include <__algorithm/min.h> +#include <__algorithm/move.h> +#include <__algorithm/move_backward.h> #include <__algorithm/remove.h> #include <__algorithm/remove_if.h> #include <__algorithm/unwrap_iter.h> @@ -195,13 +198,18 @@ template <class T, class Allocator, class Predicate> #include <__fwd/deque.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> +#include <__iterator/move_iterator.h> #include <__iterator/next.h> #include <__iterator/prev.h> #include <__iterator/reverse_iterator.h> #include <__iterator/segmented_iterator.h> #include <__memory/addressof.h> +#include <__memory/allocator.h> #include <__memory/allocator_destructor.h> +#include <__memory/allocator_traits.h> +#include <__memory/compressed_pair.h> #include <__memory/pointer_traits.h> +#include <__memory/swap_allocator.h> #include <__memory/temp_value.h> #include <__memory/unique_ptr.h> #include <__memory_resource/polymorphic_allocator.h> @@ -211,10 +219,15 @@ template <class T, class Allocator, class Predicate> #include <__ranges/from_range.h> #include <__ranges/size.h> #include <__split_buffer> +#include <__type_traits/conditional.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_allocator.h> #include <__type_traits/is_convertible.h> +#include <__type_traits/is_nothrow_assignable.h> +#include <__type_traits/is_nothrow_constructible.h> #include <__type_traits/is_same.h> #include <__type_traits/is_swappable.h> +#include <__type_traits/is_trivially_relocatable.h> #include <__type_traits/type_identity.h> #include <__utility/forward.h> #include <__utility/move.h> @@ -378,10 +391,10 @@ public: return __x.__ptr_ == __y.__ptr_; } +#if _LIBCPP_STD_VER <= 17 _LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y) { return !(__x == __y); } - _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __deque_iterator& __x, const __deque_iterator& __y) { return __x.__m_iter_ < __y.__m_iter_ || (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_); } @@ -398,6 +411,30 @@ public: return !(__x < __y); } +#else + + _LIBCPP_HIDE_FROM_ABI friend strong_ordering operator<=>(const __deque_iterator& __x, const __deque_iterator& __y) { + if (__x.__m_iter_ < __y.__m_iter_) + return strong_ordering::less; + + if (__x.__m_iter_ == __y.__m_iter_) { + if constexpr (three_way_comparable<pointer, strong_ordering>) { + return __x.__ptr_ <=> __y.__ptr_; + } else { + if (__x.__ptr_ < __y.__ptr_) + return strong_ordering::less; + + if (__x.__ptr_ == __y.__ptr_) + return strong_ordering::equal; + + return strong_ordering::greater; + } + } + + return strong_ordering::greater; + } +#endif // _LIBCPP_STD_VER >= 20 + private: _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT : __m_iter_(__m), @@ -560,12 +597,12 @@ private: __map __map_; size_type __start_; - __compressed_pair<size_type, allocator_type> __size_; + _LIBCPP_COMPRESSED_PAIR(size_type, __size_, allocator_type, __alloc_); public: // construct/copy/destroy: _LIBCPP_HIDE_FROM_ABI deque() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) - : __start_(0), __size_(0, __default_init_tag()) { + : __start_(0), __size_(0) { __annotate_new(0); } @@ -579,7 +616,7 @@ public: } _LIBCPP_HIDE_FROM_ABI explicit deque(const allocator_type& __a) - : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { + : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { __annotate_new(0); } @@ -591,7 +628,7 @@ public: template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a) - : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { + : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { __annotate_new(0); if (__n > 0) __append(__n, __v); @@ -605,7 +642,7 @@ public: #if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI deque(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) - : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { + : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { __append_with_size(ranges::begin(__range), ranges::distance(__range)); @@ -668,8 +705,8 @@ public: _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v); _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __size_.second(); } - _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __size_.second(); } + _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __alloc_; } + _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __alloc_; } // iterators: @@ -708,8 +745,8 @@ public: // capacity: _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size(); } - _LIBCPP_HIDE_FROM_ABI size_type& __size() _NOEXCEPT { return __size_.first(); } - _LIBCPP_HIDE_FROM_ABI const size_type& __size() const _NOEXCEPT { return __size_.first(); } + _LIBCPP_HIDE_FROM_ABI size_type& __size() _NOEXCEPT { return __size_; } + _LIBCPP_HIDE_FROM_ABI const size_type& __size() const _NOEXCEPT { return __size_; } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return std::min<size_type>(__alloc_traits::max_size(__alloc()), numeric_limits<difference_type>::max()); @@ -717,7 +754,7 @@ public: _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v); _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } // element access: _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __i) _NOEXCEPT; @@ -1229,7 +1266,7 @@ deque(from_range_t, _Range&&, _Alloc = _Alloc()) -> deque<ranges::range_value_t< #endif template <class _Tp, class _Allocator> -deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0, __default_init_tag()) { +deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0) { __annotate_new(0); if (__n > 0) __append(__n); @@ -1238,7 +1275,7 @@ deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0, __default #if _LIBCPP_STD_VER >= 14 template <class _Tp, class _Allocator> deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a) - : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { + : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { __annotate_new(0); if (__n > 0) __append(__n); @@ -1246,7 +1283,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a) #endif template <class _Tp, class _Allocator> -deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0), __size_(0, __default_init_tag()) { +deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0), __size_(0) { __annotate_new(0); if (__n > 0) __append(__n, __v); @@ -1254,7 +1291,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0 template <class _Tp, class _Allocator> template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > -deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __size_(0, __default_init_tag()) { +deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __size_(0) { __annotate_new(0); __append(__f, __l); } @@ -1262,7 +1299,7 @@ deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __s template <class _Tp, class _Allocator> template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a) - : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { + : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { __annotate_new(0); __append(__f, __l); } @@ -1271,14 +1308,15 @@ template <class _Tp, class _Allocator> deque<_Tp, _Allocator>::deque(const deque& __c) : __map_(__pointer_allocator(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))), __start_(0), - __size_(0, __map_.__alloc()) { + __size_(0), + __alloc_(__map_.__alloc()) { __annotate_new(0); __append(__c.begin(), __c.end()); } template <class _Tp, class _Allocator> deque<_Tp, _Allocator>::deque(const deque& __c, const __type_identity_t<allocator_type>& __a) - : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { + : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { __annotate_new(0); __append(__c.begin(), __c.end()); } @@ -1295,21 +1333,24 @@ deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(const deque& __c) { #ifndef _LIBCPP_CXX03_LANG template <class _Tp, class _Allocator> -deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il) : __start_(0), __size_(0, __default_init_tag()) { +deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il) : __start_(0), __size_(0) { __annotate_new(0); __append(__il.begin(), __il.end()); } template <class _Tp, class _Allocator> deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator_type& __a) - : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { + : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { __annotate_new(0); __append(__il.begin(), __il.end()); } template <class _Tp, class _Allocator> inline deque<_Tp, _Allocator>::deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value) - : __map_(std::move(__c.__map_)), __start_(std::move(__c.__start_)), __size_(std::move(__c.__size_)) { + : __map_(std::move(__c.__map_)), + __start_(std::move(__c.__start_)), + __size_(std::move(__c.__size_)), + __alloc_(std::move(__c.__alloc_)) { __c.__start_ = 0; __c.__size() = 0; } @@ -1318,7 +1359,8 @@ template <class _Tp, class _Allocator> inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<allocator_type>& __a) : __map_(std::move(__c.__map_), __pointer_allocator(__a)), __start_(std::move(__c.__start_)), - __size_(std::move(__c.__size()), __a) { + __size_(std::move(__c.__size_)), + __alloc_(__a) { if (__a == __c.__alloc()) { __c.__start_ = 0; __c.__size() = 0; @@ -2532,8 +2574,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const deque<_Tp, _Allocator>& __x, template <class _Tp, class _Allocator> _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { - return std::lexicographical_compare_three_way( - __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } #endif // _LIBCPP_STD_VER <= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/exception b/contrib/libs/cxxsupp/libcxx/include/exception index 5eff8e3f8a..64463e02cb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/exception +++ b/contrib/libs/cxxsupp/libcxx/include/exception @@ -47,7 +47,7 @@ terminate_handler set_terminate(terminate_handler f ) noexcept; terminate_handler get_terminate() noexcept; [[noreturn]] void terminate() noexcept; -bool uncaught_exception() noexcept; +bool uncaught_exception() noexcept; // deprecated in C++17, removed in C++20 int uncaught_exceptions() noexcept; // C++17 typedef unspecified exception_ptr; diff --git a/contrib/libs/cxxsupp/libcxx/include/expected b/contrib/libs/cxxsupp/libcxx/include/expected index f455ab7d5d..ccdbc3b1f6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/expected +++ b/contrib/libs/cxxsupp/libcxx/include/expected @@ -39,14 +39,24 @@ namespace std { */ #include <__config> -#include <__expected/bad_expected_access.h> -#include <__expected/expected.h> -#include <__expected/unexpect.h> -#include <__expected/unexpected.h> + +#if _LIBCPP_STD_VER >= 20 +# include <__expected/bad_expected_access.h> +# include <__expected/expected.h> +# include <__expected/unexpect.h> +# include <__expected/unexpected.h> +#endif + #include <version> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include <cstddef> +# include <initializer_list> +# include <new> +#endif + #endif // _LIBCPP_EXPECTED diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__config b/contrib/libs/cxxsupp/libcxx/include/experimental/__config deleted file mode 100644 index 7b23791511..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__config +++ /dev/null @@ -1,45 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_EXPERIMENTAL_CONFIG -#define _LIBCPP_EXPERIMENTAL_CONFIG - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL \ - namespace std { \ - namespace experimental { -#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL \ - } \ - } - -#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 { -#define _LIBCPP_END_NAMESPACE_LFTS \ - } \ - } \ - } - -#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 { -#define _LIBCPP_END_NAMESPACE_LFTS_V2 \ - } \ - } \ - } - -// TODO: support more targets -#if defined(__AVX__) -# define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 -#else -# define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 -#endif - -#endif diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/aligned_tag.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/aligned_tag.h index 31d2b50aa1..e364e146a6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/aligned_tag.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/aligned_tag.h @@ -10,10 +10,10 @@ #ifndef _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H #define _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H +#include <__config> #include <__memory/assume_aligned.h> #include <__type_traits/remove_const.h> #include <cstddef> -#include <experimental/__config> #include <experimental/__simd/traits.h> #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/declaration.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/declaration.h index 7b45d035c2..2ac7224159 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/declaration.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/declaration.h @@ -10,11 +10,18 @@ #ifndef _LIBCPP_EXPERIMENTAL___SIMD_DECLARATION_H #define _LIBCPP_EXPERIMENTAL___SIMD_DECLARATION_H +#include <__config> #include <cstddef> -#include <experimental/__config> #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) +// TODO: support more targets +# if defined(__AVX__) +# define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 +# else +# define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 +# endif + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 { namespace simd_abi { diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/reference.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/reference.h index af61dbcc2f..cba460baaa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/reference.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/reference.h @@ -10,12 +10,14 @@ #ifndef _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H #define _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H +#include <__config> +#include <__type_traits/enable_if.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_same.h> +#include <__utility/declval.h> #include <__utility/forward.h> #include <__utility/move.h> #include <cstddef> -#include <experimental/__config> #include <experimental/__simd/utility.h> _LIBCPP_PUSH_MACROS @@ -71,6 +73,91 @@ public: template <class _Tp1, class _Storage1, class _Vp1> friend void swap(__simd_reference<_Tp1, _Storage1, _Vp1>&& __a, _Vp1& __b) noexcept; + + template <class _Up, class = decltype(std::declval<value_type&>() += std::declval<_Up>())> + _LIBCPP_HIDE_FROM_ABI __simd_reference operator+=(_Up&& __v) && noexcept { + __set(__get() + static_cast<value_type>(std::forward<_Up>(__v))); + return {__s_, __idx_}; + } + + template <class _Up, class = decltype(std::declval<value_type&>() -= std::declval<_Up>())> + _LIBCPP_HIDE_FROM_ABI __simd_reference operator-=(_Up&& __v) && noexcept { + __set(__get() - static_cast<value_type>(std::forward<_Up>(__v))); + return {__s_, __idx_}; + } + + template <class _Up, class = decltype(std::declval<value_type&>() *= std::declval<_Up>())> + _LIBCPP_HIDE_FROM_ABI __simd_reference operator*=(_Up&& __v) && noexcept { + __set(__get() * static_cast<value_type>(std::forward<_Up>(__v))); + return {__s_, __idx_}; + } + + template <class _Up, class = decltype(std::declval<value_type&>() /= std::declval<_Up>())> + _LIBCPP_HIDE_FROM_ABI __simd_reference operator/=(_Up&& __v) && noexcept { + __set(__get() / static_cast<value_type>(std::forward<_Up>(__v))); + return {__s_, __idx_}; + } + + template <class _Up, class = decltype(std::declval<value_type&>() %= std::declval<_Up>())> + _LIBCPP_HIDE_FROM_ABI __simd_reference operator%=(_Up&& __v) && noexcept { + __set(__get() % static_cast<value_type>(std::forward<_Up>(__v))); + return {__s_, __idx_}; + } + + template <class _Up, class = decltype(std::declval<value_type&>() &= std::declval<_Up>())> + _LIBCPP_HIDE_FROM_ABI __simd_reference operator&=(_Up&& __v) && noexcept { + __set(__get() & static_cast<value_type>(std::forward<_Up>(__v))); + return {__s_, __idx_}; + } + + template <class _Up, class = decltype(std::declval<value_type&>() |= std::declval<_Up>())> + _LIBCPP_HIDE_FROM_ABI __simd_reference operator|=(_Up&& __v) && noexcept { + __set(__get() | static_cast<value_type>(std::forward<_Up>(__v))); + return {__s_, __idx_}; + } + + template <class _Up, class = decltype(std::declval<value_type&>() ^= std::declval<_Up>())> + _LIBCPP_HIDE_FROM_ABI __simd_reference operator^=(_Up&& __v) && noexcept { + __set(__get() ^ static_cast<value_type>(std::forward<_Up>(__v))); + return {__s_, __idx_}; + } + + template <class _Up, class = decltype(std::declval<value_type&>() <<= std::declval<_Up>())> + _LIBCPP_HIDE_FROM_ABI __simd_reference operator<<=(_Up&& __v) && noexcept { + __set(__get() << static_cast<value_type>(std::forward<_Up>(__v))); + return {__s_, __idx_}; + } + + template <class _Up, class = decltype(std::declval<value_type&>() >>= std::declval<_Up>())> + _LIBCPP_HIDE_FROM_ABI __simd_reference operator>>=(_Up&& __v) && noexcept { + __set(__get() >> static_cast<value_type>(std::forward<_Up>(__v))); + return {__s_, __idx_}; + } + + // Note: All legal vectorizable types support operator++/--. + // There doesn't seem to be a way to trigger the constraint. + // Therefore, no SFINAE check is added here. + __simd_reference _LIBCPP_HIDE_FROM_ABI operator++() && noexcept { + __set(__get() + 1); + return {__s_, __idx_}; + } + + value_type _LIBCPP_HIDE_FROM_ABI operator++(int) && noexcept { + auto __r = __get(); + __set(__get() + 1); + return __r; + } + + __simd_reference _LIBCPP_HIDE_FROM_ABI operator--() && noexcept { + __set(__get() - 1); + return {__s_, __idx_}; + } + + value_type _LIBCPP_HIDE_FROM_ABI operator--(int) && noexcept { + auto __r = __get(); + __set(__get() - 1); + return __r; + } }; template <class _Tp, class _Storage, class _Vp> diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h index 1add465320..a76933e1a5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h @@ -11,8 +11,9 @@ #define _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H #include <__assert> +#include <__config> +#include <__type_traits/integral_constant.h> #include <cstddef> -#include <experimental/__config> #include <experimental/__simd/declaration.h> #include <experimental/__simd/traits.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h index 37e334aad6..2c65d19e67 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h @@ -10,11 +10,12 @@ #ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H #define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H +#include <__config> +#include <__type_traits/enable_if.h> #include <__type_traits/is_same.h> #include <__type_traits/remove_cvref.h> #include <__utility/forward.h> #include <cstddef> -#include <experimental/__config> #include <experimental/__simd/declaration.h> #include <experimental/__simd/reference.h> #include <experimental/__simd/traits.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd_mask.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd_mask.h index fd6dee2e28..5527319415 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd_mask.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd_mask.h @@ -10,9 +10,10 @@ #ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H #define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H +#include <__config> +#include <__type_traits/enable_if.h> #include <__type_traits/is_same.h> #include <cstddef> -#include <experimental/__config> #include <experimental/__simd/declaration.h> #include <experimental/__simd/reference.h> #include <experimental/__simd/traits.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/traits.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/traits.h index ec25b4bfa7..b817df604e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/traits.h @@ -11,10 +11,10 @@ #define _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H #include <__bit/bit_ceil.h> +#include <__config> #include <__type_traits/integral_constant.h> #include <__type_traits/is_same.h> #include <cstddef> -#include <experimental/__config> #include <experimental/__simd/declaration.h> #include <experimental/__simd/utility.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h index 708fa3d8f7..0103b06b71 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h @@ -10,6 +10,7 @@ #ifndef _LIBCPP_EXPERIMENTAL___SIMD_UTILITY_H #define _LIBCPP_EXPERIMENTAL___SIMD_UTILITY_H +#include <__config> #include <__type_traits/is_arithmetic.h> #include <__type_traits/is_const.h> #include <__type_traits/is_constant_evaluated.h> @@ -22,7 +23,6 @@ #include <__utility/integer_sequence.h> #include <cstddef> #include <cstdint> -#include <experimental/__config> #include <limits> _LIBCPP_PUSH_MACROS diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h index 316866b848..6c7fb8b09a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h @@ -12,10 +12,11 @@ #include <__assert> #include <__bit/bit_ceil.h> +#include <__config> +#include <__type_traits/integral_constant.h> #include <__utility/forward.h> #include <__utility/integer_sequence.h> #include <cstddef> -#include <experimental/__config> #include <experimental/__simd/declaration.h> #include <experimental/__simd/traits.h> #include <experimental/__simd/utility.h> @@ -39,11 +40,11 @@ struct __simd_storage<_Tp, simd_abi::__vec_ext<_Np>> { _Tp __data __attribute__((__vector_size__(std::__bit_ceil((sizeof(_Tp) * _Np))))); _LIBCPP_HIDE_FROM_ABI _Tp __get(size_t __idx) const noexcept { - _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds"); + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < _Np, "Index is out of bounds"); return __data[__idx]; } _LIBCPP_HIDE_FROM_ABI void __set(size_t __idx, _Tp __v) noexcept { - _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds"); + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < _Np, "Index is out of bounds"); __data[__idx] = __v; } }; diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/iterator b/contrib/libs/cxxsupp/libcxx/include/experimental/iterator index de82da2d3d..e3a9c771fe 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/iterator +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/iterator @@ -52,11 +52,13 @@ namespace std { */ +#include <__config> #include <__memory/addressof.h> +#include <__ostream/basic_ostream.h> +#include <__string/char_traits.h> #include <__type_traits/decay.h> #include <__utility/forward.h> #include <__utility/move.h> -#include <experimental/__config> #include <iterator> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/memory b/contrib/libs/cxxsupp/libcxx/include/experimental/memory index e9663d43a8..bf8a154690 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/memory +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/memory @@ -49,6 +49,7 @@ public: } */ +#include <__config> #include <__functional/hash.h> #include <__functional/operations.h> #include <__type_traits/add_lvalue_reference.h> @@ -57,7 +58,6 @@ public: #include <__type_traits/enable_if.h> #include <__type_traits/is_convertible.h> #include <cstddef> -#include <experimental/__config> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/propagate_const b/contrib/libs/cxxsupp/libcxx/include/experimental/propagate_const index d7a695d838..510d374bb4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/propagate_const +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/propagate_const @@ -107,6 +107,7 @@ */ +#include <__config> #include <__functional/operations.h> #include <__fwd/functional.h> #include <__type_traits/conditional.h> @@ -128,7 +129,6 @@ #include <__utility/move.h> #include <__utility/swap.h> #include <cstddef> -#include <experimental/__config> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/simd b/contrib/libs/cxxsupp/libcxx/include/experimental/simd index 484543b81d..35120b4b4a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/simd +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/simd @@ -75,7 +75,7 @@ inline namespace parallelism_v2 { # pragma GCC system_header #endif -#include <experimental/__config> +#include <__config> #include <experimental/__simd/aligned_tag.h> #include <experimental/__simd/declaration.h> #include <experimental/__simd/reference.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits b/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits index 31b041bc94..a4bb59afaf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/type_traits @@ -68,7 +68,7 @@ inline namespace fundamentals_v1 { */ -#include <experimental/__config> +#include <__config> #if _LIBCPP_STD_VER >= 14 diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/utility b/contrib/libs/cxxsupp/libcxx/include/experimental/utility index 8bd0a055b7..cbc7ad140e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/utility +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/utility @@ -30,7 +30,7 @@ inline namespace fundamentals_v1 { */ -#include <experimental/__config> +#include <__config> #include <utility> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/filesystem b/contrib/libs/cxxsupp/libcxx/include/filesystem index eff7dff4a4..6ea04df0a0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/filesystem +++ b/contrib/libs/cxxsupp/libcxx/include/filesystem @@ -534,22 +534,26 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct */ #include <__config> -#include <__filesystem/copy_options.h> -#include <__filesystem/directory_entry.h> -#include <__filesystem/directory_iterator.h> -#include <__filesystem/directory_options.h> -#include <__filesystem/file_status.h> -#include <__filesystem/file_time_type.h> -#include <__filesystem/file_type.h> -#include <__filesystem/filesystem_error.h> -#include <__filesystem/operations.h> -#include <__filesystem/path.h> -#include <__filesystem/path_iterator.h> -#include <__filesystem/perm_options.h> -#include <__filesystem/perms.h> -#include <__filesystem/recursive_directory_iterator.h> -#include <__filesystem/space_info.h> -#include <__filesystem/u8path.h> + +#if _LIBCPP_STD_VER >= 17 +# include <__filesystem/copy_options.h> +# include <__filesystem/directory_entry.h> +# include <__filesystem/directory_iterator.h> +# include <__filesystem/directory_options.h> +# include <__filesystem/file_status.h> +# include <__filesystem/file_time_type.h> +# include <__filesystem/file_type.h> +# include <__filesystem/filesystem_error.h> +# include <__filesystem/operations.h> +# include <__filesystem/path.h> +# include <__filesystem/path_iterator.h> +# include <__filesystem/perm_options.h> +# include <__filesystem/perms.h> +# include <__filesystem/recursive_directory_iterator.h> +# include <__filesystem/space_info.h> +# include <__filesystem/u8path.h> +#endif + #include <version> // standard-mandated includes diff --git a/contrib/libs/cxxsupp/libcxx/include/format b/contrib/libs/cxxsupp/libcxx/include/format index 07c2ba0831..449e6f0bf3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/format +++ b/contrib/libs/cxxsupp/libcxx/include/format @@ -126,6 +126,9 @@ namespace std { // [format.formatter], formatter template<class T, class charT = char> struct formatter; + template<class T> + constexpr bool enable_nonlocking_formatter_optimization = false; // since C++23 + // [format.parse.ctx], class template basic_format_parse_context template<class charT> class basic_format_parse_context; using format_parse_context = basic_format_parse_context<char>; @@ -133,7 +136,7 @@ namespace std { // [format.range], formatting of ranges // [format.range.fmtkind], variable template format_kind - enum class range_format { // since C++23 + enum class range_format { // since C++23 disabled, map, set, @@ -143,20 +146,20 @@ namespace std { }; template<class R> - constexpr unspecified format_kind = unspecified; // since C++23 + constexpr unspecified format_kind = unspecified; // since C++23 template<ranges::input_range R> requires same_as<R, remove_cvref_t<R>> - constexpr range_format format_kind<R> = see below; // since C++23 + constexpr range_format format_kind<R> = see below; // since C++23 // [format.range.formatter], class template range_formatter template<class T, class charT = char> requires same_as<remove_cvref_t<T>, T> && formattable<T, charT> - class range_formatter; // since C++23 + class range_formatter; // since C++23 // [format.range.fmtdef], class template range-default-formatter template<range_format K, ranges::input_range R, class charT> - struct range-default-formatter; // exposition only, since C++23 + struct range-default-formatter; // exposition only, since C++23 // [format.range.fmtmap], [format.range.fmtset], [format.range.fmtstr], // specializations for maps, sets, and strings @@ -173,7 +176,7 @@ namespace std { see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg); // Deprecated in C++26 // [format.arg.store], class template format-arg-store - template<class Context, class... Args> struct format-arg-store; // exposition only + template<class Context, class... Args> struct format-arg-store; // exposition only template<class Context = format_context, class... Args> format-arg-store<Context, Args...> @@ -189,34 +192,38 @@ namespace std { */ #include <__config> -#include <__format/buffer.h> -#include <__format/concepts.h> -#include <__format/container_adaptor.h> -#include <__format/enable_insertable.h> -#include <__format/escaped_output_table.h> -#include <__format/extended_grapheme_cluster_table.h> -#include <__format/format_arg.h> -#include <__format/format_arg_store.h> -#include <__format/format_args.h> -#include <__format/format_context.h> -#include <__format/format_error.h> -#include <__format/format_functions.h> -#include <__format/format_parse_context.h> -#include <__format/format_string.h> -#include <__format/format_to_n_result.h> -#include <__format/formatter.h> -#include <__format/formatter_bool.h> -#include <__format/formatter_char.h> -#include <__format/formatter_floating_point.h> -#include <__format/formatter_integer.h> -#include <__format/formatter_pointer.h> -#include <__format/formatter_string.h> -#include <__format/formatter_tuple.h> -#include <__format/parser_std_format_spec.h> -#include <__format/range_default_formatter.h> -#include <__format/range_formatter.h> -#include <__format/unicode.h> -#include <__fwd/format.h> + +#if _LIBCPP_STD_VER >= 20 +# include <__format/buffer.h> +# include <__format/concepts.h> +# include <__format/container_adaptor.h> +# include <__format/enable_insertable.h> +# include <__format/escaped_output_table.h> +# include <__format/extended_grapheme_cluster_table.h> +# include <__format/format_arg.h> +# include <__format/format_arg_store.h> +# include <__format/format_args.h> +# include <__format/format_context.h> +# include <__format/format_error.h> +# include <__format/format_functions.h> +# include <__format/format_parse_context.h> +# include <__format/format_string.h> +# include <__format/format_to_n_result.h> +# include <__format/formatter.h> +# include <__format/formatter_bool.h> +# include <__format/formatter_char.h> +# include <__format/formatter_floating_point.h> +# include <__format/formatter_integer.h> +# include <__format/formatter_pointer.h> +# include <__format/formatter_string.h> +# include <__format/formatter_tuple.h> +# include <__format/parser_std_format_spec.h> +# include <__format/range_default_formatter.h> +# include <__format/range_formatter.h> +# include <__format/unicode.h> +# include <__fwd/format.h> +#endif + #include <version> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -224,9 +231,30 @@ namespace std { #endif #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include <array> +# include <cctype> +# include <cerrno> +# include <clocale> +# include <cmath> +# include <cstddef> +# include <cstdint> +# include <cstdlib> +# include <cstring> +# include <initializer_list> +# include <limits> # include <locale> +# include <new> +# include <optional> # include <queue> # include <stack> +# include <stdexcept> +# include <string> +# include <string_view> +# include <tuple> + +# if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) +# include <cwchar> +# endif #endif #endif // _LIBCPP_FORMAT diff --git a/contrib/libs/cxxsupp/libcxx/include/forward_list b/contrib/libs/cxxsupp/libcxx/include/forward_list index 1ae19d23f8..c5ae8add51 100644 --- a/contrib/libs/cxxsupp/libcxx/include/forward_list +++ b/contrib/libs/cxxsupp/libcxx/include/forward_list @@ -218,15 +218,18 @@ template <class T, class Allocator, class Predicate> #include <__ranges/container_compatible_range.h> #include <__ranges/from_range.h> #include <__type_traits/conditional.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_allocator.h> #include <__type_traits/is_const.h> #include <__type_traits/is_nothrow_assignable.h> #include <__type_traits/is_nothrow_constructible.h> #include <__type_traits/is_pointer.h> #include <__type_traits/is_same.h> +#include <__type_traits/is_swappable.h> #include <__type_traits/type_identity.h> #include <__utility/forward.h> #include <__utility/move.h> +#include <__utility/swap.h> #include <limits> #include <new> // __launder #include <version> @@ -275,18 +278,20 @@ struct __forward_node_traits { typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer; typedef __rebind_pointer_t<_NodePtr, void> __void_pointer; -#if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB) - typedef __begin_node_pointer __iter_node_pointer; -#else - typedef __conditional_t<is_pointer<__void_pointer>::value, __begin_node_pointer, __node_pointer> __iter_node_pointer; +// TODO(LLVM 22): Remove this check +#ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB + static_assert(sizeof(__begin_node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__begin_node_pointer) == + _LIBCPP_ALIGNOF(__node_pointer), + "It looks like you are using std::forward_list with a fancy pointer type that thas a different " + "representation depending on whether it points to a forward_list base pointer or a forward_list node " + "pointer (both of which are implementation details of the standard library). This means that your ABI " + "is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define " + "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); #endif - typedef __conditional_t<is_same<__iter_node_pointer, __node_pointer>::value, __begin_node_pointer, __node_pointer> - __non_iter_node_pointer; - - _LIBCPP_HIDE_FROM_ABI static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) { return __p; } - _LIBCPP_HIDE_FROM_ABI static __iter_node_pointer __as_iter_node(__non_iter_node_pointer __p) { - return static_cast<__iter_node_pointer>(static_cast<__void_pointer>(__p)); + _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__begin_node_pointer __p) { return __p; } + _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__node_pointer __p) { + return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__p)); } }; @@ -348,10 +353,9 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_iterator { typedef __forward_node_traits<_NodePtr> __traits; typedef typename __traits::__node_pointer __node_pointer; typedef typename __traits::__begin_node_pointer __begin_node_pointer; - typedef typename __traits::__iter_node_pointer __iter_node_pointer; typedef typename __traits::__void_pointer __void_pointer; - __iter_node_pointer __ptr_; + __begin_node_pointer __ptr_; _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const { return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_)); @@ -414,10 +418,9 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator { typedef typename __traits::__node_type __node_type; typedef typename __traits::__node_pointer __node_pointer; typedef typename __traits::__begin_node_pointer __begin_node_pointer; - typedef typename __traits::__iter_node_pointer __iter_node_pointer; typedef typename __traits::__void_pointer __void_pointer; - __iter_node_pointer __ptr_; + __begin_node_pointer __ptr_; _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const { return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_)); @@ -489,27 +492,27 @@ protected: typedef __rebind_alloc<allocator_traits<allocator_type>, __begin_node> __begin_node_allocator; typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer; - __compressed_pair<__begin_node, __node_allocator> __before_begin_; + _LIBCPP_COMPRESSED_PAIR(__begin_node, __before_begin_, __node_allocator, __alloc_); _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() _NOEXCEPT { - return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_.first()); + return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_); } _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() const _NOEXCEPT { - return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_.first())); + return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_)); } - _LIBCPP_HIDE_FROM_ABI __node_allocator& __alloc() _NOEXCEPT { return __before_begin_.second(); } - _LIBCPP_HIDE_FROM_ABI const __node_allocator& __alloc() const _NOEXCEPT { return __before_begin_.second(); } + _LIBCPP_HIDE_FROM_ABI __node_allocator& __alloc() _NOEXCEPT { return __alloc_; } + _LIBCPP_HIDE_FROM_ABI const __node_allocator& __alloc() const _NOEXCEPT { return __alloc_; } typedef __forward_list_iterator<__node_pointer> iterator; typedef __forward_list_const_iterator<__node_pointer> const_iterator; _LIBCPP_HIDE_FROM_ABI __forward_list_base() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) - : __before_begin_(__begin_node(), __default_init_tag()) {} + : __before_begin_(__begin_node()) {} _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const allocator_type& __a) - : __before_begin_(__begin_node(), __node_allocator(__a)) {} + : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {} _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a) - : __before_begin_(__begin_node(), __a) {} + : __before_begin_(__begin_node()), __alloc_(__a) {} public: #ifndef _LIBCPP_CXX03_LANG @@ -591,13 +594,13 @@ private: template <class _Tp, class _Alloc> inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) noexcept( is_nothrow_move_constructible<__node_allocator>::value) - : __before_begin_(std::move(__x.__before_begin_)) { + : __before_begin_(std::move(__x.__before_begin_)), __alloc_(std::move(__x.__alloc_)) { __x.__before_begin()->__next_ = nullptr; } template <class _Tp, class _Alloc> inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x, const allocator_type& __a) - : __before_begin_(__begin_node(), __node_allocator(__a)) { + : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) { if (__alloc() == __x.__alloc()) { __before_begin()->__next_ = __x.__before_begin()->__next_; __x.__before_begin()->__next_ = nullptr; @@ -619,8 +622,7 @@ inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>) #endif { - std::__swap_allocator( - __alloc(), __x.__alloc(), integral_constant<bool, __node_traits::propagate_on_container_swap::value>()); + std::__swap_allocator(__alloc(), __x.__alloc()); using std::swap; swap(__before_begin()->__next_, __x.__before_begin()->__next_); } @@ -755,7 +757,7 @@ public: return const_iterator(base::__before_begin()); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return base::__before_begin()->__next_ == nullptr; } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { @@ -1517,8 +1519,7 @@ operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc> template <class _Tp, class _Allocator> _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) { - return std::lexicographical_compare_three_way( - __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } #endif // #if _LIBCPP_STD_VER <= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/fstream b/contrib/libs/cxxsupp/libcxx/include/fstream index ab5ebf8e2c..de7c614836 100644 --- a/contrib/libs/cxxsupp/libcxx/include/fstream +++ b/contrib/libs/cxxsupp/libcxx/include/fstream @@ -189,15 +189,16 @@ typedef basic_fstream<wchar_t> wfstream; #include <__algorithm/max.h> #include <__assert> #include <__config> +#include <__filesystem/path.h> #include <__fwd/fstream.h> #include <__locale> +#include <__memory/addressof.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_same.h> #include <__utility/move.h> #include <__utility/swap.h> #include <__utility/unreachable.h> #include <cstdio> -#include <filesystem> #include <istream> #include <ostream> #include <typeinfo> @@ -214,7 +215,7 @@ _LIBCPP_PUSH_MACROS # define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS #endif -#if !defined(_LIBCPP_HAS_NO_FILESYSTEM) +#if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) _LIBCPP_BEGIN_NAMESPACE_STD @@ -1136,11 +1137,12 @@ private: }; template <class _CharT, class _Traits> -inline basic_ifstream<_CharT, _Traits>::basic_ifstream() : basic_istream<char_type, traits_type>(&__sb_) {} +inline basic_ifstream<_CharT, _Traits>::basic_ifstream() + : basic_istream<char_type, traits_type>(std::addressof(__sb_)) {} template <class _CharT, class _Traits> inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode) - : basic_istream<char_type, traits_type>(&__sb_) { + : basic_istream<char_type, traits_type>(std::addressof(__sb_)) { if (__sb_.open(__s, __mode | ios_base::in) == nullptr) this->setstate(ios_base::failbit); } @@ -1148,15 +1150,16 @@ inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR template <class _CharT, class _Traits> inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode) - : basic_istream<char_type, traits_type>(&__sb_) { + : basic_istream<char_type, traits_type>(std::addressof(__sb_)) { if (__sb_.open(__s, __mode | ios_base::in) == nullptr) this->setstate(ios_base::failbit); } # endif +// extension template <class _CharT, class _Traits> inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode) - : basic_istream<char_type, traits_type>(&__sb_) { + : basic_istream<char_type, traits_type>(std::addressof(__sb_)) { if (__sb_.open(__s, __mode | ios_base::in) == nullptr) this->setstate(ios_base::failbit); } @@ -1164,7 +1167,7 @@ inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_ba template <class _CharT, class _Traits> inline basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs) : basic_istream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { - this->set_rdbuf(&__sb_); + this->set_rdbuf(std::addressof(__sb_)); } template <class _CharT, class _Traits> @@ -1187,7 +1190,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_ifstream<_CharT, _Traits>& __x, bas template <class _CharT, class _Traits> inline basic_filebuf<_CharT, _Traits>* basic_ifstream<_CharT, _Traits>::rdbuf() const { - return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_); + return const_cast<basic_filebuf<char_type, traits_type>*>(std::addressof(__sb_)); } template <class _CharT, class _Traits> @@ -1293,11 +1296,12 @@ private: }; template <class _CharT, class _Traits> -inline basic_ofstream<_CharT, _Traits>::basic_ofstream() : basic_ostream<char_type, traits_type>(&__sb_) {} +inline basic_ofstream<_CharT, _Traits>::basic_ofstream() + : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) {} template <class _CharT, class _Traits> inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode) - : basic_ostream<char_type, traits_type>(&__sb_) { + : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) { if (__sb_.open(__s, __mode | ios_base::out) == nullptr) this->setstate(ios_base::failbit); } @@ -1305,15 +1309,16 @@ inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR template <class _CharT, class _Traits> inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode) - : basic_ostream<char_type, traits_type>(&__sb_) { + : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) { if (__sb_.open(__s, __mode | ios_base::out) == nullptr) this->setstate(ios_base::failbit); } # endif +// extension template <class _CharT, class _Traits> inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode) - : basic_ostream<char_type, traits_type>(&__sb_) { + : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) { if (__sb_.open(__s, __mode | ios_base::out) == nullptr) this->setstate(ios_base::failbit); } @@ -1321,7 +1326,7 @@ inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_ba template <class _CharT, class _Traits> inline basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs) : basic_ostream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { - this->set_rdbuf(&__sb_); + this->set_rdbuf(std::addressof(__sb_)); } template <class _CharT, class _Traits> @@ -1344,7 +1349,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_ofstream<_CharT, _Traits>& __x, bas template <class _CharT, class _Traits> inline basic_filebuf<_CharT, _Traits>* basic_ofstream<_CharT, _Traits>::rdbuf() const { - return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_); + return const_cast<basic_filebuf<char_type, traits_type>*>(std::addressof(__sb_)); } template <class _CharT, class _Traits> @@ -1454,11 +1459,12 @@ private: }; template <class _CharT, class _Traits> -inline basic_fstream<_CharT, _Traits>::basic_fstream() : basic_iostream<char_type, traits_type>(&__sb_) {} +inline basic_fstream<_CharT, _Traits>::basic_fstream() + : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) {} template <class _CharT, class _Traits> inline basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode) - : basic_iostream<char_type, traits_type>(&__sb_) { + : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) { if (__sb_.open(__s, __mode) == nullptr) this->setstate(ios_base::failbit); } @@ -1466,7 +1472,7 @@ inline basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base:: # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR template <class _CharT, class _Traits> inline basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode) - : basic_iostream<char_type, traits_type>(&__sb_) { + : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) { if (__sb_.open(__s, __mode) == nullptr) this->setstate(ios_base::failbit); } @@ -1474,15 +1480,16 @@ inline basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_bas template <class _CharT, class _Traits> inline basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode) - : basic_iostream<char_type, traits_type>(&__sb_) { + : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) { if (__sb_.open(__s, __mode) == nullptr) this->setstate(ios_base::failbit); } +// extension template <class _CharT, class _Traits> inline basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs) : basic_iostream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { - this->set_rdbuf(&__sb_); + this->set_rdbuf(std::addressof(__sb_)); } template <class _CharT, class _Traits> @@ -1505,7 +1512,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_fstream<_CharT, _Traits>& __x, basi template <class _CharT, class _Traits> inline basic_filebuf<_CharT, _Traits>* basic_fstream<_CharT, _Traits>::rdbuf() const { - return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_); + return const_cast<basic_filebuf<char_type, traits_type>*>(std::addressof(__sb_)); } template <class _CharT, class _Traits> @@ -1553,7 +1560,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>; _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_HAS_NO_FILESYSTEM +#endif // !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) _LIBCPP_POP_MACROS @@ -1569,4 +1576,8 @@ _LIBCPP_POP_MACROS # include <type_traits> #endif +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 +# include <filesystem> +#endif + #endif // _LIBCPP_FSTREAM diff --git a/contrib/libs/cxxsupp/libcxx/include/functional b/contrib/libs/cxxsupp/libcxx/include/functional index 27cf21e1a4..3d39f654dd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/functional +++ b/contrib/libs/cxxsupp/libcxx/include/functional @@ -527,41 +527,60 @@ POLICY: For non-variadic implementations, the number of arguments is limited */ -#include <__algorithm/search.h> -#include <__compare/compare_three_way.h> #include <__config> + #include <__functional/binary_function.h> #include <__functional/binary_negate.h> #include <__functional/bind.h> -#include <__functional/bind_back.h> -#include <__functional/bind_front.h> #include <__functional/binder1st.h> #include <__functional/binder2nd.h> -#include <__functional/boyer_moore_searcher.h> -#include <__functional/compose.h> -#include <__functional/default_searcher.h> -#include <__functional/function.h> #include <__functional/hash.h> -#include <__functional/identity.h> -#include <__functional/invoke.h> #include <__functional/mem_fn.h> // TODO: deprecate #include <__functional/mem_fun_ref.h> -#include <__functional/not_fn.h> #include <__functional/operations.h> #include <__functional/pointer_to_binary_function.h> #include <__functional/pointer_to_unary_function.h> -#include <__functional/ranges_operations.h> #include <__functional/reference_wrapper.h> #include <__functional/unary_function.h> #include <__functional/unary_negate.h> -#include <__type_traits/unwrap_ref.h> -#include <__utility/forward.h> + +#ifndef _LIBCPP_CXX03_LANG +# include <__functional/function.h> +#endif + +#if _LIBCPP_STD_VER >= 17 +# include <__functional/boyer_moore_searcher.h> +# include <__functional/default_searcher.h> +# include <__functional/invoke.h> +# include <__functional/not_fn.h> +#endif + +#if _LIBCPP_STD_VER >= 20 +# include <__functional/bind_back.h> +# include <__functional/bind_front.h> +# include <__functional/identity.h> +# include <__functional/ranges_operations.h> +# include <__type_traits/unwrap_ref.h> +#endif + #include <version> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && defined(_LIBCPP_CXX03_LANG) +# include <limits> +# include <new> +#endif + +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 +# include <array> +# include <initializer_list> +# include <unordered_map> +# include <vector> +#endif + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <atomic> # include <concepts> diff --git a/contrib/libs/cxxsupp/libcxx/include/future b/contrib/libs/cxxsupp/libcxx/include/future index dea73dc638..7dc38a3354 100644 --- a/contrib/libs/cxxsupp/libcxx/include/future +++ b/contrib/libs/cxxsupp/libcxx/include/future @@ -329,7 +329,7 @@ public: template <class F> explicit packaged_task(F&& f); template <class F, class Allocator> - packaged_task(allocator_arg_t, const Allocator& a, F&& f); + packaged_task(allocator_arg_t, const Allocator& a, F&& f); // removed in C++17 ~packaged_task(); // no copy @@ -356,7 +356,7 @@ public: template <class R> void swap(packaged_task<R(ArgTypes...)&, packaged_task<R(ArgTypes...)>&) noexcept; -template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; +template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; // removed in C++17 } // std @@ -364,44 +364,48 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; #include <__config> -#ifdef _LIBCPP_HAS_NO_THREADS -# error "<future> is not supported since libc++ has been configured without support for threads." -#endif - -#include <__assert> -#include <__chrono/duration.h> -#include <__chrono/time_point.h> -#include <__exception/exception_ptr.h> -#include <__memory/addressof.h> -#include <__memory/allocator.h> -#include <__memory/allocator_arg_t.h> -#include <__memory/allocator_destructor.h> -#include <__memory/allocator_traits.h> -#include <__memory/compressed_pair.h> -#include <__memory/pointer_traits.h> -#include <__memory/shared_ptr.h> -#include <__memory/unique_ptr.h> -#include <__memory/uses_allocator.h> -#include <__system_error/error_category.h> -#include <__system_error/error_code.h> -#include <__system_error/error_condition.h> -#include <__type_traits/aligned_storage.h> -#include <__type_traits/strip_signature.h> -#include <__utility/auto_cast.h> -#include <__utility/forward.h> -#include <__utility/move.h> -#include <mutex> -#include <new> -#include <stdexcept> -#include <thread> -#include <version> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if !defined(_LIBCPP_HAS_NO_THREADS) + +# include <__assert> +# include <__chrono/duration.h> +# include <__chrono/time_point.h> +# include <__condition_variable/condition_variable.h> +# include <__exception/exception_ptr.h> +# include <__memory/addressof.h> +# include <__memory/allocator.h> +# include <__memory/allocator_arg_t.h> +# include <__memory/allocator_destructor.h> +# include <__memory/allocator_traits.h> +# include <__memory/compressed_pair.h> +# include <__memory/pointer_traits.h> +# include <__memory/shared_ptr.h> +# include <__memory/unique_ptr.h> +# include <__memory/uses_allocator.h> +# include <__system_error/error_category.h> +# include <__system_error/error_code.h> +# include <__system_error/error_condition.h> +# include <__type_traits/add_lvalue_reference.h> +# include <__type_traits/aligned_storage.h> +# include <__type_traits/conditional.h> +# include <__type_traits/decay.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/strip_signature.h> +# include <__type_traits/underlying_type.h> +# include <__utility/auto_cast.h> +# include <__utility/forward.h> +# include <__utility/move.h> +# include <mutex> +# include <new> +# include <stdexcept> +# include <thread> +# include <version> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -413,16 +417,16 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {}; -#ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type {}; -#endif +# endif // enum class launch _LIBCPP_DECLARE_STRONG_ENUM(launch){async = 1, deferred = 2, any = async | deferred}; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch) -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG typedef underlying_type<launch>::type __launch_underlying_type; @@ -457,7 +461,7 @@ inline _LIBCPP_HIDE_FROM_ABI launch& operator^=(launch& __x, launch __y) { return __x; } -#endif // !_LIBCPP_CXX03_LANG +# endif // !_LIBCPP_CXX03_LANG // enum class future_status _LIBCPP_DECLARE_STRONG_ENUM(future_status){ready, timeout, deferred}; @@ -473,7 +477,7 @@ inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(future_errc __ return error_condition(static_cast<int>(__e), future_category()); } -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_future_error(future_errc __ev); +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_future_error(future_errc __ev); class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error { error_code __ec_; @@ -484,9 +488,9 @@ class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error { friend class promise; public: -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {} -#endif +# endif _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } @@ -496,12 +500,12 @@ public: // Declared above std::future_error void __throw_future_error(future_errc __ev) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw future_error(make_error_code(__ev)); -#else +# else (void)__ev; _LIBCPP_VERBOSE_ABORT("future_error was thrown in -fno-exceptions mode"); -#endif +# endif } class _LIBCPP_EXPORTED_FROM_ABI __assoc_sub_state : public __shared_count { @@ -775,15 +779,15 @@ inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __f template <class _Rp, class _Fp> void __deferred_assoc_state<_Rp, _Fp>::__execute() { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS this->set_value(__func_()); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } template <class _Fp> @@ -805,16 +809,16 @@ inline __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f) : __ template <class _Fp> void __deferred_assoc_state<void, _Fp>::__execute() { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __func_(); this->set_value(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } template <class _Rp, class _Fp> @@ -836,15 +840,15 @@ inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(s template <class _Rp, class _Fp> void __async_assoc_state<_Rp, _Fp>::__execute() { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS this->set_value(__func_()); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } template <class _Rp, class _Fp> @@ -872,16 +876,16 @@ inline __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f) : __func_( template <class _Fp> void __async_assoc_state<void, _Fp>::__execute() { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __func_(); this->set_value(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } template <class _Fp> @@ -1386,7 +1390,7 @@ template <class _Rp, class... _ArgTypes> class __packaged_task_base<_Rp(_ArgTypes...)> { public: _LIBCPP_HIDE_FROM_ABI __packaged_task_base() {} - __packaged_task_base(const __packaged_task_base&) = delete; + __packaged_task_base(const __packaged_task_base&) = delete; __packaged_task_base& operator=(const __packaged_task_base&) = delete; _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__packaged_task_base() {} @@ -1401,13 +1405,13 @@ class __packaged_task_func; template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> class __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __packaged_task_base<_Rp(_ArgTypes...)> { - __compressed_pair<_Fp, _Alloc> __f_; + _LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Alloc, __alloc_); public: - _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(const _Fp& __f) : __f_(__f, __default_init_tag()) {} - _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(_Fp&& __f) : __f_(std::move(__f), __default_init_tag()) {} - _LIBCPP_HIDE_FROM_ABI __packaged_task_func(const _Fp& __f, const _Alloc& __a) : __f_(__f, __a) {} - _LIBCPP_HIDE_FROM_ABI __packaged_task_func(_Fp&& __f, const _Alloc& __a) : __f_(std::move(__f), __a) {} + _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(const _Fp& __f) : __func_(__f) {} + _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(_Fp&& __f) : __func_(std::move(__f)) {} + _LIBCPP_HIDE_FROM_ABI __packaged_task_func(const _Fp& __f, const _Alloc& __a) : __func_(__f), __alloc_(__a) {} + _LIBCPP_HIDE_FROM_ABI __packaged_task_func(_Fp&& __f, const _Alloc& __a) : __func_(std::move(__f)), __alloc_(__a) {} _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __move_to(__packaged_task_base<_Rp(_ArgTypes...)>*) _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy(); _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate(); @@ -1417,12 +1421,13 @@ public: template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to( __packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT { - ::new ((void*)__p) __packaged_task_func(std::move(__f_.first()), std::move(__f_.second())); + ::new ((void*)__p) __packaged_task_func(std::move(__func_), std::move(__alloc_)); } template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() { - __f_.~__compressed_pair<_Fp, _Alloc>(); + __func_.~_Fp(); + __alloc_.~_Alloc(); } template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> @@ -1430,14 +1435,15 @@ void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() typedef typename __allocator_traits_rebind<_Alloc, __packaged_task_func>::type _Ap; typedef allocator_traits<_Ap> _ATraits; typedef pointer_traits<typename _ATraits::pointer> _PTraits; - _Ap __a(__f_.second()); - __f_.~__compressed_pair<_Fp, _Alloc>(); + _Ap __a(__alloc_); + __func_.~_Fp(); + __alloc_.~_Alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> _Rp __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) { - return std::__invoke(__f_.first(), std::forward<_ArgTypes>(__arg)...); + return std::__invoke(__func_, std::forward<_ArgTypes>(__arg)...); } template <class _Callable> @@ -1607,9 +1613,11 @@ public: template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {} +# if _LIBCPP_STD_VER <= 14 template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {} +# endif // ~packaged_task() = default; // no copy @@ -1648,15 +1656,15 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __p_.set_value(__f_(std::forward<_ArgTypes>(__args)...)); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __p_.set_exception(current_exception()); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } template <class _Rp, class... _ArgTypes> @@ -1665,15 +1673,15 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __ __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __p_.set_value_at_thread_exit(__f_(std::forward<_ArgTypes>(__args)...)); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __p_.set_exception_at_thread_exit(current_exception()); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } template <class _Rp, class... _ArgTypes> @@ -1697,9 +1705,11 @@ public: _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {} template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {} +# if _LIBCPP_STD_VER <= 14 template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {} +# endif // ~packaged_task() = default; // no copy @@ -1732,7 +1742,7 @@ public: _LIBCPP_HIDE_FROM_ABI void reset(); }; -#if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 template <class _Rp, class... _Args> packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>; @@ -1740,7 +1750,7 @@ packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>; template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type> packaged_task(_Fp) -> packaged_task<_Stripped>; -#endif +# endif template <class... _ArgTypes> void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { @@ -1748,16 +1758,16 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __f_(std::forward<_ArgTypes>(__args)...); __p_.set_value(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __p_.set_exception(current_exception()); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } template <class... _ArgTypes> @@ -1766,16 +1776,16 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _ __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __f_(std::forward<_ArgTypes>(__args)...); __p_.set_value_at_thread_exit(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __p_.set_exception_at_thread_exit(current_exception()); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } template <class... _ArgTypes> @@ -1791,8 +1801,10 @@ swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __ __x.swap(__y); } +# if _LIBCPP_STD_VER <= 14 template <class _Callable, class _Alloc> struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc> : public true_type {}; +# endif template <class _Rp, class _Fp> _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_deferred_assoc_state(_Fp&& __f) { @@ -1809,7 +1821,7 @@ _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) { return future<_Rp>(__h.get()); } -#ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template <class _Fp, class... _Args> class _LIBCPP_HIDDEN __async_func { @@ -1840,23 +1852,23 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch } template <class _Fp, class... _Args> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type> async(launch __policy, _Fp&& __f, _Args&&... __args) { typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF; typedef typename _BF::_Rp _Rp; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -# endif +# endif if (__does_policy_contain(__policy, launch::async)) return std::__make_async_assoc_state<_Rp>( _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...)); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { if (__policy == launch::async) throw; } -# endif +# endif if (__does_policy_contain(__policy, launch::deferred)) return std::__make_deferred_assoc_state<_Rp>( @@ -1865,12 +1877,12 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) { } template <class _Fp, class... _Args> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type> +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type> async(_Fp&& __f, _Args&&... __args) { return std::async(launch::any, std::forward<_Fp>(__f), std::forward<_Args>(__args)...); } -#endif // C++03 +# endif // C++03 // shared_future @@ -2047,6 +2059,8 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS +#endif // !defined(_LIBCPP_HAS_NO_THREADS) + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 # include <chrono> #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/iomanip b/contrib/libs/cxxsupp/libcxx/include/iomanip index fb4f15b9a5..2c4023d4ee 100644 --- a/contrib/libs/cxxsupp/libcxx/include/iomanip +++ b/contrib/libs/cxxsupp/libcxx/include/iomanip @@ -43,12 +43,17 @@ template <class charT, class traits, class Allocator> */ #include <__config> -#include <istream> -#include <version> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#ifndef _LIBCPP_HAS_NO_LOCALIZATION + +# include <__ostream/basic_ostream.h> +# include <ios> +# include <istream> +# include <version> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -231,9 +236,9 @@ public: template <class _CharT, class _Traits, class _MoneyT> _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { typedef istreambuf_iterator<_CharT, _Traits> _Ip; @@ -243,11 +248,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) { __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_); __is.setstate(__err); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return __is; } @@ -280,9 +285,9 @@ public: template <class _CharT, class _Traits, class _MoneyT> _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Op; @@ -291,11 +296,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) { if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed()) __os.setstate(ios_base::badbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return __os; } @@ -328,9 +333,9 @@ public: template <class _CharT, class _Traits> _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { typedef istreambuf_iterator<_CharT, _Traits> _Ip; @@ -340,11 +345,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) { __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)); __is.setstate(__err); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return __is; } @@ -377,9 +382,9 @@ public: template <class _CharT, class _Traits> _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Op; @@ -389,11 +394,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) { .failed()) __os.setstate(ios_base::badbit); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS return __os; } @@ -505,7 +510,7 @@ __quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape); } -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 template <class _CharT> _LIBCPP_HIDE_FROM_ABI auto quoted(const _CharT* __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { @@ -535,8 +540,10 @@ quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _C return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape); } -#endif // _LIBCPP_STD_VER >= 14 +# endif // _LIBCPP_STD_VER >= 14 _LIBCPP_END_NAMESPACE_STD +#endif // !_LIBCPP_HAS_NO_LOCALIZATION + #endif // _LIBCPP_IOMANIP diff --git a/contrib/libs/cxxsupp/libcxx/include/ios b/contrib/libs/cxxsupp/libcxx/include/ios index a653af005a..61a05fadd2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/ios +++ b/contrib/libs/cxxsupp/libcxx/include/ios @@ -213,36 +213,35 @@ storage-class-specifier const error_category& iostream_category() noexcept; #include <__config> -#if defined(_LIBCPP_HAS_NO_LOCALIZATION) -# error "The iostreams library is not supported since libc++ has been configured without support for localization." -#endif - -#include <__fwd/ios.h> -#include <__ios/fpos.h> -#include <__locale> -#include <__system_error/error_category.h> -#include <__system_error/error_code.h> -#include <__system_error/error_condition.h> -#include <__system_error/system_error.h> -#include <__utility/swap.h> -#include <__verbose_abort> -#include <version> +#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__fwd/ios.h> +# include <__ios/fpos.h> +# include <__locale> +# include <__memory/addressof.h> +# include <__system_error/error_category.h> +# include <__system_error/error_code.h> +# include <__system_error/error_condition.h> +# include <__system_error/system_error.h> +# include <__utility/swap.h> +# include <__verbose_abort> +# include <version> // standard-mandated includes // [ios.syn] -#include <iosfwd> +# include <iosfwd> -#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) -# include <__atomic/atomic.h> // for __xindex_ -#endif +# if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) +# include <__atomic/atomic.h> // for __xindex_ +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -285,20 +284,20 @@ public: static const openmode in = 0x08; static const openmode out = 0x10; static const openmode trunc = 0x20; -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 static const openmode noreplace = 0x40; -#endif +# endif enum seekdir { beg, cur, end }; -#if _LIBCPP_STD_VER <= 14 +# if _LIBCPP_STD_VER <= 14 typedef iostate io_state; typedef openmode open_mode; typedef seekdir seek_dir; typedef std::streamoff streamoff; typedef std::streampos streampos; -#endif +# endif class _LIBCPP_EXPORTED_FROM_ABI Init; @@ -398,11 +397,11 @@ private: size_t __event_cap_; // TODO(EricWF): Enable this for both Clang and GCC. Currently it is only // enabled with clang. -#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) +# if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) static atomic<int> __xindex_; -#else +# else static int __xindex_; -#endif +# endif long* __iarray_; size_t __iarray_size_; size_t __iarray_cap_; @@ -418,10 +417,10 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {}; -#ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {}; -#endif +# endif _LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT; @@ -441,12 +440,12 @@ public: ~failure() _NOEXCEPT override; }; -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) { +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw ios_base::failure(__msg); -#else +# else _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg); -#endif +# endif } class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init { @@ -521,6 +520,38 @@ inline _LIBCPP_HIDE_FROM_ABI void ios_base::exceptions(iostate __iostate) { clear(__rdstate_); } +template <class _Traits> +// Attribute 'packed' is used to keep the layout compatible with the previous +// definition of the '__fill_' and '_set_' pair in basic_ios on AIX & z/OS. +struct _LIBCPP_PACKED _FillHelper { + _LIBCPP_HIDE_FROM_ABI void __init() { __set_ = false; } + _LIBCPP_HIDE_FROM_ABI _FillHelper& operator=(typename _Traits::int_type __x) { + __set_ = true; + __fill_val_ = __x; + return *this; + } + _LIBCPP_HIDE_FROM_ABI bool __is_set() const { return __set_; } + _LIBCPP_HIDE_FROM_ABI typename _Traits::int_type __get() const { return __fill_val_; } + +private: + typename _Traits::int_type __fill_val_; + bool __set_; +}; + +template <class _Traits> +struct _LIBCPP_PACKED _SentinelValueFill { + _LIBCPP_HIDE_FROM_ABI void __init() { __fill_val_ = _Traits::eof(); } + _LIBCPP_HIDE_FROM_ABI _SentinelValueFill& operator=(typename _Traits::int_type __x) { + __fill_val_ = __x; + return *this; + } + _LIBCPP_HIDE_FROM_ABI bool __is_set() const { return __fill_val_ != _Traits::eof(); } + _LIBCPP_HIDE_FROM_ABI typename _Traits::int_type __get() const { return __fill_val_; } + +private: + typename _Traits::int_type __fill_val_; +}; + template <class _CharT, class _Traits> class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base { public: @@ -535,13 +566,13 @@ public: static_assert(is_same<_CharT, typename traits_type::char_type>::value, "traits_type::char_type must be the same type as CharT"); -#ifdef _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG // Preserve the ability to compare with literal 0, // and implicitly convert to bool, but not implicitly convert to int. _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; } -#else +# else _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); } -#endif +# endif _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); } _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); } @@ -590,7 +621,13 @@ protected: private: basic_ostream<char_type, traits_type>* __tie_; - mutable int_type __fill_; + +# if defined(_LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE) + using _FillType = _FillHelper<traits_type>; +# else + using _FillType = _SentinelValueFill<traits_type>; +# endif + mutable _FillType __fill_; }; template <class _CharT, class _Traits> @@ -604,8 +641,8 @@ basic_ios<_CharT, _Traits>::~basic_ios() {} template <class _CharT, class _Traits> inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) { ios_base::init(__sb); - __tie_ = nullptr; - __fill_ = traits_type::eof(); + __tie_ = nullptr; + __fill_.__init(); } template <class _CharT, class _Traits> @@ -655,23 +692,23 @@ inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::widen(char __c) template <class _CharT, class _Traits> inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill() const { - if (traits_type::eq_int_type(traits_type::eof(), __fill_)) + if (!__fill_.__is_set()) __fill_ = widen(' '); - return __fill_; + return __fill_.__get(); } template <class _CharT, class _Traits> inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill(char_type __ch) { - if (traits_type::eq_int_type(traits_type::eof(), __fill_)) + if (!__fill_.__is_set()) __fill_ = widen(' '); - char_type __r = __fill_; + char_type __r = __fill_.__get(); __fill_ = __ch; return __r; } template <class _CharT, class _Traits> basic_ios<_CharT, _Traits>& basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) { - if (this != &__rhs) { + if (this != std::addressof(__rhs)) { __call_callbacks(erase_event); ios_base::copyfmt(__rhs); __tie_ = __rhs.__tie_; @@ -704,9 +741,9 @@ inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_st extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>; -#endif +# endif _LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) { __str.setf(ios_base::boolalpha); @@ -832,6 +869,8 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS +#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <atomic> # include <concepts> diff --git a/contrib/libs/cxxsupp/libcxx/include/iosfwd b/contrib/libs/cxxsupp/libcxx/include/iosfwd index 051c73995e..eeafcc37c5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/iosfwd +++ b/contrib/libs/cxxsupp/libcxx/include/iosfwd @@ -170,8 +170,8 @@ class __save_flags { _CharT __fill_; public: - __save_flags(const __save_flags&) = delete; - __save_flags& operator=(const __save_flags&) = delete; + __save_flags(const __save_flags&) = delete; + __save_flags& operator=(const __save_flags&) = delete; _LIBCPP_HIDE_FROM_ABI explicit __save_flags(__stream_type& __stream) : __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {} diff --git a/contrib/libs/cxxsupp/libcxx/include/istream b/contrib/libs/cxxsupp/libcxx/include/istream index d2b577a9ad..8ee29ba330 100644 --- a/contrib/libs/cxxsupp/libcxx/include/istream +++ b/contrib/libs/cxxsupp/libcxx/include/istream @@ -159,25 +159,29 @@ template <class Stream, class T> */ #include <__config> -#include <__fwd/istream.h> -#include <__iterator/istreambuf_iterator.h> -#include <__ostream/basic_ostream.h> -#include <__type_traits/conjunction.h> -#include <__type_traits/enable_if.h> -#include <__type_traits/is_base_of.h> -#include <__utility/declval.h> -#include <__utility/forward.h> -#include <bitset> -#include <ios> -#include <locale> -#include <version> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif + +#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__fwd/istream.h> +# include <__iterator/istreambuf_iterator.h> +# include <__ostream/basic_ostream.h> +# include <__type_traits/conjunction.h> +# include <__type_traits/enable_if.h> +# include <__type_traits/is_base_of.h> +# include <__type_traits/make_unsigned.h> +# include <__utility/declval.h> +# include <__utility/forward.h> +# include <bitset> +# include <ios> +# include <locale> +# include <version> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -353,13 +357,13 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) { ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef istreambuf_iterator<_CharT, _Traits> _Ip; typedef num_get<_CharT, _Ip> _Fp; std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -367,7 +371,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) { throw; } } -#endif +# endif __is.setstate(__state); } return __is; @@ -434,9 +438,9 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef istreambuf_iterator<_CharT, _Traits> _Ip; typedef num_get<_CharT, _Ip> _Fp; long __temp; @@ -450,7 +454,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp } else { __n = static_cast<_Tp>(__temp); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -458,7 +462,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __is.setstate(__state); } return __is; @@ -480,9 +484,9 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif +# endif _CharT* __s = __p; const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc()); while (__s != __p + (__n - 1)) { @@ -501,7 +505,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) __is.width(0); if (__s == __p) __state |= ios_base::failbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -509,13 +513,13 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) throw; } } -#endif +# endif __is.setstate(__state); } return __is; } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _CharT, class _Traits, size_t _Np> inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& @@ -538,7 +542,7 @@ operator>>(basic_istream<char, _Traits>& __is, signed char (&__buf)[_Np]) { return __is >> (char(&)[_Np])__buf; } -#else +# else template <class _CharT, class _Traits> inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& @@ -561,22 +565,22 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s) { return __is >> (char*)__s; } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template <class _CharT, class _Traits> _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) { ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif +# endif typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); if (_Traits::eq_int_type(__i, _Traits::eof())) __state |= ios_base::eofbit | ios_base::failbit; else __c = _Traits::to_char_type(__i); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -584,7 +588,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_ throw; } } -#endif +# endif __is.setstate(__state); } return __is; @@ -610,9 +614,9 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ sentry __s(*this, true); if (__s) { if (__sb) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, _Traits::eof())) { @@ -626,7 +630,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ } if (__gc_ == 0) __state |= ios_base::failbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; if (__gc_ == 0) @@ -637,7 +641,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -653,22 +657,22 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> int_type __r = traits_type::eof(); sentry __s(*this, true); if (__s) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif +# endif __r = this->rdbuf()->sbumpc(); if (traits_type::eq_int_type(__r, traits_type::eof())) __state |= ios_base::failbit | ios_base::eofbit; else __gc_ = 1; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__setstate_nothrow(this->rdstate() | ios_base::badbit); if (this->exceptions() & ios_base::badbit) { throw; } } -#endif +# endif this->setstate(__state); } return __r; @@ -681,9 +685,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ sentry __sen(*this, true); if (__sen) { if (__n > 0) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif +# endif while (__gc_ < __n - 1) { int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { @@ -699,7 +703,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ } if (__gc_ == 0) __state |= ios_base::failbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -709,7 +713,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ throw; } } -#endif +# endif } else { __state |= ios_base::failbit; } @@ -730,9 +734,9 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s __gc_ = 0; sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { @@ -747,12 +751,12 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s __inc_gcount(); this->rdbuf()->sbumpc(); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; // according to the spec, exceptions here are caught but not rethrown } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS if (__gc_ == 0) __state |= ios_base::failbit; this->setstate(__state); @@ -767,9 +771,9 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ __gc_ = 0; sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { @@ -790,7 +794,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ this->rdbuf()->sbumpc(); __inc_gcount(); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -802,7 +806,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } if (__n > 0) *__s = char_type(); @@ -818,9 +822,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz __gc_ = 0; sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS if (__n == numeric_limits<streamsize>::max()) { while (true) { typename traits_type::int_type __i = this->rdbuf()->sbumpc(); @@ -844,7 +848,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz break; } } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -852,7 +856,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS this->setstate(__state); } return *this; @@ -865,13 +869,13 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> int_type __r = traits_type::eof(); sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __r = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__r, traits_type::eof())) __state |= ios_base::eofbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -879,7 +883,7 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS this->setstate(__state); } return __r; @@ -891,13 +895,13 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type* __gc_ = 0; sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __gc_ = this->rdbuf()->sgetn(__s, __n); if (__gc_ != __n) __state |= ios_base::failbit | ios_base::eofbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -905,7 +909,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type* throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -919,9 +923,9 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ __gc_ = 0; sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS streamsize __c = this->rdbuf()->in_avail(); switch (__c) { case -1: @@ -936,7 +940,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ __state |= ios_base::failbit | ios_base::eofbit; break; } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -944,7 +948,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -959,12 +963,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ this->clear(__state); sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof()) __state |= ios_base::badbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -972,7 +976,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -987,12 +991,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { this->clear(__state); sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof()) __state |= ios_base::badbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1000,7 +1004,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -1017,14 +1021,14 @@ int basic_istream<_CharT, _Traits>::sync() { int __r = 0; if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS if (this->rdbuf()->pubsync() == -1) { __state |= ios_base::badbit; __r = -1; } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1032,7 +1036,7 @@ int basic_istream<_CharT, _Traits>::sync() { throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS this->setstate(__state); } return __r; @@ -1044,11 +1048,11 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits> pos_type __r(-1); sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1056,7 +1060,7 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits> throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS this->setstate(__state); } return __r; @@ -1068,12 +1072,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _ this->clear(__state); sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) __state |= ios_base::failbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1081,7 +1085,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _ throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS this->setstate(__state); } return *this; @@ -1093,12 +1097,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _ this->clear(__state); sentry __sen(*this, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) __state |= ios_base::failbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1106,7 +1110,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _ throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS this->setstate(__state); } return *this; @@ -1117,9 +1121,9 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc()); while (true) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); @@ -1131,7 +1135,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ break; __is.rdbuf()->sbumpc(); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1139,7 +1143,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ throw; } } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __is.setstate(__state); } return __is; @@ -1207,16 +1211,21 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif +# endif __str.clear(); - streamsize __n = __is.width(); - if (__n <= 0) - __n = __str.max_size(); - if (__n <= 0) - __n = numeric_limits<streamsize>::max(); - streamsize __c = 0; + using _Size = typename basic_string<_CharT, _Traits, _Allocator>::size_type; + streamsize const __width = __is.width(); + _Size const __max_size = __str.max_size(); + _Size __n; + if (__width <= 0) { + __n = __max_size; + } else { + __n = std::__to_unsigned_like(__width) < __max_size ? static_cast<_Size>(__width) : __max_size; + } + + _Size __c = 0; const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc()); while (__c < __n) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); @@ -1234,7 +1243,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ __is.width(0); if (__c == 0) __state |= ios_base::failbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1242,7 +1251,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ throw; } } -#endif +# endif __is.setstate(__state); } return __is; @@ -1254,9 +1263,9 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif +# endif __str.clear(); streamsize __extr = 0; while (true) { @@ -1277,7 +1286,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All } if (__extr == 0) __state |= ios_base::failbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1285,7 +1294,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All throw; } } -#endif +# endif __is.setstate(__state); } return __is; @@ -1315,9 +1324,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif +# endif basic_string<_CharT, _Traits> __str; const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc()); size_t __c = 0; @@ -1339,7 +1348,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { __x = bitset<_Size>(__str); if (_Size > 0 && __c == 0) __state |= ios_base::failbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1347,20 +1356,22 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { throw; } } -#endif +# endif __is.setstate(__state); } return __is; } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>; -#endif +# endif extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>; _LIBCPP_END_NAMESPACE_STD +#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <concepts> # include <iosfwd> diff --git a/contrib/libs/cxxsupp/libcxx/include/iterator b/contrib/libs/cxxsupp/libcxx/include/iterator index 1b9e7eaf0c..fca75f0a19 100644 --- a/contrib/libs/cxxsupp/libcxx/include/iterator +++ b/contrib/libs/cxxsupp/libcxx/include/iterator @@ -683,43 +683,49 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; #include <__iterator/access.h> #include <__iterator/advance.h> #include <__iterator/back_insert_iterator.h> -#include <__iterator/bounded_iter.h> -#include <__iterator/common_iterator.h> -#include <__iterator/concepts.h> -#include <__iterator/counted_iterator.h> -#include <__iterator/data.h> -#include <__iterator/default_sentinel.h> #include <__iterator/distance.h> -#include <__iterator/empty.h> -#include <__iterator/erase_if_container.h> #include <__iterator/front_insert_iterator.h> -#include <__iterator/incrementable_traits.h> -#include <__iterator/indirectly_comparable.h> #include <__iterator/insert_iterator.h> #include <__iterator/istream_iterator.h> #include <__iterator/istreambuf_iterator.h> -#include <__iterator/iter_move.h> -#include <__iterator/iter_swap.h> #include <__iterator/iterator.h> #include <__iterator/iterator_traits.h> -#include <__iterator/mergeable.h> #include <__iterator/move_iterator.h> -#include <__iterator/move_sentinel.h> #include <__iterator/next.h> #include <__iterator/ostream_iterator.h> #include <__iterator/ostreambuf_iterator.h> -#include <__iterator/permutable.h> #include <__iterator/prev.h> -#include <__iterator/projected.h> -#include <__iterator/readable_traits.h> -#include <__iterator/reverse_access.h> #include <__iterator/reverse_iterator.h> -#include <__iterator/size.h> -#include <__iterator/sortable.h> -#include <__iterator/unreachable_sentinel.h> #include <__iterator/wrap_iter.h> -#include <__memory/addressof.h> -#include <__memory/pointer_traits.h> + +#if _LIBCPP_STD_VER >= 14 +# include <__iterator/reverse_access.h> +#endif + +#if _LIBCPP_STD_VER >= 17 +# include <__iterator/data.h> +# include <__iterator/empty.h> +# include <__iterator/size.h> +#endif + +#if _LIBCPP_STD_VER >= 20 +# include <__iterator/common_iterator.h> +# include <__iterator/concepts.h> +# include <__iterator/counted_iterator.h> +# include <__iterator/default_sentinel.h> +# include <__iterator/incrementable_traits.h> +# include <__iterator/indirectly_comparable.h> +# include <__iterator/iter_move.h> +# include <__iterator/iter_swap.h> +# include <__iterator/mergeable.h> +# include <__iterator/move_sentinel.h> +# include <__iterator/permutable.h> +# include <__iterator/projected.h> +# include <__iterator/readable_traits.h> +# include <__iterator/sortable.h> +# include <__iterator/unreachable_sentinel.h> +#endif + #include <version> // standard-mandated includes @@ -732,6 +738,10 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; # pragma GCC system_header #endif +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include <variant> +#endif + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <cstdlib> # include <exception> diff --git a/contrib/libs/cxxsupp/libcxx/include/latch b/contrib/libs/cxxsupp/libcxx/include/latch index da8dae149c..b56e49bc76 100644 --- a/contrib/libs/cxxsupp/libcxx/include/latch +++ b/contrib/libs/cxxsupp/libcxx/include/latch @@ -16,7 +16,7 @@ namespace std { - class latch + class latch // since C++20 { public: static constexpr ptrdiff_t max() noexcept; @@ -42,30 +42,28 @@ namespace std #include <__config> -#ifdef _LIBCPP_HAS_NO_THREADS -# error "<latch> is not supported since libc++ has been configured without support for threads." -#endif +#if !defined(_LIBCPP_HAS_NO_THREADS) -#include <__assert> -#include <__atomic/atomic_base.h> -#include <__atomic/atomic_sync.h> -#include <__atomic/memory_order.h> -#include <cstddef> -#include <limits> -#include <version> +# include <__assert> +# include <__atomic/atomic_base.h> +# include <__atomic/atomic_sync.h> +# include <__atomic/memory_order.h> +# include <cstddef> +# include <limits> +# include <version> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_BEGIN_NAMESPACE_STD -class _LIBCPP_DEPRECATED_ATOMIC_SYNC latch { +class latch { __atomic_base<ptrdiff_t> __a_; public: @@ -118,12 +116,14 @@ private: _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_STD_VER >= 14 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_POP_MACROS +#endif // !defined(_LIBCPP_HAS_NO_THREADS) + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <atomic> #endif -#endif //_LIBCPP_LATCH +#endif // _LIBCPP_LATCH diff --git a/contrib/libs/cxxsupp/libcxx/include/limits b/contrib/libs/cxxsupp/libcxx/include/limits index d55c7cd75f..b85c66257d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/limits +++ b/contrib/libs/cxxsupp/libcxx/include/limits @@ -137,9 +137,9 @@ protected: typedef _Tp type; static _LIBCPP_CONSTEXPR const bool is_specialized = false; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); } static _LIBCPP_CONSTEXPR const int digits = 0; static _LIBCPP_CONSTEXPR const int digits10 = 0; @@ -148,8 +148,8 @@ protected: static _LIBCPP_CONSTEXPR const bool is_integer = false; static _LIBCPP_CONSTEXPR const bool is_exact = false; static _LIBCPP_CONSTEXPR const int radix = 0; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); } static _LIBCPP_CONSTEXPR const int min_exponent = 0; static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; @@ -161,10 +161,10 @@ protected: static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); } static _LIBCPP_CONSTEXPR const bool is_iec559 = false; static _LIBCPP_CONSTEXPR const bool is_bounded = false; @@ -198,15 +198,15 @@ protected: static _LIBCPP_CONSTEXPR const int max_digits10 = 0; static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value; static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0); - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } static _LIBCPP_CONSTEXPR const bool is_integer = true; static _LIBCPP_CONSTEXPR const bool is_exact = true; static _LIBCPP_CONSTEXPR const int radix = 2; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } static _LIBCPP_CONSTEXPR const int min_exponent = 0; static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; @@ -218,10 +218,10 @@ protected: static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } static _LIBCPP_CONSTEXPR const bool is_iec559 = false; static _LIBCPP_CONSTEXPR const bool is_bounded = true; @@ -249,15 +249,15 @@ protected: static _LIBCPP_CONSTEXPR const int max_digits10 = 0; static _LIBCPP_CONSTEXPR const type __min = false; static _LIBCPP_CONSTEXPR const type __max = true; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } static _LIBCPP_CONSTEXPR const bool is_integer = true; static _LIBCPP_CONSTEXPR const bool is_exact = true; static _LIBCPP_CONSTEXPR const int radix = 2; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } static _LIBCPP_CONSTEXPR const int min_exponent = 0; static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; @@ -269,10 +269,10 @@ protected: static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } static _LIBCPP_CONSTEXPR const bool is_iec559 = false; static _LIBCPP_CONSTEXPR const bool is_bounded = true; @@ -294,15 +294,15 @@ protected: static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__; static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__; static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } static _LIBCPP_CONSTEXPR const bool is_integer = false; static _LIBCPP_CONSTEXPR const bool is_exact = false; static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; } static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__; static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__; @@ -314,16 +314,16 @@ protected: static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_valf(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nanf(""); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nansf(""); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __FLT_DENORM_MIN__; } @@ -351,15 +351,15 @@ protected: static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__; static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__; static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } static _LIBCPP_CONSTEXPR const bool is_integer = false; static _LIBCPP_CONSTEXPR const bool is_exact = false; static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; } static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__; static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__; @@ -371,16 +371,16 @@ protected: static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_val(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nan(""); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nans(""); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __DBL_DENORM_MIN__; } @@ -408,15 +408,15 @@ protected: static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__; static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__; static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } static _LIBCPP_CONSTEXPR const bool is_integer = false; static _LIBCPP_CONSTEXPR const bool is_exact = false; static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; } static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__; static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__; @@ -428,16 +428,16 @@ protected: static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_vall(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nanl(""); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nansl(""); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __LDBL_DENORM_MIN__; } @@ -465,9 +465,9 @@ class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> public: static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } static _LIBCPP_CONSTEXPR const int digits = __base::digits; static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; @@ -476,10 +476,10 @@ public: static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; static _LIBCPP_CONSTEXPR const int radix = __base::radix; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return __base::round_error(); } @@ -495,16 +495,16 @@ public: static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; _LIBCPP_SUPPRESS_DEPRECATED_POP - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __base::denorm_min(); } diff --git a/contrib/libs/cxxsupp/libcxx/include/list b/contrib/libs/cxxsupp/libcxx/include/list index 929c84de7b..05234f7696 100644 --- a/contrib/libs/cxxsupp/libcxx/include/list +++ b/contrib/libs/cxxsupp/libcxx/include/list @@ -225,6 +225,7 @@ template <class T, class Allocator, class Predicate> #include <__ranges/container_compatible_range.h> #include <__ranges/from_range.h> #include <__type_traits/conditional.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_allocator.h> #include <__type_traits/is_nothrow_assignable.h> #include <__type_traits/is_nothrow_constructible.h> @@ -271,19 +272,21 @@ struct __list_node_pointer_traits { typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> > __node_pointer; typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> > __base_pointer; -#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB) - typedef __base_pointer __link_pointer; -#else - typedef __conditional_t<is_pointer<_VoidPtr>::value, __base_pointer, __node_pointer> __link_pointer; +// TODO(LLVM 22): Remove this check +#ifndef _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB + static_assert(sizeof(__node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__base_pointer) == + _LIBCPP_ALIGNOF(__node_pointer), + "It looks like you are using std::list with a fancy pointer type that thas a different representation " + "depending on whether it points to a list base pointer or a list node pointer (both of which are " + "implementation details of the standard library). This means that your ABI is being broken between " + "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the " + "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); #endif - typedef __conditional_t<is_same<__link_pointer, __node_pointer>::value, __base_pointer, __node_pointer> - __non_link_pointer; - - static _LIBCPP_HIDE_FROM_ABI __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) { return __p; } + static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__base_pointer __p) { return __p; } - static _LIBCPP_HIDE_FROM_ABI __link_pointer __unsafe_link_pointer_cast(__non_link_pointer __p) { - return static_cast<__link_pointer>(static_cast<_VoidPtr>(__p)); + static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__node_pointer __p) { + return static_cast<__base_pointer>(static_cast<_VoidPtr>(__p)); } }; @@ -292,16 +295,13 @@ struct __list_node_base { typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; typedef typename _NodeTraits::__node_pointer __node_pointer; typedef typename _NodeTraits::__base_pointer __base_pointer; - typedef typename _NodeTraits::__link_pointer __link_pointer; - __link_pointer __prev_; - __link_pointer __next_; + __base_pointer __prev_; + __base_pointer __next_; - _LIBCPP_HIDE_FROM_ABI __list_node_base() - : __prev_(_NodeTraits::__unsafe_link_pointer_cast(__self())), - __next_(_NodeTraits::__unsafe_link_pointer_cast(__self())) {} + _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {} - _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__link_pointer __prev, __link_pointer __next) + _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__base_pointer __prev, __base_pointer __next) : __prev_(__prev), __next_(__next) {} _LIBCPP_HIDE_FROM_ABI __base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); } @@ -332,12 +332,12 @@ public: #endif typedef __list_node_base<_Tp, _VoidPtr> __base; - typedef typename __base::__link_pointer __link_pointer; + typedef typename __base::__base_pointer __base_pointer; - _LIBCPP_HIDE_FROM_ABI explicit __list_node(__link_pointer __prev, __link_pointer __next) : __base(__prev, __next) {} + _LIBCPP_HIDE_FROM_ABI explicit __list_node(__base_pointer __prev, __base_pointer __next) : __base(__prev, __next) {} _LIBCPP_HIDE_FROM_ABI ~__list_node() {} - _LIBCPP_HIDE_FROM_ABI __link_pointer __as_link() { return static_cast<__link_pointer>(__base::__self()); } + _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() { return __base::__self(); } }; template <class _Tp, class _Alloc = allocator<_Tp> > @@ -350,11 +350,11 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator; template <class _Tp, class _VoidPtr> class _LIBCPP_TEMPLATE_VIS __list_iterator { typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; - typedef typename _NodeTraits::__link_pointer __link_pointer; + typedef typename _NodeTraits::__base_pointer __base_pointer; - __link_pointer __ptr_; + __base_pointer __ptr_; - _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {} + _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {} template <class, class> friend class list; @@ -408,11 +408,11 @@ public: template <class _Tp, class _VoidPtr> class _LIBCPP_TEMPLATE_VIS __list_const_iterator { typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; - typedef typename _NodeTraits::__link_pointer __link_pointer; + typedef typename _NodeTraits::__base_pointer __base_pointer; - __link_pointer __ptr_; + __base_pointer __ptr_; - _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {} + _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {} template <class, class> friend class list; @@ -466,7 +466,7 @@ public: template <class _Tp, class _Alloc> class __list_imp { public: - __list_imp(const __list_imp&) = delete; + __list_imp(const __list_imp&) = delete; __list_imp& operator=(const __list_imp&) = delete; typedef _Alloc allocator_type; @@ -485,8 +485,8 @@ protected: typedef typename __node_alloc_traits::pointer __node_pointer; typedef typename __node_alloc_traits::pointer __node_const_pointer; typedef __list_node_pointer_traits<value_type, __void_pointer> __node_pointer_traits; - typedef typename __node_pointer_traits::__link_pointer __link_pointer; - typedef __link_pointer __link_const_pointer; + typedef typename __node_pointer_traits::__base_pointer __base_pointer; + typedef __base_pointer __link_const_pointer; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; typedef typename __alloc_traits::difference_type difference_type; @@ -497,21 +497,21 @@ protected: "internal allocator type must differ from user-specified type; otherwise overload resolution breaks"); __node_base __end_; - __compressed_pair<size_type, __node_allocator> __size_alloc_; + _LIBCPP_COMPRESSED_PAIR(size_type, __size_, __node_allocator, __node_alloc_); - _LIBCPP_HIDE_FROM_ABI __link_pointer __end_as_link() const _NOEXCEPT { + _LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT { return __node_pointer_traits::__unsafe_link_pointer_cast(const_cast<__node_base&>(__end_).__self()); } - _LIBCPP_HIDE_FROM_ABI size_type& __sz() _NOEXCEPT { return __size_alloc_.first(); } - _LIBCPP_HIDE_FROM_ABI const size_type& __sz() const _NOEXCEPT { return __size_alloc_.first(); } - _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __size_alloc_.second(); } - _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __size_alloc_.second(); } + _LIBCPP_HIDE_FROM_ABI size_type& __sz() _NOEXCEPT { return __size_; } + _LIBCPP_HIDE_FROM_ABI const size_type& __sz() const _NOEXCEPT { return __size_; } + _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; } + _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; } _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT { return __node_alloc_traits::max_size(__node_alloc()); } - _LIBCPP_HIDE_FROM_ABI static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI static void __unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value); _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a); @@ -548,7 +548,7 @@ protected: } template <class... _Args> - _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__link_pointer __prev, __link_pointer __next, _Args&&... __args) { + _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__base_pointer __prev, __base_pointer __next, _Args&&... __args) { __node_allocator& __alloc = __node_alloc(); __allocation_guard<__node_allocator> __guard(__alloc, 1); // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value @@ -593,24 +593,27 @@ private: // Unlink nodes [__f, __l] template <class _Tp, class _Alloc> -inline void __list_imp<_Tp, _Alloc>::__unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT { +inline void __list_imp<_Tp, _Alloc>::__unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT { __f->__prev_->__next_ = __l->__next_; __l->__next_->__prev_ = __f->__prev_; } template <class _Tp, class _Alloc> inline __list_imp<_Tp, _Alloc>::__list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) - : __size_alloc_(0, __default_init_tag()) {} + : __size_(0) {} template <class _Tp, class _Alloc> -inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a) : __size_alloc_(0, __node_allocator(__a)) {} +inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a) + : __size_(0), __node_alloc_(__node_allocator(__a)) {} template <class _Tp, class _Alloc> -inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_alloc_(0, __a) {} +inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_(0), __node_alloc_(__a) {} #ifndef _LIBCPP_CXX03_LANG template <class _Tp, class _Alloc> -inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT : __size_alloc_(0, std::move(__a)) {} +inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT + : __size_(0), + __node_alloc_(std::move(__a)) {} #endif template <class _Tp, class _Alloc> @@ -621,8 +624,8 @@ __list_imp<_Tp, _Alloc>::~__list_imp() { template <class _Tp, class _Alloc> void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT { if (!empty()) { - __link_pointer __f = __end_.__next_; - __link_pointer __l = __end_as_link(); + __base_pointer __f = __end_.__next_; + __base_pointer __l = __end_as_link(); __unlink_nodes(__f, __l->__prev_); __sz() = 0; while (__f != __l) { @@ -668,7 +671,7 @@ class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> { typedef typename base::__node_alloc_traits __node_alloc_traits; typedef typename base::__node_base __node_base; typedef typename base::__node_base_pointer __node_base_pointer; - typedef typename base::__link_pointer __link_pointer; + typedef typename base::__base_pointer __base_pointer; public: typedef _Tp value_type; @@ -754,7 +757,7 @@ public: _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return base::__sz(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return base::empty(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return base::empty(); } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return std::min<size_type>(base::__node_alloc_max_size(), numeric_limits<difference_type >::max()); } @@ -917,9 +920,9 @@ private: template <class _Iterator, class _Sentinel> _LIBCPP_HIDE_FROM_ABI iterator __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l); - _LIBCPP_HIDE_FROM_ABI static void __link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l); - _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_front(__link_pointer __f, __link_pointer __l); - _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__link_pointer __f, __link_pointer __l); + _LIBCPP_HIDE_FROM_ABI static void __link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l); + _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_front(__base_pointer __f, __base_pointer __l); + _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__base_pointer __f, __base_pointer __l); _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n); // TODO: Make this _LIBCPP_HIDE_FROM_ABI template <class _Comp> @@ -953,7 +956,7 @@ list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_R // Link in nodes [__f, __l] just prior to __p template <class _Tp, class _Alloc> -inline void list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l) { +inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l) { __p->__prev_->__next_ = __f; __f->__prev_ = __p->__prev_; __p->__prev_ = __l; @@ -962,7 +965,7 @@ inline void list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer _ // Link in nodes [__f, __l] at the front of the list template <class _Tp, class _Alloc> -inline void list<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_pointer __l) { +inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_pointer __l) { __f->__prev_ = base::__end_as_link(); __l->__next_ = base::__end_.__next_; __l->__next_->__prev_ = __l; @@ -971,7 +974,7 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_ // Link in nodes [__f, __l] at the back of the list template <class _Tp, class _Alloc> -inline void list<_Tp, _Alloc>::__link_nodes_at_back(__link_pointer __f, __link_pointer __l) { +inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_pointer __l) { __l->__next_ = base::__end_as_link(); __f->__prev_ = base::__end_.__prev_; __f->__prev_->__next_ = __f; @@ -1163,7 +1166,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { while (true) { - __link_pointer __prev = __e.__ptr_->__prev_; + __base_pointer __prev = __e.__ptr_->__prev_; __node_pointer __current = __e.__ptr_->__as_node(); this->__delete_node(__current); if (__prev == 0) @@ -1205,7 +1208,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { while (true) { - __link_pointer __prev = __e.__ptr_->__prev_; + __base_pointer __prev = __e.__ptr_->__prev_; __node_pointer __current = __e.__ptr_->__as_node(); this->__delete_node(__current); if (__prev == 0) @@ -1224,7 +1227,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::push_front(const value_type& __x) { __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); - __link_pointer __nl = __node->__as_link(); + __base_pointer __nl = __node->__as_link(); __link_nodes_at_front(__nl, __nl); ++base::__sz(); } @@ -1232,7 +1235,7 @@ void list<_Tp, _Alloc>::push_front(const value_type& __x) { template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::push_back(const value_type& __x) { __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); - __link_pointer __nl = __node->__as_link(); + __base_pointer __nl = __node->__as_link(); __link_nodes_at_back(__nl, __nl); ++base::__sz(); } @@ -1242,7 +1245,7 @@ void list<_Tp, _Alloc>::push_back(const value_type& __x) { template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::push_front(value_type&& __x) { __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); - __link_pointer __nl = __node->__as_link(); + __base_pointer __nl = __node->__as_link(); __link_nodes_at_front(__nl, __nl); ++base::__sz(); } @@ -1250,7 +1253,7 @@ void list<_Tp, _Alloc>::push_front(value_type&& __x) { template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::push_back(value_type&& __x) { __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); - __link_pointer __nl = __node->__as_link(); + __base_pointer __nl = __node->__as_link(); __link_nodes_at_back(__nl, __nl); ++base::__sz(); } @@ -1265,7 +1268,7 @@ void list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); - __link_pointer __nl = __node->__as_link(); + __base_pointer __nl = __node->__as_link(); __link_nodes_at_front(__nl, __nl); ++base::__sz(); # if _LIBCPP_STD_VER >= 17 @@ -1283,7 +1286,7 @@ void list<_Tp, _Alloc>::emplace_back(_Args&&... __args) { __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); - __link_pointer __nl = __node->__as_link(); + __base_pointer __nl = __node->__as_link(); __link_nodes_at_back(__nl, __nl); ++base::__sz(); # if _LIBCPP_STD_VER >= 17 @@ -1296,7 +1299,7 @@ template <class... _Args> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) { __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); - __link_pointer __nl = __node->__as_link(); + __base_pointer __nl = __node->__as_link(); __link_nodes(__p.__ptr_, __nl, __nl); ++base::__sz(); return iterator(__nl); @@ -1305,7 +1308,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator _ template <class _Tp, class _Alloc> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) { __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); - __link_pointer __nl = __node->__as_link(); + __base_pointer __nl = __node->__as_link(); __link_nodes(__p.__ptr_, __nl, __nl); ++base::__sz(); return iterator(__nl); @@ -1316,7 +1319,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __ template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::pop_front() { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list"); - __link_pointer __n = base::__end_.__next_; + __base_pointer __n = base::__end_.__next_; base::__unlink_nodes(__n, __n); --base::__sz(); this->__delete_node(__n->__as_node()); @@ -1325,7 +1328,7 @@ void list<_Tp, _Alloc>::pop_front() { template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::pop_back() { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list"); - __link_pointer __n = base::__end_.__prev_; + __base_pointer __n = base::__end_.__prev_; base::__unlink_nodes(__n, __n); --base::__sz(); this->__delete_node(__n->__as_node()); @@ -1334,8 +1337,8 @@ void list<_Tp, _Alloc>::pop_back() { template <class _Tp, class _Alloc> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator"); - __link_pointer __n = __p.__ptr_; - __link_pointer __r = __n->__next_; + __base_pointer __n = __p.__ptr_; + __base_pointer __r = __n->__next_; base::__unlink_nodes(__n, __n); --base::__sz(); this->__delete_node(__n->__as_node()); @@ -1347,7 +1350,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f if (__f != __l) { base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_); while (__f != __l) { - __link_pointer __n = __f.__ptr_; + __base_pointer __n = __f.__ptr_; ++__f; --base::__sz(); this->__delete_node(__n->__as_node()); @@ -1376,7 +1379,7 @@ void list<_Tp, _Alloc>::resize(size_type __n) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { while (true) { - __link_pointer __prev = __e.__ptr_->__prev_; + __base_pointer __prev = __e.__ptr_->__prev_; __node_pointer __current = __e.__ptr_->__as_node(); this->__delete_node(__current); if (__prev == 0) @@ -1400,7 +1403,7 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { size_type __ds = 0; __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); ++__ds; - __link_pointer __nl = __node->__as_link(); + __base_pointer __nl = __node->__as_link(); iterator __r = iterator(__nl); iterator __e = __r; #ifndef _LIBCPP_HAS_NO_EXCEPTIONS @@ -1412,7 +1415,7 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { while (true) { - __link_pointer __prev = __e.__ptr_->__prev_; + __base_pointer __prev = __e.__ptr_->__prev_; __node_pointer __current = __e.__ptr_->__as_node(); this->__delete_node(__current); if (__prev == 0) @@ -1432,8 +1435,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) { _LIBCPP_ASSERT_VALID_INPUT_RANGE( this != std::addressof(__c), "list::splice(iterator, list) called with this == &list"); if (!__c.empty()) { - __link_pointer __f = __c.__end_.__next_; - __link_pointer __l = __c.__end_.__prev_; + __base_pointer __f = __c.__end_.__next_; + __base_pointer __l = __c.__end_.__prev_; base::__unlink_nodes(__f, __l); __link_nodes(__p.__ptr_, __f, __l); base::__sz() += __c.__sz(); @@ -1444,7 +1447,7 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) { template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) { if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) { - __link_pointer __f = __i.__ptr_; + __base_pointer __f = __i.__ptr_; base::__unlink_nodes(__f, __f); __link_nodes(__p.__ptr_, __f, __f); --__c.__sz(); @@ -1455,9 +1458,9 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) { if (__f != __l) { - __link_pointer __first = __f.__ptr_; + __base_pointer __first = __f.__ptr_; --__l; - __link_pointer __last = __l.__ptr_; + __base_pointer __last = __l.__ptr_; if (this != std::addressof(__c)) { size_type __s = std::distance(__f, __l) + 1; __c.__sz() -= __s; @@ -1545,8 +1548,8 @@ void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) { ; base::__sz() += __ds; __c.__sz() -= __ds; - __link_pointer __f = __f2.__ptr_; - __link_pointer __l = __m2.__ptr_->__prev_; + __base_pointer __f = __f2.__ptr_; + __base_pointer __l = __m2.__ptr_->__prev_; __f2 = __m2; base::__unlink_nodes(__f, __l); __m2 = std::next(__f1); @@ -1580,7 +1583,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ return __f1; case 2: if (__comp(*--__e2, *__f1)) { - __link_pointer __f = __e2.__ptr_; + __base_pointer __f = __e2.__ptr_; base::__unlink_nodes(__f, __f); __link_nodes(__f1.__ptr_, __f, __f); return __e2; @@ -1595,8 +1598,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ iterator __m2 = std::next(__f2); for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2) ; - __link_pointer __f = __f2.__ptr_; - __link_pointer __l = __m2.__ptr_->__prev_; + __base_pointer __f = __f2.__ptr_; + __base_pointer __l = __m2.__ptr_->__prev_; __r = __f2; __e1 = __f2 = __m2; base::__unlink_nodes(__f, __l); @@ -1610,8 +1613,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ iterator __m2 = std::next(__f2); for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2) ; - __link_pointer __f = __f2.__ptr_; - __link_pointer __l = __m2.__ptr_->__prev_; + __base_pointer __f = __f2.__ptr_; + __base_pointer __l = __m2.__ptr_->__prev_; if (__e1 == __f2) __e1 = __m2; __f2 = __m2; @@ -1679,8 +1682,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const list<_Tp, _Alloc>& __x, const template <class _Tp, class _Allocator> _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) { - return std::lexicographical_compare_three_way( - __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } #endif // _LIBCPP_STD_VER <= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/locale b/contrib/libs/cxxsupp/libcxx/include/locale index 0b2ac488e1..4a3df88d28 100644 --- a/contrib/libs/cxxsupp/libcxx/include/locale +++ b/contrib/libs/cxxsupp/libcxx/include/locale @@ -187,67 +187,74 @@ template <class charT> class messages_byname; */ -#include <__algorithm/copy.h> -#include <__algorithm/equal.h> -#include <__algorithm/find.h> -#include <__algorithm/max.h> -#include <__algorithm/reverse.h> -#include <__algorithm/unwrap_iter.h> -#include <__assert> #include <__config> -#include <__iterator/access.h> -#include <__iterator/back_insert_iterator.h> -#include <__iterator/istreambuf_iterator.h> -#include <__iterator/ostreambuf_iterator.h> -#include <__locale> -#include <__memory/unique_ptr.h> -#include <__type_traits/make_unsigned.h> -#include <cerrno> -#include <cstdio> -#include <cstdlib> -#include <ctime> -#include <ios> -#include <limits> -#include <new> -#include <streambuf> -#include <version> + +#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__algorithm/copy.h> +# include <__algorithm/equal.h> +# include <__algorithm/find.h> +# include <__algorithm/max.h> +# include <__algorithm/reverse.h> +# include <__algorithm/unwrap_iter.h> +# include <__assert> +# include <__iterator/access.h> +# include <__iterator/back_insert_iterator.h> +# include <__iterator/istreambuf_iterator.h> +# include <__iterator/ostreambuf_iterator.h> +# include <__locale> +# include <__memory/unique_ptr.h> +# include <__type_traits/make_unsigned.h> +# include <cerrno> +# include <cstdio> +# include <cstdlib> +# include <ctime> +# include <ios> +# include <limits> +# include <new> +# include <streambuf> +# include <version> // TODO: Fix __bsd_locale_defaults.h // NOLINTBEGIN(libcpp-robust-against-adl) -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +# if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) // Most unix variants have catopen. These are the specific ones that don't. -# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) -# define _LIBCPP_HAS_CATOPEN 1 -# include <nl_types.h> +# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) +# define _LIBCPP_HAS_CATOPEN 1 +# include <nl_types.h> +# endif # endif -#endif -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -# include <__locale_dir/locale_base_api/bsd_locale_defaults.h> -#else -# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> -#endif +# ifdef _LIBCPP_LOCALE__L_EXTENSIONS +# include <__locale_dir/locale_base_api/bsd_locale_defaults.h> +# else +# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if defined(__APPLE__) || defined(__FreeBSD__) +# include <xlocale.h> +# endif + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD -#if defined(__APPLE__) || defined(__FreeBSD__) -# define _LIBCPP_GET_C_LOCALE 0 -#elif defined(__NetBSD__) -# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE -#else -# define _LIBCPP_GET_C_LOCALE __cloc() +# if defined(__APPLE__) || defined(__FreeBSD__) +# define _LIBCPP_GET_C_LOCALE 0 +# elif defined(__NetBSD__) +# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE +# else +# define _LIBCPP_GET_C_LOCALE __cloc() // Get the C locale object _LIBCPP_EXPORTED_FROM_ABI locale_t __cloc(); -# define __cloc_defined -#endif +# define __cloc_defined +# endif // __scan_keyword // Scans [__b, __e) until a match is found in the basic_strings range @@ -395,7 +402,7 @@ struct __num_get : protected __num_get_base { unsigned*& __g_end, unsigned& __dc, _CharT* __atoms); -#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep); static int __stage2_int_loop( _CharT __ct, @@ -409,7 +416,7 @@ struct __num_get : protected __num_get_base { unsigned*& __g_end, _CharT* __atoms); -#else +# else static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) { locale __loc = __iob.getloc(); const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); @@ -444,10 +451,10 @@ private: (void)__atoms; return __src; } -#endif +# endif }; -#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET template <class _CharT> string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) { locale __loc = __iob.getloc(); @@ -456,7 +463,7 @@ string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _C __thousands_sep = __np.thousands_sep(); return __np.grouping(); } -#endif +# endif template <class _CharT> string __num_get<_CharT>::__stage2_float_prep( @@ -471,16 +478,16 @@ string __num_get<_CharT>::__stage2_float_prep( template <class _CharT> int -#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, unsigned& __dc, _CharT __thousands_sep, const string& __grouping, unsigned* __g, unsigned*& __g_end, _CharT* __atoms) -#else +# else __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, unsigned& __dc, _CharT __thousands_sep, const string& __grouping, unsigned* __g, unsigned*& __g_end, const _CharT* __atoms) -#endif +# endif { if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) { *__a_end++ = __ct == __atoms[24] ? '+' : '-'; @@ -579,9 +586,9 @@ int __num_get<_CharT>::__stage2_float_loop( } extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>; -#endif +# endif template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> { @@ -851,14 +858,14 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_signed( // Stage 2 char_type __thousands_sep; const int __atoms_size = __num_get_base::__int_chr_cnt; -#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET char_type __atoms1[__atoms_size]; const char_type* __atoms = this->__do_widen(__iob, __atoms1); string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); -#else +# else char_type __atoms[__atoms_size]; string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); -#endif +# endif string __buf; __buf.resize(__buf.capacity()); char* __a = &__buf[0]; @@ -900,14 +907,14 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned( // Stage 2 char_type __thousands_sep; const int __atoms_size = __num_get_base::__int_chr_cnt; -#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET char_type __atoms1[__atoms_size]; const char_type* __atoms = this->__do_widen(__iob, __atoms1); string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); -#else +# else char_type __atoms[__atoms_size]; string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); -#endif +# endif string __buf; __buf.resize(__buf.capacity()); char* __a = &__buf[0]; @@ -1050,9 +1057,9 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>; -#endif +# endif struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base { protected: @@ -1168,9 +1175,9 @@ void __num_put<_CharT>::__widen_and_group_float( } extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>; -#endif +# endif template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> { @@ -1455,9 +1462,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>; -#endif +# endif template <class _CharT, class _InputIterator> _LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits( @@ -1522,7 +1529,7 @@ _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const; template <> _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const; template <> @@ -1537,7 +1544,7 @@ template <> _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const; template <> _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const; -#endif +# endif template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> { @@ -1991,9 +1998,9 @@ _InputIterator time_get<_CharT, _InputIterator>::do_get( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>; -#endif +# endif class _LIBCPP_EXPORTED_FROM_ABI __time_get { protected: @@ -2029,31 +2036,32 @@ private: string_type __analyze(char __fmt, const ctype<_CharT>&); }; -#define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \ - template <> \ - _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ - template <> \ - _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ - template <> \ - _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ - template <> \ - _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ - template <> \ - _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ - char, const ctype<_CharT>&); \ - extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ - extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ - extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ - extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ - extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ - __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \ - /**/ +# define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \ + template <> \ + _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ + template <> \ + _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ + template <> \ + _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ + template <> \ + _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ + template <> \ + _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ + char, const ctype<_CharT>&); \ + extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \ + const; \ + extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ + extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ + extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ + extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ + __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \ + /**/ _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char) -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t) -#endif -#undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION +# endif +# undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > class _LIBCPP_TEMPLATE_VIS time_get_byname @@ -2086,9 +2094,9 @@ private: }; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>; -#endif +# endif class _LIBCPP_EXPORTED_FROM_ABI __time_put { locale_t __loc_; @@ -2099,9 +2107,9 @@ protected: __time_put(const string& __nm); ~__time_put(); void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const; -#endif +# endif }; template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > @@ -2175,9 +2183,9 @@ _OutputIterator time_put<_CharT, _OutputIterator>::do_put( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>; -#endif +# endif template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> { @@ -2197,9 +2205,9 @@ protected: }; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>; -#endif +# endif // money_base @@ -2264,10 +2272,10 @@ const bool moneypunct<_CharT, _International>::intl; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>; -#endif +# endif // moneypunct_byname @@ -2322,14 +2330,14 @@ _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*); extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*); template <> _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*); extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>; -#endif +# endif // money_get @@ -2390,9 +2398,9 @@ void __money_get<_CharT>::__gather_info( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>; -#endif +# endif template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> { @@ -2700,9 +2708,9 @@ _InputIterator money_get<_CharT, _InputIterator>::do_get( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>; -#endif +# endif // money_put @@ -2878,9 +2886,9 @@ void __money_put<_CharT>::__format( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>; -#endif +# endif template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> { @@ -3024,9 +3032,9 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put( } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>; -#endif +# endif // messages @@ -3070,18 +3078,18 @@ locale::id messages<_CharT>::id; template <class _CharT> typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const { -#ifdef _LIBCPP_HAS_CATOPEN +# ifdef _LIBCPP_HAS_CATOPEN return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); -#else // !_LIBCPP_HAS_CATOPEN +# else // !_LIBCPP_HAS_CATOPEN (void)__nm; return -1; -#endif // _LIBCPP_HAS_CATOPEN +# endif // _LIBCPP_HAS_CATOPEN } template <class _CharT> typename messages<_CharT>::string_type messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { -#ifdef _LIBCPP_HAS_CATOPEN +# ifdef _LIBCPP_HAS_CATOPEN string __ndflt; __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()( std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); @@ -3091,27 +3099,27 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& string_type __w; __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n)); return __w; -#else // !_LIBCPP_HAS_CATOPEN +# else // !_LIBCPP_HAS_CATOPEN (void)__c; (void)__set; (void)__msgid; return __dflt; -#endif // _LIBCPP_HAS_CATOPEN +# endif // _LIBCPP_HAS_CATOPEN } template <class _CharT> void messages<_CharT>::do_close(catalog __c) const { -#ifdef _LIBCPP_HAS_CATOPEN +# ifdef _LIBCPP_HAS_CATOPEN catclose((nl_catd)__c); -#else // !_LIBCPP_HAS_CATOPEN +# else // !_LIBCPP_HAS_CATOPEN (void)__c; -#endif // _LIBCPP_HAS_CATOPEN +# endif // _LIBCPP_HAS_CATOPEN } extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>; -#endif +# endif template <class _CharT> class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> { @@ -3128,11 +3136,11 @@ protected: }; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>; -#endif +# endif -#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) +# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) template <class _Codecvt, class _Elem = wchar_t, @@ -3153,19 +3161,19 @@ private: size_t __cvtcount_; public: -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {} _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt); -# else +# else _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt); -# endif +# endif _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state); _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc); -# endif +# endif _LIBCPP_HIDE_FROM_ABI ~wstring_convert(); wstring_convert(const wstring_convert& __wc) = delete; @@ -3210,7 +3218,7 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert( __cvtptr_ = new _Codecvt; } -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc) @@ -3222,7 +3230,7 @@ inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert __wc.__cvtptr_ = nullptr; } -# endif // _LIBCPP_CXX03_LANG +# endif // _LIBCPP_CXX03_LANG _LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> @@ -3376,14 +3384,14 @@ private: bool __always_noconv_; public: -# ifndef _LIBCPP_CXX03_LANG +# ifndef _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {} explicit _LIBCPP_HIDE_FROM_ABI wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); -# else +# else _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); -# endif +# endif _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert(); @@ -3739,7 +3747,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__ _LIBCPP_SUPPRESS_DEPRECATED_POP -#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) +# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) _LIBCPP_END_NAMESPACE_STD @@ -3747,6 +3755,8 @@ _LIBCPP_POP_MACROS // NOLINTEND(libcpp-robust-against-adl) +#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <atomic> # include <concepts> diff --git a/contrib/libs/cxxsupp/libcxx/include/locale.h b/contrib/libs/cxxsupp/libcxx/include/locale.h index 20910fa2f9..425bf47d43 100644 --- a/contrib/libs/cxxsupp/libcxx/include/locale.h +++ b/contrib/libs/cxxsupp/libcxx/include/locale.h @@ -35,10 +35,6 @@ Functions: #include <__config> -#if defined(_LIBCPP_HAS_NO_LOCALIZATION) -# error "<locale.h> is not supported since libc++ has been configured without support for localization." -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/map b/contrib/libs/cxxsupp/libcxx/include/map index 3fabceff68..04d2316bab 100644 --- a/contrib/libs/cxxsupp/libcxx/include/map +++ b/contrib/libs/cxxsupp/libcxx/include/map @@ -585,6 +585,9 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 #include <__iterator/reverse_iterator.h> #include <__memory/addressof.h> #include <__memory/allocator.h> +#include <__memory/allocator_traits.h> +#include <__memory/pointer_traits.h> +#include <__memory/unique_ptr.h> #include <__memory_resource/polymorphic_allocator.h> #include <__node_handle> #include <__ranges/concepts.h> @@ -592,9 +595,13 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 #include <__ranges/from_range.h> #include <__tree> #include <__type_traits/is_allocator.h> +#include <__type_traits/remove_const.h> +#include <__type_traits/type_identity.h> #include <__utility/forward.h> +#include <__utility/pair.h> #include <__utility/piecewise_construct.h> #include <__utility/swap.h> +#include <new> // for std::launder #include <stdexcept> #include <tuple> #include <version> @@ -1144,7 +1151,7 @@ public: _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } @@ -1825,7 +1832,7 @@ public: _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } diff --git a/contrib/libs/cxxsupp/libcxx/include/math.h b/contrib/libs/cxxsupp/libcxx/include/math.h index 4d245d4736..99ec5ef28a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/math.h +++ b/contrib/libs/cxxsupp/libcxx/include/math.h @@ -391,22 +391,22 @@ namespace __math { // template on non-double overloads to make them weaker than same overloads from MSVC runtime template <class = int> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); } template <class = int> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); } template <class = int> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); } template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { return __x == 0 ? FP_ZERO : FP_NORMAL; } diff --git a/contrib/libs/cxxsupp/libcxx/include/math_cuda.h b/contrib/libs/cxxsupp/libcxx/include/math_cuda.h index afbea8a039..0d8ff2bc0d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/math_cuda.h +++ b/contrib/libs/cxxsupp/libcxx/include/math_cuda.h @@ -372,29 +372,29 @@ extern "C++" { // signbit template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { return __builtin_signbit(__x); } template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { return __x < 0; } template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { return false; } // fpclassify template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); } template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { return __x == 0 ? FP_ZERO : FP_NORMAL; } @@ -405,13 +405,13 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT template <class _A1, std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT { return __builtin_isfinite((typename std::__promote<_A1>::type)__x); } template <class _A1, std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { return true; } @@ -419,27 +419,27 @@ _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfin template <class _A1, std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT { return __builtin_isinf((typename std::__promote<_A1>::type)__x); } template <class _A1> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type isinf(_A1) _NOEXCEPT { return false; } #if defined(_LIBCPP_PREFERRED_OVERLOAD) && !defined(__CUDACC__) -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { return __builtin_isinf(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { return __builtin_isinf(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __builtin_isinf(__x); } # endif @@ -447,25 +447,25 @@ _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI boo // isnan template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT { return __builtin_isnan(__x); } template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { return false; } #if defined(_LIBCPP_PREFERRED_OVERLOAD) && !defined(__CUDACC__) -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { return __builtin_isnan(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { return __builtin_isnan(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __builtin_isnan(__x); } # endif @@ -473,12 +473,12 @@ _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI boo // isnormal template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { return __builtin_isnormal(__x); } template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { return __x != 0; } @@ -487,7 +487,7 @@ _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnor template <class _A1, class _A2, std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; return __builtin_isgreater((type)__x, (type)__y); } @@ -497,7 +497,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) template <class _A1, class _A2, std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; return __builtin_isgreaterequal((type)__x, (type)__y); } @@ -507,7 +507,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 template <class _A1, class _A2, std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; return __builtin_isless((type)__x, (type)__y); } @@ -517,7 +517,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NO template <class _A1, class _A2, std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; return __builtin_islessequal((type)__x, (type)__y); } @@ -527,7 +527,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y template <class _A1, class _A2, std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; return __builtin_islessgreater((type)__x, (type)__y); } @@ -537,7 +537,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 _ template <class _A1, class _A2, std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type type; return __builtin_isunordered((type)__x, (type)__y); } @@ -634,17 +634,17 @@ atan2(_A1 __y, _A2 __x) _NOEXCEPT // ceil -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);} template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { return __builtin_ceil(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return __builtin_ceill(__x);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return __builtin_ceill(__x);} template <class _A1> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, double>::type ceil(_A1 __x) _NOEXCEPT {return __builtin_ceil((double)__x);} @@ -698,33 +698,33 @@ exp(_A1 __x) _NOEXCEPT {return __builtin_exp((double)__x);} // fabs -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);} template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { return __builtin_fabs(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return __builtin_fabsl(__x);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return __builtin_fabsl(__x);} template <class _A1> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, double>::type fabs(_A1 __x) _NOEXCEPT {return __builtin_fabs((double)__x);} // floor -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);} template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { return __builtin_floor(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return __builtin_floorl(__x);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return __builtin_floorl(__x);} template <class _A1> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, double>::type floor(_A1 __x) _NOEXCEPT {return __builtin_floor((double)__x);} @@ -988,31 +988,31 @@ atanh(_A1 __x) _NOEXCEPT {return __builtin_atanh((double)__x);} // cbrt -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);} template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { return __builtin_cbrt(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return __builtin_cbrtl(__x);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return __builtin_cbrtl(__x);} template <class _A1> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, double>::type cbrt(_A1 __x) _NOEXCEPT {return __builtin_cbrt((double)__x);} // copysign -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { return ::__builtin_copysignf(__x, __y); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { return ::__builtin_copysignl(__x, __y); } template <class _A1, class _A2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::__enable_if_t < std::is_arithmetic<_A1>::value && @@ -1152,17 +1152,17 @@ fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT // fmax -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);} template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { return __builtin_fmax(__x, __y); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return __builtin_fmaxl(__x, __y);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return __builtin_fmaxl(__x, __y);} template <class _A1, class _A2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::__enable_if_t < std::is_arithmetic<_A1>::value && @@ -1179,17 +1179,17 @@ fmax(_A1 __x, _A2 __y) _NOEXCEPT // fmin -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);} template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { return __builtin_fmin(__x, __y); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return __builtin_fminl(__x, __y);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return __builtin_fminl(__x, __y);} template <class _A1, class _A2> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::__enable_if_t < std::is_arithmetic<_A1>::value && @@ -1415,17 +1415,17 @@ lround(_A1 __x) _NOEXCEPT // nearbyint -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);} template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { return __builtin_nearbyint(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return __builtin_nearbyintl(__x);} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return __builtin_nearbyintl(__x);} template <class _A1> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, double>::type nearbyint(_A1 __x) _NOEXCEPT {return __builtin_nearbyint((double)__x);} @@ -1528,23 +1528,23 @@ remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT // rint -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { return __builtin_rint(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT { return __builtin_rintl(__x); } template <class _A1> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, double>::type rint(_A1 __x) _NOEXCEPT { @@ -1553,23 +1553,23 @@ rint(_A1 __x) _NOEXCEPT // round -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_roundf(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { return __builtin_round(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT { return __builtin_roundl(__x); } template <class _A1> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, double>::type round(_A1 __x) _NOEXCEPT { @@ -1626,23 +1626,23 @@ tgamma(_A1 __x) _NOEXCEPT {return __builtin_tgamma((double)__x);} // trunc -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_truncf(__x); } template <class = int> -_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { return __builtin_trunc(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT { return __builtin_truncl(__x); } template <class _A1> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename std::enable_if<std::is_integral<_A1>::value, double>::type trunc(_A1 __x) _NOEXCEPT { diff --git a/contrib/libs/cxxsupp/libcxx/include/mdspan b/contrib/libs/cxxsupp/libcxx/include/mdspan index 8d443f4acd..29190e4a99 100644 --- a/contrib/libs/cxxsupp/libcxx/include/mdspan +++ b/contrib/libs/cxxsupp/libcxx/include/mdspan @@ -20,6 +20,10 @@ namespace std { template<class IndexType, size_t Rank> using dextents = see below; + // [mdspan.extents.dims], alias template dims + template<size_t Rank, class IndexType = size_t> + using dims = see below; // since C++26 + // [mdspan.layout], layout mapping struct layout_left; struct layout_right; @@ -405,17 +409,30 @@ namespace std { #define _LIBCPP_MDSPAN #include <__config> -#include <__fwd/mdspan.h> -#include <__mdspan/default_accessor.h> -#include <__mdspan/extents.h> -#include <__mdspan/layout_left.h> -#include <__mdspan/layout_right.h> -#include <__mdspan/layout_stride.h> -#include <__mdspan/mdspan.h> + +#if _LIBCPP_STD_VER >= 23 +# include <__fwd/mdspan.h> +# include <__mdspan/default_accessor.h> +# include <__mdspan/extents.h> +# include <__mdspan/layout_left.h> +# include <__mdspan/layout_right.h> +# include <__mdspan/layout_stride.h> +# include <__mdspan/mdspan.h> +#endif + #include <version> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include <array> +# include <cinttypes> +# include <concepts> +# include <cstddef> +# include <limits> +# include <span> +#endif + #endif // _LIBCPP_MDSPAN diff --git a/contrib/libs/cxxsupp/libcxx/include/memory b/contrib/libs/cxxsupp/libcxx/include/memory index a8c0264eb9..db3386cca4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/memory +++ b/contrib/libs/cxxsupp/libcxx/include/memory @@ -182,8 +182,8 @@ public: raw_storage_iterator operator++(int); }; -template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept; -template <class T> void return_temporary_buffer(T* p) noexcept; +template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept; // deprecated in C++17, removed in C++20 +template <class T> void return_temporary_buffer(T* p) noexcept; // deprecated in C++17, removed in C++20 template <class T> T* addressof(T& r) noexcept; template <class T> T* addressof(const T&& r) noexcept = delete; @@ -451,7 +451,8 @@ public: constexpr unique_ptr& operator=(nullptr_t) noexcept; // constexpr since C++23 // observers - typename constexpr add_lvalue_reference<T>::type operator*() const; // constexpr since C++23 + constexpr + add_lvalue_reference<T>::type operator*() const noexcept(see below); // constexpr since C++23 constexpr pointer operator->() const noexcept; // constexpr since C++23 constexpr pointer get() const noexcept; // constexpr since C++23 constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23 @@ -911,6 +912,22 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); template<size_t N, class T> [[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20 +// [out.ptr.t], class template out_ptr_t +template<class Smart, class Pointer, class... Args> + class out_ptr_t; // since c++23 + +// [out.ptr], function template out_ptr +template<class Pointer = void, class Smart, class... Args> + auto out_ptr(Smart& s, Args&&... args); // since c++23 + +// [inout.ptr.t], class template inout_ptr_t +template<class Smart, class Pointer, class... Args> + class inout_ptr_t; // since c++23 + +// [inout.ptr], function template inout_ptr +template<class Pointer = void, class Smart, class... Args> + auto inout_ptr(Smart& s, Args&&... args); // since c++23 + } // std */ @@ -920,30 +937,40 @@ template<size_t N, class T> #include <__config> #include <__memory/addressof.h> #include <__memory/align.h> -#include <__memory/allocate_at_least.h> -#include <__memory/allocation_guard.h> #include <__memory/allocator.h> #include <__memory/allocator_arg_t.h> #include <__memory/allocator_traits.h> -#include <__memory/assume_aligned.h> #include <__memory/auto_ptr.h> -#include <__memory/compressed_pair.h> -#include <__memory/concepts.h> -#include <__memory/construct_at.h> +#include <__memory/inout_ptr.h> +#include <__memory/out_ptr.h> #include <__memory/pointer_traits.h> -#include <__memory/ranges_construct_at.h> -#include <__memory/ranges_uninitialized_algorithms.h> #include <__memory/raw_storage_iterator.h> #include <__memory/shared_ptr.h> #include <__memory/temporary_buffer.h> #include <__memory/uninitialized_algorithms.h> #include <__memory/unique_ptr.h> #include <__memory/uses_allocator.h> -#include <__memory/uses_allocator_construction.h> -#include <version> // standard-mandated includes +#if _LIBCPP_STD_VER >= 17 +# include <__memory/construct_at.h> +#endif + +#if _LIBCPP_STD_VER >= 20 +# include <__memory/assume_aligned.h> +# include <__memory/concepts.h> +# include <__memory/ranges_construct_at.h> +# include <__memory/ranges_uninitialized_algorithms.h> +# include <__memory/uses_allocator_construction.h> +#endif + +#if _LIBCPP_STD_VER >= 23 +# include <__memory/allocate_at_least.h> +#endif + +#include <version> + // [memory.syn] #include <compare> diff --git a/contrib/libs/cxxsupp/libcxx/include/memory_resource b/contrib/libs/cxxsupp/libcxx/include/memory_resource index e9c87777e8..e98ca20aa0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/memory_resource +++ b/contrib/libs/cxxsupp/libcxx/include/memory_resource @@ -50,18 +50,31 @@ namespace std::pmr { */ #include <__config> -#include <__memory_resource/memory_resource.h> -#include <__memory_resource/monotonic_buffer_resource.h> -#include <__memory_resource/polymorphic_allocator.h> -#include <__memory_resource/pool_options.h> -#include <__memory_resource/synchronized_pool_resource.h> -#include <__memory_resource/unsynchronized_pool_resource.h> + +#if _LIBCPP_STD_VER >= 17 +# include <__memory_resource/memory_resource.h> +# include <__memory_resource/monotonic_buffer_resource.h> +# include <__memory_resource/polymorphic_allocator.h> +# include <__memory_resource/pool_options.h> +# include <__memory_resource/synchronized_pool_resource.h> +# include <__memory_resource/unsynchronized_pool_resource.h> +#endif + #include <version> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 +# include <cstddef> +# include <cstdint> +# include <limits> +# include <mutex> +# include <new> +# include <tuple> +#endif + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <stdexcept> #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/module.modulemap b/contrib/libs/cxxsupp/libcxx/include/module.modulemap index 9ffccf66ff..c1181a3622 100644 --- a/contrib/libs/cxxsupp/libcxx/include/module.modulemap +++ b/contrib/libs/cxxsupp/libcxx/include/module.modulemap @@ -29,6 +29,16 @@ module std_bitset [system] { } module std_charconv [system] { header "charconv" + module chars_format { header "__charconv/chars_format.h" } + module from_chars_integral { header "__charconv/from_chars_integral.h" } + module from_chars_result { header "__charconv/from_chars_result.h" } + module tables { header "__charconv/tables.h" } + module to_chars { header "__charconv/to_chars.h" } + module to_chars_base_10 { header "__charconv/to_chars_base_10.h" } + module to_chars_floating_point { header "__charconv/to_chars_floating_point.h" } + module to_chars_integral { header "__charconv/to_chars_integral.h" } + module to_chars_result { header "__charconv/to_chars_result.h" } + module traits { header "__charconv/traits.h" } export * } module std_chrono [system] { @@ -53,10 +63,15 @@ module std_concepts [system] { } module std_condition_variable [system] { header "condition_variable" + module condition_variable { header "__condition_variable/condition_variable.h" } export * } module std_coroutine [system] { header "coroutine" + module coroutine_handle { header "__coroutine/coroutine_handle.h" } + module coroutine_traits { header "__coroutine/coroutine_traits.h" } + module noop_coroutine_handle { header "__coroutine/noop_coroutine_handle.h" } + module trivial_awaitables { header "__coroutine/trivial_awaitables.h" } export * } module std_deque [system] { @@ -77,6 +92,28 @@ module std_expected [system] { } module std_filesystem [system] { header "filesystem" + module copy_options { header "__filesystem/copy_options.h" } + module directory_entry { header "__filesystem/directory_entry.h" } + module directory_iterator { header "__filesystem/directory_iterator.h" } + module directory_options { header "__filesystem/directory_options.h" } + module file_status { header "__filesystem/file_status.h" } + module file_time_type { header "__filesystem/file_time_type.h" } + module file_type { header "__filesystem/file_type.h" } + module filesystem_error { + header "__filesystem/filesystem_error.h" + export std_private_memory_shared_ptr + } + module operations { header "__filesystem/operations.h" } + module path { + header "__filesystem/path.h" + export std_string // returned by various methods + } + module path_iterator { header "__filesystem/path_iterator.h" } + module perm_options { header "__filesystem/perm_options.h" } + module perms { header "__filesystem/perms.h" } + module recursive_directory_iterator { header "__filesystem/recursive_directory_iterator.h" } + module space_info { header "__filesystem/space_info.h" } + module u8path { header "__filesystem/u8path.h" } export * } module std_format [system] { @@ -149,6 +186,16 @@ module std_map [system] { } module std_mdspan [system] { header "mdspan" + module default_accessor { header "__mdspan/default_accessor.h" } + module extents { header "__mdspan/extents.h" } + module fwd { header "__fwd/mdspan.h" } + module layout_left { header "__mdspan/layout_left.h" } + module layout_right { header "__mdspan/layout_right.h" } + module layout_stride { header "__mdspan/layout_stride.h" } + module mdspan { + header "__mdspan/mdspan.h" + export std_array // for strides() + } export * } module std_memory [system] { @@ -245,8 +292,15 @@ module std_stdexcept [system] { header "stdexcept" export * } -module std_stop_token { +module std_stop_token [system] { header "stop_token" + private header "__stop_token/atomic_unique_lock.h" + private header "__stop_token/intrusive_list_view.h" + private header "__stop_token/intrusive_shared_ptr.h" + private header "__stop_token/stop_callback.h" + private header "__stop_token/stop_source.h" + private header "__stop_token/stop_state.h" + private header "__stop_token/stop_token.h" export * } module std_streambuf [system] { @@ -386,6 +440,11 @@ module std_cstdbool [system] { } module std_cstddef [system] { header "cstddef" + module byte { header "__cstddef/byte.h" } + module max_align_t { header "__cstddef/max_align_t.h" } + module nullptr_t { header "__cstddef/nullptr_t.h" } + module ptrdiff_t { header "__cstddef/ptrdiff_t.h" } + module size_t { header "__cstddef/size_t.h" } export * } module std_cstdint [system] { @@ -551,10 +610,6 @@ module std_experimental [system] { header "experimental/utility" export * } - module __config { - textual header "experimental/__config" - export * - } } // Convenience method to get all of the above modules in a single import statement. @@ -577,6 +632,9 @@ module std_private_bit_reference [system] { module std_private_fwd_bit_reference [system] { header "__fwd/bit_reference.h" } +module std_private_fwd_byte [system] { + header "__fwd/byte.h" +} module std_private_config [system] { textual header "__config" textual header "__configuration/abi.h" @@ -764,6 +822,7 @@ module std_private_algorithm_ranges_find_end [system module std_private_algorithm_ranges_find_first_of [system] { header "__algorithm/ranges_find_first_of.h" } module std_private_algorithm_ranges_find_if [system] { header "__algorithm/ranges_find_if.h" } module std_private_algorithm_ranges_find_if_not [system] { header "__algorithm/ranges_find_if_not.h" } +module std_private_algorithm_ranges_find_last [system] { header "__algorithm/ranges_find_last.h" } module std_private_algorithm_ranges_for_each [system] { header "__algorithm/ranges_for_each.h" export std_private_algorithm_in_fun_result @@ -1074,20 +1133,6 @@ module std_private_bit_invert_if [system] { header "__bit/invert_if.h" } module std_private_bit_popcount [system] { header "__bit/popcount.h" } module std_private_bit_rotate [system] { header "__bit/rotate.h" } -module std_private_charconv_chars_format [system] { header "__charconv/chars_format.h" } -module std_private_charconv_from_chars_integral [system] { header "__charconv/from_chars_integral.h" } -module std_private_charconv_from_chars_result [system] { header "__charconv/from_chars_result.h" } -module std_private_charconv_tables [system] { header "__charconv/tables.h" } -module std_private_charconv_to_chars [system] { header "__charconv/to_chars.h" } -module std_private_charconv_to_chars_base_10 [system] { header "__charconv/to_chars_base_10.h" } -module std_private_charconv_to_chars_floating_point [system] { header "__charconv/to_chars_floating_point.h" } -module std_private_charconv_to_chars_integral [system] { header "__charconv/to_chars_integral.h" } -module std_private_charconv_to_chars_result [system] { - header "__charconv/to_chars_result.h" - export * -} -module std_private_charconv_traits [system] { header "__charconv/traits.h" } - module std_private_chrono_calendar [system] { header "__chrono/calendar.h" } module std_private_chrono_concepts [system] { header "__chrono/concepts.h" } module std_private_chrono_convert_to_timespec [system] { header "__chrono/convert_to_timespec.h" } @@ -1130,6 +1175,7 @@ module std_private_chrono_steady_clock [system] { } module std_private_chrono_time_zone [system] { header "__chrono/time_zone.h" + export std_private_memory_unique_ptr } module std_private_chrono_time_zone_link [system] { header "__chrono/time_zone_link.h" @@ -1211,16 +1257,6 @@ module std_private_concepts_semiregular [system] { header "__concepts/ module std_private_concepts_swappable [system] { header "__concepts/swappable.h" } module std_private_concepts_totally_ordered [system] { header "__concepts/totally_ordered.h" } -module std_private_condition_variable_condition_variable [system] { - header "__condition_variable/condition_variable.h" - export * -} - -module std_private_coroutine_coroutine_handle [system] { header "__coroutine/coroutine_handle.h" } -module std_private_coroutine_coroutine_traits [system] { header "__coroutine/coroutine_traits.h" } -module std_private_coroutine_noop_coroutine_handle [system] { header "__coroutine/noop_coroutine_handle.h" } -module std_private_coroutine_trivial_awaitables [system] { header "__coroutine/trivial_awaitables.h" } - module std_private_debug_utils_randomize_range [system] { header "__debug_utils/randomize_range.h" } module std_private_debug_utils_sanitizers [system] { header "__debug_utils/sanitizers.h" } module std_private_debug_utils_strict_weak_ordering_check [system] { @@ -1244,38 +1280,6 @@ module std_private_expected_expected [system] { header "__expected/ex module std_private_expected_unexpect [system] { header "__expected/unexpect.h" } module std_private_expected_unexpected [system] { header "__expected/unexpected.h" } -module std_private_filesystem_copy_options [system] { header "__filesystem/copy_options.h" } -module std_private_filesystem_directory_entry [system] { - header "__filesystem/directory_entry.h" - export * -} -module std_private_filesystem_directory_iterator [system] { - header "__filesystem/directory_iterator.h" - export * -} -module std_private_filesystem_directory_options [system] { header "__filesystem/directory_options.h" } -module std_private_filesystem_file_status [system] { header "__filesystem/file_status.h" } -module std_private_filesystem_file_time_type [system] { header "__filesystem/file_time_type.h" } -module std_private_filesystem_file_type [system] { header "__filesystem/file_type.h" } -module std_private_filesystem_filesystem_error [system] { - header "__filesystem/filesystem_error.h" - export * -} -module std_private_filesystem_operations [system] { header "__filesystem/operations.h" } -module std_private_filesystem_path [system] { - header "__filesystem/path.h" - export * -} -module std_private_filesystem_path_iterator [system] { header "__filesystem/path_iterator.h" } -module std_private_filesystem_perm_options [system] { header "__filesystem/perm_options.h" } -module std_private_filesystem_perms [system] { header "__filesystem/perms.h" } -module std_private_filesystem_recursive_directory_iterator [system] { - header "__filesystem/recursive_directory_iterator.h" - export * -} -module std_private_filesystem_space_info [system] { header "__filesystem/space_info.h" } -module std_private_filesystem_u8path [system] { header "__filesystem/u8path.h" } - module std_private_format_buffer [system] { header "__format/buffer.h" } module std_private_format_concepts [system] { header "__format/concepts.h" } module std_private_format_container_adaptor [system] { header "__format/container_adaptor.h" } @@ -1418,6 +1422,7 @@ module std_private_iterator_iterator [system] { header "__iterato module std_private_iterator_iterator_traits [system] { header "__iterator/iterator_traits.h" export std_private_type_traits_is_primary_template + export std_private_type_traits_integral_constant } module std_private_iterator_iterator_with_data [system] { header "__iterator/iterator_with_data.h" } module std_private_iterator_mergeable [system] { @@ -1480,20 +1485,10 @@ module std_private_math_modulo [system] { header "__mat module std_private_math_remainder [system] { header "__math/remainder.h" } module std_private_math_roots [system] { header "__math/roots.h" } module std_private_math_rounding_functions [system] { header "__math/rounding_functions.h" } +module std_private_math_special_functions [system] { header "__math/special_functions.h" } module std_private_math_traits [system] { header "__math/traits.h" } module std_private_math_trigonometric_functions [system] { header "__math/trigonometric_functions.h" } -module std_private_mdspan_default_accessor [system] { header "__mdspan/default_accessor.h" } -module std_private_mdspan_extents [system] { - header "__mdspan/extents.h" - export * -} -module std_private_mdspan_layout_left [system] { header "__mdspan/layout_left.h" } -module std_private_mdspan_layout_right [system] { header "__mdspan/layout_right.h" } -module std_private_mdspan_layout_stride [system] { header "__mdspan/layout_stride.h" } -module std_private_mdspan_mdspan [system] { header "__mdspan/mdspan.h" } -module std_private_mdspan_mdspan_fwd [system] { header "__fwd/mdspan.h" } - module std_private_memory_addressof [system] { header "__memory/addressof.h" } module std_private_memory_align [system] { header "__memory/align.h" } module std_private_memory_aligned_alloc [system] { header "__memory/aligned_alloc.h" } @@ -1517,6 +1512,9 @@ module std_private_memory_concepts [system] { module std_private_memory_construct_at [system] { header "__memory/construct_at.h" } module std_private_memory_destruct_n [system] { header "__memory/destruct_n.h" } module std_private_memory_fwd [system] { header "__fwd/memory.h" } +module std_private_memory_inout_ptr [system] { header "__memory/inout_ptr.h" } +module std_private_memory_noexcept_move_assign_container [system] { header "__memory/noexcept_move_assign_container.h" } +module std_private_memory_out_ptr [system] { header "__memory/out_ptr.h" } module std_private_memory_pointer_traits [system] { header "__memory/pointer_traits.h" } module std_private_memory_ranges_construct_at [system] { header "__memory/ranges_construct_at.h" } module std_private_memory_ranges_uninitialized_algorithms [system] { @@ -1544,6 +1542,11 @@ module std_private_memory_unique_ptr [system] { export std_private_type_traits_is_pointer export std_private_type_traits_type_identity } +module std_private_memory_unique_temporary_buffer [system] { + header "__memory/unique_temporary_buffer.h" + export std_private_memory_unique_ptr + export std_private_type_traits_is_constant_evaluated +} module std_private_memory_uses_allocator [system] { header "__memory/uses_allocator.h" } module std_private_memory_uses_allocator_construction [system] { header "__memory/uses_allocator_construction.h" } module std_private_memory_voidify [system] { header "__memory/voidify.h" } @@ -1584,41 +1587,25 @@ module std_private_numeric_transform_exclusive_scan [system] { header "__numeric module std_private_numeric_transform_inclusive_scan [system] { header "__numeric/transform_inclusive_scan.h" } module std_private_numeric_transform_reduce [system] { header "__numeric/transform_reduce.h" } -module std_private_pstl_backend [system] { +module std_private_pstl [system] { header "__pstl/backend.h" - export * -} -module std_private_pstl_backend_fwd [system] { header "__pstl/backend_fwd.h" - export * -} -module std_private_pstl_backends_default [system] { header "__pstl/backends/default.h" - export * -} -module std_private_pstl_backends_libdispatch [system] { header "__pstl/backends/libdispatch.h" - export * -} -module std_private_pstl_backends_serial [system] { header "__pstl/backends/serial.h" - export * -} -module std_private_pstl_backends_std_thread [system] { header "__pstl/backends/std_thread.h" - export * + header "__pstl/cpu_algos/any_of.h" + header "__pstl/cpu_algos/cpu_traits.h" + header "__pstl/cpu_algos/fill.h" + header "__pstl/cpu_algos/find_if.h" + header "__pstl/cpu_algos/for_each.h" + header "__pstl/cpu_algos/merge.h" + header "__pstl/cpu_algos/stable_sort.h" + header "__pstl/cpu_algos/transform.h" + header "__pstl/cpu_algos/transform_reduce.h" + header "__pstl/dispatch.h" + header "__pstl/handle_exception.h" } -module std_private_pstl_cpu_algos_any_of [system] { header "__pstl/cpu_algos/any_of.h" } -module std_private_pstl_cpu_algos_cpu_traits [system] { header "__pstl/cpu_algos/cpu_traits.h" } -module std_private_pstl_cpu_algos_fill [system] { header "__pstl/cpu_algos/fill.h" } -module std_private_pstl_cpu_algos_find_if [system] { header "__pstl/cpu_algos/find_if.h" } -module std_private_pstl_cpu_algos_for_each [system] { header "__pstl/cpu_algos/for_each.h" } -module std_private_pstl_cpu_algos_merge [system] { header "__pstl/cpu_algos/merge.h" } -module std_private_pstl_cpu_algos_stable_sort [system] { header "__pstl/cpu_algos/stable_sort.h" } -module std_private_pstl_cpu_algos_transform [system] { header "__pstl/cpu_algos/transform.h" } -module std_private_pstl_cpu_algos_transform_reduce [system] { header "__pstl/cpu_algos/transform_reduce.h" } -module std_private_pstl_dispatch [system] { header "__pstl/dispatch.h" } -module std_private_pstl_handle_exception [system] { header "__pstl/handle_exception.h" } module std_private_queue_fwd [system] { header "__fwd/queue.h" } @@ -1773,23 +1760,6 @@ module std_private_span_span_fwd [system] { header "__fwd/span.h" } module std_private_stack_fwd [system] { header "__fwd/stack.h" } -module std_private_stop_token_atomic_unique_lock [system] { header "__stop_token/atomic_unique_lock.h" } -module std_private_stop_token_intrusive_list_view [system] { header "__stop_token/intrusive_list_view.h" } -module std_private_stop_token_intrusive_shared_ptr [system] { header "__stop_token/intrusive_shared_ptr.h" } -module std_private_stop_token_stop_callback [system] { header "__stop_token/stop_callback.h" } -module std_private_stop_token_stop_source [system] { - header "__stop_token/stop_source.h" - export * -} -module std_private_stop_token_stop_state [system] { - header "__stop_token/stop_state.h" - export * -} -module std_private_stop_token_stop_token [system] { - header "__stop_token/stop_token.h" - export * -} - module std_private_string_char_traits [system] { header "__string/char_traits.h" export * @@ -1840,6 +1810,7 @@ module std_private_thread_thread [system] { module std_private_thread_timed_backoff_policy [system] { header "__thread/timed_backoff_policy.h" } module std_private_tuple_find_index [system] { header "__tuple/find_index.h" } +module std_private_tuple_ignore [system] { header "__tuple/ignore.h" } module std_private_tuple_make_tuple_types [system] { header "__tuple/make_tuple_types.h" } module std_private_tuple_tuple_like_no_subrange [system] { header "__tuple/tuple_like_no_subrange.h" @@ -1847,13 +1818,25 @@ module std_private_tuple_tuple_like_no_subrange [system] { module std_private_tuple_sfinae_helpers [system] { header "__tuple/sfinae_helpers.h" } module std_private_tuple_tuple_element [system] { header "__tuple/tuple_element.h" } module std_private_tuple_tuple_fwd [system] { header "__fwd/tuple.h" } +module std_private_get_fwd [system] { + header "__fwd/get.h" + export std_private_array_array_fwd + export std_private_complex_complex_fwd + export std_private_ranges_subrange_fwd + export std_private_tuple_tuple_fwd + export std_private_utility_pair_fwd + export std_private_variant_fwd +} module std_private_tuple_tuple_indices [system] { header "__tuple/tuple_indices.h" } module std_private_tuple_tuple_like [system] { header "__tuple/tuple_like.h" export * } module std_private_tuple_tuple_like_ext [system] { header "__tuple/tuple_like_ext.h" } -module std_private_tuple_tuple_size [system] { header "__tuple/tuple_size.h" } +module std_private_tuple_tuple_size [system] { + header "__tuple/tuple_size.h" + export std_private_type_traits_integral_constant +} module std_private_tuple_tuple_types [system] { header "__tuple/tuple_types.h" } module std_private_type_traits_add_const [system] { header "__type_traits/add_const.h" } @@ -1923,7 +1906,10 @@ module std_private_type_traits_is_array [system module std_private_type_traits_is_assignable [system] { header "__type_traits/is_assignable.h" } module std_private_type_traits_is_base_of [system] { header "__type_traits/is_base_of.h" } module std_private_type_traits_is_bounded_array [system] { header "__type_traits/is_bounded_array.h" } -module std_private_type_traits_is_callable [system] { header "__type_traits/is_callable.h" } +module std_private_type_traits_is_callable [system] { + header "__type_traits/is_callable.h" + export std_private_type_traits_integral_constant +} module std_private_type_traits_is_char_like_type [system] { header "__type_traits/is_char_like_type.h" } module std_private_type_traits_is_class [system] { header "__type_traits/is_class.h" } module std_private_type_traits_is_compound [system] { header "__type_traits/is_compound.h" } @@ -1958,11 +1944,15 @@ module std_private_type_traits_is_final [system module std_private_type_traits_is_floating_point [system] { header "__type_traits/is_floating_point.h" } module std_private_type_traits_is_function [system] { header "__type_traits/is_function.h" } module std_private_type_traits_is_fundamental [system] { header "__type_traits/is_fundamental.h" } -module std_private_type_traits_is_implicitly_default_constructible [system] { header "__type_traits/is_implicitly_default_constructible.h" } -module std_private_type_traits_is_integral [system] { header "__type_traits/is_integral.h" } +module std_private_type_traits_is_implicitly_default_constructible [system] { + header "__type_traits/is_implicitly_default_constructible.h" + export std_private_type_traits_integral_constant +} +module std_private_type_traits_is_integral [system] { + header "__type_traits/is_integral.h" + export std_private_type_traits_integral_constant +} module std_private_type_traits_is_literal_type [system] { header "__type_traits/is_literal_type.h" } -module std_private_type_traits_is_member_function_pointer [system] { header "__type_traits/is_member_function_pointer.h" } -module std_private_type_traits_is_member_object_pointer [system] { header "__type_traits/is_member_object_pointer.h" } module std_private_type_traits_is_member_pointer [system] { header "__type_traits/is_member_pointer.h" } module std_private_type_traits_is_nothrow_assignable [system] { header "__type_traits/is_nothrow_assignable.h" } module std_private_type_traits_is_nothrow_constructible [system] { @@ -1989,7 +1979,10 @@ module std_private_type_traits_is_primary_template [system header "__type_traits/is_primary_template.h" export std_private_type_traits_enable_if } -module std_private_type_traits_is_reference [system] { header "__type_traits/is_reference.h" } +module std_private_type_traits_is_reference [system] { + header "__type_traits/is_reference.h" + export std_private_type_traits_integral_constant +} module std_private_type_traits_is_reference_wrapper [system] { header "__type_traits/is_reference_wrapper.h" } module std_private_type_traits_is_referenceable [system] { header "__type_traits/is_referenceable.h" } module std_private_type_traits_is_same [system] { @@ -2000,7 +1993,6 @@ module std_private_type_traits_is_scalar [system header "__type_traits/is_scalar.h" export std_private_type_traits_is_null_pointer } -module std_private_type_traits_is_scoped_enum [system] { header "__type_traits/is_scoped_enum.h" } module std_private_type_traits_is_signed [system] { header "__type_traits/is_signed.h" } module std_private_type_traits_is_signed_integer [system] { header "__type_traits/is_signed_integer.h" } module std_private_type_traits_is_specialization [system] { header "__type_traits/is_specialization.h" } @@ -2012,7 +2004,10 @@ module std_private_type_traits_is_swappable [system module std_private_type_traits_is_trivial [system] { header "__type_traits/is_trivial.h" } module std_private_type_traits_is_trivially_assignable [system] { header "__type_traits/is_trivially_assignable.h" } module std_private_type_traits_is_trivially_constructible [system] { header "__type_traits/is_trivially_constructible.h" } -module std_private_type_traits_is_trivially_copyable [system] { header "__type_traits/is_trivially_copyable.h" } +module std_private_type_traits_is_trivially_copyable [system] { + header "__type_traits/is_trivially_copyable.h" + export std_private_type_traits_integral_constant +} module std_private_type_traits_is_trivially_destructible [system] { header "__type_traits/is_trivially_destructible.h" } module std_private_type_traits_is_trivially_lexicographically_comparable [system] { header "__type_traits/is_trivially_lexicographically_comparable.h" } module std_private_type_traits_is_trivially_relocatable [system] { header "__type_traits/is_trivially_relocatable.h" } @@ -2037,7 +2032,6 @@ module std_private_type_traits_make_unsigned [system module std_private_type_traits_maybe_const [system] { header "__type_traits/maybe_const.h" } module std_private_type_traits_nat [system] { header "__type_traits/nat.h" } module std_private_type_traits_negation [system] { header "__type_traits/negation.h" } -module std_private_type_traits_noexcept_move_assign_container [system] { header "__type_traits/noexcept_move_assign_container.h" } module std_private_type_traits_promote [system] { header "__type_traits/promote.h" } module std_private_type_traits_rank [system] { header "__type_traits/rank.h" } module std_private_type_traits_remove_all_extents [system] { header "__type_traits/remove_all_extents.h" } @@ -2081,7 +2075,10 @@ module std_private_utility_exception_guard [system] { header "__utility/e module std_private_utility_exchange [system] { header "__utility/exchange.h" } module std_private_utility_forward [system] { header "__utility/forward.h" } module std_private_utility_forward_like [system] { header "__utility/forward_like.h" } -module std_private_utility_in_place [system] { header "__utility/in_place.h" } +module std_private_utility_in_place [system] { + header "__utility/in_place.h" + export std_private_type_traits_integral_constant +} module std_private_utility_integer_sequence [system] { header "__utility/integer_sequence.h" } module std_private_utility_is_pointer_in_range [system] { header "__utility/is_pointer_in_range.h" } module std_private_utility_is_valid_range [system] { header "__utility/is_valid_range.h" } @@ -2120,5 +2117,6 @@ module std_private_utility_to_underlying [system] { header "__utility/ module std_private_utility_unreachable [system] { header "__utility/unreachable.h" } module std_private_variant_monostate [system] { header "__variant/monostate.h" } +module std_private_variant_fwd [system] { header "__fwd/variant.h" } module std_private_vector_fwd [system] { header "__fwd/vector.h" } diff --git a/contrib/libs/cxxsupp/libcxx/include/new b/contrib/libs/cxxsupp/libcxx/include/new index 214dbc3985..3252b0bb1a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/new +++ b/contrib/libs/cxxsupp/libcxx/include/new @@ -79,8 +79,8 @@ void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // repla void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept; // replaceable, C++17 -void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++20 -void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++20 +void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++20, constexpr since C++26 +void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++20, constexpr since C++26 void operator delete (void* ptr, void*) noexcept; void operator delete[](void* ptr, void*) noexcept; @@ -166,9 +166,9 @@ public: }; #endif // defined(_LIBCPP_ABI_VCRUNTIME) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 -_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_bad_alloc(); // not in C++ spec +[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_bad_alloc(); // not in C++ spec -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_array_new_length() { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_array_new_length() { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw bad_array_new_length(); #else @@ -203,8 +203,8 @@ inline constexpr destroying_delete_t destroying_delete{}; #if !defined(_LIBCPP_ABI_VCRUNTIME) -_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC; -_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT +[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC; +[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; @@ -212,8 +212,8 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; # endif -_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC; -_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT +[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC; +[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; @@ -222,8 +222,8 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) # endif # ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION -_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; -_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* +[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; +[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; @@ -231,9 +231,9 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, c _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; # endif -_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* +[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; -_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* +[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; @@ -242,8 +242,14 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, # endif # endif -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI void* operator new(std::size_t, void* __p) _NOEXCEPT { return __p; } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI void* operator new[](std::size_t, void* __p) _NOEXCEPT { return __p; } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void* +operator new(std::size_t, void* __p) _NOEXCEPT { + return __p; +} +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void* +operator new[](std::size_t, void* __p) _NOEXCEPT { + return __p; +} inline _LIBCPP_HIDE_FROM_ABI void operator delete(void*, void*) _NOEXCEPT {} inline _LIBCPP_HIDE_FROM_ABI void operator delete[](void*, void*) _NOEXCEPT {} @@ -328,7 +334,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_ } template <class _Tp> -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT { static_assert(!(is_function<_Tp>::value), "can't launder functions"); static_assert(!(is_same<void, __remove_cv_t<_Tp> >::value), "can't launder cv-void"); return __builtin_launder(__p); diff --git a/contrib/libs/cxxsupp/libcxx/include/numeric b/contrib/libs/cxxsupp/libcxx/include/numeric index 9fb5e9fb1d..6b92ce3a07 100644 --- a/contrib/libs/cxxsupp/libcxx/include/numeric +++ b/contrib/libs/cxxsupp/libcxx/include/numeric @@ -157,31 +157,40 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin */ #include <__config> -#include <version> #include <__numeric/accumulate.h> #include <__numeric/adjacent_difference.h> -#include <__numeric/exclusive_scan.h> -#include <__numeric/gcd_lcm.h> -#include <__numeric/inclusive_scan.h> #include <__numeric/inner_product.h> #include <__numeric/iota.h> -#include <__numeric/midpoint.h> #include <__numeric/partial_sum.h> -#include <__numeric/reduce.h> -#include <__numeric/saturation_arithmetic.h> -#include <__numeric/transform_exclusive_scan.h> -#include <__numeric/transform_inclusive_scan.h> -#include <__numeric/transform_reduce.h> #if _LIBCPP_STD_VER >= 17 +# include <__numeric/exclusive_scan.h> +# include <__numeric/gcd_lcm.h> +# include <__numeric/inclusive_scan.h> # include <__numeric/pstl.h> +# include <__numeric/reduce.h> +# include <__numeric/transform_exclusive_scan.h> +# include <__numeric/transform_inclusive_scan.h> +# include <__numeric/transform_reduce.h> +#endif + +#if _LIBCPP_STD_VER >= 20 +# include <__numeric/midpoint.h> +# include <__numeric/saturation_arithmetic.h> #endif +#include <version> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 +# include <initializer_list> +# include <limits> +#endif + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <climits> # include <cmath> diff --git a/contrib/libs/cxxsupp/libcxx/include/optional b/contrib/libs/cxxsupp/libcxx/include/optional index 992189b0e0..f7224a2e03 100644 --- a/contrib/libs/cxxsupp/libcxx/include/optional +++ b/contrib/libs/cxxsupp/libcxx/include/optional @@ -136,12 +136,12 @@ namespace std { void swap(optional &) noexcept(see below ); // constexpr in C++20 // [optional.observe], observers - constexpr T const *operator->() const; - constexpr T *operator->(); - constexpr T const &operator*() const &; - constexpr T &operator*() &; - constexpr T &&operator*() &&; - constexpr const T &&operator*() const &&; + constexpr T const *operator->() const noexcept; + constexpr T *operator->() noexcept; + constexpr T const &operator*() const & noexcept; + constexpr T &operator*() & noexcept; + constexpr T &&operator*() && noexcept; + constexpr const T &&operator*() const && noexcept; constexpr explicit operator bool() const noexcept; constexpr bool has_value() const noexcept; constexpr T const &value() const &; @@ -179,6 +179,7 @@ namespace std { #include <__assert> #include <__compare/compare_three_way_result.h> +#include <__compare/ordering.h> #include <__compare/three_way_comparable.h> #include <__concepts/invocable.h> #include <__config> @@ -195,6 +196,8 @@ namespace std { #include <__type_traits/conjunction.h> #include <__type_traits/decay.h> #include <__type_traits/disjunction.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_array.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_constructible.h> @@ -255,7 +258,7 @@ public: _LIBCPP_BEGIN_NAMESPACE_STD -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void +[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void __throw_bad_optional_access() { # ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw bad_optional_access(); @@ -301,7 +304,7 @@ struct __optional_destruct_base<_Tp, false> { # if _LIBCPP_STD_VER >= 23 template <class _Fp, class... _Args> - _LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base( + _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base( __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {} # endif @@ -707,8 +710,11 @@ public: } # if _LIBCPP_STD_VER >= 23 - template <class _Fp, class... _Args> - _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) + template <class _Tag, + class _Fp, + class... _Args, + __enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args) : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {} # endif @@ -783,12 +789,12 @@ public: } } - _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type const> operator->() const { + _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type const> operator->() const noexcept { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); return std::addressof(this->__get()); } - _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type> operator->() { + _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type> operator->() noexcept { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); return std::addressof(this->__get()); } diff --git a/contrib/libs/cxxsupp/libcxx/include/ostream b/contrib/libs/cxxsupp/libcxx/include/ostream index f75110e7d7..83742882f7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/ostream +++ b/contrib/libs/cxxsupp/libcxx/include/ostream @@ -173,21 +173,32 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args); */ #include <__config> -#include <__ostream/basic_ostream.h> -#include <__ostream/print.h> -#include <version> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__ostream/basic_ostream.h> + +# if _LIBCPP_STD_VER >= 23 +# include <__ostream/print.h> +# endif + +# include <version> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <atomic> # include <concepts> # include <cstdio> # include <cstdlib> +# include <format> # include <iosfwd> # include <iterator> +# include <print> # include <stdexcept> # include <type_traits> #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/print b/contrib/libs/cxxsupp/libcxx/include/print index 1a579daff2..2798a6bda2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/print +++ b/contrib/libs/cxxsupp/libcxx/include/print @@ -199,7 +199,7 @@ _LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream) // the behavior in the test. This is not part of the public API. # ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream); -# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 +# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 || defined(_LIBCPP_HAS_NO_TERMINAL) return false; # elif defined(_LIBCPP_WIN32API) return std::__is_windows_terminal(__stream); diff --git a/contrib/libs/cxxsupp/libcxx/include/queue b/contrib/libs/cxxsupp/libcxx/include/queue index 9508de9f9e..db9ad26eae 100644 --- a/contrib/libs/cxxsupp/libcxx/include/queue +++ b/contrib/libs/cxxsupp/libcxx/include/queue @@ -372,7 +372,7 @@ public: _LIBCPP_HIDE_FROM_ABI queue(queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a) {} #endif // _LIBCPP_CXX03_LANG - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); } @@ -416,7 +416,7 @@ public: swap(c, __q.c); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } template <class _T1, class _OtherContainer> friend _LIBCPP_HIDE_FROM_ABI bool @@ -649,7 +649,7 @@ public: #endif - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } @@ -678,7 +678,7 @@ public: _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q) _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>); - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } }; #if _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/random b/contrib/libs/cxxsupp/libcxx/include/random index 9edd6c4608..6cc3760c20 100644 --- a/contrib/libs/cxxsupp/libcxx/include/random +++ b/contrib/libs/cxxsupp/libcxx/include/random @@ -1682,7 +1682,6 @@ class piecewise_linear_distribution #include <__random/binomial_distribution.h> #include <__random/cauchy_distribution.h> #include <__random/chi_squared_distribution.h> -#include <__random/clamp_to_integral.h> #include <__random/default_random_engine.h> #include <__random/discard_block_engine.h> #include <__random/discrete_distribution.h> @@ -1694,10 +1693,8 @@ class piecewise_linear_distribution #include <__random/geometric_distribution.h> #include <__random/independent_bits_engine.h> #include <__random/is_seed_sequence.h> -#include <__random/is_valid.h> #include <__random/knuth_b.h> #include <__random/linear_congruential_engine.h> -#include <__random/log2.h> #include <__random/lognormal_distribution.h> #include <__random/mersenne_twister_engine.h> #include <__random/negative_binomial_distribution.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/ranges b/contrib/libs/cxxsupp/libcxx/include/ranges index 07a525ed86..fa35874265 100644 --- a/contrib/libs/cxxsupp/libcxx/include/ranges +++ b/contrib/libs/cxxsupp/libcxx/include/ranges @@ -381,49 +381,56 @@ namespace std { */ #include <__config> -#include <__ranges/access.h> -#include <__ranges/all.h> -#include <__ranges/as_rvalue_view.h> -#include <__ranges/chunk_by_view.h> -#include <__ranges/common_view.h> -#include <__ranges/concepts.h> -#include <__ranges/counted.h> -#include <__ranges/dangling.h> -#include <__ranges/data.h> -#include <__ranges/drop_view.h> -#include <__ranges/drop_while_view.h> -#include <__ranges/elements_view.h> -#include <__ranges/empty.h> -#include <__ranges/empty_view.h> -#include <__ranges/enable_borrowed_range.h> -#include <__ranges/enable_view.h> -#include <__ranges/filter_view.h> -#include <__ranges/from_range.h> -#include <__ranges/iota_view.h> -#include <__ranges/join_view.h> -#include <__ranges/lazy_split_view.h> -#include <__ranges/rbegin.h> -#include <__ranges/ref_view.h> -#include <__ranges/rend.h> -#include <__ranges/repeat_view.h> -#include <__ranges/reverse_view.h> -#include <__ranges/single_view.h> -#include <__ranges/size.h> -#include <__ranges/split_view.h> -#include <__ranges/subrange.h> -#include <__ranges/take_view.h> -#include <__ranges/take_while_view.h> -#include <__ranges/to.h> -#include <__ranges/transform_view.h> -#include <__ranges/view_interface.h> -#include <__ranges/views.h> -#include <__ranges/zip_view.h> -#include <version> -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include <__ranges/istream_view.h> +#if _LIBCPP_STD_VER >= 20 +# include <__ranges/access.h> +# include <__ranges/all.h> +# include <__ranges/common_view.h> +# include <__ranges/concepts.h> +# include <__ranges/counted.h> +# include <__ranges/dangling.h> +# include <__ranges/data.h> +# include <__ranges/drop_view.h> +# include <__ranges/drop_while_view.h> +# include <__ranges/elements_view.h> +# include <__ranges/empty.h> +# include <__ranges/empty_view.h> +# include <__ranges/enable_borrowed_range.h> +# include <__ranges/enable_view.h> +# include <__ranges/filter_view.h> +# include <__ranges/iota_view.h> +# include <__ranges/join_view.h> +# include <__ranges/lazy_split_view.h> +# include <__ranges/rbegin.h> +# include <__ranges/ref_view.h> +# include <__ranges/rend.h> +# include <__ranges/reverse_view.h> +# include <__ranges/single_view.h> +# include <__ranges/size.h> +# include <__ranges/split_view.h> +# include <__ranges/subrange.h> +# include <__ranges/take_view.h> +# include <__ranges/take_while_view.h> +# include <__ranges/transform_view.h> +# include <__ranges/view_interface.h> +# include <__ranges/views.h> + +# if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# include <__ranges/istream_view.h> +# endif +#endif + +#if _LIBCPP_STD_VER >= 23 +# include <__ranges/as_rvalue_view.h> +# include <__ranges/chunk_by_view.h> +# include <__ranges/from_range.h> +# include <__ranges/repeat_view.h> +# include <__ranges/to.h> +# include <__ranges/zip_view.h> #endif +#include <version> + // standard-mandated includes // [ranges.syn] @@ -439,6 +446,14 @@ namespace std { # pragma GCC system_header #endif +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 +# include <cstddef> +# include <limits> +# include <optional> +# include <span> +# include <tuple> +#endif + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <cstdlib> # include <iosfwd> diff --git a/contrib/libs/cxxsupp/libcxx/include/regex b/contrib/libs/cxxsupp/libcxx/include/regex index b814135121..d6b8768a25 100644 --- a/contrib/libs/cxxsupp/libcxx/include/regex +++ b/contrib/libs/cxxsupp/libcxx/include/regex @@ -983,7 +983,7 @@ public: }; template <regex_constants::error_type _Ev> -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw regex_error(_Ev); #else @@ -3921,7 +3921,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape( if (__hd == -1) __throw_regex_error<regex_constants::error_escape>(); __sum = 16 * __sum + static_cast<unsigned>(__hd); - // fallthrough + _LIBCPP_FALLTHROUGH(); case 'x': ++__first; if (__first == __last) @@ -4577,7 +4577,7 @@ public: // size: _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __matches_.size(); } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __matches_.max_size(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } // element access: _LIBCPP_HIDE_FROM_ABI difference_type length(size_type __sub = 0) const { diff --git a/contrib/libs/cxxsupp/libcxx/include/scoped_allocator b/contrib/libs/cxxsupp/libcxx/include/scoped_allocator index a49ff465b1..13e43c2f15 100644 --- a/contrib/libs/cxxsupp/libcxx/include/scoped_allocator +++ b/contrib/libs/cxxsupp/libcxx/include/scoped_allocator @@ -389,10 +389,10 @@ public: return _Base::outer_allocator(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) { return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) { return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n, __hint); } diff --git a/contrib/libs/cxxsupp/libcxx/include/semaphore b/contrib/libs/cxxsupp/libcxx/include/semaphore index 8d3b04475c..bf6317c587 100644 --- a/contrib/libs/cxxsupp/libcxx/include/semaphore +++ b/contrib/libs/cxxsupp/libcxx/include/semaphore @@ -16,7 +16,7 @@ namespace std { template<ptrdiff_t least_max_value = implementation-defined> -class counting_semaphore +class counting_semaphore // since C++20 { public: static constexpr ptrdiff_t max() noexcept; @@ -39,7 +39,7 @@ private: ptrdiff_t counter; // exposition only }; -using binary_semaphore = counting_semaphore<1>; +using binary_semaphore = counting_semaphore<1>; // since C++20 } @@ -47,30 +47,28 @@ using binary_semaphore = counting_semaphore<1>; #include <__config> -#ifdef _LIBCPP_HAS_NO_THREADS -# error "<semaphore> is not supported since libc++ has been configured without support for threads." -#endif +#if !defined(_LIBCPP_HAS_NO_THREADS) -#include <__assert> -#include <__atomic/atomic_base.h> -#include <__atomic/atomic_sync.h> -#include <__atomic/memory_order.h> -#include <__chrono/time_point.h> -#include <__thread/poll_with_backoff.h> -#include <__thread/support.h> -#include <__thread/timed_backoff_policy.h> -#include <cstddef> -#include <limits> -#include <version> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# include <__assert> +# include <__atomic/atomic_base.h> +# include <__atomic/atomic_sync.h> +# include <__atomic/memory_order.h> +# include <__chrono/time_point.h> +# include <__thread/poll_with_backoff.h> +# include <__thread/support.h> +# include <__thread/timed_backoff_policy.h> +# include <cstddef> +# include <limits> +# include <version> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_BEGIN_NAMESPACE_STD @@ -82,7 +80,7 @@ functions. It avoids contention against users' own use of those facilities. */ -# define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max()) +# define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max()) class __atomic_semaphore_base { __atomic_base<ptrdiff_t> __a_; @@ -126,7 +124,7 @@ private: }; template <ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX> -class _LIBCPP_DEPRECATED_ATOMIC_SYNC counting_semaphore { +class counting_semaphore { __atomic_semaphore_base __semaphore_; public: @@ -171,18 +169,18 @@ public: } }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH -using binary_semaphore _LIBCPP_DEPRECATED_ATOMIC_SYNC = counting_semaphore<1>; -_LIBCPP_SUPPRESS_DEPRECATED_POP +using binary_semaphore = counting_semaphore<1>; _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_STD_VER >= 14 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_POP_MACROS +#endif // !defined(_LIBCPP_HAS_NO_THREADS) + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <atomic> #endif -#endif //_LIBCPP_SEMAPHORE +#endif // _LIBCPP_SEMAPHORE diff --git a/contrib/libs/cxxsupp/libcxx/include/set b/contrib/libs/cxxsupp/libcxx/include/set index f2d2b05f93..6215f3ce49 100644 --- a/contrib/libs/cxxsupp/libcxx/include/set +++ b/contrib/libs/cxxsupp/libcxx/include/set @@ -524,14 +524,23 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 #include <__iterator/ranges_iterator_traits.h> #include <__iterator/reverse_iterator.h> #include <__memory/allocator.h> +#include <__memory/allocator_traits.h> #include <__memory_resource/polymorphic_allocator.h> #include <__node_handle> #include <__ranges/concepts.h> #include <__ranges/container_compatible_range.h> #include <__ranges/from_range.h> #include <__tree> +#include <__type_traits/enable_if.h> #include <__type_traits/is_allocator.h> +#include <__type_traits/is_nothrow_assignable.h> +#include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/is_same.h> +#include <__type_traits/is_swappable.h> +#include <__type_traits/type_identity.h> #include <__utility/forward.h> +#include <__utility/move.h> +#include <__utility/pair.h> #include <version> // standard-mandated includes @@ -713,7 +722,7 @@ public: _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } @@ -1171,7 +1180,7 @@ public: _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } @@ -1454,8 +1463,7 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, template <class _Key, class _Allocator> _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) { - return std::lexicographical_compare_three_way( - __x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); } #endif // _LIBCPP_STD_VER <= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/shared_mutex b/contrib/libs/cxxsupp/libcxx/include/shared_mutex index 397ac290d9..f63bd25493 100644 --- a/contrib/libs/cxxsupp/libcxx/include/shared_mutex +++ b/contrib/libs/cxxsupp/libcxx/include/shared_mutex @@ -124,31 +124,29 @@ template <class Mutex> #include <__config> -#ifdef _LIBCPP_HAS_NO_THREADS -# error "<shared_mutex> is not supported since libc++ has been configured without support for threads." -#endif - -#include <__chrono/duration.h> -#include <__chrono/steady_clock.h> -#include <__chrono/time_point.h> -#include <__condition_variable/condition_variable.h> -#include <__memory/addressof.h> -#include <__mutex/mutex.h> -#include <__mutex/tag_types.h> -#include <__mutex/unique_lock.h> -#include <__system_error/system_error.h> -#include <__utility/swap.h> -#include <cerrno> -#include <version> +#if !defined(_LIBCPP_HAS_NO_THREADS) + +# include <__chrono/duration.h> +# include <__chrono/steady_clock.h> +# include <__chrono/time_point.h> +# include <__condition_variable/condition_variable.h> +# include <__memory/addressof.h> +# include <__mutex/mutex.h> +# include <__mutex/tag_types.h> +# include <__mutex/unique_lock.h> +# include <__system_error/system_error.h> +# include <__utility/swap.h> +# include <cerrno> +# include <version> _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> -#if _LIBCPP_STD_VER >= 14 +# if _LIBCPP_STD_VER >= 14 -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -181,7 +179,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base { // native_handle_type native_handle(); // See 30.2.3 }; -# if _LIBCPP_STD_VER >= 17 +# if _LIBCPP_STD_VER >= 17 class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_mutex")) shared_mutex { __shared_mutex_base __base_; @@ -218,7 +216,7 @@ public: // typedef __shared_mutex_base::native_handle_type native_handle_type; // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); } }; -# endif +# endif class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex")) shared_timed_mutex { @@ -453,10 +451,12 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_lock<_Mutex>& __x, shared_lock<_Mu _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_STD_VER >= 14 +# endif // _LIBCPP_STD_VER >= 14 _LIBCPP_POP_MACROS +#endif // !defined(_LIBCPP_HAS_NO_THREADS) + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <system_error> #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/span b/contrib/libs/cxxsupp/libcxx/include/span index 60d76d830f..a32f7a372e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/span +++ b/contrib/libs/cxxsupp/libcxx/include/span @@ -206,11 +206,11 @@ struct __is_std_span<span<_Tp, _Sz>> : true_type {}; template <class _Range, class _ElementType> concept __span_compatible_range = + !__is_std_span<remove_cvref_t<_Range>>::value && // ranges::contiguous_range<_Range> && // ranges::sized_range<_Range> && // (ranges::borrowed_range<_Range> || is_const_v<_ElementType>) && // - !__is_std_span<remove_cvref_t<_Range>>::value && // - !__is_std_array<remove_cvref_t<_Range>>::value && // + !__is_std_array_v<remove_cvref_t<_Range>> && // !is_array_v<remove_cvref_t<_Range>> && // is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>> (*)[], _ElementType (*)[]>; diff --git a/contrib/libs/cxxsupp/libcxx/include/sstream b/contrib/libs/cxxsupp/libcxx/include/sstream index 9ba43ffeb8..c29abab9c5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/sstream +++ b/contrib/libs/cxxsupp/libcxx/include/sstream @@ -313,21 +313,26 @@ typedef basic_stringstream<wchar_t> wstringstream; // clang-format on #include <__config> -#include <__fwd/sstream.h> -#include <__ostream/basic_ostream.h> -#include <__type_traits/is_convertible.h> -#include <__utility/swap.h> -#include <istream> -#include <string> -#include <string_view> -#include <version> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif + +#ifndef _LIBCPP_HAS_NO_LOCALIZATION + +# include <__fwd/sstream.h> +# include <__ostream/basic_ostream.h> +# include <__type_traits/is_convertible.h> +# include <__utility/swap.h> +# include <ios> +# include <istream> +# include <locale> +# include <string> +# include <string_view> +# include <version> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -354,9 +359,15 @@ private: public: // [stringbuf.cons] constructors: - _LIBCPP_HIDE_FROM_ABI basic_stringbuf() : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {} + _LIBCPP_HIDE_FROM_ABI basic_stringbuf() : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) { + // it is implementation-defined whether we initialize eback() & friends to nullptr, and libc++ doesn't + __init_buf_ptrs(); + } - _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(ios_base::openmode __wch) : __hm_(nullptr), __mode_(__wch) {} + _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(ios_base::openmode __wch) : __hm_(nullptr), __mode_(__wch) { + // it is implementation-defined whether we initialize eback() & friends to nullptr, and libc++ doesn't + __init_buf_ptrs(); + } _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const string_type& __s, ios_base::openmode __wch = ios_base::in | ios_base::out) @@ -364,12 +375,14 @@ public: str(__s); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const allocator_type& __a) : basic_stringbuf(ios_base::in | ios_base::out, __a) {} _LIBCPP_HIDE_FROM_ABI basic_stringbuf(ios_base::openmode __wch, const allocator_type& __a) - : __str_(__a), __hm_(nullptr), __mode_(__wch) {} + : __str_(__a), __hm_(nullptr), __mode_(__wch) { + __init_buf_ptrs(); + } _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(string_type&& __s, ios_base::openmode __wch = ios_base::in | ios_base::out) @@ -396,9 +409,9 @@ public: : __str_(__s), __hm_(nullptr), __mode_(__wch) { __init_buf_ptrs(); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template <class _Tp> requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> @@ -420,37 +433,37 @@ public: __init_buf_ptrs(); } -#endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 basic_stringbuf(const basic_stringbuf&) = delete; basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a) : basic_stringbuf(__rhs.__mode_, __a) { __move_init(std::move(__rhs)); } -#endif +# endif // [stringbuf.assign] Assign and swap: basic_stringbuf& operator=(const basic_stringbuf&) = delete; basic_stringbuf& operator=(basic_stringbuf&& __rhs); void swap(basic_stringbuf& __rhs) -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || allocator_traits<allocator_type>::is_always_equal::value) -#endif +# endif ; // [stringbuf.members] Member functions: -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); } -#endif +# endif -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) string_type str() const; -#else +# else _LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); } _LIBCPP_HIDE_FROM_ABI string_type str() && { @@ -464,9 +477,9 @@ public: __init_buf_ptrs(); return __result; } -#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _SAlloc> requires __is_allocator<_SAlloc>::value _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { @@ -474,14 +487,14 @@ public: } _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept; -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 void str(const string_type& __s) { __str_ = __s; __init_buf_ptrs(); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _SAlloc> requires(!is_same_v<_SAlloc, allocator_type>) _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) { @@ -493,9 +506,9 @@ public: __str_ = std::move(__s); __init_buf_ptrs(); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template <class _Tp> requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> @@ -505,7 +518,7 @@ public: __init_buf_ptrs(); } -#endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 protected: // [stringbuf.virtuals] Overridden virtual functions: @@ -601,10 +614,10 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs) template <class _CharT, class _Traits, class _Allocator> void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs) -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 noexcept(allocator_traits<_Allocator>::propagate_on_container_swap::value || allocator_traits<_Allocator>::is_always_equal::value) -#endif +# endif { char_type* __p = const_cast<char_type*>(__rhs.__str_.data()); ptrdiff_t __rbinp = -1; @@ -674,14 +687,14 @@ void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs) template <class _CharT, class _Traits, class _Allocator> inline _LIBCPP_HIDE_FROM_ABI void swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y) -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 noexcept(noexcept(__x.swap(__y))) -#endif +# endif { __x.swap(__y); } -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allocator>::str() const { if (__mode_ & ios_base::out) { @@ -692,7 +705,7 @@ basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allo return string_type(this->eback(), this->egptr(), __str_.get_allocator()); return string_type(__str_.get_allocator()); } -#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) template <class _CharT, class _Traits, class _Allocator> _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_buf_ptrs() { @@ -718,7 +731,7 @@ _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_ } } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _CharT, class _Traits, class _Allocator> _LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT, _Traits> basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept { @@ -730,7 +743,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept { return basic_string_view<_CharT, _Traits>(this->eback(), this->egptr()); return basic_string_view<_CharT, _Traits>(); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 template <class _CharT, class _Traits, class _Allocator> typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type @@ -773,9 +786,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) { if (this->pptr() == this->epptr()) { if (!(__mode_ & ios_base::out)) return traits_type::eof(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS ptrdiff_t __nout = this->pptr() - this->pbase(); ptrdiff_t __hm = __hm_ - this->pbase(); __str_.push_back(char_type()); @@ -784,11 +797,11 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) { this->setp(__p, __p + __str_.size()); this->__pbump(__nout); __hm_ = this->pbase() + __hm; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { return traits_type::eof(); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS } __hm_ = std::max(this->pptr() + 1, __hm_); if (__mode_ & ios_base::in) { @@ -864,15 +877,16 @@ private: public: // [istringstream.cons] Constructors: - _LIBCPP_HIDE_FROM_ABI basic_istringstream() : basic_istream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in) {} + _LIBCPP_HIDE_FROM_ABI basic_istringstream() + : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(ios_base::in) {} _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(ios_base::openmode __wch) - : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {} + : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::in) {} _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in) - : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch | ios_base::in) {} + : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {} -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI basic_istringstream(ios_base::openmode __wch, const _Allocator& __a) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::in, __a) {} @@ -892,9 +906,9 @@ public: _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __wch = ios_base::in) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {} -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template <class _Tp> requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> @@ -911,12 +925,12 @@ public: _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {} -#endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 basic_istringstream(const basic_istringstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs) : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { - basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); + basic_istream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } // [istringstream.assign] Assign and swap: @@ -933,18 +947,18 @@ public: // [istringstream.members] Member functions: _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { - return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_); + return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); } -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } -#else +# else _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } -#endif +# endif -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _SAlloc> requires __is_allocator<_SAlloc>::value _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { @@ -952,26 +966,26 @@ public: } _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _SAlloc> _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) { __sb_.str(__s); } _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template <class _Tp> requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { rdbuf()->str(__t); } -#endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 }; template <class _CharT, class _Traits, class _Allocator> @@ -999,15 +1013,16 @@ private: public: // [ostringstream.cons] Constructors: - _LIBCPP_HIDE_FROM_ABI basic_ostringstream() : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::out) {} + _LIBCPP_HIDE_FROM_ABI basic_ostringstream() + : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(ios_base::out) {} _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(ios_base::openmode __wch) - : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::out) {} + : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::out) {} _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const string_type& __s, ios_base::openmode __wch = ios_base::out) - : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch | ios_base::out) {} + : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {} -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(ios_base::openmode __wch, const _Allocator& __a) : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::out, __a) {} @@ -1028,9 +1043,9 @@ public: _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __wch = ios_base::out) : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {} -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template <class _Tp> requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> @@ -1047,12 +1062,12 @@ public: _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {} -#endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 basic_ostringstream(const basic_ostringstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs) : basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { - basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_); + basic_ostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } // [ostringstream.assign] Assign and swap: @@ -1070,18 +1085,18 @@ public: // [ostringstream.members] Member functions: _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { - return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_); + return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); } -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } -#else +# else _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } -#endif +# endif -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _SAlloc> requires __is_allocator<_SAlloc>::value _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { @@ -1089,26 +1104,26 @@ public: } _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _SAlloc> _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) { __sb_.str(__s); } _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template <class _Tp> requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { rdbuf()->str(__t); } -#endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 }; template <class _CharT, class _Traits, class _Allocator> @@ -1137,16 +1152,16 @@ private: public: // [stringstream.cons] constructors _LIBCPP_HIDE_FROM_ABI basic_stringstream() - : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in | ios_base::out) {} + : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(ios_base::in | ios_base::out) {} _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(ios_base::openmode __wch) - : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {} + : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch) {} _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in | ios_base::out) - : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch) {} + : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {} -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI basic_stringstream(ios_base::openmode __wch, const _Allocator& __a) : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch, __a) {} @@ -1168,9 +1183,9 @@ public: _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __wch = ios_base::out | ios_base::in) : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {} -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template <class _Tp> requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> @@ -1188,12 +1203,12 @@ public: _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which, __a) {} -#endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 basic_stringstream(const basic_stringstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs) : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { - basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); + basic_istream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } // [stringstream.assign] Assign and swap: @@ -1210,18 +1225,18 @@ public: // [stringstream.members] Member functions: _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { - return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_); + return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); } -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) +# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } -#else +# else _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } -#endif +# endif -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _SAlloc> requires __is_allocator<_SAlloc>::value _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { @@ -1229,26 +1244,26 @@ public: } _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } -#if _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 template <class _SAlloc> _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) { __sb_.str(__s); } _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } -#endif // _LIBCPP_STD_VER >= 20 +# endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER >= 26 +# if _LIBCPP_STD_VER >= 26 template <class _Tp> requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { rdbuf()->str(__t); } -#endif // _LIBCPP_STD_VER >= 26 +# endif // _LIBCPP_STD_VER >= 26 }; template <class _CharT, class _Traits, class _Allocator> @@ -1257,17 +1272,19 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_C __x.swap(__y); } -#if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 +# if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>; -#endif +# endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS +#endif // !_LIBCPP_HAS_NO_LOCALIZATION + #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) # include <ostream> # include <type_traits> diff --git a/contrib/libs/cxxsupp/libcxx/include/stack b/contrib/libs/cxxsupp/libcxx/include/stack index 90f8933cca..f75769f8a4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stack +++ b/contrib/libs/cxxsupp/libcxx/include/stack @@ -231,7 +231,7 @@ public: #endif - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } _LIBCPP_HIDE_FROM_ABI reference top() { return c.back(); } _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); } @@ -273,7 +273,7 @@ public: swap(c, __s.c); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } template <class _T1, class _OtherContainer> friend bool operator==(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); diff --git a/contrib/libs/cxxsupp/libcxx/include/stdatomic.h b/contrib/libs/cxxsupp/libcxx/include/stdatomic.h index 79772eb7fc..3206f7da8c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stdatomic.h +++ b/contrib/libs/cxxsupp/libcxx/include/stdatomic.h @@ -103,6 +103,8 @@ using std::atomic_fetch_sub // see below using std::atomic_fetch_sub_explicit // see below using std::atomic_fetch_or // see below using std::atomic_fetch_or_explicit // see below +using std::atomic_fetch_xor // see below +using std::atomic_fetch_xor_explicit // see below using std::atomic_fetch_and // see below using std::atomic_fetch_and_explicit // see below using std::atomic_flag_test_and_set // see below @@ -121,7 +123,7 @@ using std::atomic_signal_fence // see below # pragma GCC system_header #endif -#if defined(__cplusplus) && _LIBCPP_STD_VER >= 23 +#if defined(__cplusplus) # include <atomic> # include <version> @@ -154,10 +156,14 @@ using std::atomic_long _LIBCPP_USING_IF_EXISTS; using std::atomic_ulong _LIBCPP_USING_IF_EXISTS; using std::atomic_llong _LIBCPP_USING_IF_EXISTS; using std::atomic_ullong _LIBCPP_USING_IF_EXISTS; +# ifndef _LIBCPP_HAS_NO_CHAR8_T using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS; +# endif using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS; using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS; +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::atomic_wchar_t _LIBCPP_USING_IF_EXISTS; +# endif using std::atomic_int8_t _LIBCPP_USING_IF_EXISTS; using std::atomic_uint8_t _LIBCPP_USING_IF_EXISTS; @@ -204,6 +210,8 @@ using std::atomic_fetch_add_explicit _LIBCPP_USING_IF_EXISTS; using std::atomic_fetch_and _LIBCPP_USING_IF_EXISTS; using std::atomic_fetch_and_explicit _LIBCPP_USING_IF_EXISTS; using std::atomic_fetch_or _LIBCPP_USING_IF_EXISTS; +using std::atomic_fetch_xor_explicit _LIBCPP_USING_IF_EXISTS; +using std::atomic_fetch_xor _LIBCPP_USING_IF_EXISTS; using std::atomic_fetch_or_explicit _LIBCPP_USING_IF_EXISTS; using std::atomic_fetch_sub _LIBCPP_USING_IF_EXISTS; using std::atomic_fetch_sub_explicit _LIBCPP_USING_IF_EXISTS; @@ -220,16 +228,12 @@ using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS; using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS; using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS; -#elif defined(_LIBCPP_COMPILER_CLANG_BASED) +#else -// Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking -// the header. We do this because Clang has historically shipped a <stdatomic.h> -// header that would be available in all Standard modes, and we don't want to -// break that use case. # if __has_include_next(<stdatomic.h>) # include_next <stdatomic.h> # endif -#endif // defined(__cplusplus) && _LIBCPP_STD_VER >= 23 +#endif // defined(__cplusplus) #endif // _LIBCPP_STDATOMIC_H diff --git a/contrib/libs/cxxsupp/libcxx/include/stdexcept b/contrib/libs/cxxsupp/libcxx/include/stdexcept index 853c185187..bdfc27aeac 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stdexcept +++ b/contrib/libs/cxxsupp/libcxx/include/stdexcept @@ -209,9 +209,9 @@ public: _LIBCPP_BEGIN_NAMESPACE_STD // in the dylib -_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*); +[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*); -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw logic_error(__msg); #else @@ -219,7 +219,7 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const cha #endif } -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw domain_error(__msg); #else @@ -227,7 +227,7 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const ch #endif } -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw invalid_argument(__msg); #else @@ -235,7 +235,7 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(cons #endif } -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw length_error(__msg); #else @@ -243,7 +243,7 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const ch #endif } -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw out_of_range(__msg); #else @@ -251,7 +251,7 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const ch #endif } -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw range_error(__msg); #else @@ -259,7 +259,7 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const cha #endif } -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw overflow_error(__msg); #else @@ -267,7 +267,7 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const #endif } -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw underflow_error(__msg); #else diff --git a/contrib/libs/cxxsupp/libcxx/include/stdlib.h b/contrib/libs/cxxsupp/libcxx/include/stdlib.h index a74344d491..358b10c039 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stdlib.h +++ b/contrib/libs/cxxsupp/libcxx/include/stdlib.h @@ -110,19 +110,19 @@ extern "C++" { // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined # if !defined(_LIBCPP_MSVCRT) -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } # endif // !defined(_LIBCPP_MSVCRT) -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT { return __builtin_fabs(__lcpp_x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT { return __builtin_fabsl(__lcpp_x); } diff --git a/contrib/libs/cxxsupp/libcxx/include/stop_token b/contrib/libs/cxxsupp/libcxx/include/stop_token index fee195f9d6..d4e651d954 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stop_token +++ b/contrib/libs/cxxsupp/libcxx/include/stop_token @@ -33,18 +33,21 @@ namespace std { #include <__config> -#ifdef _LIBCPP_HAS_NO_THREADS -# error "<stop_token> is not supported since libc++ has been configured without support for threads." -#endif +#if !defined(_LIBCPP_HAS_NO_THREADS) -#include <__stop_token/stop_callback.h> -#include <__stop_token/stop_source.h> -#include <__stop_token/stop_token.h> -#include <version> +# if _LIBCPP_STD_VER >= 20 +# include <__stop_token/stop_callback.h> +# include <__stop_token/stop_source.h> +# include <__stop_token/stop_token.h> +# endif -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# include <version> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +#endif // !defined(_LIBCPP_HAS_NO_THREADS) #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <iosfwd> diff --git a/contrib/libs/cxxsupp/libcxx/include/streambuf b/contrib/libs/cxxsupp/libcxx/include/streambuf index 5a3c17ef7c..906340ef03 100644 --- a/contrib/libs/cxxsupp/libcxx/include/streambuf +++ b/contrib/libs/cxxsupp/libcxx/include/streambuf @@ -107,23 +107,26 @@ protected: */ -#include <__assert> #include <__config> -#include <__fwd/streambuf.h> -#include <__locale> -#include <__type_traits/is_same.h> -#include <__utility/is_valid_range.h> -#include <climits> -#include <ios> -#include <iosfwd> -#include <version> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif + +#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__assert> +# include <__fwd/streambuf.h> +# include <__locale> +# include <__type_traits/is_same.h> +# include <__utility/is_valid_range.h> +# include <climits> +# include <ios> +# include <iosfwd> +# include <version> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD @@ -430,14 +433,16 @@ typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Tra extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>; -#endif +# endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS +#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <cstdint> #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/string b/contrib/libs/cxxsupp/libcxx/include/string index 74c0690617..5b960cd1ca 100644 --- a/contrib/libs/cxxsupp/libcxx/include/string +++ b/contrib/libs/cxxsupp/libcxx/include/string @@ -409,6 +409,24 @@ basic_string<charT, traits, Allocator> operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); // constexpr since C++20 template<class charT, class traits, class Allocator> + constexpr basic_string<charT, traits, Allocator> + operator+(const basic_string<charT, traits, Allocator>& lhs, + type_identity_t<basic_string_view<charT, traits>> rhs); // Since C++26 +template<class charT, class traits, class Allocator> + constexpr basic_string<charT, traits, Allocator> + operator+(basic_string<charT, traits, Allocator>&& lhs, + type_identity_t<basic_string_view<charT, traits>> rhs); // Since C++26 +template<class charT, class traits, class Allocator> + constexpr basic_string<charT, traits, Allocator> + operator+(type_identity_t<basic_string_view<charT, traits>> lhs, + const basic_string<charT, traits, Allocator>& rhs); // Since C++26 +template<class charT, class traits, class Allocator> + constexpr basic_string<charT, traits, Allocator> + operator+(type_identity_t<basic_string_view<charT, traits>> lhs, + basic_string<charT, traits, Allocator>&& rhs); // Since C++26 + + +template<class charT, class traits, class Allocator> bool operator==(const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 @@ -581,6 +599,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); #include <__functional/unary_function.h> #include <__fwd/string.h> #include <__ios/fpos.h> +#include <__iterator/bounded_iter.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__iterator/reverse_iterator.h> @@ -591,6 +610,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> #include <__memory/construct_at.h> +#include <__memory/noexcept_move_assign_container.h> #include <__memory/pointer_traits.h> #include <__memory/swap_allocator.h> #include <__memory_resource/polymorphic_allocator.h> @@ -602,6 +622,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); #include <__string/char_traits.h> #include <__string/extern_template_lists.h> #include <__type_traits/conditional.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_allocator.h> #include <__type_traits/is_array.h> #include <__type_traits/is_convertible.h> @@ -611,7 +632,6 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); #include <__type_traits/is_standard_layout.h> #include <__type_traits/is_trivial.h> #include <__type_traits/is_trivially_relocatable.h> -#include <__type_traits/noexcept_move_assign_container.h> #include <__type_traits/remove_cvref.h> #include <__type_traits/void_t.h> #include <__utility/auto_cast.h> @@ -688,6 +708,28 @@ template <class _CharT, class _Traits, class _Allocator> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); +#if _LIBCPP_STD_VER >= 26 + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> +operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, + type_identity_t<basic_string_view<_CharT, _Traits>> __rhs); + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> +operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, type_identity_t<basic_string_view<_CharT, _Traits>> __rhs); + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> +operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, + const basic_string<_CharT, _Traits, _Allocator>& __rhs); + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> +operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs); + +#endif + extern template _LIBCPP_EXPORTED_FROM_ABI string operator+ <char, char_traits<char>, allocator<char> >(char const*, string const&); @@ -708,6 +750,14 @@ struct __can_be_converted_to_string_view struct __uninitialized_size_tag {}; struct __init_with_sentinel_tag {}; +template <size_t _PaddingSize> +struct __padding { + char __padding_[_PaddingSize]; +}; + +template <> +struct __padding<0> {}; + template <class _CharT, class _Traits, class _Allocator> class basic_string { private: @@ -786,8 +836,13 @@ public: #if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1 typedef pointer iterator; typedef const_pointer const_iterator; +#elif defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING) + // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's + // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is + // considered contiguous. + typedef __bounded_iter<__wrap_iter<pointer> > iterator; + typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator; #else - // TODO: Implement iterator bounds checking without requiring the global database. typedef __wrap_iter<pointer> iterator; typedef __wrap_iter<const_pointer> const_iterator; #endif @@ -810,7 +865,7 @@ private: struct __short { value_type __data_[__min_cap]; - unsigned char __padding_[sizeof(value_type) - 1]; + _LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_; unsigned char __size_ : 7; unsigned char __is_long_ : 1; }; @@ -862,7 +917,7 @@ private: unsigned char __is_long_ : 1; unsigned char __size_ : 7; }; - char __padding_[sizeof(value_type) - 1]; + _LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_; value_type __data_[__min_cap]; }; @@ -875,18 +930,18 @@ private: __long __l; }; - __compressed_pair<__rep, allocator_type> __r_; + _LIBCPP_COMPRESSED_PAIR(__rep, __rep_, allocator_type, __alloc_); // Construct a string with the given allocator and enough storage to hold `__size` characters, but // don't initialize the characters. The contents of the string, including the null terminator, must be // initialized separately. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string( __uninitialized_size_tag, size_type __size, const allocator_type& __a) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { if (__size > max_size()) __throw_length_error(); if (__fits_in_sso(__size)) { - __r_.first() = __rep(); + __rep_ = __rep(); __set_short_size(__size); } else { auto __capacity = __recommend(__size) + 1; @@ -902,14 +957,37 @@ private: template <class _Iter, class _Sent> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(__init_with_sentinel_tag, _Iter __first, _Sent __last, const allocator_type& __a) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { __init_with_sentinel(std::move(__first), std::move(__last)); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) { return iterator(__p); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) { +#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING + // Bound the iterator according to the size (and not the capacity, unlike vector). + // + // By the Standard, string iterators are generally not guaranteed to stay valid when the container is modified, + // regardless of whether reallocation occurs. This allows us to check for out-of-bounds accesses using logical size, + // a stricter check, since correct code can never rely on being able to access newly-added elements via an existing + // iterator. + return std::__make_bounded_iter( + std::__wrap_iter<pointer>(__p), + std::__wrap_iter<pointer>(__get_pointer()), + std::__wrap_iter<pointer>(__get_pointer() + size())); +#else + return iterator(__p); +#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING + } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const { +#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING + // Bound the iterator according to the size (and not the capacity, unlike vector). + return std::__make_bounded_iter( + std::__wrap_iter<const_pointer>(__p), + std::__wrap_iter<const_pointer>(__get_pointer()), + std::__wrap_iter<const_pointer>(__get_pointer() + size())); +#else return const_iterator(__p); +#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING } public: @@ -917,7 +995,7 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) - : __r_(__value_init_tag(), __default_init_tag()) { + : __rep_() { __annotate_new(0); } @@ -927,14 +1005,14 @@ public: #else _NOEXCEPT #endif - : __r_(__value_init_tag(), __a) { + : __rep_(), __alloc_(__a) { __annotate_new(0); } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& __str) - : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) { + : __alloc_(__alloc_traits::select_on_container_copy_construction(__str.__alloc())) { if (!__str.__is_long()) { - __r_.first() = __str.__r_.first(); + __rep_ = __str.__rep_; __annotate_new(__get_short_size()); } else __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); @@ -942,9 +1020,9 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& __str, const allocator_type& __a) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { if (!__str.__is_long()) { - __r_.first() = __str.__r_.first(); + __rep_ = __str.__rep_; __annotate_new(__get_short_size()); } else __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); @@ -960,45 +1038,45 @@ public: // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first. // __str's memory needs to be unpoisoned only in the case where it's a short string. - : __r_([](basic_string& __s) -> decltype(__s.__r_)&& { + : __rep_([](basic_string& __s) -> decltype(__s.__rep_)&& { if (!__s.__is_long()) __s.__annotate_delete(); - return std::move(__s.__r_); - }(__str)) { - __str.__r_.first() = __rep(); + return std::move(__s.__rep_); + }(__str)), + __alloc_(std::move(__str.__alloc_)) { + __str.__rep_ = __rep(); __str.__annotate_new(0); if (!__is_long()) __annotate_new(size()); } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str, const allocator_type& __a) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { if (__str.__is_long() && __a != __str.__alloc()) // copy, not move __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); else { if (__libcpp_is_constant_evaluated()) - __r_.first() = __rep(); + __rep_ = __rep(); if (!__str.__is_long()) __str.__annotate_delete(); - __r_.first() = __str.__r_.first(); - __str.__r_.first() = __rep(); + __rep_ = __str.__rep_; + __str.__rep_ = __rep(); __str.__annotate_new(0); - if (!__is_long() && this != &__str) + if (!__is_long() && this != std::addressof(__str)) __annotate_new(size()); } } #endif // _LIBCPP_CXX03_LANG template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) - : __r_(__default_init_tag(), __default_init_tag()) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) { _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr"); __init(__s, traits_type::length(__s)); } template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); __init(__s, traits_type::length(__s)); } @@ -1008,8 +1086,7 @@ public: #endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(nullptr_t, size_t) = delete; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) - : __r_(__default_init_tag(), __default_init_tag()) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) { _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); __init(__s, __n); } @@ -1018,15 +1095,12 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); __init(__s, __n); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c) - : __r_(__default_init_tag(), __default_init_tag()) { - __init(__n, __c); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c) { __init(__n, __c); } #if _LIBCPP_STD_VER >= 23 _LIBCPP_HIDE_FROM_ABI constexpr basic_string( @@ -1035,7 +1109,7 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr basic_string( basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator()) - : __r_(__default_init_tag(), __alloc) { + : __alloc_(__alloc) { if (__pos > __str.size()) __throw_out_of_range(); @@ -1051,13 +1125,13 @@ public: template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { __init(__n, __c); } _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator()) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { size_type __str_sz = __str.size(); if (__pos > __str_sz) __throw_out_of_range(); @@ -1066,7 +1140,7 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator()) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { size_type __str_sz = __str.size(); if (__pos > __str_sz) __throw_out_of_range(); @@ -1079,7 +1153,7 @@ public: int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type()) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { __self_view __sv0 = __t; __self_view __sv = __sv0.substr(__pos, __n); __init(__sv.data(), __sv.size()); @@ -1089,8 +1163,8 @@ public: __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, int> = 0> - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) - : __r_(__default_init_tag(), __default_init_tag()) { + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS + _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) { __self_view __sv = __t; __init(__sv.data(), __sv.size()); } @@ -1101,21 +1175,20 @@ public: int> = 0> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { __self_view __sv = __t; __init(__sv.data(), __sv.size()); } template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last) - : __r_(__default_init_tag(), __default_init_tag()) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last) { __init(__first, __last); } template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { __init(__first, __last); } @@ -1123,7 +1196,7 @@ public: template <_ContainerCompatibleRange<_CharT> _Range> _LIBCPP_HIDE_FROM_ABI constexpr basic_string( from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { __init_with_size(ranges::begin(__range), ranges::end(__range), ranges::distance(__range)); } else { @@ -1133,13 +1206,12 @@ public: #endif #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il) - : __r_(__default_init_tag(), __default_init_tag()) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il) { __init(__il.begin(), __il.end()); } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il, const _Allocator& __a) - : __r_(__default_init_tag(), __a) { + : __alloc_(__a) { __init(__il.begin(), __il.end()); } #endif // _LIBCPP_CXX03_LANG @@ -1151,7 +1223,7 @@ public: } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator __self_view() const _NOEXCEPT { - return __self_view(data(), size()); + return __self_view(typename __self_view::__assume_valid(), data(), size()); } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string& @@ -1277,7 +1349,7 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT; - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { return size() == 0; } @@ -1423,8 +1495,8 @@ public: size_type __old_sz = __str.size(); if (!__str.__is_long()) __str.__annotate_delete(); - __r_.first() = __str.__r_.first(); - __str.__r_.first() = __rep(); + __rep_ = __str.__rep_; + __str.__rep_ = __rep(); __str.__annotate_new(0); _Traits::move(data(), data() + __pos, __len); @@ -1779,7 +1851,7 @@ public: #if _LIBCPP_STD_VER >= 20 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept { - return __self_view(data(), size()).starts_with(__sv); + return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv); } constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept { @@ -1791,7 +1863,7 @@ public: } constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept { - return __self_view(data(), size()).ends_with(__sv); + return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv); } constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept { @@ -1805,15 +1877,15 @@ public: #if _LIBCPP_STD_VER >= 20 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept { - return __self_view(data(), size()).contains(__sv); + return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv); } constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { - return __self_view(data(), size()).contains(__c); + return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__c); } constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { - return __self_view(data(), size()).contains(__s); + return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s); } #endif @@ -1831,10 +1903,10 @@ private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS bool __is_long() const _NOEXCEPT { - if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__r_.first().__l.__is_long_)) { - return __r_.first().__l.__is_long_; + if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__rep_.__l.__is_long_)) { + return __rep_.__l.__is_long_; } - return __r_.first().__s.__is_long_; + return __rep_.__s.__is_long_; } static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __begin_lifetime(pointer __begin, size_type __n) { @@ -1858,6 +1930,23 @@ private: template <class _Iterator, class _Sentinel> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last); + // Copy [__first, __last) into [__dest, __dest + (__last - __first)). Assumes that the ranges don't overlap. + template <class _ForwardIter, class _Sent> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static value_type* + __copy_non_overlapping_range(_ForwardIter __first, _Sent __last, value_type* __dest) { +#ifndef _LIBCPP_CXX03_LANG + if constexpr (__libcpp_is_contiguous_iterator<_ForwardIter>::value && + is_same<value_type, __iter_value_type<_ForwardIter>>::value && is_same<_ForwardIter, _Sent>::value) { + traits_type::copy(__dest, std::__to_address(__first), __last - __first); + return __dest + (__last - __first); + } +#endif + + for (; __first != __last; ++__first) + traits_type::assign(*__dest++, *__first); + return __dest; + } + template <class _ForwardIterator, class _Sentinel> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 iterator __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _Sentinel __last) { @@ -1877,8 +1966,7 @@ private: __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); - for (__p += __ip; __first != __last; ++__p, ++__first) - traits_type::assign(*__p, *__first); + __copy_non_overlapping_range(__first, __last, __p + __ip); return begin() + __ip; } @@ -1887,27 +1975,27 @@ private: _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __insert_with_size(const_iterator __pos, _Iterator __first, _Sentinel __last, size_type __n); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 allocator_type& __alloc() _NOEXCEPT { return __alloc_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __alloc_; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void __set_short_size(size_type __s) _NOEXCEPT { _LIBCPP_ASSERT_INTERNAL(__s < __min_cap, "__s should never be greater than or equal to the short string capacity"); - __r_.first().__s.__size_ = __s; - __r_.first().__s.__is_long_ = false; + __rep_.__s.__size_ = __s; + __rep_.__s.__is_long_ = false; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS size_type __get_short_size() const _NOEXCEPT { - _LIBCPP_ASSERT_INTERNAL(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size"); - return __r_.first().__s.__size_; + _LIBCPP_ASSERT_INTERNAL(!__rep_.__s.__is_long_, "String has to be short when trying to get the short size"); + return __rep_.__s.__size_; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_size(size_type __s) _NOEXCEPT { - __r_.first().__l.__size_ = __s; + __rep_.__l.__size_ = __s; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_size() const _NOEXCEPT { - return __r_.first().__l.__size_; + return __rep_.__l.__size_; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_size(size_type __s) _NOEXCEPT { if (__is_long()) @@ -1917,31 +2005,36 @@ private: } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_cap(size_type __s) _NOEXCEPT { - __r_.first().__l.__cap_ = __s / __endian_factor; - __r_.first().__l.__is_long_ = true; + __rep_.__l.__cap_ = __s / __endian_factor; + __rep_.__l.__is_long_ = true; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_cap() const _NOEXCEPT { - return __r_.first().__l.__cap_ * __endian_factor; + return __rep_.__l.__cap_ * __endian_factor; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_pointer(pointer __p) _NOEXCEPT { - __r_.first().__l.__data_ = __p; + __rep_.__l.__data_ = __p; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT { - return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_); + return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_long_pointer() const _NOEXCEPT { - return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_); + return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS pointer __get_short_pointer() _NOEXCEPT { - return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0])); + return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__rep_.__s.__data_[0])); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS const_pointer __get_short_pointer() const _NOEXCEPT { - return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0])); + return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__rep_.__s.__data_[0])); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_pointer() _NOEXCEPT { return __is_long() ? __get_long_pointer() : __get_short_pointer(); } @@ -1955,6 +2048,11 @@ private: (void)__old_mid; (void)__new_mid; #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +# if defined(__APPLE__) + // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099) + if (!__is_long()) + return; +# endif std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid); #endif } @@ -2165,11 +2263,11 @@ private: return std::__is_pointer_in_range(data(), data() + size() + 1, std::addressof(__v)); } - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { + [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("basic_string"); } - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { + [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("basic_string"); } @@ -2178,6 +2276,14 @@ private: friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&); friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*); friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type); +#if _LIBCPP_STD_VER >= 26 + friend constexpr basic_string operator+ <>(const basic_string&, type_identity_t<__self_view>); + friend constexpr basic_string operator+ <>(type_identity_t<__self_view>, const basic_string&); +#endif + + template <class _CharT2, class _Traits2, class _Allocator2> + friend inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool + operator==(const basic_string<_CharT2, _Traits2, _Allocator2>&, const _CharT2*) _NOEXCEPT; }; // These declarations must appear before any functions are implicitly used @@ -2233,7 +2339,7 @@ template <class _CharT, class _Traits, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) { if (__libcpp_is_constant_evaluated()) - __r_.first() = __rep(); + __rep_ = __rep(); if (__reserve > max_size()) __throw_length_error(); pointer __p; @@ -2257,7 +2363,7 @@ template <class _CharT, class _Traits, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) { if (__libcpp_is_constant_evaluated()) - __r_.first() = __rep(); + __rep_ = __rep(); if (__sz > max_size()) __throw_length_error(); pointer __p; @@ -2281,7 +2387,7 @@ template <class _CharT, class _Traits, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value_type* __s, size_type __sz) { if (__libcpp_is_constant_evaluated()) - __r_.first() = __rep(); + __rep_ = __rep(); pointer __p; if (__fits_in_sso(__sz)) { @@ -2304,7 +2410,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value template <class _CharT, class _Traits, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) { if (__libcpp_is_constant_evaluated()) - __r_.first() = __rep(); + __rep_ = __rep(); if (__n > max_size()) __throw_length_error(); @@ -2336,7 +2442,7 @@ template <class _CharT, class _Traits, class _Allocator> template <class _InputIterator, class _Sentinel> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator __first, _Sentinel __last) { - __r_.first() = __rep(); + __rep_ = __rep(); __annotate_new(0); #ifndef _LIBCPP_HAS_NO_EXCEPTIONS @@ -2367,7 +2473,7 @@ template <class _InputIterator, class _Sentinel> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz) { if (__libcpp_is_constant_evaluated()) - __r_.first() = __rep(); + __rep_ = __rep(); if (__sz > max_size()) __throw_length_error(); @@ -2389,9 +2495,8 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif // _LIBCPP_HAS_NO_EXCEPTIONS - for (; __first != __last; ++__first, (void)++__p) - traits_type::assign(*__p, *__first); - traits_type::assign(*__p, value_type()); + auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__p)); + traits_type::assign(*__end, value_type()); #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { if (__is_long()) @@ -2588,7 +2693,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) size_type __old_size = __get_short_size(); if (__get_short_size() < __str.__get_short_size()) __annotate_increase(__str.__get_short_size() - __get_short_size()); - __r_.first() = __str.__r_.first(); + __rep_ = __str.__rep_; if (__old_size > __get_short_size()) __annotate_shrink(__old_size); } else { @@ -2636,11 +2741,11 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr bool __str_was_short = !__str.__is_long(); __move_assign_alloc(__str); - __r_.first() = __str.__r_.first(); + __rep_ = __str.__rep_; __str.__set_short_size(0); traits_type::assign(__str.__get_short_pointer()[0], value_type()); - if (__str_was_short && this != &__str) + if (__str_was_short && this != std::addressof(__str)) __str.__annotate_shrink(__str_old_size); else // ASan annotations: was long, so object memory is unpoisoned as new. @@ -2654,7 +2759,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr // invariants hold (so functions without preconditions, such as the assignment operator, // can be safely used on the object after it was moved from):" // Quote: "v = std::move(v); // the value of v is unspecified" - if (!__is_long() && &__str != this) + if (!__is_long() && std::addressof(__str) != this) // If it is long string, delete was never called on original __str's buffer. __annotate_new(__get_short_size()); } @@ -2857,10 +2962,8 @@ basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _For if (__cap - __sz < __n) __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0); __annotate_increase(__n); - pointer __p = __get_pointer() + __sz; - for (; __first != __last; ++__p, (void)++__first) - traits_type::assign(*__p, *__first); - traits_type::assign(*__p, value_type()); + auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz)); + traits_type::assign(*__end, value_type()); __set_size(__sz + __n); } else { const basic_string __temp(__first, __last, __alloc()); @@ -3293,23 +3396,34 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target __p = __get_long_pointer(); } else { if (__target_capacity > __cap) { + // Extend + // - called from reserve should propagate the exception thrown. auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); __new_data = __allocation.ptr; __target_capacity = __allocation.count - 1; } else { + // Shrink + // - called from shrink_to_fit should not throw. + // - called from reserve may throw but is not required to. #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif // _LIBCPP_HAS_NO_EXCEPTIONS auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); + + // The Standard mandates shrink_to_fit() does not increase the capacity. + // With equal capacity keep the existing buffer. This avoids extra work + // due to swapping the elements. + if (__allocation.count - 1 > __target_capacity) { + __alloc_traits::deallocate(__alloc(), __allocation.ptr, __allocation.count); + __annotate_new(__sz); // Undoes the __annotate_delete() + return; + } __new_data = __allocation.ptr; __target_capacity = __allocation.count - 1; #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { return; } -#else // _LIBCPP_HAS_NO_EXCEPTIONS - if (__new_data == nullptr) - return; #endif // _LIBCPP_HAS_NO_EXCEPTIONS } __begin_lifetime(__new_data, __target_capacity + 1); @@ -3370,26 +3484,18 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat "swapping non-equal allocators"); if (!__is_long()) __annotate_delete(); - if (this != &__str && !__str.__is_long()) + if (this != std::addressof(__str) && !__str.__is_long()) __str.__annotate_delete(); - std::swap(__r_.first(), __str.__r_.first()); + std::swap(__rep_, __str.__rep_); std::__swap_allocator(__alloc(), __str.__alloc()); if (!__is_long()) __annotate_new(__get_short_size()); - if (this != &__str && !__str.__is_long()) + if (this != std::addressof(__str) && !__str.__is_long()) __str.__annotate_new(__str.__get_short_size()); } // find -template <class _Traits> -struct _LIBCPP_HIDDEN __traits_eq { - typedef typename _Traits::char_type char_type; - _LIBCPP_HIDE_FROM_ABI bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT { - return _Traits::eq(__x, __y); - } -}; - template <class _CharT, class _Traits, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { @@ -3735,7 +3841,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat if (__is_long()) { __annotate_delete(); __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1); - __r_.first() = __rep(); + __rep_ = __rep(); } } @@ -3779,16 +3885,18 @@ operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& template <class _CharT, class _Traits, class _Allocator> inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { -#if _LIBCPP_STD_VER >= 20 - return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs); -#else - typedef basic_string<_CharT, _Traits, _Allocator> _String; _LIBCPP_ASSERT_NON_NULL(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); + + using _String = basic_string<_CharT, _Traits, _Allocator>; + size_t __rhs_len = _Traits::length(__rhs); + if (__builtin_constant_p(__rhs_len) && !_String::__fits_in_sso(__rhs_len)) { + if (!__lhs.__is_long()) + return false; + } if (__rhs_len != __lhs.size()) return false; return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; -#endif } #if _LIBCPP_STD_VER >= 20 @@ -4035,6 +4143,60 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { #endif // _LIBCPP_CXX03_LANG +#if _LIBCPP_STD_VER >= 26 + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> +operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, + type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) { + using _String = basic_string<_CharT, _Traits, _Allocator>; + typename _String::size_type __lhs_sz = __lhs.size(); + typename _String::size_type __rhs_sz = __rhs.size(); + _String __r(__uninitialized_size_tag(), + __lhs_sz + __rhs_sz, + _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); + auto __ptr = std::__to_address(__r.__get_pointer()); + _Traits::copy(__ptr, __lhs.data(), __lhs_sz); + _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); + _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); + return __r; +} + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> +operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, + type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) { + __lhs.append(__rhs); + return std::move(__lhs); +} + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> +operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, + const basic_string<_CharT, _Traits, _Allocator>& __rhs) { + using _String = basic_string<_CharT, _Traits, _Allocator>; + typename _String::size_type __lhs_sz = __lhs.size(); + typename _String::size_type __rhs_sz = __rhs.size(); + _String __r(__uninitialized_size_tag(), + __lhs_sz + __rhs_sz, + _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); + auto __ptr = std::__to_address(__r.__get_pointer()); + _Traits::copy(__ptr, __lhs.data(), __lhs_sz); + _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); + _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); + return __r; +} + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> +operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, + basic_string<_CharT, _Traits, _Allocator>&& __rhs) { + __rhs.insert(0, __lhs); + return std::move(__rhs); +} + +#endif // _LIBCPP_STD_VER >= 26 + // swap template <class _CharT, class _Traits, class _Allocator> diff --git a/contrib/libs/cxxsupp/libcxx/include/string_view b/contrib/libs/cxxsupp/libcxx/include/string_view index 058ca72184..69854c1706 100644 --- a/contrib/libs/cxxsupp/libcxx/include/string_view +++ b/contrib/libs/cxxsupp/libcxx/include/string_view @@ -210,6 +210,8 @@ namespace std { #include <__config> #include <__functional/hash.h> #include <__functional/unary_function.h> +#include <__fwd/ostream.h> +#include <__fwd/string.h> #include <__fwd/string_view.h> #include <__iterator/bounded_iter.h> #include <__iterator/concepts.h> @@ -396,7 +398,7 @@ public: return numeric_limits<size_type>::max() / sizeof(value_type); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; } // [string.view.access], element access _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __pos) const _NOEXCEPT { @@ -449,8 +451,11 @@ public: } _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view substr(size_type __pos = 0, size_type __n = npos) const { + // Use the `__assume_valid` form of the constructor to avoid an unnecessary check. Any substring of a view is a + // valid view. In particular, `size()` is known to be smaller than `numeric_limits<difference_type>::max()`, so the + // new size is also smaller. See also https://github.com/llvm/llvm-project/issues/91634. return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view()) - : basic_string_view(data() + __pos, std::min(__n, size() - __pos)); + : basic_string_view(__assume_valid(), data() + __pos, std::min(__n, size() - __pos)); } _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT { @@ -675,8 +680,21 @@ public: #endif private: + struct __assume_valid {}; + + // This is the same as the pointer and length constructor, but without the additional hardening checks. It is intended + // for use within the class, when the class invariants already guarantee the resulting object is valid. The compiler + // usually cannot eliminate the redundant checks because it does not know class invariants. + _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI + basic_string_view(__assume_valid, const _CharT* __s, size_type __len) _NOEXCEPT + : __data_(__s), + __size_(__len) {} + const value_type* __data_; size_type __size_; + + template <class, class, class> + friend class basic_string; }; _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view); diff --git a/contrib/libs/cxxsupp/libcxx/include/syncstream b/contrib/libs/cxxsupp/libcxx/include/syncstream index e6f35b6f42..a2e1c7edad 100644 --- a/contrib/libs/cxxsupp/libcxx/include/syncstream +++ b/contrib/libs/cxxsupp/libcxx/include/syncstream @@ -46,7 +46,9 @@ namespace std { using streambuf_type = basic_streambuf<charT, traits>; // [syncstream.syncbuf.cons], construction and destruction - explicit basic_syncbuf(streambuf_type* obuf = nullptr) + basic_syncbuf() + : basic_syncbuf(nullptr) {} + explicit basic_syncbuf(streambuf_type* obuf) : basic_syncbuf(obuf, Allocator()) {} basic_syncbuf(streambuf_type*, const Allocator&); basic_syncbuf(basic_syncbuf&&); @@ -116,33 +118,36 @@ namespace std { */ #include <__config> -#include <__utility/move.h> -#include <ios> -#include <iosfwd> // required for declaration of default arguments -#include <streambuf> -#include <string> - -#ifndef _LIBCPP_HAS_NO_THREADS -# include <map> -# include <mutex> -# include <shared_mutex> -#endif + +#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__utility/move.h> +# include <ios> +# include <iosfwd> // required for declaration of default arguments +# include <streambuf> +# include <string> + +# ifndef _LIBCPP_HAS_NO_THREADS +# include <map> +# include <mutex> +# include <shared_mutex> +# endif // standard-mandated includes // [syncstream.syn] -#include <ostream> +# include <ostream> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) +# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) // [syncstream.syncbuf.overview]/1 // Class template basic_syncbuf stores character data written to it, @@ -155,7 +160,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // // This helper singleton is used to implement the required // synchronisation guarantees. -# ifndef _LIBCPP_HAS_NO_THREADS +# ifndef _LIBCPP_HAS_NO_THREADS class __wrapped_streambuf_mutex { _LIBCPP_HIDE_FROM_ABI __wrapped_streambuf_mutex() = default; @@ -228,7 +233,7 @@ private: return __it; } }; -# endif // _LIBCPP_HAS_NO_THREADS +# endif // _LIBCPP_HAS_NO_THREADS // basic_syncbuf @@ -253,8 +258,9 @@ public: // [syncstream.syncbuf.cons], construction and destruction - _LIBCPP_HIDE_FROM_ABI explicit basic_syncbuf(streambuf_type* __obuf = nullptr) - : basic_syncbuf(__obuf, _Allocator()) {} + _LIBCPP_HIDE_FROM_ABI basic_syncbuf() : basic_syncbuf(nullptr) {} + + _LIBCPP_HIDE_FROM_ABI explicit basic_syncbuf(streambuf_type* __obuf) : basic_syncbuf(__obuf, _Allocator()) {} _LIBCPP_HIDE_FROM_ABI basic_syncbuf(streambuf_type* __obuf, _Allocator const& __alloc) : __wrapped_(__obuf), __str_(__alloc) { @@ -267,14 +273,14 @@ public: } _LIBCPP_HIDE_FROM_ABI ~basic_syncbuf() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS emit(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_NO_EXCEPTIONS __dec_reference(); } @@ -331,9 +337,9 @@ protected: return traits_type::not_eof(__c); if (this->pptr() == this->epptr()) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -# endif +# endif size_t __size = __str_.size(); __str_.resize(__str_.capacity() + 1); _LIBCPP_ASSERT_INTERNAL(__str_.size() > __size, "the buffer hasn't grown"); @@ -342,11 +348,11 @@ protected: this->setp(__p, __p + __str_.size()); this->pbump(__size); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { return traits_type::eof(); } -# endif +# endif } return this->sputc(traits_type::to_char_type(__c)); @@ -358,7 +364,7 @@ private: // TODO Use a more generic buffer. // That buffer should be light with almost no additional headers. Then // it can be use here, the __retarget_buffer, and place that use - // the now deprecated get_temporary_buffer + // the now removed get_temporary_buffer basic_string<_CharT, _Traits, _Allocator> __str_; bool __emit_on_sync_{false}; @@ -367,9 +373,9 @@ private: if (!__wrapped_) return false; -# ifndef _LIBCPP_HAS_NO_THREADS +# ifndef _LIBCPP_HAS_NO_THREADS lock_guard<mutex> __lock = __wrapped_streambuf_mutex::__instance().__get_lock(__wrapped_); -# endif +# endif bool __result = true; if (this->pptr() != this->pbase()) { @@ -401,24 +407,24 @@ private: } _LIBCPP_HIDE_FROM_ABI void __inc_reference() { -# ifndef _LIBCPP_HAS_NO_THREADS +# ifndef _LIBCPP_HAS_NO_THREADS if (__wrapped_) __wrapped_streambuf_mutex::__instance().__inc_reference(__wrapped_); -# endif +# endif } _LIBCPP_HIDE_FROM_ABI void __dec_reference() noexcept { -# ifndef _LIBCPP_HAS_NO_THREADS +# ifndef _LIBCPP_HAS_NO_THREADS if (__wrapped_) __wrapped_streambuf_mutex::__instance().__dec_reference(__wrapped_); -# endif +# endif } }; using std::syncbuf; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wsyncbuf; -# endif +# endif // [syncstream.syncbuf.special], specialized algorithms template <class _CharT, class _Traits, class _Allocator> @@ -474,17 +480,17 @@ public: // TODO validate other unformatted output functions. typename basic_ostream<char_type, traits_type>::sentry __s(*this); if (__s) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -# endif +# endif if (__sb_.emit() == false) this->setstate(ios::badbit); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif +# endif } } @@ -499,14 +505,16 @@ private: }; using std::osyncstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wosyncstream; -# endif +# endif -#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) +# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS +#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) + #endif // _LIBCPP_SYNCSTREAM diff --git a/contrib/libs/cxxsupp/libcxx/include/thread b/contrib/libs/cxxsupp/libcxx/include/thread index 68ce63bd01..25cb7ce6d7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/thread +++ b/contrib/libs/cxxsupp/libcxx/include/thread @@ -88,25 +88,25 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time); #include <__config> -#ifdef _LIBCPP_HAS_NO_THREADS -# error "<thread> is not supported since libc++ has been configured without support for threads." -#endif +#if !defined(_LIBCPP_HAS_NO_THREADS) -#include <__thread/formatter.h> -#include <__thread/jthread.h> -#include <__thread/support.h> -#include <__thread/this_thread.h> -#include <__thread/thread.h> -#include <version> +# include <__thread/formatter.h> +# include <__thread/jthread.h> +# include <__thread/support.h> +# include <__thread/this_thread.h> +# include <__thread/thread.h> +# include <version> // standard-mandated includes // [thread.syn] -#include <compare> +# include <compare> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +#endif // !defined(_LIBCPP_HAS_NO_THREADS) #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) # include <cstddef> diff --git a/contrib/libs/cxxsupp/libcxx/include/tuple b/contrib/libs/cxxsupp/libcxx/include/tuple index 9caeaaf926..ab90d2bf5e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/tuple +++ b/contrib/libs/cxxsupp/libcxx/include/tuple @@ -132,7 +132,12 @@ tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++ template <class Alloc, class ...T> tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17 -inline constexpr unspecified ignore; +struct ignore-type { // exposition only // Since C++26 + constexpr const ignore-type& + operator=(const auto &) const noexcept + { return *this; } +}; +inline constexpr ignore-type ignore; template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14 template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14 @@ -206,15 +211,16 @@ template <class... Types> // clang-format on #include <__compare/common_comparison_category.h> +#include <__compare/ordering.h> #include <__compare/synth_three_way.h> #include <__config> -#include <__functional/invoke.h> #include <__fwd/array.h> #include <__fwd/pair.h> #include <__fwd/tuple.h> #include <__memory/allocator_arg_t.h> #include <__memory/uses_allocator.h> #include <__tuple/find_index.h> +#include <__tuple/ignore.h> #include <__tuple/make_tuple_types.h> #include <__tuple/sfinae_helpers.h> #include <__tuple/tuple_element.h> @@ -228,6 +234,8 @@ template <class... Types> #include <__type_traits/conjunction.h> #include <__type_traits/copy_cvref.h> #include <__type_traits/disjunction.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_arithmetic.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_constructible.h> @@ -248,6 +256,7 @@ template <class... Types> #include <__type_traits/remove_cvref.h> #include <__type_traits/remove_reference.h> #include <__type_traits/unwrap_ref.h> +#include <__utility/declval.h> #include <__utility/forward.h> #include <__utility/integer_sequence.h> #include <__utility/move.h> @@ -835,8 +844,8 @@ public: // [tuple.assign] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& - operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) - noexcept(_And<is_nothrow_copy_assignable<_Tp>...>::value) { + operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) noexcept( + _And<is_nothrow_copy_assignable<_Tp>...>::value) { std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); return *this; } @@ -859,8 +868,8 @@ public: # endif // _LIBCPP_STD_VER >= 23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& - operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) - noexcept(_And<is_nothrow_move_assignable<_Tp>...>::value) { + operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) noexcept( + _And<is_nothrow_move_assignable<_Tp>...>::value) { std::__memberwise_forward_assign( *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); return *this; @@ -870,8 +879,8 @@ public: class... _Up, __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...> const& __tuple) - noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& + operator=(tuple<_Up...> const& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); return *this; } @@ -879,8 +888,8 @@ public: template <class... _Up, __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up>... >::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...>&& __tuple) - noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& + operator=(tuple<_Up...>&& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { std::__memberwise_forward_assign( *this, std::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); return *this; @@ -944,16 +953,16 @@ public: template <class _Up1, class _Up2, __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2> const& __pair) - noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& + operator=(pair<_Up1, _Up2> const& __pair) noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value) { std::get<0>(*this) = __pair.first; std::get<1>(*this) = __pair.second; return *this; } template <class _Up1, class _Up2, __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2>&& __pair) - noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& + operator=(pair<_Up1, _Up2>&& __pair) noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value) { std::get<0>(*this) = std::forward<_Up1>(__pair.first); std::get<1>(*this) = std::forward<_Up2>(__pair.second); return *this; @@ -964,8 +973,8 @@ public: class _Up, size_t _Np, __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np> const& __array) - noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& + operator=(array<_Up, _Np> const& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { std::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices<sizeof...(_Tp)>::type()); return *this; } @@ -975,8 +984,8 @@ public: size_t _Np, class = void, __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up>... >::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np>&& __array) - noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& + operator=(array<_Up, _Np>&& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { std::__memberwise_forward_assign( *this, std::move(__array), @@ -986,8 +995,8 @@ public: } // [tuple.swap] - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple& __t) - noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void + swap(tuple& __t) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { __base_.swap(__t.__base_); } @@ -1045,8 +1054,8 @@ tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>; # endif template <class... _Tp, __enable_if_t<__all<__is_swappable_v<_Tp>...>::value, int> = 0> -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) - noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void +swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { __t.swap(__u); } @@ -1120,22 +1129,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_T return tuple<_Tp&...>(__t...); } -template <class _Up> -struct __ignore_t { - template <class _Tp> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const __ignore_t& operator=(_Tp&&) const { - return *this; - } -}; - -# if _LIBCPP_STD_VER >= 17 -inline constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); -# else -namespace { -constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); -} // namespace -# endif - template <class... _Tp> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<typename __unwrap_ref_decay<_Tp>::type...> make_tuple(_Tp&&... __t) { diff --git a/contrib/libs/cxxsupp/libcxx/include/type_traits b/contrib/libs/cxxsupp/libcxx/include/type_traits index aee9fcf413..26c85f2284 100644 --- a/contrib/libs/cxxsupp/libcxx/include/type_traits +++ b/contrib/libs/cxxsupp/libcxx/include/type_traits @@ -144,6 +144,7 @@ namespace std // Relationships between types: template <class T, class U> struct is_same; template <class Base, class Derived> struct is_base_of; + template <class Base, class Derived> struct is_virtual_base_of; // C++26 template <class From, class To> struct is_convertible; template <typename From, typename To> struct is_nothrow_convertible; // C++20 @@ -391,6 +392,8 @@ namespace std = is_same<T, U>::value; // C++17 template <class Base, class Derived> inline constexpr bool is_base_of_v = is_base_of<Base, Derived>::value; // C++17 + template <class Base, class Derived> inline constexpr bool is_virtual_base_of_v + = is_virtual_base_of<Base, Derived>::value; // C++26 template <class From, class To> inline constexpr bool is_convertible_v = is_convertible<From, To>::value; // C++17 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v @@ -418,7 +421,6 @@ namespace std */ #include <__config> -#include <__fwd/functional.h> // This is https://llvm.org/PR56938 #include <__type_traits/add_const.h> #include <__type_traits/add_cv.h> #include <__type_traits/add_lvalue_reference.h> @@ -428,99 +430,92 @@ namespace std #include <__type_traits/aligned_storage.h> #include <__type_traits/aligned_union.h> #include <__type_traits/alignment_of.h> -#include <__type_traits/can_extract_key.h> -#include <__type_traits/common_reference.h> #include <__type_traits/common_type.h> #include <__type_traits/conditional.h> -#include <__type_traits/conjunction.h> #include <__type_traits/decay.h> -#include <__type_traits/dependent_type.h> -#include <__type_traits/disjunction.h> #include <__type_traits/enable_if.h> #include <__type_traits/extent.h> -#include <__type_traits/has_unique_object_representation.h> #include <__type_traits/has_virtual_destructor.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/invoke.h> #include <__type_traits/is_abstract.h> -#include <__type_traits/is_aggregate.h> #include <__type_traits/is_arithmetic.h> #include <__type_traits/is_array.h> #include <__type_traits/is_assignable.h> #include <__type_traits/is_base_of.h> -#include <__type_traits/is_bounded_array.h> -#include <__type_traits/is_callable.h> -#include <__type_traits/is_char_like_type.h> #include <__type_traits/is_class.h> #include <__type_traits/is_compound.h> #include <__type_traits/is_const.h> -#include <__type_traits/is_constant_evaluated.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_convertible.h> #include <__type_traits/is_destructible.h> #include <__type_traits/is_empty.h> #include <__type_traits/is_enum.h> -#include <__type_traits/is_final.h> #include <__type_traits/is_floating_point.h> #include <__type_traits/is_function.h> #include <__type_traits/is_fundamental.h> -#include <__type_traits/is_implicitly_default_constructible.h> #include <__type_traits/is_integral.h> #include <__type_traits/is_literal_type.h> -#include <__type_traits/is_member_function_pointer.h> -#include <__type_traits/is_member_object_pointer.h> #include <__type_traits/is_member_pointer.h> #include <__type_traits/is_nothrow_assignable.h> #include <__type_traits/is_nothrow_constructible.h> -#include <__type_traits/is_nothrow_convertible.h> #include <__type_traits/is_nothrow_destructible.h> -#include <__type_traits/is_null_pointer.h> #include <__type_traits/is_object.h> #include <__type_traits/is_pod.h> #include <__type_traits/is_pointer.h> #include <__type_traits/is_polymorphic.h> #include <__type_traits/is_reference.h> -#include <__type_traits/is_reference_wrapper.h> -#include <__type_traits/is_referenceable.h> #include <__type_traits/is_same.h> #include <__type_traits/is_scalar.h> -#include <__type_traits/is_scoped_enum.h> #include <__type_traits/is_signed.h> -#include <__type_traits/is_specialization.h> #include <__type_traits/is_standard_layout.h> -#include <__type_traits/is_swappable.h> #include <__type_traits/is_trivial.h> #include <__type_traits/is_trivially_assignable.h> #include <__type_traits/is_trivially_constructible.h> #include <__type_traits/is_trivially_copyable.h> #include <__type_traits/is_trivially_destructible.h> -#include <__type_traits/is_unbounded_array.h> #include <__type_traits/is_union.h> #include <__type_traits/is_unsigned.h> #include <__type_traits/is_void.h> #include <__type_traits/is_volatile.h> -#include <__type_traits/make_const_lvalue_ref.h> #include <__type_traits/make_signed.h> #include <__type_traits/make_unsigned.h> -#include <__type_traits/maybe_const.h> -#include <__type_traits/negation.h> #include <__type_traits/rank.h> #include <__type_traits/remove_all_extents.h> #include <__type_traits/remove_const.h> -#include <__type_traits/remove_const_ref.h> #include <__type_traits/remove_cv.h> #include <__type_traits/remove_extent.h> #include <__type_traits/remove_pointer.h> #include <__type_traits/remove_reference.h> #include <__type_traits/remove_volatile.h> #include <__type_traits/result_of.h> -#include <__type_traits/type_identity.h> #include <__type_traits/underlying_type.h> -#include <__type_traits/unwrap_ref.h> -#include <__type_traits/void_t.h> -#include <__utility/declval.h> -#include <cstddef> -#include <cstdint> + +#if _LIBCPP_STD_VER >= 14 +# include <__type_traits/is_final.h> +# include <__type_traits/is_null_pointer.h> +#endif + +#if _LIBCPP_STD_VER >= 17 +# include <__type_traits/conjunction.h> +# include <__type_traits/disjunction.h> +# include <__type_traits/has_unique_object_representation.h> +# include <__type_traits/invoke.h> +# include <__type_traits/is_aggregate.h> +# include <__type_traits/is_swappable.h> +# include <__type_traits/negation.h> +# include <__type_traits/void_t.h> +#endif + +#if _LIBCPP_STD_VER >= 20 +# include <__type_traits/common_reference.h> +# include <__type_traits/is_bounded_array.h> +# include <__type_traits/is_constant_evaluated.h> +# include <__type_traits/is_nothrow_convertible.h> +# include <__type_traits/is_unbounded_array.h> +# include <__type_traits/type_identity.h> +# include <__type_traits/unwrap_ref.h> +#endif + #include <version> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/contrib/libs/cxxsupp/libcxx/include/typeinfo b/contrib/libs/cxxsupp/libcxx/include/typeinfo index 266ae9550e..3808966b11 100644 --- a/contrib/libs/cxxsupp/libcxx/include/typeinfo +++ b/contrib/libs/cxxsupp/libcxx/include/typeinfo @@ -58,6 +58,7 @@ public: #include <__config> #include <__exception/exception.h> +#include <__type_traits/integral_constant.h> #include <__type_traits/is_constant_evaluated.h> #include <__verbose_abort> #include <cstddef> @@ -281,13 +282,14 @@ struct __type_info_implementations { __impl; }; -# if defined(__arm64__) && __has_cpp_attribute(clang::ptrauth_vtable_pointer) -# if __has_feature(ptrauth_type_info_discriminated_vtable_pointer) +# if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__) +# if __has_feature(ptrauth_type_info_vtable_pointer_discrimination) # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \ - [[clang::ptrauth_vtable_pointer(process_independent, address_discrimination, type_discrimination)]] + [[_Clang::__ptrauth_vtable_pointer__(process_independent, address_discrimination, type_discrimination)]] # else # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \ - [[clang::ptrauth_vtable_pointer(process_independent, no_address_discrimination, no_extra_discrimination)]] + [[_Clang::__ptrauth_vtable_pointer__( \ + process_independent, no_address_discrimination, no_extra_discrimination)]] # endif # else # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH @@ -393,7 +395,7 @@ private: #endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0 _LIBCPP_BEGIN_NAMESPACE_STD -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_cast() { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_cast() { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw bad_cast(); #else diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_map b/contrib/libs/cxxsupp/libcxx/include/unordered_map index 7c31c4fce2..0d71a51ee9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/unordered_map +++ b/contrib/libs/cxxsupp/libcxx/include/unordered_map @@ -586,6 +586,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc> #include <__algorithm/is_permutation.h> #include <__assert> #include <__config> +#include <__functional/hash.h> #include <__functional/is_transparent.h> #include <__functional/operations.h> #include <__hash_table> @@ -595,14 +596,22 @@ template <class Key, class T, class Hash, class Pred, class Alloc> #include <__iterator/ranges_iterator_traits.h> #include <__memory/addressof.h> #include <__memory/allocator.h> +#include <__memory/allocator_traits.h> +#include <__memory/pointer_traits.h> +#include <__memory/unique_ptr.h> #include <__memory_resource/polymorphic_allocator.h> #include <__node_handle> #include <__ranges/concepts.h> #include <__ranges/container_compatible_range.h> #include <__ranges/from_range.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_allocator.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/remove_const.h> #include <__type_traits/type_identity.h> #include <__utility/forward.h> +#include <__utility/pair.h> +#include <new> // launder #include <stdexcept> #include <tuple> #include <version> @@ -1202,7 +1211,7 @@ public: return allocator_type(__table_.__node_alloc()); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } @@ -2001,7 +2010,7 @@ public: return allocator_type(__table_.__node_alloc()); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } @@ -2532,6 +2541,7 @@ _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <algorithm> # include <bit> +# include <cmath> # include <concepts> # include <cstdlib> # include <iterator> diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_set b/contrib/libs/cxxsupp/libcxx/include/unordered_set index 3297294a89..2b09c72b86 100644 --- a/contrib/libs/cxxsupp/libcxx/include/unordered_set +++ b/contrib/libs/cxxsupp/libcxx/include/unordered_set @@ -534,6 +534,7 @@ template <class Value, class Hash, class Pred, class Alloc> #include <__algorithm/is_permutation.h> #include <__assert> #include <__config> +#include <__functional/hash.h> #include <__functional/is_transparent.h> #include <__functional/operations.h> #include <__hash_table> @@ -543,13 +544,23 @@ template <class Value, class Hash, class Pred, class Alloc> #include <__iterator/ranges_iterator_traits.h> #include <__memory/addressof.h> #include <__memory/allocator.h> +#include <__memory/allocator_traits.h> #include <__memory_resource/polymorphic_allocator.h> #include <__node_handle> #include <__ranges/concepts.h> #include <__ranges/container_compatible_range.h> #include <__ranges/from_range.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_allocator.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/is_nothrow_assignable.h> +#include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/is_same.h> +#include <__type_traits/is_swappable.h> +#include <__type_traits/type_identity.h> #include <__utility/forward.h> +#include <__utility/move.h> +#include <__utility/pair.h> #include <version> // standard-mandated includes @@ -731,7 +742,7 @@ public: return allocator_type(__table_.__node_alloc()); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } @@ -1325,7 +1336,7 @@ public: return allocator_type(__table_.__node_alloc()); } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } @@ -1800,6 +1811,7 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include <cmath> # include <concepts> # include <cstdlib> # include <functional> diff --git a/contrib/libs/cxxsupp/libcxx/include/utility b/contrib/libs/cxxsupp/libcxx/include/utility index 90713da621..f97907fbf7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/utility +++ b/contrib/libs/cxxsupp/libcxx/include/utility @@ -247,25 +247,35 @@ template <class T> */ #include <__config> -#include <__utility/as_const.h> -#include <__utility/as_lvalue.h> -#include <__utility/auto_cast.h> -#include <__utility/cmp.h> + #include <__utility/declval.h> -#include <__utility/exception_guard.h> -#include <__utility/exchange.h> #include <__utility/forward.h> -#include <__utility/forward_like.h> -#include <__utility/in_place.h> -#include <__utility/integer_sequence.h> #include <__utility/move.h> #include <__utility/pair.h> #include <__utility/piecewise_construct.h> -#include <__utility/priority_tag.h> #include <__utility/rel_ops.h> #include <__utility/swap.h> -#include <__utility/to_underlying.h> -#include <__utility/unreachable.h> + +#if _LIBCPP_STD_VER >= 14 +# include <__utility/exchange.h> +# include <__utility/integer_sequence.h> +#endif + +#if _LIBCPP_STD_VER >= 17 +# include <__utility/as_const.h> +# include <__utility/in_place.h> +#endif + +#if _LIBCPP_STD_VER >= 20 +# include <__utility/cmp.h> +#endif + +#if _LIBCPP_STD_VER >= 23 +# include <__utility/forward_like.h> +# include <__utility/to_underlying.h> +# include <__utility/unreachable.h> +#endif + #include <version> // standard-mandated includes @@ -274,6 +284,10 @@ template <class T> #include <compare> #include <initializer_list> +// [tuple.creation] + +#include <__tuple/ignore.h> + // [tuple.helper] #include <__tuple/tuple_element.h> #include <__tuple/tuple_size.h> @@ -283,6 +297,10 @@ template <class T> #endif #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include <limits> +#endif + +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <cstdlib> # include <iosfwd> # include <type_traits> diff --git a/contrib/libs/cxxsupp/libcxx/include/variant b/contrib/libs/cxxsupp/libcxx/include/variant index 5f2d03b722..fd3aebaea0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/variant +++ b/contrib/libs/cxxsupp/libcxx/include/variant @@ -214,13 +214,14 @@ namespace std { #include <__compare/common_comparison_category.h> #include <__compare/compare_three_way_result.h> +#include <__compare/ordering.h> #include <__compare/three_way_comparable.h> #include <__config> #include <__exception/exception.h> #include <__functional/hash.h> -#include <__functional/invoke.h> #include <__functional/operations.h> #include <__functional/unary_function.h> +#include <__fwd/variant.h> #include <__memory/addressof.h> #include <__memory/construct_at.h> #include <__tuple/find_index.h> @@ -230,14 +231,21 @@ namespace std { #include <__type_traits/add_pointer.h> #include <__type_traits/add_volatile.h> #include <__type_traits/common_type.h> +#include <__type_traits/conditional.h> #include <__type_traits/conjunction.h> +#include <__type_traits/decay.h> #include <__type_traits/dependent_type.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/invoke.h> #include <__type_traits/is_array.h> +#include <__type_traits/is_assignable.h> #include <__type_traits/is_constructible.h> +#include <__type_traits/is_convertible.h> #include <__type_traits/is_destructible.h> #include <__type_traits/is_nothrow_assignable.h> #include <__type_traits/is_nothrow_constructible.h> #include <__type_traits/is_reference.h> +#include <__type_traits/is_swappable.h> #include <__type_traits/is_trivially_assignable.h> #include <__type_traits/is_trivially_constructible.h> #include <__type_traits/is_trivially_destructible.h> @@ -245,6 +253,7 @@ namespace std { #include <__type_traits/is_void.h> #include <__type_traits/remove_const.h> #include <__type_traits/remove_cvref.h> +#include <__type_traits/remove_reference.h> #include <__type_traits/type_identity.h> #include <__type_traits/void_t.h> #include <__utility/declval.h> @@ -296,7 +305,7 @@ struct __farray { _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; } }; -_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void +[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void __throw_bad_variant_access() { # ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw bad_variant_access(); @@ -305,15 +314,7 @@ __throw_bad_variant_access() { # endif } -template <class... _Types> -class _LIBCPP_TEMPLATE_VIS variant; - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS variant_size; - -template <class _Tp> -inline constexpr size_t variant_size_v = variant_size<_Tp>::value; - +// variant_size template <class _Tp> struct _LIBCPP_TEMPLATE_VIS variant_size<const _Tp> : variant_size<_Tp> {}; @@ -326,12 +327,7 @@ struct _LIBCPP_TEMPLATE_VIS variant_size<const volatile _Tp> : variant_size<_Tp> template <class... _Types> struct _LIBCPP_TEMPLATE_VIS variant_size<variant<_Types...>> : integral_constant<size_t, sizeof...(_Types)> {}; -template <size_t _Ip, class _Tp> -struct _LIBCPP_TEMPLATE_VIS variant_alternative; - -template <size_t _Ip, class _Tp> -using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type; - +// variant_alternative template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const _Tp> : add_const<variant_alternative_t<_Ip, _Tp>> {}; @@ -347,8 +343,6 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> { using type = __type_pack_element<_Ip, _Types...>; }; -inline constexpr size_t variant_npos = static_cast<size_t>(-1); - template <size_t _NumAlternatives> _LIBCPP_HIDE_FROM_ABI constexpr auto __choose_index_type() { # ifdef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION @@ -368,9 +362,6 @@ template <class _IndexType> constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1); template <class... _Types> -class _LIBCPP_TEMPLATE_VIS variant; - -template <class... _Types> _LIBCPP_HIDE_FROM_ABI constexpr variant<_Types...>& __as_variant(variant<_Types...>& __vs) noexcept { return __vs; } diff --git a/contrib/libs/cxxsupp/libcxx/include/vector b/contrib/libs/cxxsupp/libcxx/include/vector index 2f714f1ec8..fd58458edb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/vector +++ b/contrib/libs/cxxsupp/libcxx/include/vector @@ -170,7 +170,7 @@ public: vector() noexcept(is_nothrow_default_constructible<allocator_type>::value); - explicit vector(const allocator_type&); + explicit vector(const allocator_type&) noexcept; explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14 vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); template <class InputIterator> @@ -178,8 +178,7 @@ public: template<container-compatible-range<bool> R> constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator()); vector(const vector& x); - vector(vector&& x) - noexcept(is_nothrow_move_constructible<allocator_type>::value); + vector(vector&& x) noexcept; vector(initializer_list<value_type> il); vector(initializer_list<value_type> il, const allocator_type& a); ~vector(); @@ -311,6 +310,10 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ #include <__algorithm/iterator_operations.h> #include <__algorithm/lexicographical_compare.h> #include <__algorithm/lexicographical_compare_three_way.h> +#include <__algorithm/max.h> +#include <__algorithm/min.h> +#include <__algorithm/move.h> +#include <__algorithm/move_backward.h> #include <__algorithm/remove.h> #include <__algorithm/remove_if.h> #include <__algorithm/rotate.h> @@ -327,13 +330,20 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ #include <__functional/unary_function.h> #include <__fwd/vector.h> #include <__iterator/advance.h> +#include <__iterator/bounded_iter.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> +#include <__iterator/move_iterator.h> +#include <__iterator/next.h> #include <__iterator/reverse_iterator.h> #include <__iterator/wrap_iter.h> #include <__memory/addressof.h> #include <__memory/allocate_at_least.h> +#include <__memory/allocator.h> #include <__memory/allocator_traits.h> +#include <__memory/compressed_pair.h> +#include <__memory/construct_at.h> +#include <__memory/noexcept_move_assign_container.h> #include <__memory/pointer_traits.h> #include <__memory/swap_allocator.h> #include <__memory/temp_value.h> @@ -345,11 +355,15 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ #include <__ranges/from_range.h> #include <__ranges/size.h> #include <__split_buffer> +#include <__type_traits/conditional.h> +#include <__type_traits/enable_if.h> #include <__type_traits/is_allocator.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_nothrow_assignable.h> +#include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/is_same.h> #include <__type_traits/is_trivially_destructible.h> -#include <__type_traits/noexcept_move_assign_container.h> +#include <__type_traits/is_trivially_relocatable.h> #include <__type_traits/type_identity.h> #include <__utility/exception_guard.h> #include <__utility/forward.h> @@ -401,11 +415,16 @@ public: typedef typename __alloc_traits::difference_type difference_type; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; -#if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 1 +#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1 typedef pointer iterator; typedef const_pointer const_iterator; +#elif defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR) + // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's + // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is + // considered contiguous. + typedef __bounded_iter<__wrap_iter<pointer> > iterator; + typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator; #else - // TODO: Implement iterator bounds checking without requiring the global database. typedef __wrap_iter<pointer> iterator; typedef __wrap_iter<const_pointer> const_iterator; #endif @@ -431,9 +450,9 @@ public: #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) #else - _NOEXCEPT + noexcept #endif - : __end_cap_(nullptr, __a) { + : __alloc_(__a) { } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n) { @@ -447,7 +466,7 @@ public: #if _LIBCPP_STD_VER >= 14 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a) - : __end_cap_(nullptr, __a) { + : __alloc_(__a) { auto __guard = std::__make_exception_guard(__destroy_vector(*this)); if (__n > 0) { __vallocate(__n); @@ -469,7 +488,7 @@ public: template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x, const allocator_type& __a) - : __end_cap_(nullptr, __a) { + : __alloc_(__a) { if (__n > 0) { __vallocate(__n); __construct_at_end(__n, __x); @@ -507,7 +526,7 @@ public: template <_ContainerCompatibleRange<_Tp> _Range> _LIBCPP_HIDE_FROM_ABI constexpr vector( from_range_t, _Range&& __range, const allocator_type& __alloc = allocator_type()) - : __end_cap_(nullptr, __alloc) { + : __alloc_(__alloc) { if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { auto __n = static_cast<size_type>(ranges::distance(__range)); __init_with_size(ranges::begin(__range), ranges::end(__range), __n); @@ -635,7 +654,7 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT { return static_cast<size_type>(__end_cap() - this->__begin_); } - _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return this->__begin_ == this->__end_; } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT; @@ -773,8 +792,7 @@ public: private: pointer __begin_ = nullptr; pointer __end_ = nullptr; - __compressed_pair<pointer, allocator_type> __end_cap_ = - __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag()); + _LIBCPP_COMPRESSED_PAIR(pointer, __cap_ = nullptr, allocator_type, __alloc_); // Allocate space for __n objects // throws length_error if __n > max_size() @@ -843,8 +861,46 @@ private: void __append_uninitialized(size_type __n); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x); - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT; - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; + + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT { + +// We need to save the make_iter function and replace all constructor calls with it +// Made to support pointer iterators +#if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 0 + return iterator(this, __p); +#elif defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR) + // Bound the iterator according to the capacity, rather than the size. + // + // Vector guarantees that iterators stay valid as long as no reallocation occurs even if new elements are inserted + // into the container; for these cases, we need to make sure that the newly-inserted elements can be accessed + // through the bounded iterator without failing checks. The downside is that the bounded iterator won't catch + // access that is logically out-of-bounds, i.e., goes beyond the size, but is still within the capacity. With the + // current implementation, there is no connection between a bounded iterator and its associated container, so we + // don't have a way to update existing valid iterators when the container is resized and thus have to go with + // a laxer approach. + return std::__make_bounded_iter( + std::__wrap_iter<pointer>(__p), + std::__wrap_iter<pointer>(this->__begin_), + std::__wrap_iter<pointer>(this->__end_cap())); +#else + return iterator(__p); +#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { +#if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 0 + return const_iterator(this, __p); +#elif defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR) + // Bound the iterator according to the capacity, rather than the size. + return std::__make_bounded_iter( + std::__wrap_iter<const_pointer>(__p), + std::__wrap_iter<const_pointer>(this->__begin_), + std::__wrap_iter<const_pointer>(this->__end_cap())); +#else + return const_iterator(__p); +#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR + } + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer @@ -939,17 +995,14 @@ private: ++__tx.__pos_; } - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { - return this->__end_cap_.second(); - } + // TODO: Remove these now redundant accessors + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return this->__alloc_; } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { - return this->__end_cap_.second(); - } - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT { - return this->__end_cap_.first(); + return this->__alloc_; } + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT { return this->__cap_; } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT { - return this->__end_cap_.first(); + return this->__cap_; } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __clear() _NOEXCEPT { @@ -973,9 +1026,9 @@ private: __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); } - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("vector"); } + [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("vector"); } - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("vector"); } + [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("vector"); } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c, true_type) { if (__alloc() != __c.__alloc()) { @@ -1196,7 +1249,7 @@ template <class _InputIterator, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a) - : __end_cap_(nullptr, __a) { + : __alloc_(__a) { __init_with_sentinel(__first, __last); } @@ -1217,21 +1270,21 @@ template <class _ForwardIterator, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a) - : __end_cap_(nullptr, __a) { + : __alloc_(__a) { size_type __n = static_cast<size_type>(std::distance(__first, __last)); __init_with_size(__first, __last, __n); } template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(const vector& __x) - : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc())) { + : __alloc_(__alloc_traits::select_on_container_copy_construction(__x.__alloc())) { __init_with_size(__x.__begin_, __x.__end_, __x.size()); } template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a) - : __end_cap_(nullptr, __a) { + : __alloc_(__a) { __init_with_size(__x.__begin_, __x.__end_, __x.size()); } @@ -1242,7 +1295,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocato #else _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) #endif - : __end_cap_(nullptr, std::move(__x.__alloc())) { + : __alloc_(std::move(__x.__alloc())) { this->__begin_ = __x.__begin_; this->__end_ = __x.__end_; this->__end_cap() = __x.__end_cap(); @@ -1252,7 +1305,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocato template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a) - : __end_cap_(nullptr, __a) { + : __alloc_(__a) { if (__a == __x.__alloc()) { this->__begin_ = __x.__begin_; this->__end_ = __x.__end_; @@ -1282,7 +1335,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) { template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) - : __end_cap_(nullptr, __a) { + : __alloc_(__a) { auto __guard = std::__make_exception_guard(__destroy_vector(*this)); if (__il.size() > 0) { __vallocate(__il.size()); @@ -1380,28 +1433,6 @@ vector<_Tp, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sentinel } } -// We need to save the make_iter function and replace all constructor calls with it -// Made to support pointer iterators -template <class _Tp, class _Allocator> -_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator -vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT { -#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1 - return iterator(__p); -#else - return iterator(this, __p); -#endif -} - -template <class _Tp, class _Allocator> -_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_iterator -vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT { -#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1 - return const_iterator(__p); -#else - return const_iterator(this, __p); -#endif -} - template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) { if (__n <= capacity()) { @@ -1490,7 +1521,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOE #endif // _LIBCPP_HAS_NO_EXCEPTIONS allocator_type& __a = this->__alloc(); __split_buffer<value_type, allocator_type&> __v(size(), size(), __a); - __swap_out_circular_buffer(__v); + // The Standard mandates shrink_to_fit() does not increase the capacity. + // With equal capacity keep the existing buffer. This avoids extra work + // due to swapping the elements. + if (__v.capacity() < capacity()) + __swap_out_circular_buffer(__v); #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { } @@ -1849,8 +1884,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x) std::swap(this->__begin_, __x.__begin_); std::swap(this->__end_, __x.__end_); std::swap(this->__end_cap(), __x.__end_cap()); - std::__swap_allocator( - this->__alloc(), __x.__alloc(), integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>()); + std::__swap_allocator(this->__alloc(), __x.__alloc()); } template <class _Tp, class _Allocator> @@ -1908,7 +1942,7 @@ private: __storage_pointer __begin_; size_type __size_; - __compressed_pair<size_type, __storage_allocator> __cap_alloc_; + _LIBCPP_COMPRESSED_PAIR(size_type, __cap_, __storage_allocator, __alloc_); public: typedef __bit_reference<vector> reference; @@ -1919,15 +1953,12 @@ public: #endif private: - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type& __cap() _NOEXCEPT { return __cap_alloc_.first(); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const size_type& __cap() const _NOEXCEPT { - return __cap_alloc_.first(); - } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __storage_allocator& __alloc() _NOEXCEPT { - return __cap_alloc_.second(); - } + // TODO: Remove these now redundant accessors + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type& __cap() _NOEXCEPT { return __cap_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const size_type& __cap() const _NOEXCEPT { return __cap_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __storage_allocator& __alloc() _NOEXCEPT { return __alloc_; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const __storage_allocator& __alloc() const _NOEXCEPT { - return __cap_alloc_.second(); + return __alloc_; } static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); @@ -1990,7 +2021,7 @@ public: #if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<bool> _Range> _LIBCPP_HIDE_FROM_ABI constexpr vector(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { + : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { auto __n = static_cast<size_type>(ranges::distance(__range)); __init_with_size(ranges::begin(__range), ranges::end(__range), __n); @@ -2063,7 +2094,7 @@ public: return __internal_cap_to_external(__cap()); } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { return __size_; } - _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { + [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { return __size_ == 0; } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n); @@ -2195,9 +2226,9 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const; private: - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("vector"); } + [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("vector"); } - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("vector"); } + [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("vector"); } template <class _InputIterator, class _Sentinel> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void @@ -2397,7 +2428,7 @@ vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel _ template <class _Allocator> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {} + : __begin_(nullptr), __size_(0), __cap_(0) {} template <class _Allocator> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const allocator_type& __a) @@ -2406,12 +2437,12 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocat #else _NOEXCEPT #endif - : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { + : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { } template <class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) { + : __begin_(nullptr), __size_(0), __cap_(0) { if (__n > 0) { __vallocate(__n); __construct_at_end(__n, false); @@ -2421,7 +2452,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n) #if _LIBCPP_STD_VER >= 14 template <class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { + : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { if (__n > 0) { __vallocate(__n); __construct_at_end(__n, false); @@ -2431,7 +2462,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, co template <class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) { + : __begin_(nullptr), __size_(0), __cap_(0) { if (__n > 0) { __vallocate(__n); __construct_at_end(__n, __x); @@ -2441,7 +2472,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, co template <class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { + : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { if (__n > 0) { __vallocate(__n); __construct_at_end(__n, __x); @@ -2451,7 +2482,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all template <class _Allocator> template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) { + : __begin_(nullptr), __size_(0), __cap_(0) { __init_with_sentinel(__first, __last); } @@ -2459,14 +2490,14 @@ template <class _Allocator> template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { + : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { __init_with_sentinel(__first, __last); } template <class _Allocator> template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) { + : __begin_(nullptr), __size_(0), __cap_(0) { auto __n = static_cast<size_type>(std::distance(__first, __last)); __init_with_size(__first, __last, __n); } @@ -2475,7 +2506,7 @@ template <class _Allocator> template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { + : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { auto __n = static_cast<size_type>(std::distance(__first, __last)); __init_with_size(__first, __last, __n); } @@ -2484,7 +2515,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la template <class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(initializer_list<value_type> __il) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) { + : __begin_(nullptr), __size_(0), __cap_(0) { size_type __n = static_cast<size_type>(__il.size()); if (__n > 0) { __vallocate(__n); @@ -2495,7 +2526,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(initializer_list< template <class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { + : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { size_type __n = static_cast<size_type>(__il.size()); if (__n > 0) { __vallocate(__n); @@ -2509,7 +2540,8 @@ template <class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v) : __begin_(nullptr), __size_(0), - __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc())) { + __cap_(0), + __alloc_(__storage_traits::select_on_container_copy_construction(__v.__alloc())) { if (__v.size() > 0) { __vallocate(__v.size()); __construct_at_end(__v.begin(), __v.end(), __v.size()); @@ -2518,7 +2550,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v template <class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) { + : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(__a) { if (__v.size() > 0) { __vallocate(__v.size()); __construct_at_end(__v.begin(), __v.end(), __v.size()); @@ -2550,7 +2582,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocat #endif : __begin_(__v.__begin_), __size_(__v.__size_), - __cap_alloc_(std::move(__v.__cap_alloc_)) { + __cap_(__v.__cap_), + __alloc_(std::move(__v.__alloc_)) { __v.__begin_ = nullptr; __v.__size_ = 0; __v.__cap() = 0; @@ -2559,7 +2592,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocat template <class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a) - : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) { + : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(__a) { if (__a == allocator_type(__v.__alloc())) { this->__begin_ = __v.__begin_; this->__size_ = __v.__size_; @@ -2851,8 +2884,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x) std::swap(this->__begin_, __x.__begin_); std::swap(this->__size_, __x.__size_); std::swap(this->__cap(), __x.__cap()); - std::__swap_allocator( - this->__alloc(), __x.__alloc(), integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>()); + std::__swap_allocator(this->__alloc(), __x.__alloc()); } template <class _Allocator> @@ -2995,8 +3027,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const vector<_Tp, _Allocator>& __x, template <class _Tp, class _Allocator> _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { - return std::lexicographical_compare_three_way( - __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } #endif // _LIBCPP_STD_VER <= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/version b/contrib/libs/cxxsupp/libcxx/include/version index 460af8b6d3..5d679caac0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/version +++ b/contrib/libs/cxxsupp/libcxx/include/version @@ -101,7 +101,7 @@ __cpp_lib_execution 201902L <execution> 201603L // C++17 __cpp_lib_expected 202211L <expected> __cpp_lib_filesystem 201703L <filesystem> -__cpp_lib_format 202106L <format> +__cpp_lib_format 202110L <format> __cpp_lib_format_path 202403L <filesystem> __cpp_lib_format_ranges 202207L <format> __cpp_lib_format_uchar 202311L <format> @@ -159,7 +159,8 @@ __cpp_lib_make_unique 201304L <memory> __cpp_lib_map_try_emplace 201411L <map> __cpp_lib_math_constants 201907L <numbers> __cpp_lib_math_special_functions 201603L <cmath> -__cpp_lib_mdspan 202207L <mdspan> +__cpp_lib_mdspan 202406L <mdspan> + 202207L // C++23 __cpp_lib_memory_resource 201603L <memory_resource> __cpp_lib_move_iterator_concept 202207L <iterator> __cpp_lib_move_only_function 202110L <functional> @@ -181,14 +182,16 @@ __cpp_lib_philox_engine 202406L <random> __cpp_lib_polymorphic_allocator 201902L <memory_resource> __cpp_lib_print 202207L <ostream> <print> __cpp_lib_quoted_string_io 201304L <iomanip> -__cpp_lib_ranges 202207L <algorithm> <functional> <iterator> +__cpp_lib_ranges 202406L <algorithm> <functional> <iterator> <memory> <ranges> + 202110L // C++20 __cpp_lib_ranges_as_const 202207L <ranges> __cpp_lib_ranges_as_rvalue 202207L <ranges> __cpp_lib_ranges_chunk 202202L <ranges> __cpp_lib_ranges_chunk_by 202202L <ranges> __cpp_lib_ranges_concat 202403L <ranges> __cpp_lib_ranges_contains 202207L <algorithm> +__cpp_lib_ranges_find_last 202207L <algorithm> __cpp_lib_ranges_iota 202202L <numeric> __cpp_lib_ranges_join_with 202202L <ranges> __cpp_lib_ranges_repeat 202207L <ranges> @@ -230,12 +233,13 @@ __cpp_lib_stdatomic_h 202011L <stdatomic.h> __cpp_lib_string_contains 202011L <string> <string_view> __cpp_lib_string_resize_and_overwrite 202110L <string> __cpp_lib_string_udls 201304L <string> -__cpp_lib_string_view 201803L <string> <string_view> +__cpp_lib_string_view 202403L <string> <string_view> + 201803L // C++20 201606L // C++17 __cpp_lib_submdspan 202306L <mdspan> __cpp_lib_syncbuf 201803L <syncstream> __cpp_lib_text_encoding 202306L <text_encoding> -__cpp_lib_three_way_comparison 201711L <compare> +__cpp_lib_three_way_comparison 201907L <compare> __cpp_lib_to_address 201711L <memory> __cpp_lib_to_array 201907L <array> __cpp_lib_to_chars 202306L <charconv> @@ -366,7 +370,7 @@ __cpp_lib_void_t 201411L <type_traits> # define __cpp_lib_atomic_flag_test 201907L // # define __cpp_lib_atomic_float 201711L # define __cpp_lib_atomic_lock_free_type_aliases 201907L -// # define __cpp_lib_atomic_ref 201806L +# define __cpp_lib_atomic_ref 201806L // # define __cpp_lib_atomic_shared_ptr 201711L # define __cpp_lib_atomic_value_initialization 201911L # if _LIBCPP_AVAILABILITY_HAS_SYNC @@ -403,7 +407,7 @@ __cpp_lib_void_t 201411L <type_traits> # define __cpp_lib_erase_if 202002L # undef __cpp_lib_execution // # define __cpp_lib_execution 201902L -// # define __cpp_lib_format 202106L +# define __cpp_lib_format 202110L # define __cpp_lib_format_uchar 202311L # define __cpp_lib_generic_unordered_lookup 201811L # define __cpp_lib_int_pow2 202002L @@ -413,7 +417,7 @@ __cpp_lib_void_t 201411L <type_traits> // # define __cpp_lib_is_layout_compatible 201907L # define __cpp_lib_is_nothrow_convertible 201806L // # define __cpp_lib_is_pointer_interconvertible 201907L -# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC +# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC # define __cpp_lib_jthread 201911L # endif # if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC @@ -425,7 +429,7 @@ __cpp_lib_void_t 201411L <type_traits> # if _LIBCPP_AVAILABILITY_HAS_PMR # define __cpp_lib_polymorphic_allocator 201902L # endif -# define __cpp_lib_ranges 202207L +# define __cpp_lib_ranges 202110L # define __cpp_lib_remove_cvref 201711L # if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC # define __cpp_lib_semaphore 201907L @@ -443,7 +447,7 @@ __cpp_lib_void_t 201411L <type_traits> # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) # define __cpp_lib_syncbuf 201803L # endif -# define __cpp_lib_three_way_comparison 201711L +# define __cpp_lib_three_way_comparison 201907L # define __cpp_lib_to_address 201711L # define __cpp_lib_to_array 201907L # define __cpp_lib_type_identity 201806L @@ -475,13 +479,16 @@ __cpp_lib_void_t 201411L <type_traits> // # define __cpp_lib_move_only_function 202110L # undef __cpp_lib_optional # define __cpp_lib_optional 202110L -// # define __cpp_lib_out_ptr 202106L +# define __cpp_lib_out_ptr 202106L # define __cpp_lib_print 202207L +# undef __cpp_lib_ranges +# define __cpp_lib_ranges 202406L // # define __cpp_lib_ranges_as_const 202207L # define __cpp_lib_ranges_as_rvalue 202207L // # define __cpp_lib_ranges_chunk 202202L # define __cpp_lib_ranges_chunk_by 202202L # define __cpp_lib_ranges_contains 202207L +# define __cpp_lib_ranges_find_last 202207L // # define __cpp_lib_ranges_iota 202202L // # define __cpp_lib_ranges_join_with 202202L # define __cpp_lib_ranges_repeat 202207L @@ -506,7 +513,9 @@ __cpp_lib_void_t 201411L <type_traits> # undef __cpp_lib_bind_front # define __cpp_lib_bind_front 202306L # define __cpp_lib_bitset 202306L -// # define __cpp_lib_constexpr_new 202406L +# if !defined(_LIBCPP_ABI_VCRUNTIME) +# define __cpp_lib_constexpr_new 202406L +# endif // # define __cpp_lib_constrained_equality 202403L // # define __cpp_lib_copyable_function 202306L // # define __cpp_lib_debugging 202311L @@ -527,12 +536,16 @@ __cpp_lib_void_t 201411L <type_traits> // # define __cpp_lib_generate_random 202403L // # define __cpp_lib_hazard_pointer 202306L // # define __cpp_lib_inplace_vector 202406L -// # define __cpp_lib_is_virtual_base_of 202406L +# if __has_builtin(__builtin_is_virtual_base_of) +# define __cpp_lib_is_virtual_base_of 202406L +# endif // # define __cpp_lib_is_within_lifetime 202306L // # define __cpp_lib_linalg 202311L +# undef __cpp_lib_mdspan +# define __cpp_lib_mdspan 202406L // # define __cpp_lib_optional_range_support 202406L # undef __cpp_lib_out_ptr -// # define __cpp_lib_out_ptr 202311L +# define __cpp_lib_out_ptr 202311L // # define __cpp_lib_philox_engine 202406L // # define __cpp_lib_ranges_concat 202403L # define __cpp_lib_ratio 202306L @@ -544,6 +557,8 @@ __cpp_lib_void_t 201411L <type_traits> # define __cpp_lib_span_at 202311L # define __cpp_lib_span_initializer_list 202311L # define __cpp_lib_sstream_from_string_view 202306L +# undef __cpp_lib_string_view +# define __cpp_lib_string_view 202403L // # define __cpp_lib_submdspan 202306L // # define __cpp_lib_text_encoding 202306L # undef __cpp_lib_to_chars diff --git a/contrib/libs/cxxsupp/libcxx/include/wchar.h b/contrib/libs/cxxsupp/libcxx/include/wchar.h index d4268c6d2c..c965b28e57 100644 --- a/contrib/libs/cxxsupp/libcxx/include/wchar.h +++ b/contrib/libs/cxxsupp/libcxx/include/wchar.h @@ -108,11 +108,6 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, # include <__config> # include <stddef.h> -# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) -# error \ - "The <wchar.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled" -# endif - # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header # endif @@ -142,7 +137,8 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, # endif # endif -# if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) extern "C++" { inline _LIBCPP_HIDE_FROM_ABI wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) { return (wchar_t*)wcschr(__s, __c); @@ -197,15 +193,16 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD wchar_t* wmemchr(wchar_t return __libcpp_wmemchr(__s, __c, __n); } } -# endif +# endif -# if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__)) +# if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__)) extern "C" { size_t mbsnrtowcs( wchar_t* __restrict __dst, const char** __restrict __src, size_t __nmc, size_t __len, mbstate_t* __restrict __ps); size_t wcsnrtombs( char* __restrict __dst, const wchar_t** __restrict __src, size_t __nwc, size_t __len, mbstate_t* __restrict __ps); } // extern "C" -# endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__) +# endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__) +# endif // !_LIBCPP_HAS_NO_WIDE_CHARACTERS #endif // _LIBCPP_WCHAR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/wctype.h b/contrib/libs/cxxsupp/libcxx/include/wctype.h index c76ec5a3f0..9f378eaf82 100644 --- a/contrib/libs/cxxsupp/libcxx/include/wctype.h +++ b/contrib/libs/cxxsupp/libcxx/include/wctype.h @@ -46,11 +46,6 @@ wctrans_t wctrans(const char* property); #include <__config> -#if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) -# error \ - "The <wctype.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled" -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/patches/00-future-2024-07-26-atomic_ref.patch b/contrib/libs/cxxsupp/libcxx/patches/00-future-2024-07-26-atomic_ref.patch deleted file mode 100644 index a08f8be83e..0000000000 --- a/contrib/libs/cxxsupp/libcxx/patches/00-future-2024-07-26-atomic_ref.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff --git a/include/__atomic/atomic_ref.h b/include/__atomic/atomic_ref.h -index 156f196..2849b82 100644 ---- a/include/__atomic/atomic_ref.h -+++ b/include/__atomic/atomic_ref.h -@@ -42,6 +42,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD - - #if _LIBCPP_STD_VER >= 20 - -+// These types are required to make __atomic_is_always_lock_free work across GCC and Clang. -+// The purpose of this trick is to make sure that we provide an object with the correct alignment -+// to __atomic_is_always_lock_free, since that answer depends on the alignment. -+template <size_t _Alignment> -+struct __alignment_checker_type { -+ alignas(_Alignment) char __data; -+}; -+ -+template <size_t _Alignment> -+struct __get_aligner_instance { -+ static constexpr __alignment_checker_type<_Alignment> __instance{}; -+}; -+ - template <class _Tp> - struct __atomic_ref_base { - protected: -@@ -105,7 +118,7 @@ public: - // that the pointer is going to be aligned properly at runtime because that is a (checked) precondition - // of atomic_ref's constructor. - static constexpr bool is_always_lock_free = -- __atomic_always_lock_free(sizeof(_Tp), reinterpret_cast<void*>(-required_alignment)); -+ __atomic_always_lock_free(sizeof(_Tp), &__get_aligner_instance<required_alignment>::__instance); - - _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_Tp), __ptr_); } - diff --git a/contrib/libs/cxxsupp/libcxx/patches/00-future-2024-09-03-datasizeof.patch b/contrib/libs/cxxsupp/libcxx/patches/00-future-2024-09-03-datasizeof.patch deleted file mode 100644 index ba6d2a9e17..0000000000 --- a/contrib/libs/cxxsupp/libcxx/patches/00-future-2024-09-03-datasizeof.patch +++ /dev/null @@ -1,43 +0,0 @@ -diff --git a/include/__type_traits/datasizeof.h b/include/__type_traits/datasizeof.h -index 35c1292..b4cbd1d 100644 ---- a/include/__type_traits/datasizeof.h -+++ b/include/__type_traits/datasizeof.h -@@ -26,34 +26,22 @@ - - _LIBCPP_BEGIN_NAMESPACE_STD - --#if __has_keyword(__datasizeof) || __has_extension(datasizeof) -+// TODO: Enable this again once #94816 is fixed. -+#if (__has_keyword(__datasizeof) || __has_extension(datasizeof)) && 0 - template <class _Tp> - inline const size_t __datasizeof_v = __datasizeof(_Tp); - #else --// NOLINTNEXTLINE(readability-redundant-preprocessor) This is https://llvm.org/PR64825 --# if __has_cpp_attribute(__no_unique_address__) - template <class _Tp> - struct _FirstPaddingByte { -- [[__no_unique_address__]] _Tp __v_; -+ _LIBCPP_NO_UNIQUE_ADDRESS _Tp __v_; - char __first_padding_byte_; - }; --# else --template <class _Tp, bool = __libcpp_is_final<_Tp>::value || !is_class<_Tp>::value> --struct _FirstPaddingByte : _Tp { -- char __first_padding_byte_; --}; -- --template <class _Tp> --struct _FirstPaddingByte<_Tp, true> { -- _Tp __v_; -- char __first_padding_byte_; --}; --# endif // __has_cpp_attribute(__no_unique_address__) - - // _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow - // the use as an extension. - _LIBCPP_DIAGNOSTIC_PUSH - _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof") -+_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Winvalid-offsetof") - template <class _Tp> - inline const size_t __datasizeof_v = offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_); - _LIBCPP_DIAGNOSTIC_POP diff --git a/contrib/libs/cxxsupp/libcxx/patches/00-future-2024-09-09-cache-direntry.patch b/contrib/libs/cxxsupp/libcxx/patches/00-future-2024-09-09-cache-direntry.patch deleted file mode 100644 index e5da115d7a..0000000000 --- a/contrib/libs/cxxsupp/libcxx/patches/00-future-2024-09-09-cache-direntry.patch +++ /dev/null @@ -1,185 +0,0 @@ -diff --git a/include/__filesystem/directory_entry.h b/include/__filesystem/directory_entry.h -index 96d88dc..c40b5d7 100644 ---- a/include/__filesystem/directory_entry.h -+++ b/include/__filesystem/directory_entry.h -@@ -201,7 +201,9 @@ private: - _IterNonSymlink, - _RefreshSymlink, - _RefreshSymlinkUnresolved, -- _RefreshNonSymlink -+ _RefreshNonSymlink, -+ _IterCachedSymlink, -+ _IterCachedNonSymlink - }; - - struct __cached_data { -@@ -240,6 +242,29 @@ private: - return __data; - } - -+ _LIBCPP_HIDE_FROM_ABI static __cached_data -+ __create_iter_cached_result(file_type __ft, uintmax_t __size, perms __perm, file_time_type __write_time) { -+ __cached_data __data; -+ __data.__type_ = __ft; -+ __data.__size_ = __size; -+ __data.__write_time_ = __write_time; -+ if (__ft == file_type::symlink) -+ __data.__sym_perms_ = __perm; -+ else -+ __data.__non_sym_perms_ = __perm; -+ __data.__cache_type_ = [&]() { -+ switch (__ft) { -+ case file_type::none: -+ return _Empty; -+ case file_type::symlink: -+ return _IterCachedSymlink; -+ default: -+ return _IterCachedNonSymlink; -+ } -+ }(); -+ return __data; -+ } -+ - _LIBCPP_HIDE_FROM_ABI void __assign_iter_entry(_Path&& __p, __cached_data __dt) { - __p_ = std::move(__p); - __data_ = __dt; -@@ -281,13 +306,15 @@ private: - case _Empty: - return __symlink_status(__p_, __ec).type(); - case _IterSymlink: -+ case _IterCachedSymlink: - case _RefreshSymlink: - case _RefreshSymlinkUnresolved: - if (__ec) - __ec->clear(); - return file_type::symlink; -+ case _IterCachedNonSymlink: - case _IterNonSymlink: -- case _RefreshNonSymlink: -+ case _RefreshNonSymlink: { - file_status __st(__data_.__type_); - if (__ec && !filesystem::exists(__st)) - *__ec = make_error_code(errc::no_such_file_or_directory); -@@ -295,6 +322,7 @@ private: - __ec->clear(); - return __data_.__type_; - } -+ } - __libcpp_unreachable(); - } - -@@ -302,8 +330,10 @@ private: - switch (__data_.__cache_type_) { - case _Empty: - case _IterSymlink: -+ case _IterCachedSymlink: - case _RefreshSymlinkUnresolved: - return __status(__p_, __ec).type(); -+ case _IterCachedNonSymlink: - case _IterNonSymlink: - case _RefreshNonSymlink: - case _RefreshSymlink: { -@@ -323,8 +353,10 @@ private: - case _Empty: - case _IterNonSymlink: - case _IterSymlink: -+ case _IterCachedSymlink: - case _RefreshSymlinkUnresolved: - return __status(__p_, __ec); -+ case _IterCachedNonSymlink: - case _RefreshNonSymlink: - case _RefreshSymlink: - return file_status(__get_ft(__ec), __data_.__non_sym_perms_); -@@ -338,8 +370,10 @@ private: - case _IterNonSymlink: - case _IterSymlink: - return __symlink_status(__p_, __ec); -+ case _IterCachedNonSymlink: - case _RefreshNonSymlink: - return file_status(__get_sym_ft(__ec), __data_.__non_sym_perms_); -+ case _IterCachedSymlink: - case _RefreshSymlink: - case _RefreshSymlinkUnresolved: - return file_status(__get_sym_ft(__ec), __data_.__sym_perms_); -@@ -352,8 +386,10 @@ private: - case _Empty: - case _IterNonSymlink: - case _IterSymlink: -+ case _IterCachedSymlink: - case _RefreshSymlinkUnresolved: - return filesystem::__file_size(__p_, __ec); -+ case _IterCachedNonSymlink: - case _RefreshSymlink: - case _RefreshNonSymlink: { - error_code __m_ec; -@@ -374,6 +410,8 @@ private: - case _Empty: - case _IterNonSymlink: - case _IterSymlink: -+ case _IterCachedNonSymlink: -+ case _IterCachedSymlink: - case _RefreshSymlinkUnresolved: - return filesystem::__hard_link_count(__p_, __ec); - case _RefreshSymlink: -@@ -392,8 +430,10 @@ private: - case _Empty: - case _IterNonSymlink: - case _IterSymlink: -+ case _IterCachedSymlink: - case _RefreshSymlinkUnresolved: - return filesystem::__last_write_time(__p_, __ec); -+ case _IterCachedNonSymlink: - case _RefreshSymlink: - case _RefreshNonSymlink: { - error_code __m_ec; -diff --git a/src/filesystem/directory_iterator.cpp b/src/filesystem/directory_iterator.cpp -index dceb348..d7ed9a3 100644 ---- a/src/filesystem/directory_iterator.cpp -+++ b/src/filesystem/directory_iterator.cpp -@@ -77,13 +77,13 @@ public: - bool assign() { - if (!wcscmp(__data_.cFileName, L".") || !wcscmp(__data_.cFileName, L"..")) - return false; -- // FIXME: Cache more of this -- // directory_entry::__cached_data cdata; -- // cdata.__type_ = get_file_type(__data_); -- // cdata.__size_ = get_file_size(__data_); -- // cdata.__write_time_ = get_write_time(__data_); - __entry_.__assign_iter_entry( -- __root_ / __data_.cFileName, directory_entry::__create_iter_result(detail::get_file_type(__data_))); -+ __root_ / __data_.cFileName, -+ directory_entry::__create_iter_cached_result( -+ detail::get_file_type(__data_), -+ detail::get_file_size(__data_), -+ detail::get_file_perm(__data_), -+ detail::get_write_time(__data_))); - return true; - } - -diff --git a/src/filesystem/file_descriptor.h b/src/filesystem/file_descriptor.h -index 50178ff..2c9e0d7 100644 ---- a/src/filesystem/file_descriptor.h -+++ b/src/filesystem/file_descriptor.h -@@ -97,11 +97,18 @@ inline uintmax_t get_file_size(const WIN32_FIND_DATAW& data) { - return (static_cast<uint64_t>(data.nFileSizeHigh) << 32) + data.nFileSizeLow; - } - inline file_time_type get_write_time(const WIN32_FIND_DATAW& data) { -- ULARGE_INTEGER tmp; -+ using detail::fs_time; - const FILETIME& time = data.ftLastWriteTime; -- tmp.u.LowPart = time.dwLowDateTime; -- tmp.u.HighPart = time.dwHighDateTime; -- return file_time_type(file_time_type::duration(tmp.QuadPart)); -+ auto ts = filetime_to_timespec(time); -+ if (!fs_time::is_representable(ts)) -+ return file_time_type::min(); -+ return fs_time::convert_from_timespec(ts); -+} -+inline perms get_file_perm(const WIN32_FIND_DATAW& data) { -+ unsigned st_mode = 0555; // Read-only -+ if (!(data.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) -+ st_mode |= 0222; // Write -+ return static_cast<perms>(st_mode) & perms::mask; - } - - #endif // !_LIBCPP_WIN32API diff --git a/contrib/libs/cxxsupp/libcxx/patches/00-future-45a09d1811d5d6597385ef02ecf2d4b7320c37c5.patch b/contrib/libs/cxxsupp/libcxx/patches/00-future-45a09d1811d5d6597385ef02ecf2d4b7320c37c5.patch new file mode 100644 index 0000000000..fd90f28b92 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/patches/00-future-45a09d1811d5d6597385ef02ecf2d4b7320c37c5.patch @@ -0,0 +1,285 @@ +diff --git a/include/__configuration/abi.h b/include/__configuration/abi.h +index 707e10b..62c129f 100644 +--- a/include/__configuration/abi.h ++++ b/include/__configuration/abi.h +@@ -181,6 +181,13 @@ + # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING + #endif + ++// Tracks the bounds of the array owned by std::unique_ptr<T[]>, allowing it to trap when accessed out-of-bounds. ++// Note that limited bounds checking is also available outside of this ABI configuration, but only some categories ++// of types can be checked. ++// ++// ABI impact: This causes the layout of std::unique_ptr<T[]> to change and its size to increase. ++// #define _LIBCPP_ABI_BOUNDED_UNIQUE_PTR ++ + #if defined(_LIBCPP_COMPILER_CLANG_BASED) + # if defined(__APPLE__) + # if defined(__i386__) || defined(__x86_64__) +diff --git a/include/__memory/unique_ptr.h b/include/__memory/unique_ptr.h +index 9ca13d0..11215dc 100644 +--- a/include/__memory/unique_ptr.h ++++ b/include/__memory/unique_ptr.h +@@ -10,6 +10,7 @@ + #ifndef _LIBCPP___MEMORY_UNIQUE_PTR_H + #define _LIBCPP___MEMORY_UNIQUE_PTR_H + ++#include <__assert> + #include <__compare/compare_three_way.h> + #include <__compare/compare_three_way_result.h> + #include <__compare/three_way_comparable.h> +@@ -17,8 +18,10 @@ + #include <__functional/hash.h> + #include <__functional/operations.h> + #include <__memory/allocator_traits.h> // __pointer ++#include <__memory/array_cookie.h> + #include <__memory/auto_ptr.h> + #include <__memory/compressed_pair.h> ++#include <__memory/pointer_traits.h> + #include <__type_traits/add_lvalue_reference.h> + #include <__type_traits/common_type.h> + #include <__type_traits/conditional.h> +@@ -27,6 +30,7 @@ + #include <__type_traits/integral_constant.h> + #include <__type_traits/is_array.h> + #include <__type_traits/is_assignable.h> ++#include <__type_traits/is_constant_evaluated.h> + #include <__type_traits/is_constructible.h> + #include <__type_traits/is_convertible.h> + #include <__type_traits/is_function.h> +@@ -41,7 +45,9 @@ + #include <__utility/declval.h> + #include <__utility/forward.h> + #include <__utility/move.h> ++#include <__utility/private_constructor_tag.h> + #include <cstddef> ++#include <cstdint> + + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) + # pragma GCC system_header +@@ -292,6 +298,91 @@ public: + } + }; + ++// Bounds checking in unique_ptr<T[]> ++// ================================== ++// ++// We provide some helper classes that allow bounds checking when accessing a unique_ptr<T[]>. ++// There are a few cases where bounds checking can be implemented: ++// ++// 1. When an array cookie (see [1]) exists at the beginning of the array allocation, we are ++// able to reuse that cookie to extract the size of the array and perform bounds checking. ++// An array cookie is a size inserted at the beginning of the allocation by the compiler. ++// That size is inserted implicitly when doing `new T[n]` in some cases, and its purpose ++// is to allow the runtime to destroy the `n` array elements when doing `delete array`. ++// When we are able to use array cookies, we reuse information already available in the ++// current runtime, so bounds checking does not require changing libc++'s ABI. ++// ++// 2. When the "bounded unique_ptr" ABI configuration (controlled by `_LIBCPP_ABI_BOUNDED_UNIQUE_PTR`) ++// is enabled, we store the size of the allocation (when it is known) so we can check it when ++// indexing into the `unique_ptr`. That changes the layout of `std::unique_ptr<T[]>`, which is ++// an ABI break from the default configuration. ++// ++// Note that even under this ABI configuration, we can't always know the size of the unique_ptr. ++// Indeed, the size of the allocation can only be known when the unique_ptr is created via ++// make_unique or a similar API. For example, it can't be known when constructed from an arbitrary ++// pointer, in which case we are not able to check the bounds on access: ++// ++// unique_ptr<T[], MyDeleter> ptr(new T[3]); ++// ++// When we don't know the size of the allocation via the API used to create the unique_ptr, we ++// try to fall back to using an array cookie when available. ++// ++// Finally, note that when this ABI configuration is enabled, we have no choice but to always ++// make space for a size to be stored in the unique_ptr. Indeed, while we might want to avoid ++// storing the size when an array cookie is available, knowing whether an array cookie is available ++// requires the type stored in the unique_ptr to be complete, while unique_ptr can normally ++// accommodate incomplete types. ++// ++// (1) Implementation where we rely on the array cookie to know the size of the allocation, if ++// an array cookie exists. ++struct __unique_ptr_array_bounds_stateless { ++ __unique_ptr_array_bounds_stateless() = default; ++ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __unique_ptr_array_bounds_stateless(size_t) {} ++ ++ template <class _Tp, __enable_if_t<__has_array_cookie<_Tp>::value, int> = 0> ++ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const { ++ // In constant expressions, we can't check the array cookie so we just pretend that the index ++ // is in-bounds. The compiler catches invalid accesses anyway. ++ if (__libcpp_is_constant_evaluated()) ++ return true; ++ size_t __cookie = std::__get_array_cookie(__ptr); ++ return __index < __cookie; ++ } ++ ++ template <class _Tp, __enable_if_t<!__has_array_cookie<_Tp>::value, int> = 0> ++ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t) const { ++ return true; // If we don't have an array cookie, we assume the access is in-bounds ++ } ++}; ++ ++// (2) Implementation where we store the size in the class whenever we have it. ++// ++// Semantically, we'd need to store the size as an optional<size_t>. However, since that ++// is really heavy weight, we instead store a size_t and use SIZE_MAX as a magic value ++// meaning that we don't know the size. ++struct __unique_ptr_array_bounds_stored { ++ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __unique_ptr_array_bounds_stored() : __size_(SIZE_MAX) {} ++ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __unique_ptr_array_bounds_stored(size_t __size) : __size_(__size) {} ++ ++ // Use the array cookie if there's one ++ template <class _Tp, __enable_if_t<__has_array_cookie<_Tp>::value, int> = 0> ++ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const { ++ if (__libcpp_is_constant_evaluated()) ++ return true; ++ size_t __cookie = std::__get_array_cookie(__ptr); ++ return __index < __cookie; ++ } ++ ++ // Otherwise, fall back on the stored size (if any) ++ template <class _Tp, __enable_if_t<!__has_array_cookie<_Tp>::value, int> = 0> ++ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t __index) const { ++ return __index < __size_; ++ } ++ ++private: ++ size_t __size_; ++}; ++ + template <class _Tp, class _Dp> + class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> { + public: +@@ -300,8 +391,9 @@ public: + typedef typename __pointer<_Tp, deleter_type>::type pointer; + + // A unique_ptr contains the following members which may be trivially relocatable: +- // - pointer : this may be trivially relocatable, so it's checked ++ // - pointer: this may be trivially relocatable, so it's checked + // - deleter_type: this may be trivially relocatable, so it's checked ++ // - (optionally) size: this is trivially relocatable + // + // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no + // references to itself. This means that the entire structure is trivially relocatable if its members are. +@@ -311,7 +403,16 @@ public: + void>; + + private: ++ template <class _Up, class _OtherDeleter> ++ friend class unique_ptr; ++ + _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_); ++#ifdef _LIBCPP_ABI_BOUNDED_UNIQUE_PTR ++ using _BoundsChecker = __unique_ptr_array_bounds_stored; ++#else ++ using _BoundsChecker = __unique_ptr_array_bounds_stateless; ++#endif ++ _LIBCPP_NO_UNIQUE_ADDRESS _BoundsChecker __checker_; + + template <class _From> + struct _CheckArrayPointerConversion : is_same<_From, pointer> {}; +@@ -373,6 +474,12 @@ public: + : __ptr_(__p), + __deleter_() {} + ++ // Private constructor used by make_unique & friends to pass the size that was allocated ++ template <class _Tag, class _Ptr, __enable_if_t<is_same<_Tag, __private_constructor_tag>::value, int> = 0> ++ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Tag, _Ptr __ptr, size_t __size) _NOEXCEPT ++ : __ptr_(__ptr), ++ __checker_(__size) {} ++ + template <class _Pp, + bool _Dummy = true, + class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >, +@@ -411,11 +518,13 @@ public: + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT + : __ptr_(__u.release()), +- __deleter_(std::forward<deleter_type>(__u.get_deleter())) {} ++ __deleter_(std::forward<deleter_type>(__u.get_deleter())), ++ __checker_(std::move(__u.__checker_)) {} + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT { + reset(__u.release()); + __deleter_ = std::forward<deleter_type>(__u.get_deleter()); ++ __checker_ = std::move(std::move(__u.__checker_)); + return *this; + } + +@@ -425,7 +534,8 @@ public: + class = _EnableIfDeleterConvertible<_Ep> > + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT + : __ptr_(__u.release()), +- __deleter_(std::forward<_Ep>(__u.get_deleter())) {} ++ __deleter_(std::forward<_Ep>(__u.get_deleter())), ++ __checker_(std::move(__u.__checker_)) {} + + template <class _Up, + class _Ep, +@@ -434,6 +544,7 @@ public: + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT { + reset(__u.release()); + __deleter_ = std::forward<_Ep>(__u.get_deleter()); ++ __checker_ = std::move(__u.__checker_); + return *this; + } + +@@ -451,6 +562,8 @@ public: + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator[](size_t __i) const { ++ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__checker_.__in_bounds(std::__to_address(__ptr_), __i), ++ "unique_ptr<T[]>::operator[](index): index out of range"); + return __ptr_[__i]; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; } +@@ -467,6 +580,8 @@ public: + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT { + pointer __t = __ptr_; + __ptr_ = pointer(); ++ // The deleter and the optional bounds-checker are left unchanged. The bounds-checker ++ // will be reinitialized appropriately when/if the unique_ptr gets assigned-to or reset. + return __t; + } + +@@ -474,6 +589,7 @@ public: + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(_Pp __p) _NOEXCEPT { + pointer __tmp = __ptr_; + __ptr_ = __p; ++ __checker_ = _BoundsChecker(); + if (__tmp) + __deleter_(__tmp); + } +@@ -481,6 +597,7 @@ public: + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(nullptr_t = nullptr) _NOEXCEPT { + pointer __tmp = __ptr_; + __ptr_ = nullptr; ++ __checker_ = _BoundsChecker(); + if (__tmp) + __deleter_(__tmp); + } +@@ -489,6 +606,7 @@ public: + using std::swap; + swap(__ptr_, __u.__ptr_); + swap(__deleter_, __u.__deleter_); ++ swap(__checker_, __u.__checker_); + } + }; + +@@ -645,7 +763,7 @@ template <class _Tp> + inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound + make_unique(size_t __n) { + typedef __remove_extent_t<_Tp> _Up; +- return unique_ptr<_Tp>(new _Up[__n]()); ++ return unique_ptr<_Tp>(__private_constructor_tag(), new _Up[__n](), __n); + } + + template <class _Tp, class... _Args> +@@ -664,7 +782,7 @@ make_unique_for_overwrite() { + template <class _Tp> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound + make_unique_for_overwrite(size_t __n) { +- return unique_ptr<_Tp>(new __remove_extent_t<_Tp>[__n]); ++ return unique_ptr<_Tp>(__private_constructor_tag(), new __remove_extent_t<_Tp>[__n], __n); + } + + template <class _Tp, class... _Args> diff --git a/contrib/libs/cxxsupp/libcxx/patches/01-commit-e0e82fc-initial.patch b/contrib/libs/cxxsupp/libcxx/patches/01-commit-e0e82fc-initial.patch index 2de61b54c8..5da71f016b 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/01-commit-e0e82fc-initial.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/01-commit-e0e82fc-initial.patch @@ -1,8 +1,8 @@ diff --git a/include/__configuration/abi.h b/include/__configuration/abi.h -index 513da6e..c31fbba 100644 +index 707e10b..1e4c9cf 100644 --- a/include/__configuration/abi.h +++ b/include/__configuration/abi.h -@@ -47,7 +47,12 @@ +@@ -66,7 +66,12 @@ // Previously libc++ used "unsigned int" exclusively. # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION // Unstable attempt to provide a more optimized std::function @@ -17,10 +17,10 @@ index 513da6e..c31fbba 100644 # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO // Re-worked external template instantiations for std::string with a focus on diff --git a/include/typeinfo b/include/typeinfo -index d1c0de3..8b75ced 100644 +index a44fa4d..51d6305 100644 --- a/include/typeinfo +++ b/include/typeinfo -@@ -96,7 +96,13 @@ public: +@@ -97,7 +97,13 @@ public: size_t hash_code() const _NOEXCEPT; @@ -36,7 +36,7 @@ index d1c0de3..8b75ced 100644 // from different translation units, so it is sufficient to compare their addresses. if (__libcpp_is_constant_evaluated()) { diff --git a/src/filesystem/operations.cpp b/src/filesystem/operations.cpp -index a83c1ae..fd770e1 100644 +index d771f20..074f10b 100644 --- a/src/filesystem/operations.cpp +++ b/src/filesystem/operations.cpp @@ -37,7 +37,7 @@ @@ -68,7 +68,7 @@ index b0c7316..7f1cc67 100644 # define _LIBCPP_ASSERT_SHIM(expr, str) _LIBCPP_ASSERT(expr, str) diff --git a/src/support/runtime/exception_fallback.ipp b/src/support/runtime/exception_fallback.ipp -index 18ff4b8..d54a9a5 100644 +index bedb16e..09ec68e 100644 --- a/src/support/runtime/exception_fallback.ipp +++ b/src/support/runtime/exception_fallback.ipp @@ -33,6 +33,7 @@ terminate_handler set_terminate(terminate_handler func) noexcept { @@ -76,10 +76,10 @@ index 18ff4b8..d54a9a5 100644 terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__terminate_handler); } +#ifndef __EMSCRIPTEN__ // We provide this in JS - _LIBCPP_NORETURN void terminate() noexcept { + [[noreturn]] void terminate() noexcept { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -@@ -49,7 +50,9 @@ _LIBCPP_NORETURN void terminate() noexcept { +@@ -47,13 +48,16 @@ terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__term } #endif // _LIBCPP_HAS_NO_EXCEPTIONS } @@ -89,9 +89,8 @@ index 18ff4b8..d54a9a5 100644 bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } int uncaught_exceptions() noexcept { -@@ -57,6 +60,7 @@ int uncaught_exceptions() noexcept { - fprintf(stderr, "uncaught_exceptions not yet implemented\n"); - ::abort(); + #warning uncaught_exception not yet implemented + __libcpp_verbose_abort("uncaught_exceptions not yet implemented\n"); } +#endif // !__EMSCRIPTEN__ diff --git a/contrib/libs/cxxsupp/libcxx/patches/05-compiler-msvc.patch b/contrib/libs/cxxsupp/libcxx/patches/05-compiler-msvc.patch index 7fd238b6e0..660abaa75e 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/05-compiler-msvc.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/05-compiler-msvc.patch @@ -1,5 +1,5 @@ diff --git a/include/__functional/bind.h b/include/__functional/bind.h -index b4f4644..3996460 100644 +index 4251ef7..c1af67f 100644 --- a/include/__functional/bind.h +++ b/include/__functional/bind.h @@ -231,6 +231,10 @@ public: diff --git a/contrib/libs/cxxsupp/libcxx/patches/09-clang-cl-abi.patch b/contrib/libs/cxxsupp/libcxx/patches/09-clang-cl-abi.patch index bc70dbad33..1bdee4f09b 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/09-clang-cl-abi.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/09-clang-cl-abi.patch @@ -1,8 +1,8 @@ diff --git a/include/locale b/include/locale -index 19e81e1..0b2ac48 100644 +index 573910a..4a3df88 100644 --- a/include/locale +++ b/include/locale -@@ -2189,7 +2189,11 @@ public: +@@ -2197,7 +2197,11 @@ public: : time_put<_CharT, _OutputIterator>(__nm, __refs) {} protected: diff --git a/contrib/libs/cxxsupp/libcxx/patches/10-using_if_exists-in-clang11-and-msvcrt.patch b/contrib/libs/cxxsupp/libcxx/patches/10-using_if_exists-in-clang11-and-msvcrt.patch index 2b9affd402..b6f3270303 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/10-using_if_exists-in-clang11-and-msvcrt.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/10-using_if_exists-in-clang11-and-msvcrt.patch @@ -1,5 +1,5 @@ diff --git a/include/cstdlib b/include/cstdlib -index c817fd8..25a829b 100644 +index 1ecdd3a..02ee3a2 100644 --- a/include/cstdlib +++ b/include/cstdlib @@ -141,11 +141,11 @@ using ::wctomb _LIBCPP_USING_IF_EXISTS; @@ -17,11 +17,11 @@ index c817fd8..25a829b 100644 #endif diff --git a/include/ctime b/include/ctime -index f47b49a..cad942e 100644 +index d2d2470..2df861c 100644 --- a/include/ctime +++ b/include/ctime -@@ -65,7 +65,7 @@ using ::clock_t _LIBCPP_USING_IF_EXISTS; - using ::size_t _LIBCPP_USING_IF_EXISTS; +@@ -65,7 +65,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD + using ::clock_t _LIBCPP_USING_IF_EXISTS; using ::time_t _LIBCPP_USING_IF_EXISTS; using ::tm _LIBCPP_USING_IF_EXISTS; -#if _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/patches/14-has-no-threads.patch b/contrib/libs/cxxsupp/libcxx/patches/14-has-no-threads.patch index a3a9532a12..9a9a93c4cc 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/14-has-no-threads.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/14-has-no-threads.patch @@ -1,8 +1,8 @@ diff --git a/include/__memory/shared_ptr.h b/include/__memory/shared_ptr.h -index d487e4f..146b205 100644 +index 70964e6..0c622cd 100644 --- a/include/__memory/shared_ptr.h +++ b/include/__memory/shared_ptr.h -@@ -53,7 +53,7 @@ +@@ -55,7 +55,7 @@ #include <new> #include <typeinfo> #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) @@ -11,7 +11,7 @@ index d487e4f..146b205 100644 #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -@@ -137,7 +137,12 @@ class _LIBCPP_EXPORTED_FROM_ABI __shared_count { +@@ -139,7 +139,12 @@ class _LIBCPP_EXPORTED_FROM_ABI __shared_count { __shared_count& operator=(const __shared_count&); protected: @@ -25,7 +25,7 @@ index d487e4f..146b205 100644 virtual ~__shared_count(); private: -@@ -150,20 +155,41 @@ public: +@@ -152,20 +157,41 @@ public: void __add_shared() noexcept; bool __release_shared() noexcept; #else @@ -70,7 +70,7 @@ index d487e4f..146b205 100644 public: _LIBCPP_HIDE_FROM_ABI explicit __shared_weak_count(long __refs = 0) _NOEXCEPT -@@ -180,7 +206,13 @@ public: +@@ -182,7 +208,13 @@ public: void __release_shared() noexcept; #else _LIBCPP_HIDE_FROM_ABI void __add_shared() _NOEXCEPT { __shared_count::__add_shared(); } diff --git a/contrib/libs/cxxsupp/libcxx/patches/15-unique-ptr.patch b/contrib/libs/cxxsupp/libcxx/patches/15-unique-ptr.patch index c7ef8f3514..4d4fc9c8d3 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/15-unique-ptr.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/15-unique-ptr.patch @@ -1,8 +1,8 @@ diff --git a/include/__memory/unique_ptr.h b/include/__memory/unique_ptr.h -index 9519e42..8dd000b 100644 +index 9ca13d0..73e2f37 100644 --- a/include/__memory/unique_ptr.h +++ b/include/__memory/unique_ptr.h -@@ -40,6 +40,7 @@ +@@ -42,6 +42,7 @@ #include <__utility/forward.h> #include <__utility/move.h> #include <cstddef> @@ -10,7 +10,7 @@ index 9519e42..8dd000b 100644 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header -@@ -121,7 +122,7 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> { +@@ -123,7 +124,7 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> { # define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI #endif diff --git a/contrib/libs/cxxsupp/libcxx/patches/22__config.patch b/contrib/libs/cxxsupp/libcxx/patches/22__config.patch index ba17919a98..9397bad810 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/22__config.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/22__config.patch @@ -1,8 +1,8 @@ diff --git a/include/__config b/include/__config -index dfb14fd..56705ec 100644 +index ff5e3cf..eb1d07a 100644 --- a/include/__config +++ b/include/__config -@@ -563,7 +563,7 @@ typedef __char32_t char32_t; +@@ -518,7 +518,7 @@ typedef __char32_t char32_t; // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing // the length of symbols with an ABI tag. In practice, we should remove the escape hatch and // use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70. @@ -11,7 +11,7 @@ index dfb14fd..56705ec 100644 # define _LIBCPP_HIDE_FROM_ABI \ _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \ __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE)))) -@@ -841,7 +841,8 @@ typedef __char32_t char32_t; +@@ -803,7 +803,8 @@ typedef __char32_t char32_t; defined(__APPLE__) || \ defined(__MVS__) || \ defined(_AIX) || \ @@ -36,7 +36,7 @@ index 80ece22..d34361b 100644 # elif defined(_LIBCPP_APPLE_CLANG_VER) # if _LIBCPP_APPLE_CLANG_VER < 1500 diff --git a/include/__configuration/platform.h b/include/__configuration/platform.h -index 27f68d0..6d5b951 100644 +index 2a92ce2..78ad402 100644 --- a/include/__configuration/platform.h +++ b/include/__configuration/platform.h @@ -20,7 +20,7 @@ diff --git a/contrib/libs/cxxsupp/libcxx/patches/25__tuple.patch b/contrib/libs/cxxsupp/libcxx/patches/25__tuple.patch index 2011507f3a..7b276f342c 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/25__tuple.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/25__tuple.patch @@ -1,5 +1,5 @@ diff --git a/include/__tuple/sfinae_helpers.h b/include/__tuple/sfinae_helpers.h -index c7145e0..7db5eeb 100644 +index a785cec..4a6ff1f 100644 --- a/include/__tuple/sfinae_helpers.h +++ b/include/__tuple/sfinae_helpers.h @@ -41,7 +41,7 @@ struct __tuple_sfinae_base { diff --git a/contrib/libs/cxxsupp/libcxx/patches/28-cudacc.patch b/contrib/libs/cxxsupp/libcxx/patches/28-cudacc.patch index e67b8cac5a..9e742c148d 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/28-cudacc.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/28-cudacc.patch @@ -1,5 +1,5 @@ diff --git a/include/__algorithm/simd_utils.h b/include/__algorithm/simd_utils.h -index 549197b..c0d04c4 100644 +index 56518da..0299332 100644 --- a/include/__algorithm/simd_utils.h +++ b/include/__algorithm/simd_utils.h @@ -28,7 +28,7 @@ _LIBCPP_PUSH_MACROS @@ -40,32 +40,32 @@ index f3cd1e5..c0a77ef 100644 template <class _Iterator> using __is_segmented_iterator = __has_specialization<__segmented_iterator_traits<_Iterator> >; diff --git a/include/__math/traits.h b/include/__math/traits.h -index a448266..9fdf409 100644 +index 0c96f76..4ce554d 100644 --- a/include/__math/traits.h +++ b/include/__math/traits.h -@@ -67,7 +67,7 @@ _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf - return false; +@@ -92,7 +92,7 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> } + [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI -#ifdef _LIBCPP_PREFERRED_OVERLOAD +#ifdef _LIBCPP_PREFERRED_OVERLOAD && !defined(__CUDACC__) - _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { - return __builtin_isinf(__x); - } -@@ -94,7 +94,7 @@ _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan - return false; + _LIBCPP_PREFERRED_OVERLOAD + #endif + bool +@@ -116,7 +116,7 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> } + [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI -#ifdef _LIBCPP_PREFERRED_OVERLOAD +#ifdef _LIBCPP_PREFERRED_OVERLOAD && !defined(__CUDACC__) - _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { - return __builtin_isnan(__x); - } + _LIBCPP_PREFERRED_OVERLOAD + #endif + bool diff --git a/include/complex b/include/complex -index 22271ac..bfe61c5 100644 +index 4030d96..80471d9 100644 --- a/include/complex +++ b/include/complex -@@ -1453,6 +1453,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<double> operator""i(unsigned long +@@ -1454,6 +1454,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<double> operator""i(unsigned long return {0.0, static_cast<double>(__im)}; } @@ -73,7 +73,7 @@ index 22271ac..bfe61c5 100644 _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(long double __im) { return {0.0f, static_cast<float>(__im)}; } -@@ -1460,6 +1461,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(long double _ +@@ -1461,6 +1462,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(long double _ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long long __im) { return {0.0f, static_cast<float>(__im)}; } @@ -82,10 +82,10 @@ index 22271ac..bfe61c5 100644 } // namespace literals #endif diff --git a/include/tuple b/include/tuple -index 26652ff..9caeaaf 100644 +index e7e14b8..ab90d2b 100644 --- a/include/tuple +++ b/include/tuple -@@ -296,7 +296,7 @@ class __tuple_leaf { +@@ -305,7 +305,7 @@ class __tuple_leaf { template <class _Tp> static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() { @@ -94,7 +94,7 @@ index 26652ff..9caeaaf 100644 return !__reference_binds_to_temporary(_Hp, _Tp); # else return true; -@@ -603,8 +603,16 @@ public: +@@ -612,8 +612,16 @@ public: is_constructible<_Tp, _Up>... > {}; template <class... _Up, diff --git a/contrib/libs/cxxsupp/libcxx/patches/33__split_buffer.patch b/contrib/libs/cxxsupp/libcxx/patches/33__split_buffer.patch index e0c097402e..c119c32792 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/33__split_buffer.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/33__split_buffer.patch @@ -1,8 +1,8 @@ diff --git a/include/__split_buffer b/include/__split_buffer -index bab724d..2725b7d 100644 +index 7916769..5da7a1f 100644 --- a/include/__split_buffer +++ b/include/__split_buffer -@@ -164,7 +164,7 @@ public: +@@ -160,7 +160,7 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_front() { __destruct_at_begin(__begin_ + 1); } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() { __destruct_at_end(__end_ - 1); } @@ -11,7 +11,7 @@ index bab724d..2725b7d 100644 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x); -@@ -247,6 +247,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants +@@ -243,6 +243,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants return true; } diff --git a/contrib/libs/cxxsupp/libcxx/patches/35-set-map.patch b/contrib/libs/cxxsupp/libcxx/patches/35-set-map.patch index 1373447a0a..1026537cd8 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/35-set-map.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/35-set-map.patch @@ -1,8 +1,8 @@ diff --git a/include/map b/include/map -index 02bd17c..3fabcef 100644 +index 7fca4c8..04d2316 100644 --- a/include/map +++ b/include/map -@@ -1310,6 +1310,7 @@ public: +@@ -1317,6 +1317,7 @@ public: _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f.__i_, __l.__i_); } @@ -10,7 +10,7 @@ index 02bd17c..3fabcef 100644 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } #if _LIBCPP_STD_VER >= 17 -@@ -1936,6 +1937,7 @@ public: +@@ -1943,6 +1944,7 @@ public: } #endif @@ -19,10 +19,10 @@ index 02bd17c..3fabcef 100644 _LIBCPP_HIDE_FROM_ABI void swap(multimap& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { diff --git a/include/set b/include/set -index 9453358..f2d2b05 100644 +index 0c2ca64..6215f3c 100644 --- a/include/set +++ b/include/set -@@ -765,6 +765,7 @@ public: +@@ -774,6 +774,7 @@ public: _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); } _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); } _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); } @@ -30,7 +30,7 @@ index 9453358..f2d2b05 100644 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } #if _LIBCPP_STD_VER >= 17 -@@ -1220,6 +1221,7 @@ public: +@@ -1229,6 +1230,7 @@ public: _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); } _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); } _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); } diff --git a/contrib/libs/cxxsupp/libcxx/patches/36-math.patch b/contrib/libs/cxxsupp/libcxx/patches/36-math.patch index 1cc6ad277b..be8d095644 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/36-math.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/36-math.patch @@ -1,5 +1,5 @@ diff --git a/include/math.h b/include/math.h -index 4e6304a..4d245d4 100644 +index 509ecc4..99ec5ef 100644 --- a/include/math.h +++ b/include/math.h @@ -290,6 +290,9 @@ float truncf(float x); diff --git a/contrib/libs/cxxsupp/libcxx/patches/39-optional.patch b/contrib/libs/cxxsupp/libcxx/patches/39-optional.patch index 9428edf28d..045335beb8 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/39-optional.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/39-optional.patch @@ -1,8 +1,8 @@ diff --git a/include/optional b/include/optional -index e550745..992189b 100644 +index 7578833..f7224a2 100644 --- a/include/optional +++ b/include/optional -@@ -288,7 +288,7 @@ struct __optional_destruct_base<_Tp, false> { +@@ -291,7 +291,7 @@ struct __optional_destruct_base<_Tp, false> { }; bool __engaged_; diff --git a/contrib/libs/cxxsupp/libcxx/patches/40-deque.patch b/contrib/libs/cxxsupp/libcxx/patches/40-deque.patch index a4c0fd5d53..0f451418c9 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/40-deque.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/40-deque.patch @@ -1,8 +1,8 @@ diff --git a/include/deque b/include/deque -index 4fc994a..fc0e1ad 100644 +index bab0526..f6c748a 100644 --- a/include/deque +++ b/include/deque -@@ -248,7 +248,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD +@@ -261,7 +261,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _ValueType, class _DiffType> struct __deque_block_size { @@ -13,7 +13,7 @@ index 4fc994a..fc0e1ad 100644 }; template <class _ValueType, -@@ -804,7 +806,7 @@ public: +@@ -841,7 +843,7 @@ public: #else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); #endif @@ -22,7 +22,7 @@ index 4fc994a..fc0e1ad 100644 _LIBCPP_HIDE_FROM_ABI bool __invariants() const { if (!__map_.__invariants()) -@@ -2471,7 +2473,7 @@ inline void deque<_Tp, _Allocator>::swap(deque& __c) +@@ -2513,7 +2515,7 @@ inline void deque<_Tp, _Allocator>::swap(deque& __c) } template <class _Tp, class _Allocator> diff --git a/contrib/libs/cxxsupp/libcxx/patches/41-exception.patch b/contrib/libs/cxxsupp/libcxx/patches/41-exception.patch index 22a1fb8a4c..2cb7fcf03d 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/41-exception.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/41-exception.patch @@ -1,5 +1,5 @@ diff --git a/include/__exception/exception_ptr.h b/include/__exception/exception_ptr.h -index beadd92..d23450f 100644 +index 9e5351f..73ec464 100644 --- a/include/__exception/exception_ptr.h +++ b/include/__exception/exception_ptr.h @@ -55,8 +55,6 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception( @@ -59,10 +59,9 @@ index beadd92..d23450f 100644 - -_LIBCPP_EXPORTED_FROM_ABI void swap(exception_ptr&, exception_ptr&) _NOEXCEPT; - --_LIBCPP_EXPORTED_FROM_ABI exception_ptr __copy_exception_ptr(void* __except, const void* __ptr); + _LIBCPP_EXPORTED_FROM_ABI exception_ptr __copy_exception_ptr(void* __except, const void* __ptr); -_LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT; --_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); -+_LIBCPP_HIDE_FROM_ABI exception_ptr __copy_exception_ptr(void* __exception, const void* __ptr); +-[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); // This is a built-in template function which automagically extracts the required // information. diff --git a/contrib/libs/cxxsupp/libcxx/patches/43-string.patch b/contrib/libs/cxxsupp/libcxx/patches/43-string.patch index 7302481ce6..4bbaddb571 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/43-string.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/43-string.patch @@ -1,5 +1,5 @@ diff --git a/include/string b/include/string -index 9a52ab6..da86723 100644 +index fdb1890..e8ac1d4 100644 --- a/include/string +++ b/include/string @@ -83,6 +83,7 @@ template <> struct char_traits<char32_t>; @@ -10,7 +10,7 @@ index 9a52ab6..da86723 100644 public: // types: typedef traits traits_type; -@@ -997,9 +998,10 @@ public: +@@ -1077,15 +1078,18 @@ public: __init(__s, traits_type::length(__s)); } @@ -20,9 +20,8 @@ index 9a52ab6..da86723 100644 #endif + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(nullptr_t, size_t) = delete; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) - : __r_(__default_init_tag(), __default_init_tag()) { -@@ -1007,6 +1009,8 @@ public: + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) { + _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); __init(__s, __n); } @@ -30,8 +29,8 @@ index 9a52ab6..da86723 100644 + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) - : __r_(__default_init_tag(), __a) { -@@ -1171,7 +1175,7 @@ public: + : __alloc_(__a) { +@@ -1245,7 +1249,7 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const value_type* __s) { return assign(__s); } @@ -40,7 +39,7 @@ index 9a52ab6..da86723 100644 basic_string& operator=(nullptr_t) = delete; #endif _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c); -@@ -1228,6 +1232,10 @@ public: +@@ -1302,6 +1306,10 @@ public: return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1; } @@ -51,12 +50,12 @@ index 9a52ab6..da86723 100644 _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n, value_type __c); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__n, value_type()); } -@@ -1775,7 +1783,7 @@ public: +@@ -1849,7 +1857,7 @@ public: } #endif -#if _LIBCPP_STD_VER >= 23 +#if _LIBCPP_STD_VER >= 20 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept { - return __self_view(data(), size()).contains(__sv); + return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv); } diff --git a/contrib/libs/cxxsupp/libcxx/patches/45-type-traits.patch b/contrib/libs/cxxsupp/libcxx/patches/45-type-traits.patch index 3a28d36a24..275cfbacd7 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/45-type-traits.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/45-type-traits.patch @@ -41,33 +41,6 @@ index 05e070a..7907c1f 100644 _LIBCPP_END_NAMESPACE_STD -diff --git a/include/__type_traits/is_nothrow_constructible.h b/include/__type_traits/is_nothrow_constructible.h -index 2f7ed84..678debb 100644 ---- a/include/__type_traits/is_nothrow_constructible.h -+++ b/include/__type_traits/is_nothrow_constructible.h -@@ -25,7 +25,7 @@ - _LIBCPP_BEGIN_NAMESPACE_STD - - // GCC is disabled due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 --#if __has_builtin(__is_nothrow_constructible) && !defined(_LIBCPP_COMPILER_GCC) -+#if __has_builtin(__is_nothrow_constructible) && !defined(_LIBCPP_COMPILER_GCC) && !defined(__CUDACC__) - - template < class _Tp, class... _Args> - struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible -diff --git a/include/__type_traits/is_reference.h b/include/__type_traits/is_reference.h -index 42853d4..9d85646 100644 ---- a/include/__type_traits/is_reference.h -+++ b/include/__type_traits/is_reference.h -@@ -18,7 +18,8 @@ - - _LIBCPP_BEGIN_NAMESPACE_STD - --#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) && __has_builtin(__is_reference) -+#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) && __has_builtin(__is_reference) && \ -+ !defined(__CUDACC__) - - template <class _Tp> - struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {}; diff --git a/include/__type_traits/is_same.h b/include/__type_traits/is_same.h index 9561b7b..5013724 100644 --- a/include/__type_traits/is_same.h @@ -130,7 +103,7 @@ index 9561b7b..5013724 100644 _LIBCPP_END_NAMESPACE_STD diff --git a/include/__type_traits/remove_cv.h b/include/__type_traits/remove_cv.h -index 2c4e9e4..639a9c4 100644 +index 50e9f3e..e09cfd7 100644 --- a/include/__type_traits/remove_cv.h +++ b/include/__type_traits/remove_cv.h @@ -10,6 +10,8 @@ diff --git a/contrib/libs/cxxsupp/libcxx/patches/46-typeinfo-variant-valarray.patch b/contrib/libs/cxxsupp/libcxx/patches/46-typeinfo-variant-valarray.patch index 319af1ea80..4a7c387ffa 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/46-typeinfo-variant-valarray.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/46-typeinfo-variant-valarray.patch @@ -1,8 +1,8 @@ diff --git a/include/typeinfo b/include/typeinfo -index 8b75ced..266ae95 100644 +index 51d6305..3808966 100644 --- a/include/typeinfo +++ b/include/typeinfo -@@ -332,24 +332,40 @@ public: +@@ -334,24 +334,40 @@ public: class _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception { public: diff --git a/contrib/libs/cxxsupp/libcxx/patches/47-vector.patch b/contrib/libs/cxxsupp/libcxx/patches/47-vector.patch index e64f2e555e..d2cf1c1fdb 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/47-vector.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/47-vector.patch @@ -1,16 +1,16 @@ diff --git a/include/vector b/include/vector -index aaf51d1..0125901 100644 +index 7d3aac5..e7aea68 100644 --- a/include/vector +++ b/include/vector -@@ -348,6 +348,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ - #include <__type_traits/is_allocator.h> - #include <__type_traits/is_constructible.h> +@@ -362,6 +362,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ #include <__type_traits/is_nothrow_assignable.h> + #include <__type_traits/is_nothrow_constructible.h> + #include <__type_traits/is_same.h> +#include <__type_traits/is_trivially_destructible.h> - #include <__type_traits/noexcept_move_assign_container.h> + #include <__type_traits/is_trivially_relocatable.h> #include <__type_traits/type_identity.h> #include <__utility/exception_guard.h> -@@ -736,12 +737,22 @@ public: +@@ -757,12 +758,22 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last); @@ -34,7 +34,7 @@ index aaf51d1..0125901 100644 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz, const_reference __x); -@@ -824,7 +835,7 @@ private: +@@ -844,7 +855,7 @@ private: template <class _InputIterator, class _Sentinel> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n); @@ -42,8 +42,8 @@ index aaf51d1..0125901 100644 + void __append_uninitialized(size_type __n); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x); - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT { -@@ -1123,6 +1134,19 @@ vector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __ + +@@ -1167,6 +1178,19 @@ vector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __ __tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_); } @@ -63,7 +63,7 @@ index aaf51d1..0125901 100644 // Default constructs __n objects starting at __end_ // throws if construction throws // Postcondition: size() == size() + __n -@@ -1768,6 +1792,25 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __s +@@ -1816,6 +1840,25 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __s this->__destruct_at_end(this->__begin_ + __sz); } @@ -89,7 +89,7 @@ index aaf51d1..0125901 100644 template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x) #if _LIBCPP_STD_VER >= 14 -@@ -1803,6 +1846,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<_Tp, _Allocator>::__invariants() const +@@ -1850,6 +1893,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<_Tp, _Allocator>::__invariants() const return true; } @@ -97,7 +97,7 @@ index aaf51d1..0125901 100644 // vector<bool> template <class _Allocator> -@@ -2108,7 +2152,9 @@ public: +@@ -2152,7 +2196,9 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __position); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __first, const_iterator __last); @@ -108,7 +108,7 @@ index aaf51d1..0125901 100644 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(vector&) #if _LIBCPP_STD_VER >= 14 -@@ -2862,6 +2908,30 @@ struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > +@@ -2907,6 +2953,30 @@ struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > return __vec.__hash_code(); } }; diff --git a/contrib/libs/cxxsupp/libcxx/patches/49-string-view.patch b/contrib/libs/cxxsupp/libcxx/patches/49-string-view.patch index 65709d261a..2627f6e358 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/49-string-view.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/49-string-view.patch @@ -1,8 +1,8 @@ diff --git a/include/string_view b/include/string_view -index b2a4db4..058ca72 100644 +index 3b32117..69854c1 100644 --- a/include/string_view +++ b/include/string_view -@@ -306,6 +306,8 @@ public: +@@ -308,6 +308,8 @@ public: _LIBCPP_HIDE_FROM_ABI basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default; @@ -11,7 +11,7 @@ index b2a4db4..058ca72 100644 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT : __data_(__s), __size_(__len) { -@@ -344,7 +346,7 @@ public: +@@ -346,7 +348,7 @@ public: _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s) : __data_(__s), __size_(std::__char_traits_length_checked<_Traits>(__s)) {} @@ -20,7 +20,7 @@ index b2a4db4..058ca72 100644 basic_string_view(nullptr_t) = delete; #endif -@@ -664,7 +666,7 @@ public: +@@ -669,7 +671,7 @@ public: } #endif diff --git a/contrib/libs/cxxsupp/libcxx/patches/51-refstring.patch b/contrib/libs/cxxsupp/libcxx/patches/51-refstring.patch index f5d6d8d681..b3f983d8f6 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/51-refstring.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/51-refstring.patch @@ -1,5 +1,5 @@ diff --git a/src/include/refstring.h b/src/include/refstring.h -index 7845224..72daaef 100644 +index 3e0ec7a..bc1d7fa 100644 --- a/src/include/refstring.h +++ b/src/include/refstring.h @@ -9,12 +9,18 @@ diff --git a/contrib/libs/cxxsupp/libcxx/patches/53-exception_pointer_msvc.patch b/contrib/libs/cxxsupp/libcxx/patches/53-exception_pointer_msvc.patch index eb84ac68b1..9d9ce4d5ba 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/53-exception_pointer_msvc.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/53-exception_pointer_msvc.patch @@ -1,8 +1,8 @@ diff --git a/src/support/runtime/exception_pointer_msvc.ipp b/src/support/runtime/exception_pointer_msvc.ipp -index b87742b..43ac8ca 100644 +index 2be5136..1439f05 100644 --- a/src/support/runtime/exception_pointer_msvc.ipp +++ b/src/support/runtime/exception_pointer_msvc.ipp -@@ -7,61 +7,226 @@ +@@ -7,61 +7,225 @@ // //===----------------------------------------------------------------------===// @@ -75,7 +75,7 @@ index b87742b..43ac8ca 100644 +#ifdef __clang__ +struct _ThrowInfo; +// defined in vcruntime<ver>.dll -+extern "C" _LIBCPP_NORETURN void __stdcall _CxxThrowException(void* __exc, _ThrowInfo* __throw_info); ++extern "C" [[noreturn]] void __stdcall _CxxThrowException(void* __exc, _ThrowInfo* __throw_info); +#endif + +namespace { @@ -174,19 +174,13 @@ index b87742b..43ac8ca 100644 -exception_ptr::exception_ptr(nullptr_t) noexcept { __ExceptionPtrCreate(this); } - -exception_ptr::exception_ptr(const exception_ptr& __other) noexcept { __ExceptionPtrCopy(this, &__other); } --exception_ptr& exception_ptr::operator=(const exception_ptr& __other) noexcept { -- __ExceptionPtrAssign(this, &__other); -- return *this; +exception_ptr::exception_ptr(const exception_ptr& __other) noexcept : __ptr_(__other.__ptr_) { + if (__ptr_) { + reinterpret_cast<ExceptionPtr*>(__ptr_)->counter.fetch_add(1); + } - } - --exception_ptr& exception_ptr::operator=(nullptr_t) noexcept { -- exception_ptr dummy; -- __ExceptionPtrAssign(this, &dummy); -+exception_ptr& exception_ptr::operator=(const exception_ptr& __other) noexcept { ++} + exception_ptr& exception_ptr::operator=(const exception_ptr& __other) noexcept { +- __ExceptionPtrAssign(this, &__other); + auto before = __ptr_; + __ptr_ = __other.__ptr_; + if (__ptr_) { @@ -200,12 +194,10 @@ index b87742b..43ac8ca 100644 return *this; } --exception_ptr::~exception_ptr() noexcept { __ExceptionPtrDestroy(this); } -- --exception_ptr::operator bool() const noexcept { return __ExceptionPtrToBool(this); } -- --bool operator==(const exception_ptr& __x, const exception_ptr& __y) noexcept { -- return __ExceptionPtrCompare(&__x, &__y); +-exception_ptr& exception_ptr::operator=(nullptr_t) noexcept { +- exception_ptr dummy; +- __ExceptionPtrAssign(this, &dummy); +- return *this; +exception_ptr::~exception_ptr() noexcept { + if (__ptr_) { + if (reinterpret_cast<ExceptionPtr*>(__ptr_)->counter.fetch_sub(1) == 1) { @@ -214,6 +206,14 @@ index b87742b..43ac8ca 100644 + } } +-exception_ptr::~exception_ptr() noexcept { __ExceptionPtrDestroy(this); } +- +-exception_ptr::operator bool() const noexcept { return __ExceptionPtrToBool(this); } +- +-bool operator==(const exception_ptr& __x, const exception_ptr& __y) noexcept { +- return __ExceptionPtrCompare(&__x, &__y); +-} +- -void swap(exception_ptr& lhs, exception_ptr& rhs) noexcept { __ExceptionPtrSwap(&rhs, &lhs); } - -exception_ptr __copy_exception_ptr(void* __except, const void* __ptr) { @@ -249,8 +249,8 @@ index b87742b..43ac8ca 100644 + return exception_ptr(); } --_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); } -+_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { +-[[noreturn]] void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); } ++[[noreturn]] void rethrow_exception(exception_ptr p) { + if (!p) { + throw std::bad_exception(); + } diff --git a/contrib/libs/cxxsupp/libcxx/patches/56-iostream.patch b/contrib/libs/cxxsupp/libcxx/patches/56-iostream.patch index 3b13198871..1c412a80c4 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/56-iostream.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/56-iostream.patch @@ -1,15 +1,15 @@ diff --git a/include/__ostream/basic_ostream.h b/include/__ostream/basic_ostream.h -index 178359d..4f7e9cf 100644 +index 1f7fe83..3aadf67 100644 --- a/include/__ostream/basic_ostream.h +++ b/include/__ostream/basic_ostream.h -@@ -797,7 +797,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) { +@@ -800,7 +800,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) { std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); } --#if _LIBCPP_STD_VER >= 20 -+#if 0 && _LIBCPP_STD_VER >= 20 +-# if _LIBCPP_STD_VER >= 20 ++# if 0 && _LIBCPP_STD_VER >= 20 - # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS + # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <class _Traits> diff --git a/src/iostream.cpp b/src/iostream.cpp index c5ad77a..029de4a 100644 diff --git a/contrib/libs/cxxsupp/libcxx/patches/57-locale.patch b/contrib/libs/cxxsupp/libcxx/patches/57-locale.patch index e2858978c1..2f6f760698 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/57-locale.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/57-locale.patch @@ -1,5 +1,5 @@ diff --git a/src/locale.cpp b/src/locale.cpp -index 4efdc63..219575b 100644 +index 484963d..3d3dc3f 100644 --- a/src/locale.cpp +++ b/src/locale.cpp @@ -38,8 +38,8 @@ diff --git a/contrib/libs/cxxsupp/libcxx/patches/65-string-iterator-pointer.patch b/contrib/libs/cxxsupp/libcxx/patches/65-string-iterator-pointer.patch index 45b424726c..7e91011a87 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/65-string-iterator-pointer.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/65-string-iterator-pointer.patch @@ -1,23 +1,20 @@ diff --git a/include/string b/include/string -index da86723..74c0690 100644 +index e8ac1d4..5b960cd 100644 --- a/include/string +++ b/include/string -@@ -783,9 +783,14 @@ public: +@@ -833,7 +833,10 @@ public: "Allocator::value_type must be same type as value_type"); static_assert(__check_valid_allocator<allocator_type>::value, ""); +-#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING +#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1 + typedef pointer iterator; + typedef const_pointer const_iterator; -+#else - // TODO: Implement iterator bounds checking without requiring the global database. - typedef __wrap_iter<pointer> iterator; - typedef __wrap_iter<const_pointer> const_iterator; -+#endif - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - -@@ -1180,6 +1185,7 @@ public: ++#elif defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING) + // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's + // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is + // considered contiguous. +@@ -1254,6 +1257,7 @@ public: #endif _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c); @@ -25,7 +22,7 @@ index da86723..74c0690 100644 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { return __make_iterator(__get_pointer()); } -@@ -1192,6 +1198,20 @@ public: +@@ -1266,6 +1270,20 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT { return __make_const_iterator(__get_pointer() + size()); } diff --git a/contrib/libs/cxxsupp/libcxx/patches/66-vector-iterator-pointer.patch b/contrib/libs/cxxsupp/libcxx/patches/66-vector-iterator-pointer.patch index 603dfd0050..ab4163f0bc 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/66-vector-iterator-pointer.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/66-vector-iterator-pointer.patch @@ -1,63 +1,41 @@ diff --git a/include/vector b/include/vector -index 0125901..2f714f1 100644 +index e7aea68..fd58458 100644 --- a/include/vector +++ b/include/vector -@@ -401,9 +401,14 @@ public: +@@ -415,7 +415,10 @@ public: typedef typename __alloc_traits::difference_type difference_type; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; -+#if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 1 +-#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR ++#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1 + typedef pointer iterator; + typedef const_pointer const_iterator; -+#else - // TODO: Implement iterator bounds checking without requiring the global database. - typedef __wrap_iter<pointer> iterator; - typedef __wrap_iter<const_pointer> const_iterator; -+#endif - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - -@@ -838,12 +843,8 @@ private: - void __append_uninitialized(size_type __n); - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n); ++#elif defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR) + // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's + // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is + // considered contiguous. +@@ -860,7 +863,12 @@ private: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x); -- _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT { -- return iterator(__p); -- } -- _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { -- return const_iterator(__p); -- } -+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT; -+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void - __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer -@@ -1379,6 +1380,28 @@ vector<_Tp, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sentinel - } - } + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT { +-#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR ++ +// We need to save the make_iter function and replace all constructor calls with it +// Made to support pointer iterators -+template <class _Tp, class _Allocator> -+_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator -+vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT { -+#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1 -+ return iterator(__p); -+#else ++#if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 0 + return iterator(this, __p); -+#endif -+} -+ -+template <class _Tp, class _Allocator> -+_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_iterator -+vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT { -+#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1 -+ return const_iterator(__p); -+#else ++#elif defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR) + // Bound the iterator according to the capacity, rather than the size. + // + // Vector guarantees that iterators stay valid as long as no reallocation occurs even if new elements are inserted +@@ -880,7 +888,9 @@ private: + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { +-#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR ++#if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 0 + return const_iterator(this, __p); -+#endif -+} -+ - template <class _Tp, class _Allocator> - _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) { - if (__n <= capacity()) { ++#elif defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR) + // Bound the iterator according to the capacity, rather than the size. + return std::__make_bounded_iter( + std::__wrap_iter<const_pointer>(__p), diff --git a/contrib/libs/cxxsupp/libcxx/patches/71-char-traits-deprecated.patch b/contrib/libs/cxxsupp/libcxx/patches/71-char-traits-deprecated.patch index 15e330f8cd..5aaf2b609f 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/71-char-traits-deprecated.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/71-char-traits-deprecated.patch @@ -1,8 +1,8 @@ diff --git a/include/__string/char_traits.h b/include/__string/char_traits.h -index 2660ac2..44b46eb 100644 +index 9b7d567..39accc6 100644 --- a/include/__string/char_traits.h +++ b/include/__string/char_traits.h -@@ -74,6 +74,106 @@ exposition-only to document what members a char_traits specialization should pro +@@ -75,6 +75,106 @@ exposition-only to document what members a char_traits specialization should pro }; */ diff --git a/contrib/libs/cxxsupp/libcxx/patches/72-abi-has-no-init_primary_exception.patch b/contrib/libs/cxxsupp/libcxx/patches/72-abi-has-no-init_primary_exception.patch index 62b77eb50a..f44ea17940 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/72-abi-has-no-init_primary_exception.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/72-abi-has-no-init_primary_exception.patch @@ -1,5 +1,5 @@ diff --git a/include/__exception/exception_ptr.h b/include/__exception/exception_ptr.h -index d23450f..e9316f3 100644 +index 73ec464..fcf9074 100644 --- a/include/__exception/exception_ptr.h +++ b/include/__exception/exception_ptr.h @@ -99,7 +99,7 @@ public: diff --git a/contrib/libs/cxxsupp/libcxx/patches/75-allocator-removed-members.patch b/contrib/libs/cxxsupp/libcxx/patches/75-allocator-removed-members.patch index a99ecd0fb7..102eba4e2c 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/75-allocator-removed-members.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/75-allocator-removed-members.patch @@ -1,5 +1,5 @@ diff --git a/include/__memory/allocator.h b/include/__memory/allocator.h -index 2d8624e..c276b45 100644 +index cd146da..aa44ced 100644 --- a/include/__memory/allocator.h +++ b/include/__memory/allocator.h @@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD @@ -11,7 +11,7 @@ index 2d8624e..c276b45 100644 // These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17. // Specializing allocator<void> is deprecated, but not using it. template <> -@@ -134,7 +134,7 @@ public: +@@ -120,7 +120,7 @@ public: } // C++20 Removed members @@ -20,12 +20,3 @@ index 2d8624e..c276b45 100644 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer; _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference; -@@ -215,7 +215,7 @@ public: - } - - // C++20 Removed members --# if _LIBCPP_STD_VER <= 17 -+# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer; - _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; - _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference; diff --git a/contrib/libs/cxxsupp/libcxx/patches/77-simd_utils-clang14-win-clang18.patch b/contrib/libs/cxxsupp/libcxx/patches/77-simd_utils-clang14-win-clang18.patch index 9695de260e..e6be15e447 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/77-simd_utils-clang14-win-clang18.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/77-simd_utils-clang14-win-clang18.patch @@ -1,5 +1,5 @@ diff --git a/include/__algorithm/simd_utils.h b/include/__algorithm/simd_utils.h -index c0d04c4..8404007 100644 +index 0299332..fff3a08 100644 --- a/include/__algorithm/simd_utils.h +++ b/include/__algorithm/simd_utils.h @@ -28,7 +28,7 @@ _LIBCPP_PUSH_MACROS diff --git a/contrib/libs/cxxsupp/libcxx/patches/78-atomic_ref-clang14.patch b/contrib/libs/cxxsupp/libcxx/patches/78-atomic_ref-clang14.patch index 337e864866..1b8581ad80 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/78-atomic_ref-clang14.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/78-atomic_ref-clang14.patch @@ -1,8 +1,8 @@ diff --git a/include/__atomic/atomic_ref.h b/include/__atomic/atomic_ref.h -index 2849b82..a63a95c 100644 +index 465cd9a..301d42b 100644 --- a/include/__atomic/atomic_ref.h +++ b/include/__atomic/atomic_ref.h -@@ -254,7 +254,7 @@ template <class _Tp> +@@ -260,7 +260,7 @@ template <class _Tp> struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> { using __base = __atomic_ref_base<_Tp>; @@ -11,7 +11,7 @@ index 2849b82..a63a95c 100644 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) { _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( -@@ -300,7 +300,7 @@ template <class _Tp> +@@ -306,7 +306,7 @@ template <class _Tp> struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> { using __base = __atomic_ref_base<_Tp>; diff --git a/contrib/libs/cxxsupp/libcxx/patches/79-is_void-is_null_pointer-clang14.patch b/contrib/libs/cxxsupp/libcxx/patches/79-is_void-is_null_pointer-clang14.patch new file mode 100644 index 0000000000..5bf4f6b065 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/patches/79-is_void-is_null_pointer-clang14.patch @@ -0,0 +1,56 @@ +diff --git a/include/__type_traits/is_null_pointer.h b/include/__type_traits/is_null_pointer.h +index abc5d14..302b2f8 100644 +--- a/include/__type_traits/is_null_pointer.h ++++ b/include/__type_traits/is_null_pointer.h +@@ -12,6 +12,7 @@ + #include <__config> + #include <__cstddef/nullptr_t.h> + #include <__type_traits/integral_constant.h> ++#include <__type_traits/remove_cv.h> + + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) + # pragma GCC system_header +@@ -20,7 +21,11 @@ + _LIBCPP_BEGIN_NAMESPACE_STD + + template <class _Tp> ++#if __has_builtin(__remove_cv) + inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t); ++#else ++inline const bool __is_null_pointer_v = __is_same(__remove_cv_t<_Tp>, nullptr_t); ++#endif + + #if _LIBCPP_STD_VER >= 14 + template <class _Tp> +diff --git a/include/__type_traits/is_void.h b/include/__type_traits/is_void.h +index 562faae..813bf45 100644 +--- a/include/__type_traits/is_void.h ++++ b/include/__type_traits/is_void.h +@@ -11,6 +11,7 @@ + + #include <__config> + #include <__type_traits/integral_constant.h> ++#include <__type_traits/remove_cv.h> + + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) + # pragma GCC system_header +@@ -19,11 +20,19 @@ + _LIBCPP_BEGIN_NAMESPACE_STD + + template <class _Tp> ++#if __has_builtin(__remove_cv) + struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {}; ++#else ++struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_same(__remove_cv_t<_Tp>, void)> {}; ++#endif + + #if _LIBCPP_STD_VER >= 17 + template <class _Tp> ++# if __has_builtin(__remove_cv) + inline constexpr bool is_void_v = __is_same(__remove_cv(_Tp), void); ++# else ++inline constexpr bool is_void_v = __is_same(__remove_cv_t<_Tp>, void); ++# endif + #endif + + _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/patches/80-partial-revert-85da39d.patch b/contrib/libs/cxxsupp/libcxx/patches/80-partial-revert-85da39d.patch new file mode 100644 index 0000000000..5ea6a986a4 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/patches/80-partial-revert-85da39d.patch @@ -0,0 +1,52 @@ +diff --git a/include/__memory/allocator.h b/include/__memory/allocator.h +index aa44ced..e100e45 100644 +--- a/include/__memory/allocator.h ++++ b/include/__memory/allocator.h +@@ -170,6 +170,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const allocator<_Tp>&, const alloca + + #endif + ++#include <__memory/allocator_const.h> ++ + _LIBCPP_END_NAMESPACE_STD + + #endif // _LIBCPP___MEMORY_ALLOCATOR_H +diff --git a/include/__memory/uninitialized_algorithms.h b/include/__memory/uninitialized_algorithms.h +index 8ff87e2..a8dbde0 100644 +--- a/include/__memory/uninitialized_algorithms.h ++++ b/include/__memory/uninitialized_algorithms.h +@@ -563,8 +563,9 @@ struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_ty + + template <class _Alloc, + class _In, ++ class _RawTypeIn = __remove_const_t<_In>, + class _Out, +- __enable_if_t<is_trivially_copy_constructible<_In>::value && is_trivially_copy_assignable<_In>::value && ++ __enable_if_t<is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value && + is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value && + __allocator_has_trivial_copy_construct<_Alloc, _In>::value, + int> = 0> +@@ -578,7 +579,11 @@ __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* + } + return __first2; + } else { ++#ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST ++ return std::copy(__first1, __last1, const_cast<_RawTypeIn*>(__first2)); ++#else + return std::copy(__first1, __last1, __first2); ++#endif + } + } + +@@ -639,7 +644,11 @@ __uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _ + __guard.__complete(); + std::__allocator_destroy(__alloc, __first, __last); + } else { ++#ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST ++ __builtin_memcpy(const_cast<__remove_const_t<_Tp>*>(__result), __first, sizeof(_Tp) * (__last - __first)); ++#else + __builtin_memcpy(__result, __first, sizeof(_Tp) * (__last - __first)); ++#endif + } + } + diff --git a/contrib/libs/cxxsupp/libcxx/patches/fix-cuda-compilation.patch b/contrib/libs/cxxsupp/libcxx/patches/fix-cuda-compilation.patch deleted file mode 100644 index 9f0100d4ac..0000000000 --- a/contrib/libs/cxxsupp/libcxx/patches/fix-cuda-compilation.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/include/__random/binomial_distribution.h b/include/__random/binomial_distribution.h -index e8774bb..54f321a 100644 ---- a/include/__random/binomial_distribution.h -+++ b/include/__random/binomial_distribution.h -@@ -97,10 +97,6 @@ public: - } - }; - --#ifndef _LIBCPP_MSVCRT_LIKE --extern "C" double lgamma_r(double, int*); --#endif -- - inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) { - #if defined(_LIBCPP_MSVCRT_LIKE) - return lgamma(__d); diff --git a/contrib/libs/cxxsupp/libcxx/patches/xxx-config-epilogue.patch b/contrib/libs/cxxsupp/libcxx/patches/xxx-config-epilogue.patch index 4a19f1f583..662f1216b4 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/xxx-config-epilogue.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/xxx-config-epilogue.patch @@ -1,8 +1,8 @@ diff --git a/include/__config b/include/__config -index 56705ec..8ce18c1 100644 +index eb1d07a..8ea2c28 100644 --- a/include/__config +++ b/include/__config -@@ -1250,4 +1250,6 @@ typedef __char32_t char32_t; +@@ -1191,4 +1191,6 @@ typedef __char32_t char32_t; #endif // __cplusplus diff --git a/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch b/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch index d3d4b8d528..d5bd5b6e2f 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch @@ -12,10 +12,10 @@ index 1b73438..d954545 100644 _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/include/__expected/expected.h b/include/__expected/expected.h -index f618b20..d08222f 100644 +index f4ad455..6e5745c 100644 --- a/include/__expected/expected.h +++ b/include/__expected/expected.h -@@ -53,7 +53,7 @@ +@@ -55,7 +55,7 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> @@ -50,3 +50,16 @@ index c7fe3c5..928b677 100644 _LIBCPP_BEGIN_NAMESPACE_STD +diff --git a/include/expected b/include/expected +index 6a2f12f..ccdbc3b 100644 +--- a/include/expected ++++ b/include/expected +@@ -40,7 +40,7 @@ namespace std { + + #include <__config> + +-#if _LIBCPP_STD_VER >= 23 ++#if _LIBCPP_STD_VER >= 20 + # include <__expected/bad_expected_access.h> + # include <__expected/expected.h> + # include <__expected/unexpect.h> diff --git a/contrib/libs/cxxsupp/libcxx/src/any.cpp b/contrib/libs/cxxsupp/libcxx/src/any.cpp index b0ad695669..eaca2dd239 100644 --- a/contrib/libs/cxxsupp/libcxx/src/any.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/any.cpp @@ -12,7 +12,7 @@ namespace std { const char* bad_any_cast::what() const noexcept { return "bad any cast"; } } // namespace std -#include <experimental/__config> +#include <__config> // Preserve std::experimental::any_bad_cast for ABI compatibility // Even though it no longer exists in a header file diff --git a/contrib/libs/cxxsupp/libcxx/src/atomic.cpp b/contrib/libs/cxxsupp/libcxx/src/atomic.cpp index 1babc953ef..94b3ba72db 100644 --- a/contrib/libs/cxxsupp/libcxx/src/atomic.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/atomic.cpp @@ -94,11 +94,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) { - _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, NULL, NULL); + _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, nullptr, nullptr); } static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) { - _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL); + _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, nullptr, nullptr); } #else // <- Add other operating systems here diff --git a/contrib/libs/cxxsupp/libcxx/src/chrono.cpp b/contrib/libs/cxxsupp/libcxx/src/chrono.cpp index 83e8a64504..986360d036 100644 --- a/contrib/libs/cxxsupp/libcxx/src/chrono.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/chrono.cpp @@ -31,9 +31,10 @@ # include <sys/time.h> // for gettimeofday and timeval #endif -// OpenBSD does not have a fully conformant suite of POSIX timers, but +// OpenBSD and GPU do not have a fully conformant suite of POSIX timers, but // it does have clock_gettime and CLOCK_MONOTONIC which is all we need. -#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) +#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || defined(__AMDGPU__) || \ + defined(__NVPTX__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) # define _LIBCPP_HAS_CLOCK_GETTIME #endif diff --git a/contrib/libs/cxxsupp/libcxx/src/exception.cpp b/contrib/libs/cxxsupp/libcxx/src/exception.cpp index ddb186bf80..ac6324cd9f 100644 --- a/contrib/libs/cxxsupp/libcxx/src/exception.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/exception.cpp @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION +#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS + #include <exception> #include <new> #include <typeinfo> diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h index 572cc73292..09020fbede 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h @@ -225,7 +225,7 @@ private: ErrorHandler& operator=(ErrorHandler const&) = delete; }; -} // end namespace detail +} // namespace detail _LIBCPP_END_NAMESPACE_FILESYSTEM diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/file_descriptor.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/file_descriptor.h index 2c9e0d7f47..db66ad55bd 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/file_descriptor.h +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/file_descriptor.h @@ -291,7 +291,7 @@ inline file_status FileDescriptor::refresh_status(error_code& ec) { return m_status; } -} // end namespace detail +} // namespace detail _LIBCPP_END_NAMESPACE_FILESYSTEM diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_clock.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_clock.cpp index e13b2853e3..473a54a00f 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_clock.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_clock.cpp @@ -29,7 +29,8 @@ # include <sys/time.h> // for gettimeofday and timeval #endif -#if defined(__APPLE__) || defined(__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) +#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__AMDGPU__) || defined(__NVPTX__) || \ + (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) # define _LIBCPP_HAS_CLOCK_GETTIME #endif diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/format_string.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/format_string.h index a44def86f5..81c5a95ae3 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/format_string.h +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/format_string.h @@ -70,7 +70,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) string format_string(const cha return ret; } -} // end namespace detail +} // namespace detail _LIBCPP_END_NAMESPACE_FILESYSTEM diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp index fd770e1a4e..074f10b733 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp @@ -254,7 +254,7 @@ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_cod #endif // copy_file_impl implementation } // end anonymous namespace -} // end namespace detail +} // namespace detail bool __copy_file(const path& from, const path& to, copy_options options, error_code* ec) { using detail::FileDescriptor; @@ -732,7 +732,7 @@ uintmax_t remove_all_impl(path const& p, error_code& ec) { return count; } -} // end namespace +} // namespace uintmax_t __remove_all(const path& p, error_code* ec) { ErrorHandler<uintmax_t> err("remove_all", ec, &p); @@ -827,7 +827,7 @@ uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) { return 0; } -} // end namespace +} // namespace uintmax_t __remove_all(const path& p, error_code* ec) { ErrorHandler<uintmax_t> err("remove_all", ec, &p); diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/path.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/path.cpp index b201952137..58742442ba 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/path.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/path.cpp @@ -267,7 +267,7 @@ path path::lexically_relative(const path& base) const { // Find the first mismatching element auto PP = PathParser::CreateBegin(__pn_); auto PPBase = PathParser::CreateBegin(base.__pn_); - while (PP && PPBase && PP.State_ == PPBase.State_ && *PP == *PPBase) { + while (PP && PPBase && PP.State_ == PPBase.State_ && (*PP == *PPBase || PP.inRootDir())) { ++PP; ++PPBase; } @@ -368,7 +368,8 @@ size_t hash_value(const path& __p) noexcept { size_t hash_value = 0; hash<string_view_t> hasher; while (PP) { - hash_value = __hash_combine(hash_value, hasher(*PP)); + string_view_t Part = PP.inRootDir() ? PATHSTR("/") : *PP; + hash_value = __hash_combine(hash_value, hasher(Part)); ++PP; } return hash_value; diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h index 760cdb65da..b41c004341 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h @@ -490,7 +490,7 @@ using SSizeT = ::ssize_t; #endif -} // end namespace detail +} // namespace detail _LIBCPP_END_NAMESPACE_FILESYSTEM diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h index e05f252868..13f0d6f3b7 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h @@ -344,7 +344,7 @@ inline file_time_type __extract_last_write_time(const path& p, const StatT& st, #endif // !_LIBCPP_HAS_NO_FILESYSTEM -} // end namespace detail +} // namespace detail _LIBCPP_END_NAMESPACE_FILESYSTEM diff --git a/contrib/libs/cxxsupp/libcxx/src/include/atomic_support.h b/contrib/libs/cxxsupp/libcxx/src/include/atomic_support.h index 9ce41b3229..c4bc34ffc1 100644 --- a/contrib/libs/cxxsupp/libcxx/src/include/atomic_support.h +++ b/contrib/libs/cxxsupp/libcxx/src/include/atomic_support.h @@ -125,7 +125,7 @@ __libcpp_atomic_compare_exchange(_ValueType* __val, _ValueType* __expected, _Val #endif // _LIBCPP_HAS_NO_THREADS -} // end namespace +} // namespace _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/src/include/config_elast.h b/contrib/libs/cxxsupp/libcxx/src/include/config_elast.h index 899e124ad2..158b93e200 100644 --- a/contrib/libs/cxxsupp/libcxx/src/include/config_elast.h +++ b/contrib/libs/cxxsupp/libcxx/src/include/config_elast.h @@ -21,6 +21,8 @@ // where strerror/strerror_r can't handle out-of-range errno values. #if defined(ELAST) # define _LIBCPP_ELAST ELAST +#elif defined(__LLVM_LIBC__) +// No _LIBCPP_ELAST needed for LLVM libc #elif defined(_NEWLIB_VERSION) # define _LIBCPP_ELAST __ELASTERROR #elif defined(__NuttX__) diff --git a/contrib/libs/cxxsupp/libcxx/src/include/overridable_function.h b/contrib/libs/cxxsupp/libcxx/src/include/overridable_function.h index 10e7a856c3..dfb0d4da52 100644 --- a/contrib/libs/cxxsupp/libcxx/src/include/overridable_function.h +++ b/contrib/libs/cxxsupp/libcxx/src/include/overridable_function.h @@ -13,7 +13,7 @@ #include <__config> #include <cstdint> -#if defined(__arm64e__) && __has_feature(ptrauth_calls) +#if __has_feature(ptrauth_calls) #error # include <ptrauth.h> #endif @@ -61,8 +61,6 @@ // This mechanism should never be used outside of the libc++ built library. In particular, // attempting to use this within the libc++ headers will not work at all because we don't // want to be defining special sections inside user's executables which use our headers. -// This is provided inside libc++'s include tree solely to make it easier to share with -// libc++abi, which needs the same mechanism. // #if defined(_LIBCPP_OBJECT_FORMAT_MACHO) @@ -85,20 +83,21 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no uintptr_t __end = reinterpret_cast<uintptr_t>(&__lcxx_override_end); uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr); -#if defined(__arm64e__) && __has_feature(ptrauth_calls) +# if __has_feature(ptrauth_calls) // We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular, // we must NOT pass a function pointer, otherwise we will strip the function pointer, and then attempt // to authenticate and re-sign it when casting it to a uintptr_t again, which will fail because we just // stripped the function pointer. See rdar://122927845. __ptr = reinterpret_cast<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer)); -#endif +# endif // Finally, the function was overridden if it falls outside of the section's bounds. return __ptr < __start || __ptr > __end; } _LIBCPP_END_NAMESPACE_STD -#elif defined(_LIBCPP_OBJECT_FORMAT_ELF) +// The NVPTX linker cannot create '__start/__stop' sections. +#elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__) # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1 # define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE __attribute__((__section__("__lcxx_override"))) @@ -117,6 +116,11 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override); uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr); +# if __has_feature(ptrauth_calls) + // We must pass a void* to ptrauth_strip since it only accepts a pointer type. See full explanation above. + __ptr = reinterpret_cast<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer)); +# endif + return __ptr < __start || __ptr > __end; } _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/src/include/refstring.h b/contrib/libs/cxxsupp/libcxx/src/include/refstring.h index 72daaef62b..bc1d7fad9c 100644 --- a/contrib/libs/cxxsupp/libcxx/src/include/refstring.h +++ b/contrib/libs/cxxsupp/libcxx/src/include/refstring.h @@ -152,4 +152,4 @@ inline bool __libcpp_refstring::__uses_refcount() const { _LIBCPP_END_NAMESPACE_STD -#endif //_LIBCPP_REFSTRING_H +#endif // _LIBCPP_REFSTRING_H diff --git a/contrib/libs/cxxsupp/libcxx/src/locale.cpp b/contrib/libs/cxxsupp/libcxx/src/locale.cpp index 219575b204..3d3dc3ff64 100644 --- a/contrib/libs/cxxsupp/libcxx/src/locale.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/locale.cpp @@ -34,7 +34,7 @@ # define _CTYPE_DISABLE_MACROS #endif -#if !defined(_LIBCPP_MSVCRT) && !defined(__MINGW32__) && !defined(__BIONIC__) && !defined(__NuttX__) +#if __has_include("<langinfo.h>") # include <langinfo.h> #endif @@ -1020,7 +1020,7 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept { # warning ctype<char>::classic_table() is not implemented printf("ctype<char>::classic_table() is not implemented\n"); abort(); - return NULL; + return nullptr; # endif } #endif diff --git a/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp b/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp index 2117238e63..d2ff3509c5 100644 --- a/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp @@ -82,7 +82,7 @@ union ResourceInitHelper { // attribute with a value that's reserved for the implementation (we're the implementation). #include "memory_resource_init_helper.h" -} // end namespace +} // namespace memory_resource* new_delete_resource() noexcept { return &res_init.resources.new_delete_res; } diff --git a/contrib/libs/cxxsupp/libcxx/src/optional.cpp b/contrib/libs/cxxsupp/libcxx/src/optional.cpp index 62b474a312..4e7e28898f 100644 --- a/contrib/libs/cxxsupp/libcxx/src/optional.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/optional.cpp @@ -17,7 +17,7 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac } // namespace std -#include <experimental/__config> +#include <__config> // Preserve std::experimental::bad_optional_access for ABI compatibility // Even though it no longer exists in a header file diff --git a/contrib/libs/cxxsupp/libcxx/src/regex.cpp b/contrib/libs/cxxsupp/libcxx/src/regex.cpp index 9dc0c69854..6d9f06e213 100644 --- a/contrib/libs/cxxsupp/libcxx/src/regex.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/regex.cpp @@ -323,8 +323,8 @@ const classnames ClassNames[] = { {"xdigit", ctype_base::xdigit}}; struct use_strcmp { - bool operator()(const collationnames& x, const char* y) { return strcmp(x.elem_, y) < 0; } - bool operator()(const classnames& x, const char* y) { return strcmp(x.elem_, y) < 0; } + bool operator()(const collationnames& x, const char* y) const { return strcmp(x.elem_, y) < 0; } + bool operator()(const classnames& x, const char* y) const { return strcmp(x.elem_, y) < 0; } }; } // namespace diff --git a/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp b/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp index bc25c0f9e6..134d28efb7 100644 --- a/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -_LIBCPP_NORETURN void __throw_runtime_error(const char* msg) { +void __throw_runtime_error(const char* msg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw runtime_error(msg); #else diff --git a/contrib/libs/cxxsupp/libcxx/src/string.cpp b/contrib/libs/cxxsupp/libcxx/src/string.cpp index cf07b3ef1e..12db5381a7 100644 --- a/contrib/libs/cxxsupp/libcxx/src/string.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/string.cpp @@ -28,8 +28,8 @@ struct __basic_string_common; // The struct isn't declared anymore in the headers. It's only here for ABI compatibility. template <> struct __basic_string_common<true> { - _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; - _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; + [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; + [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; }; void __basic_string_common<true>::__throw_length_error() const { std::__throw_length_error("basic_string"); } diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp index 122dc5ed89..d0006a8468 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp @@ -48,7 +48,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs( size_t dest_remaining = max_dest_chars - dest_converted; if (dst == nullptr) { - result = mbrtowc(NULL, *src + source_converted, source_remaining, ps); + result = mbrtowc(nullptr, *src + source_converted, source_remaining, ps); } else if (dest_remaining >= source_remaining) { // dst has enough space to translate in-place. result = mbrtowc(dst + dest_converted, *src + source_converted, source_remaining, ps); @@ -86,7 +86,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs( if (dst) { if (result == terminated_sequence) - *src = NULL; + *src = nullptr; else *src += source_converted; } diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp index f037215233..df87b9ea07 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp @@ -41,7 +41,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs( size_t dest_remaining = dst_size_bytes - dest_converted; if (dst == nullptr) { - result = wcrtomb(NULL, c, ps); + result = wcrtomb(nullptr, c, ps); } else if (dest_remaining >= static_cast<size_t>(MB_CUR_MAX)) { // dst has enough space to translate in-place. result = wcrtomb(dst + dest_converted, c, ps); @@ -82,7 +82,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs( if (c == L'\0') { if (dst) - *src = NULL; + *src = nullptr; return dest_converted; } } diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp index 9a90e08e11..136999ec0b 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp @@ -20,12 +20,12 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) { std::string current_loc_name(setlocale(LC_ALL, 0)); // Check for errors. - if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == NULL) { + if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == nullptr) { errno = EINVAL; return (locale_t)0; } else { for (int _Cat = 0; _Cat <= _LC_MAX; ++_Cat) { - if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == NULL) { + if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == nullptr) { setlocale(LC_ALL, current_loc_name.c_str()); errno = EINVAL; return (locale_t)0; @@ -74,12 +74,12 @@ locale_t uselocale(locale_t newloc) { if (newloc) { // Set locales and check for errors. bool is_error = - (newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) || - (newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) || - (newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) || - (newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) || - (newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) || - (newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL); + (newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == nullptr) || + (newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == nullptr) || + (newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == nullptr) || + (newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == nullptr) || + (newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == nullptr) || + (newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == nullptr); if (is_error) { setlocale(LC_ALL, current_loc_name.c_str()); diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp index d54a9a5846..09ec68e2cd 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp +++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include <cstdio> +#include <__verbose_abort> namespace std { @@ -21,7 +21,7 @@ unexpected_handler set_unexpected(unexpected_handler func) noexcept { unexpected_handler get_unexpected() noexcept { return __libcpp_atomic_load(&__unexpected_handler); } -_LIBCPP_NORETURN void unexpected() { +[[noreturn]] void unexpected() { (*get_unexpected())(); // unexpected handler should not return terminate(); @@ -34,19 +34,17 @@ terminate_handler set_terminate(terminate_handler func) noexcept { terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__terminate_handler); } #ifndef __EMSCRIPTEN__ // We provide this in JS -_LIBCPP_NORETURN void terminate() noexcept { +[[noreturn]] void terminate() noexcept { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif // _LIBCPP_HAS_NO_EXCEPTIONS (*get_terminate())(); // handler should not return - fprintf(stderr, "terminate_handler unexpectedly returned\n"); - ::abort(); + __libcpp_verbose_abort("terminate_handler unexpectedly returned\n"); #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { // handler should not throw exception - fprintf(stderr, "terminate_handler unexpectedly threw an exception\n"); - ::abort(); + __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n"); } #endif // _LIBCPP_HAS_NO_EXCEPTIONS } @@ -57,8 +55,7 @@ bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } int uncaught_exceptions() noexcept { #warning uncaught_exception not yet implemented - fprintf(stderr, "uncaught_exceptions not yet implemented\n"); - ::abort(); + __libcpp_verbose_abort("uncaught_exceptions not yet implemented\n"); } #endif // !__EMSCRIPTEN__ diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_msvc.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_msvc.ipp index 323cd9d180..869b64d2f5 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_msvc.ipp +++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_msvc.ipp @@ -11,8 +11,7 @@ # error this header can only be used when targeting the MSVC ABI #endif -#include <stdio.h> -#include <stdlib.h> +#include <__verbose_abort> extern "C" { typedef void(__cdecl* terminate_handler)(); @@ -32,7 +31,7 @@ unexpected_handler set_unexpected(unexpected_handler func) noexcept { return ::s unexpected_handler get_unexpected() noexcept { return ::_get_unexpected(); } -_LIBCPP_NORETURN void unexpected() { +[[noreturn]] void unexpected() { (*get_unexpected())(); // unexpected handler should not return terminate(); @@ -42,19 +41,17 @@ terminate_handler set_terminate(terminate_handler func) noexcept { return ::set_ terminate_handler get_terminate() noexcept { return ::_get_terminate(); } -_LIBCPP_NORETURN void terminate() noexcept { +[[noreturn]] void terminate() noexcept { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif // _LIBCPP_HAS_NO_EXCEPTIONS (*get_terminate())(); // handler should not return - fprintf(stderr, "terminate_handler unexpectedly returned\n"); - ::abort(); + __libcpp_verbose_abort("terminate_handler unexpectedly returned\n"); #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { // handler should not throw exception - fprintf(stderr, "terminate_handler unexpectedly threw an exception\n"); - ::abort(); + __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n"); } #endif // _LIBCPP_HAS_NO_EXCEPTIONS } diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp index bdb17b9996..8f5c2060bb 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp +++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp @@ -40,7 +40,7 @@ nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {} nested_exception::~nested_exception() noexcept {} -_LIBCPP_NORETURN void nested_exception::rethrow_nested() const { +void nested_exception::rethrow_nested() const { if (__ptr_ == nullptr) terminate(); rethrow_exception(__ptr_); @@ -55,7 +55,7 @@ exception_ptr current_exception() noexcept { return ptr; } -_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { +void rethrow_exception(exception_ptr p) { __cxa_rethrow_primary_exception(p.__ptr_); // if p.__ptr_ is NULL, above returns so we terminate terminate(); diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp index 6dad248f9e..174b44ce0e 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp +++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp @@ -31,7 +31,7 @@ struct exception_ptr { } // namespace __exception_ptr -_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr); +[[noreturn]] void rethrow_exception(__exception_ptr::exception_ptr); exception_ptr::~exception_ptr() noexcept { reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); } @@ -55,13 +55,13 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {} -_LIBCPP_NORETURN void nested_exception::rethrow_nested() const { +[[noreturn]] void nested_exception::rethrow_nested() const { if (__ptr_ == nullptr) terminate(); rethrow_exception(__ptr_); } -_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { +[[noreturn]] void rethrow_exception(exception_ptr p) { rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p)); } diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp index 43ac8ca7e1..1439f058ea 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp +++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp @@ -63,7 +63,7 @@ extern "C" EHExceptionRecord** __current_exception(); #ifdef __clang__ struct _ThrowInfo; // defined in vcruntime<ver>.dll -extern "C" _LIBCPP_NORETURN void __stdcall _CxxThrowException(void* __exc, _ThrowInfo* __throw_info); +extern "C" [[noreturn]] void __stdcall _CxxThrowException(void* __exc, _ThrowInfo* __throw_info); #endif namespace { @@ -163,7 +163,6 @@ exception_ptr::exception_ptr(const exception_ptr& __other) noexcept : __ptr_(__o reinterpret_cast<ExceptionPtr*>(__ptr_)->counter.fetch_add(1); } } - exception_ptr& exception_ptr::operator=(const exception_ptr& __other) noexcept { auto before = __ptr_; __ptr_ = __other.__ptr_; @@ -211,7 +210,7 @@ exception_ptr current_exception() noexcept { return exception_ptr(); } -_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { +[[noreturn]] void rethrow_exception(exception_ptr p) { if (!p) { throw std::bad_exception(); } @@ -232,7 +231,7 @@ nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {} nested_exception::~nested_exception() noexcept {} -_LIBCPP_NORETURN void nested_exception::rethrow_nested() const { +[[noreturn]] void nested_exception::rethrow_nested() const { if (__ptr_ == nullptr) terminate(); rethrow_exception(__ptr_); diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp index e12b0caf41..05a71ce34e 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp +++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp @@ -7,33 +7,28 @@ // //===----------------------------------------------------------------------===// -#include <stdio.h> -#include <stdlib.h> +#include <__verbose_abort> namespace std { exception_ptr::~exception_ptr() noexcept { #warning exception_ptr not yet implemented - fprintf(stderr, "exception_ptr not yet implemented\n"); - ::abort(); + __libcpp_verbose_abort("exception_ptr not yet implemented\n"); } exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) { #warning exception_ptr not yet implemented - fprintf(stderr, "exception_ptr not yet implemented\n"); - ::abort(); + __libcpp_verbose_abort("exception_ptr not yet implemented\n"); } exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept { #warning exception_ptr not yet implemented - fprintf(stderr, "exception_ptr not yet implemented\n"); - ::abort(); + __libcpp_verbose_abort("exception_ptr not yet implemented\n"); } exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept { #warning exception_ptr not yet implemented - fprintf(stderr, "exception_ptr not yet implemented\n"); - ::abort(); + __libcpp_verbose_abort("exception_ptr not yet implemented\n"); } nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {} @@ -44,10 +39,9 @@ nested_exception::~nested_exception() noexcept {} #endif -_LIBCPP_NORETURN void nested_exception::rethrow_nested() const { +[[noreturn]] void nested_exception::rethrow_nested() const { #warning exception_ptr not yet implemented - fprintf(stderr, "exception_ptr not yet implemented\n"); - ::abort(); + __libcpp_verbose_abort("exception_ptr not yet implemented\n"); #if 0 if (__ptr_ == nullptr) terminate(); @@ -57,14 +51,12 @@ _LIBCPP_NORETURN void nested_exception::rethrow_nested() const { exception_ptr current_exception() noexcept { #warning exception_ptr not yet implemented - fprintf(stderr, "exception_ptr not yet implemented\n"); - ::abort(); + __libcpp_verbose_abort("exception_ptr not yet implemented\n"); } -_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { +[[noreturn]] void rethrow_exception(exception_ptr p) { #warning exception_ptr not yet implemented - fprintf(stderr, "exception_ptr not yet implemented\n"); - ::abort(); + __libcpp_verbose_abort("exception_ptr not yet implemented\n"); } } // namespace std diff --git a/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp b/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp index fed51d8b0b..ccf5ff5acb 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp @@ -17,13 +17,13 @@ // a pointer to a malloc'd string in *sptr. // If return >= 0, use free to delete *sptr. int __libcpp_vasprintf(char** sptr, const char* __restrict format, va_list ap) { - *sptr = NULL; + *sptr = nullptr; // Query the count required. va_list ap_copy; va_copy(ap_copy, ap); _LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") - int count = vsnprintf(NULL, 0, format, ap_copy); + int count = vsnprintf(nullptr, 0, format, ap_copy); _LIBCPP_DIAGNOSTIC_POP va_end(ap_copy); if (count < 0) @@ -81,7 +81,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst, // if result > 0, it's the size in bytes of that character. // othewise if result is zero it indicates the null character has been found. // otherwise it's an error and errno may be set. - size_t char_size = mbrtowc(dst ? dst + dest_converted : NULL, *src + source_converted, source_remaining, ps); + size_t char_size = mbrtowc(dst ? dst + dest_converted : nullptr, *src + source_converted, source_remaining, ps); // Don't do anything to change errno from here on. if (char_size > 0) { source_remaining -= char_size; @@ -95,7 +95,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst, } if (dst) { if (have_result && result == terminated_sequence) - *src = NULL; + *src = nullptr; else *src += source_converted; } @@ -141,7 +141,7 @@ size_t wcsnrtombs(char* __restrict dst, if (dst) result = wcrtomb_s(&char_size, dst + dest_converted, dest_remaining, c, ps); else - result = wcrtomb_s(&char_size, NULL, 0, c, ps); + result = wcrtomb_s(&char_size, nullptr, 0, c, ps); // If result is zero there is no error and char_size contains the // size of the multi-byte-sequence converted. // Otherwise result indicates an errno type error. @@ -161,7 +161,7 @@ size_t wcsnrtombs(char* __restrict dst, } if (dst) { if (terminator_found) - *src = NULL; + *src = nullptr; else *src = *src + source_converted; } diff --git a/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp b/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp index a2585c0b89..3a67d759f0 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp @@ -129,7 +129,7 @@ __libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter, int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)(void)) { if (!InitOnceExecuteOnce( - (PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), NULL)) + (PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), nullptr)) return GetLastError(); return 0; } diff --git a/contrib/libs/cxxsupp/libcxx/src/system_error.cpp b/contrib/libs/cxxsupp/libcxx/src/system_error.cpp index f518b480a2..3367bd56bd 100644 --- a/contrib/libs/cxxsupp/libcxx/src/system_error.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/system_error.cpp @@ -110,7 +110,7 @@ string make_error_str(const error_code& ec) { } return string(); } -} // end namespace +} // namespace string __do_message::message(int ev) const { #if defined(_LIBCPP_HAS_NO_THREADS) diff --git a/contrib/libs/cxxsupp/libcxx/src/vector.cpp b/contrib/libs/cxxsupp/libcxx/src/vector.cpp index b6153b0e9b..3f3a906d64 100644 --- a/contrib/libs/cxxsupp/libcxx/src/vector.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/vector.cpp @@ -17,8 +17,8 @@ struct __vector_base_common; template <> struct __vector_base_common<true> { - _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; - _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; + [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; + [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; }; void __vector_base_common<true>::__throw_length_error() const { std::__throw_length_error("vector"); } diff --git a/contrib/libs/cxxsupp/libcxx/ya.make b/contrib/libs/cxxsupp/libcxx/ya.make index c4b545164e..65279dbd8b 100644 --- a/contrib/libs/cxxsupp/libcxx/ya.make +++ b/contrib/libs/cxxsupp/libcxx/ya.make @@ -14,9 +14,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(2024-07-08) +VERSION(2024-09-20) -ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/8ab82a2dc308c27fbdd0a87b5be7dddc623f1b0e.tar.gz) +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/6d66ac51a49af7ee46f1ccac45d312352d8b942e.tar.gz) ADDINCL( GLOBAL contrib/libs/cxxsupp/libcxx/include diff --git a/contrib/libs/expat/.yandex_meta/devtools.copyrights.report b/contrib/libs/expat/.yandex_meta/devtools.copyrights.report index 57cb69b65e..62bd8e460f 100644 --- a/contrib/libs/expat/.yandex_meta/devtools.copyrights.report +++ b/contrib/libs/expat/.yandex_meta/devtools.copyrights.report @@ -29,18 +29,6 @@ # FILE_INCLUDE - include all file data into licenses text file # ======================= -KEEP COPYRIGHT_SERVICE_LABEL 007454c8100a75981ead0fc679fb038f -BELONGS ya.make - License text: - Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper - Copyright (c) 2001-2022 Expat maintainers - Scancode info: - Original SPDX id: COPYRIGHT_SERVICE_LABEL - Score : 100.00 - Match type : COPYRIGHT - Files with this license: - COPYING [1:2] - KEEP COPYRIGHT_SERVICE_LABEL 05014a3c04ec6fa887b93f5ee617cd76 BELONGS ya.make Note: matched license text is too long. Read it in the source files. @@ -272,7 +260,7 @@ KEEP COPYRIGHT_SERVICE_LABEL 581b53ae6f0fb8a0cc30c73b46bc3441 BELONGS ya.make License text: Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper - Copyright (c) 2001-2022 Expat maintainers + Copyright (c) 2001-2025 Expat maintainers Scancode info: Original SPDX id: COPYRIGHT_SERVICE_LABEL Score : 100.00 @@ -341,6 +329,7 @@ BELONGS ya.make Match type : COPYRIGHT Files with this license: expat.h [9:22] + lib/internal.h [28:36] lib/xmlparse.c [9:44] KEEP COPYRIGHT_SERVICE_LABEL 61052a80fd00eeac5fb41a5ab5fdeff7 @@ -403,6 +392,18 @@ BELONGS ya.make Files with this license: lib/xmltok.c [9:27] +KEEP COPYRIGHT_SERVICE_LABEL 868bf74335c8c4c3a6c576a3120e708c +BELONGS ya.make + License text: + Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper + Copyright (c) 2001-2025 Expat maintainers + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + COPYING [1:2] + KEEP COPYRIGHT_SERVICE_LABEL 8cba36e37749b7d96d8bc8a7b47d0f6f BELONGS ya.make Note: matched license text is too long. Read it in the source files. @@ -802,7 +803,6 @@ BELONGS ya.make Score : 100.00 Match type : COPYRIGHT Files with this license: - lib/internal.h [28:36] lib/xmltok.c [9:27] lib/xmltok.h [9:15] diff --git a/contrib/libs/expat/.yandex_meta/devtools.licenses.report b/contrib/libs/expat/.yandex_meta/devtools.licenses.report index f11728285f..c79ad13859 100644 --- a/contrib/libs/expat/.yandex_meta/devtools.licenses.report +++ b/contrib/libs/expat/.yandex_meta/devtools.licenses.report @@ -38,7 +38,7 @@ BELONGS ya.make Match type : NOTICE Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT Files with this license: - README.md [37:41] + README.md [38:42] KEEP MIT 6bb6514a1d779748b76a73215a89ae66 BELONGS ya.make diff --git a/contrib/libs/expat/.yandex_meta/licenses.list.txt b/contrib/libs/expat/.yandex_meta/licenses.list.txt index 34ffa1ea4e..c7bc6c7712 100644 --- a/contrib/libs/expat/.yandex_meta/licenses.list.txt +++ b/contrib/libs/expat/.yandex_meta/licenses.list.txt @@ -180,7 +180,7 @@ Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net> Copyright (c) 2003 Greg Stein <gstein@users.sourceforge.net> - Copyright (c) 2016-2024 Sebastian Pipping <sebastian@pipping.org> + Copyright (c) 2016-2025 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com> Copyright (c) 2019 David Loffredo <loffredo@steptools.com> Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <snild@sony.com> @@ -190,7 +190,7 @@ ====================COPYRIGHT==================== Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper -Copyright (c) 2001-2022 Expat maintainers +Copyright (c) 2001-2025 Expat maintainers ====================File: AUTHORS==================== diff --git a/contrib/libs/expat/.yandex_meta/override.nix b/contrib/libs/expat/.yandex_meta/override.nix index 01e7ca5b3c..8ca5ea46b8 100644 --- a/contrib/libs/expat/.yandex_meta/override.nix +++ b/contrib/libs/expat/.yandex_meta/override.nix @@ -1,12 +1,12 @@ pkgs: attrs: with pkgs; with attrs; rec { - version = "2.7.0"; + version = "2.7.1"; versionTag = "R_${lib.replaceStrings ["."] ["_"] version}"; src = fetchFromGitHub { owner = "libexpat"; repo = "libexpat"; rev = "${versionTag}"; - hash = "sha256-5is+ZwHM+tmKaVzDgO20wCJKJafnwxxRjNMDsv2qnYY="; + hash = "sha256-fAJgHW3KIe5qtQ0ymRiyB8WBt05bMz8b3+JBibCpzQw="; }; nativeBuildInputs = [ autoreconfHook ]; diff --git a/contrib/libs/expat/COPYING b/contrib/libs/expat/COPYING index ce9e593929..c6d184a8aa 100644 --- a/contrib/libs/expat/COPYING +++ b/contrib/libs/expat/COPYING @@ -1,5 +1,5 @@ Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper -Copyright (c) 2001-2022 Expat maintainers +Copyright (c) 2001-2025 Expat maintainers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/contrib/libs/expat/Changes b/contrib/libs/expat/Changes index 1f5ba0a028..9d6c64b6a4 100644 --- a/contrib/libs/expat/Changes +++ b/contrib/libs/expat/Changes @@ -37,6 +37,44 @@ !! THANK YOU! Sebastian Pipping -- Berlin, 2024-03-09 !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +Release 2.7.1 Thu March 27 2025 + Bug fixes: + #980 #989 Restore event pointer behavior from Expat 2.6.4 + (that the fix to CVE-2024-8176 changed in 2.7.0); + affected API functions are: + - XML_GetCurrentByteCount + - XML_GetCurrentByteIndex + - XML_GetCurrentColumnNumber + - XML_GetCurrentLineNumber + - XML_GetInputContext + + Other changes: + #976 #977 Autotools: Integrate files "fuzz/xml_lpm_fuzzer.{cpp,proto}" + with Automake that were missing from 2.7.0 release tarballs + #983 #984 Fix printf format specifiers for 32bit Emscripten + #992 docs: Promote OpenSSF Best Practices self-certification + #978 tests/benchmark: Resolve mistaken double close + #986 Address compiler warnings + #990 #993 Version info bumped from 11:1:10 (libexpat*.so.1.10.1) + to 11:2:10 (libexpat*.so.1.10.2); see https://verbump.de/ + for what these numbers do + + Infrastructure: + #982 CI: Start running Perl XML::Parser integration tests + #987 CI: Enforce Clang Static Analyzer clean code + #991 CI: Re-enable warning clang-analyzer-valist.Uninitialized + for clang-tidy + #981 CI: Cover compilation with musl + #983 #984 CI: Cover compilation with 32bit Emscripten + #976 #977 CI: Protect against fuzzer files missing from future + release archives + + Special thanks to: + Berkay Eren Ürün + Matthew Fernandez + and + Perl XML::Parser + Release 2.7.0 Thu March 13 2025 Security fixes: #893 #973 CVE-2024-8176 -- Fix crash from chaining a large number diff --git a/contrib/libs/expat/README.md b/contrib/libs/expat/README.md index 04db829909..77c6bf27d3 100644 --- a/contrib/libs/expat/README.md +++ b/contrib/libs/expat/README.md @@ -3,6 +3,7 @@ [](https://repology.org/metapackage/expat/versions) [](https://sourceforge.net/projects/expat/files/) [](https://github.com/libexpat/libexpat/releases) +[](https://www.bestpractices.dev/projects/10205) > [!CAUTION] > @@ -11,7 +12,7 @@ > at the top of the `Changes` file. -# Expat, Release 2.7.0 +# Expat, Release 2.7.1 This is Expat, a C99 library for parsing [XML 1.0 Fourth Edition](https://www.w3.org/TR/2006/REC-xml-20060816/), started by diff --git a/contrib/libs/expat/expat.h b/contrib/libs/expat/expat.h index 192cfd3f07..610e1ddc0e 100644 --- a/contrib/libs/expat/expat.h +++ b/contrib/libs/expat/expat.h @@ -1068,7 +1068,7 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled); */ #define XML_MAJOR_VERSION 2 #define XML_MINOR_VERSION 7 -#define XML_MICRO_VERSION 0 +#define XML_MICRO_VERSION 1 #ifdef __cplusplus } diff --git a/contrib/libs/expat/expat_config.h b/contrib/libs/expat/expat_config.h index 4bb2d079bd..5ccd768606 100644 --- a/contrib/libs/expat/expat_config.h +++ b/contrib/libs/expat/expat_config.h @@ -83,7 +83,7 @@ #define PACKAGE_NAME "expat" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "expat 2.7.0" +#define PACKAGE_STRING "expat 2.7.1" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "expat" @@ -92,7 +92,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "2.7.0" +#define PACKAGE_VERSION "2.7.1" /* Define to 1 if all of the C90 standard headers exist (not just the ones required in a freestanding environment). This macro is provided for @@ -100,7 +100,7 @@ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "2.7.0" +#define VERSION "2.7.1" /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ diff --git a/contrib/libs/expat/lib/internal.h b/contrib/libs/expat/lib/internal.h index 167ec36804..6bde6ae6b3 100644 --- a/contrib/libs/expat/lib/internal.h +++ b/contrib/libs/expat/lib/internal.h @@ -28,7 +28,7 @@ Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net> Copyright (c) 2003 Greg Stein <gstein@users.sourceforge.net> - Copyright (c) 2016-2024 Sebastian Pipping <sebastian@pipping.org> + Copyright (c) 2016-2025 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com> Copyright (c) 2019 David Loffredo <loffredo@steptools.com> Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <snild@sony.com> @@ -127,6 +127,9 @@ # elif ULONG_MAX == 18446744073709551615u // 2^64-1 # define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld" # define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu" +# elif defined(EMSCRIPTEN) // 32bit mode Emscripten +# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld" +# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "zu" # else # define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d" # define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u" diff --git a/contrib/libs/expat/lib/xmlparse.c b/contrib/libs/expat/lib/xmlparse.c index 1dca1c0397..803ead9220 100644 --- a/contrib/libs/expat/lib/xmlparse.c +++ b/contrib/libs/expat/lib/xmlparse.c @@ -1,4 +1,4 @@ -/* 7d6840a33c250b74adb0ba295d6ec818dccebebaffc8c3ed27d0b29c28adbeb3 (2.7.0+) +/* d19ae032c224863c1527ba44d228cc34b99192c3a4c5a27af1f4e054d45ee031 (2.7.1+) __ __ _ ___\ \/ /_ __ __ _| |_ / _ \\ /| '_ \ / _` | __| @@ -3402,12 +3402,13 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, break; /* LCOV_EXCL_STOP */ } - *eventPP = s = next; switch (parser->m_parsingStatus.parsing) { case XML_SUSPENDED: + *eventPP = next; *nextPtr = next; return XML_ERROR_NONE; case XML_FINISHED: + *eventPP = next; return XML_ERROR_ABORTED; case XML_PARSING: if (parser->m_reenter) { @@ -3416,6 +3417,7 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, } /* Fall through */ default:; + *eventPP = s = next; } } /* not reached */ @@ -4332,12 +4334,13 @@ doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr, /* LCOV_EXCL_STOP */ } - *eventPP = s = next; switch (parser->m_parsingStatus.parsing) { case XML_SUSPENDED: + *eventPP = next; *nextPtr = next; return XML_ERROR_NONE; case XML_FINISHED: + *eventPP = next; return XML_ERROR_ABORTED; case XML_PARSING: if (parser->m_reenter) { @@ -4345,6 +4348,7 @@ doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr, } /* Fall through */ default:; + *eventPP = s = next; } } /* not reached */ @@ -5951,12 +5955,13 @@ epilogProcessor(XML_Parser parser, const char *s, const char *end, default: return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; } - parser->m_eventPtr = s = next; switch (parser->m_parsingStatus.parsing) { case XML_SUSPENDED: + parser->m_eventPtr = next; *nextPtr = next; return XML_ERROR_NONE; case XML_FINISHED: + parser->m_eventPtr = next; return XML_ERROR_ABORTED; case XML_PARSING: if (parser->m_reenter) { @@ -5964,6 +5969,7 @@ epilogProcessor(XML_Parser parser, const char *s, const char *end, } /* Fall through */ default:; + parser->m_eventPtr = s = next; } } } @@ -8245,7 +8251,7 @@ entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity, (void *)rootParser, rootParser->m_entity_stats.countEverOpened, rootParser->m_entity_stats.currentDepth, rootParser->m_entity_stats.maximumDepthSeen, - (rootParser->m_entity_stats.currentDepth - 1) * 2, "", + ((int)rootParser->m_entity_stats.currentDepth - 1) * 2, "", entity->is_param ? "%" : "&", entityName, action, entity->textLen, sourceLine); } diff --git a/contrib/libs/expat/ya.make b/contrib/libs/expat/ya.make index b41c7311e2..81ab2c6e28 100644 --- a/contrib/libs/expat/ya.make +++ b/contrib/libs/expat/ya.make @@ -10,9 +10,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(2.7.0) +VERSION(2.7.1) -ORIGINAL_SOURCE(https://github.com/libexpat/libexpat/archive/R_2_7_0.tar.gz) +ORIGINAL_SOURCE(https://github.com/libexpat/libexpat/archive/R_2_7_1.tar.gz) ADDINCL( contrib/libs/expat diff --git a/contrib/libs/fmt/include/fmt/args.h b/contrib/libs/fmt/include/fmt/args.h index 9a8e4ed2ce..3efd7d021a 100644 --- a/contrib/libs/fmt/include/fmt/args.h +++ b/contrib/libs/fmt/include/fmt/args.h @@ -51,6 +51,7 @@ class dynamic_arg_list { public: template <typename T, typename Arg> const T& push(const Arg& arg) { + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) auto new_node = std::unique_ptr<typed_node<T>>(new typed_node<T>(arg)); auto& value = new_node->value; new_node->next = std::move(head_); diff --git a/contrib/libs/fmt/patches/01-clang-tidy-unique-ptr.patch b/contrib/libs/fmt/patches/01-clang-tidy-unique-ptr.patch new file mode 100644 index 0000000000..424e051e2c --- /dev/null +++ b/contrib/libs/fmt/patches/01-clang-tidy-unique-ptr.patch @@ -0,0 +1,10 @@ +--- contrib/libs/fmt/include/fmt/args.h (b92e22f2baa7a4b746902dd4641a3025ca1f424f) ++++ contrib/libs/fmt/include/fmt/args.h (working tree) +@@ -51,6 +51,7 @@ class dynamic_arg_list { + + public: + template <typename T, typename Arg> const T& push(const Arg& arg) { ++ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) + auto new_node = std::unique_ptr<typed_node<T>>(new typed_node<T>(arg)); + auto& value = new_node->value; + new_node->next = std::move(head_); diff --git a/contrib/libs/libc_compat/ya.make b/contrib/libs/libc_compat/ya.make index 537ecdb9c5..266ffcd5ff 100644 --- a/contrib/libs/libc_compat/ya.make +++ b/contrib/libs/libc_compat/ya.make @@ -23,8 +23,8 @@ IF (NOT OS_WINDOWS) ) ENDIF() -DISABLE(PROVIDE_GETRANDOM_GETENTROPY) -DISABLE(PROVIDE_REALLOCARRAY) +DEFAULT(PROVIDE_GETRANDOM_GETENTROPY "no") +DEFAULT(PROVIDE_REALLOCARRAY "no") # Android libc function appearance is documented here: # https://android.googlesource.com/platform/bionic/+/master/docs/status.md @@ -115,7 +115,7 @@ IF (OS_LINUX AND NOT MUSL) explicit_bzero.c ) ENDIF() - IF (OS_SDK != "ubuntu-20" AND OS_SDK != "ubuntu-22") + IF (OS_SDK != "ubuntu-20" AND OS_SDK != "ubuntu-22" AND OS_SDK != "local") # reallocarray was added in glibc=2.29 ENABLE(PROVIDE_REALLOCARRAY) ENDIF() diff --git a/contrib/libs/lzma/.yandex_meta/__init__.py b/contrib/libs/lzma/.yandex_meta/__init__.py index 29e2a09e7e..3705027de7 100644 --- a/contrib/libs/lzma/.yandex_meta/__init__.py +++ b/contrib/libs/lzma/.yandex_meta/__init__.py @@ -13,6 +13,7 @@ lzma = GNUMakeNixProject( flags=["--localedir=/var/empty"], disable_includes=[ "crc32_arm64.h", + "crc32_loongarch.h", "crc32_table_be.h", "crc64_table_be.h", "dpmi.h", diff --git a/contrib/libs/lzma/.yandex_meta/devtools.copyrights.report b/contrib/libs/lzma/.yandex_meta/devtools.copyrights.report index f182796fbd..4b168d8f34 100644 --- a/contrib/libs/lzma/.yandex_meta/devtools.copyrights.report +++ b/contrib/libs/lzma/.yandex_meta/devtools.copyrights.report @@ -55,7 +55,7 @@ BELONGS ya.make Score : 100.00 Match type : COPYRIGHT Files with this license: - COPYING [46:46] + COPYING [52:52] KEEP COPYRIGHT_SERVICE_LABEL 8cf91579d8cb4087b6bd775cd2b2bbed BELONGS ya.make diff --git a/contrib/libs/lzma/.yandex_meta/devtools.licenses.report b/contrib/libs/lzma/.yandex_meta/devtools.licenses.report index aed2153870..ac3196e2aa 100644 --- a/contrib/libs/lzma/.yandex_meta/devtools.licenses.report +++ b/contrib/libs/lzma/.yandex_meta/devtools.licenses.report @@ -46,24 +46,11 @@ BELONGS ya.make Match type : TAG Links : http://landley.net/toybox/license.html, https://spdx.org/licenses/0BSD Files with this license: - COPYING [43:43] - -SKIP 0BSD 14de854251593dd36ab8a222793a5b8f -BELONGS ya.make - # Not a license - License text: - domain; 0BSD-licensed code is copyrighted but available under - Scancode info: - Original SPDX id: 0BSD - Score : 50.00 - Match type : REFERENCE - Links : http://landley.net/toybox/license.html, https://spdx.org/licenses/0BSD - Files with this license: - COPYING [74:74] + COPYING [49:49] SKIP LGPL-2.1-only 181bd2f3201dc6ff4c508cb04d170817 BELONGS ya.make -FILE_INCLUDE COPYING.LGPLv2.1 found in files: README at line 81 +FILE_INCLUDE COPYING.LGPLv2.1 found in files: README at line 82 # Not a license by itself License text: COPYING.LGPLv2.1 GNU Lesser General Public License version 2.1 @@ -73,20 +60,7 @@ FILE_INCLUDE COPYING.LGPLv2.1 found in files: README at line 81 Match type : REFERENCE Links : http://www.gnu.org/licenses/lgpl-2.1.html, http://www.gnu.org/licenses/lgpl-2.1.txt, https://spdx.org/licenses/LGPL-2.1-only Files with this license: - README [81:81] - -KEEP Public-Domain 19d6afb7fb41001fbab2151dd27a7fb9 -BELONGS ya.make - License text: - There is very little *practical* difference between public - domain and 0BSD. The main difference likely is that one - Scancode info: - Original SPDX id: LicenseRef-scancode-public-domain - Score : 70.00 - Match type : REFERENCE - Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE - Files with this license: - COPYING [71:72] + README [82:82] SKIP 0BSD 1a459a2067895b8576617d7b67fe52ca BELONGS ya.make @@ -112,19 +86,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://landley.net/toybox/license.html, https://spdx.org/licenses/0BSD Files with this license: - COPYING [48:48] - -KEEP 0BSD 21b027dd1b59c23a56e34a32360d0c10 -BELONGS ya.make - License text: - 0BSD for newer releases was made in Febrary 2024 because - Scancode info: - Original SPDX id: 0BSD - Score : 50.00 - Match type : REFERENCE - Links : http://landley.net/toybox/license.html, https://spdx.org/licenses/0BSD - Files with this license: - COPYING [67:67] + COPYING [54:54] SKIP LGPL-2.1-only 23c2a5e0106b99d75238986559bb5fc6 BELONGS ya.make @@ -141,7 +103,7 @@ FILE_INCLUDE COPYING found in files: COPYING.LGPLv2.1 at line 116 SKIP GPL-2.0-only 3220ce24cf5698918173f671259bb375 BELONGS ya.make -FILE_INCLUDE COPYING.GPLv2 found in files: README at line 79 +FILE_INCLUDE COPYING.GPLv2 found in files: README at line 80 # Not a license by itself License text: COPYING.GPLv2 GNU General Public License version 2 @@ -151,7 +113,7 @@ FILE_INCLUDE COPYING.GPLv2 found in files: README at line 79 Match type : REFERENCE Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only Files with this license: - README [79:79] + README [80:80] KEEP 0BSD 327b128c3f16957fab69efc9b095e368 BELONGS ya.make @@ -221,7 +183,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://landley.net/toybox/license.html, https://spdx.org/licenses/0BSD Files with this license: - COPYING [57:57] + COPYING [63:63] SKIP LGPL-2.0-only AND LGPL-2.1-or-later 493b7c38175021ac13d1589215e13989 BELONGS ya.make @@ -282,18 +244,6 @@ BELONGS ya.make liblzma/api/lzma/vli.h [1:1] liblzma/liblzma_linux.map [1:1] -KEEP Public-Domain 65b77ffe5d577fa84afe9f017beede5c -BELONGS ya.make - License text: - public domain has (real or perceived) legal ambiguities in - Scancode info: - Original SPDX id: LicenseRef-scancode-public-domain - Score : 70.00 - Match type : REFERENCE - Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE - Files with this license: - COPYING [68:68] - SKIP GPL-3.0-only 6dbb0879a53d93955d47d50ed23aa325 BELONGS ya.make # This is a reference to the file with GPL-3.0 license @@ -305,7 +255,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://www.gnu.org/licenses/gpl-3.0-standalone.html, http://www.gnu.org/licenses/gpl-3.0.html, https://spdx.org/licenses/GPL-3.0-only Files with this license: - COPYING [60:60] + COPYING [66:66] KEEP Public-Domain 702cbf9589b30951b6a2b94913b66332 BELONGS ya.make @@ -330,7 +280,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://www.gnu.org/licenses/gpl-2.0.html, http://www.gnu.org/licenses/gpl-2.0.txt, https://spdx.org/licenses/GPL-2.0-only Files with this license: - COPYING [59:59] + COPYING [65:65] KEEP 0BSD 79430bd4c5e1b494780b3fb35b24fd7d BELONGS ya.make @@ -364,37 +314,6 @@ BELONGS ya.make Files with this license: COPYING [25:25] -KEEP 0BSD AND Public-Domain 83aabd12f73b5065603bf2054fb6d54f -BELONGS ya.make - License text: - an extremely permissive license. Neither 0BSD nor public domain - Scancode info: - Original SPDX id: 0BSD - Score : 50.00 - Match type : REFERENCE - Links : http://landley.net/toybox/license.html, https://spdx.org/licenses/0BSD - Files with this license: - COPYING [75:75] - Scancode info: - Original SPDX id: LicenseRef-scancode-public-domain - Score : 70.00 - Match type : REFERENCE - Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE - Files with this license: - COPYING [75:75] - -KEEP Public-Domain 90705824d045bd99f4cb1ef6f42a57ae -BELONGS ya.make - License text: - significant amount of code put into the public domain and - Scancode info: - Original SPDX id: LicenseRef-scancode-public-domain - Score : 100.00 - Match type : TEXT - Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE - Files with this license: - COPYING [65:65] - KEEP BSD-3-Clause AND 0BSD a675dbcfcecb36b880f01b1c31049149 BELONGS ya.make License text: @@ -414,33 +333,9 @@ BELONGS ya.make Files with this license: liblzma/api/lzma.h [23:23] -KEEP Public-Domain a7c077779fe1982e666c1f33e396f1b5 -BELONGS ya.make - License text: - that obviously remains so. The switch from public domain to - Scancode info: - Original SPDX id: LicenseRef-scancode-public-domain - Score : 70.00 - Match type : REFERENCE - Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE - Files with this license: - COPYING [66:66] - -KEEP 0BSD a8a6073ae588092bed4e746ed49b52f5 -BELONGS ya.make - License text: - domain and 0BSD. The main difference likely is that one - Scancode info: - Original SPDX id: 0BSD - Score : 50.00 - Match type : REFERENCE - Links : http://landley.net/toybox/license.html, https://spdx.org/licenses/0BSD - Files with this license: - COPYING [72:72] - SKIP GPL-3.0-only ad3e81fa9e595e378d10023b1bf20d51 BELONGS ya.make -FILE_INCLUDE COPYING.GPLv3 found in files: README at line 80 +FILE_INCLUDE COPYING.GPLv3 found in files: README at line 81 # Not a license by itself License text: COPYING.GPLv3 GNU General Public License version 3 @@ -450,31 +345,7 @@ FILE_INCLUDE COPYING.GPLv3 found in files: README at line 80 Match type : REFERENCE Links : http://www.gnu.org/licenses/gpl-3.0-standalone.html, http://www.gnu.org/licenses/gpl-3.0.html, https://spdx.org/licenses/GPL-3.0-only Files with this license: - README [80:80] - -KEEP BSD-2-Clause b3129c96ef9c28cff49bffaf9d804a88 -BELONGS ya.make - License text: - for example, BSD 2-Clause "Simplified" License which does have - Scancode info: - Original SPDX id: BSD-2-Clause - Score : 100.00 - Match type : NOTICE - Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause - Files with this license: - COPYING [78:78] - -KEEP Public-Domain c1a07f044cdb7e843b741e6236100ea3 -BELONGS ya.make - License text: - /// and the public domain code from https://github.com/rawrunprotected/crc - Scancode info: - Original SPDX id: LicenseRef-scancode-public-domain - Score : 100.00 - Match type : NOTICE - Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE - Files with this license: - liblzma/check/crc_x86_clmul.h [13:13] + README [81:81] KEEP Public-Domain cc574f0a684665d6c5ae08f28aec98dd BELONGS ya.make @@ -511,20 +382,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://www.gnu.org/licenses/lgpl-2.1.html, http://www.gnu.org/licenses/lgpl-2.1.txt, https://spdx.org/licenses/LGPL-2.1-only Files with this license: - COPYING [58:58] - -KEEP Public-Domain d2d5f589792b8c7a8679d6c69614d2e9 -BELONGS ya.make - License text: - shouldn't claim that 0BSD-licensed code is in the public - domain; 0BSD-licensed code is copyrighted but available under - Scancode info: - Original SPDX id: LicenseRef-scancode-public-domain - Score : 100.00 - Match type : TEXT - Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE - Files with this license: - COPYING [73:74] + COPYING [64:64] KEEP 0BSD deae85a8d274ed0cce9af4ffbf7f1265 BELONGS ya.make @@ -552,7 +410,7 @@ BELONGS ya.make KEEP 0BSD e5a555c3368d6625b4f901cafe6caf46 BELONGS ya.make -FILE_INCLUDE COPYING.0BSD found in files: README at line 78 +FILE_INCLUDE COPYING.0BSD found in files: README at line 79 License text: COPYING.0BSD BSD Zero Clause License Scancode info: @@ -561,7 +419,7 @@ FILE_INCLUDE COPYING.0BSD found in files: README at line 78 Match type : REFERENCE Links : http://landley.net/toybox/license.html, https://spdx.org/licenses/0BSD Files with this license: - README [78:78] + README [79:79] KEEP 0BSD e7ecdbf411fbdc32d3df058d1c7bf661 BELONGS ya.make @@ -585,10 +443,8 @@ BELONGS ya.make liblzma/check/check.c [1:1] liblzma/check/check.h [1:1] liblzma/check/crc32_fast.c [1:1] - liblzma/check/crc32_table.c [1:1] liblzma/check/crc32_table_le.h [1:1] liblzma/check/crc64_fast.c [1:1] - liblzma/check/crc64_table.c [1:1] liblzma/check/crc64_table_le.h [1:1] liblzma/check/crc_common.h [1:1] liblzma/check/crc_x86_clmul.h [1:1] @@ -706,18 +562,6 @@ BELONGS ya.make liblzma/simple/sparc.c [1:1] liblzma/simple/x86.c [1:1] -KEEP 0BSD f3ff7259b99521ac278b6ea15c6f179f -BELONGS ya.make - License text: - shouldn't claim that 0BSD-licensed code is in the public - Scancode info: - Original SPDX id: 0BSD - Score : 50.00 - Match type : REFERENCE - Links : http://landley.net/toybox/license.html, https://spdx.org/licenses/0BSD - Files with this license: - COPYING [73:73] - KEEP 0BSD f6a343d8de811f538c36fa8681cb7078 BELONGS ya.make License text: diff --git a/contrib/libs/lzma/.yandex_meta/licenses.list.txt b/contrib/libs/lzma/.yandex_meta/licenses.list.txt index e1c0273827..3120ceffdf 100644 --- a/contrib/libs/lzma/.yandex_meta/licenses.list.txt +++ b/contrib/libs/lzma/.yandex_meta/licenses.list.txt @@ -1,8 +1,4 @@ ====================0BSD==================== - 0BSD for newer releases was made in Febrary 2024 because - - -====================0BSD==================== and ChangeLog) are under 0BSD unless stated otherwise in @@ -11,14 +7,6 @@ ====================0BSD==================== - domain and 0BSD. The main difference likely is that one - - -====================0BSD==================== - shouldn't claim that 0BSD-licensed code is in the public - - -====================0BSD==================== the BSD Zero Clause License (0BSD). @@ -59,14 +47,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -====================0BSD AND Public-Domain==================== - an extremely permissive license. Neither 0BSD nor public domain - - -====================BSD-2-Clause==================== - for example, BSD 2-Clause "Simplified" License which does have - - ====================BSD-3-Clause AND 0BSD==================== * liblzma is distributed under the BSD Zero Clause License (0BSD). @@ -117,38 +97,12 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ====================Public-Domain==================== - There is very little *practical* difference between public - domain and 0BSD. The main difference likely is that one - - -====================Public-Domain==================== lzma-file-format.xt are in the public domain but may ====================Public-Domain==================== - public domain has (real or perceived) legal ambiguities in - - -====================Public-Domain==================== - shouldn't claim that 0BSD-licensed code is in the public - domain; 0BSD-licensed code is copyrighted but available under - - -====================Public-Domain==================== - significant amount of code put into the public domain and - - -====================Public-Domain==================== some old translations are in the public domain. ====================Public-Domain==================== - that obviously remains so. The switch from public domain to - - -====================Public-Domain==================== // The C code is based on the public domain SHA-256 code found from - - -====================Public-Domain==================== -/// and the public domain code from https://github.com/rawrunprotected/crc diff --git a/contrib/libs/lzma/.yandex_meta/override.nix b/contrib/libs/lzma/.yandex_meta/override.nix index 32dfe8f429..3acfc40957 100644 --- a/contrib/libs/lzma/.yandex_meta/override.nix +++ b/contrib/libs/lzma/.yandex_meta/override.nix @@ -1,12 +1,16 @@ pkgs: attrs: with pkgs; with attrs; rec { - version = "5.6.4"; + version = "5.8.1"; src = fetchFromGitHub { owner = "tukaani-project"; repo = "xz"; rev = "v${version}"; - hash = "sha256-Xp1uLtQIoOG/qVLpq5D/KFmTOJ0+mNkNclyuJsvlUbE="; + hash = "sha256-vGUNoX5VTM0aQ5GmBPXip97WGN9vaVrQLE9msToZyKs="; }; nativeBuildInputs = [ autoreconfHook ]; + + configureFlags = [ + "--build=x86_64-pc-linux-gnu" + ]; } diff --git a/contrib/libs/lzma/AUTHORS b/contrib/libs/lzma/AUTHORS index 5eff238ae4..f805a204ec 100644 --- a/contrib/libs/lzma/AUTHORS +++ b/contrib/libs/lzma/AUTHORS @@ -24,7 +24,7 @@ Authors of XZ Utils by Michał Górny. Architecture-specific CRC optimizations were contributed by - Ilya Kurdyukov, Hans Jansen, and Chenxi Mao. + Ilya Kurdyukov, Chenxi Mao, and Xi Ruoyao. Other authors: - Jonathan Nieder diff --git a/contrib/libs/lzma/COPYING b/contrib/libs/lzma/COPYING index aed2153149..ef3371389d 100644 --- a/contrib/libs/lzma/COPYING +++ b/contrib/libs/lzma/COPYING @@ -40,6 +40,12 @@ XZ Utils Licensing free software licenses. These aren't built or installed as part of XZ Utils. + The following command may be helpful in finding per-file license + information. It works on xz.git and on a clean file tree extracted + from a release tarball. + + sh build-aux/license-check.sh -v + For the files under the BSD Zero Clause License (0BSD), if a copyright notice is needed, the following is sufficient: @@ -59,25 +65,6 @@ XZ Utils Licensing - COPYING.GPLv2: GNU General Public License version 2 - COPYING.GPLv3: GNU General Public License version 3 - A note about old XZ Utils releases: - - XZ Utils releases 5.4.6 and older and 5.5.1alpha have a - significant amount of code put into the public domain and - that obviously remains so. The switch from public domain to - 0BSD for newer releases was made in Febrary 2024 because - public domain has (real or perceived) legal ambiguities in - some jurisdictions. - - There is very little *practical* difference between public - domain and 0BSD. The main difference likely is that one - shouldn't claim that 0BSD-licensed code is in the public - domain; 0BSD-licensed code is copyrighted but available under - an extremely permissive license. Neither 0BSD nor public domain - require retaining or reproducing author, copyright holder, or - license notices when distributing the software. (Compare to, - for example, BSD 2-Clause "Simplified" License which does have - such requirements.) - If you have questions, don't hesitate to ask for more information. The contact information is in the README file. diff --git a/contrib/libs/lzma/INSTALL b/contrib/libs/lzma/INSTALL index f742281771..ec89047274 100644 --- a/contrib/libs/lzma/INSTALL +++ b/contrib/libs/lzma/INSTALL @@ -16,7 +16,7 @@ XZ Utils Installation 1.2.8. DOS 1.2.9. z/OS 1.3. Adding support for new platforms - 2. configure options + 2. configure and CMake options 2.1. Static vs. dynamic linking of liblzma 2.2. Optimizing xzdec and lzmadec 3. xzgrep and other scripts @@ -76,6 +76,11 @@ XZ Utils Installation you use CC=xlc instead, you must disable threading support with --disable-threads (usually not recommended). + If building a 32-bit executable, the address space available to xz + might be limited to 256 MiB by default. To increase the address + space to 2 GiB, pass LDFLAGS=-Wl,-bmaxdata:0x80000000 as an argument + to configure. + 1.2.2. IRIX @@ -213,19 +218,53 @@ XZ Utils Installation in C89 or C++. -2. configure options --------------------- +2. configure and CMake options +------------------------------ In most cases, the defaults are what you want. Many of the options below are useful only when building a size-optimized version of liblzma or command line tools. + configure options are those that begin with two dashes "--" + or "gl_". + + CMake options begin with "XZ_", "TUKLIB_", or "CMAKE_". To use + them on the command line, prefix them with "-D", for example, + "cmake -DCMAKE_COMPILE_WARNING_AS_ERROR=ON". + + CMAKE_BUILD_TYPE=TYPE + CMake only: + + For release builds, CMAKE_BUILD_TYPE=Release is fine. + On targets where CMake defaults to -O3, the default + value is overridden to -O2. + + Empty value (CMAKE_BUILD_TYPE=) is fine if using custom + optimization options. *In this package* the empty build + type also disables debugging code just like "Release" + does. To enable debugging code with empty build type, + use -UNDEBUG in the CFLAGS environment variable or in + the CMAKE_C_FLAGS CMake variable to override -DNDEBUG. + + Non-standard build types like "None" do NOT disable + debugging code! Such non-standard build types should + be avoided for production builds! + --enable-encoders=LIST --disable-encoders - Specify a comma-separated LIST of filter encoders to - build. See "./configure --help" for exact list of - available filter encoders. The default is to build all - supported encoders. + XZ_ENCODERS=LIST + Specify a LIST of filter encoders to build. In the + configure option the list is comma separated. + CMake lists are semicolon separated. + + To see the exact list of available filter encoders: + + - Autotools: ./configure --help + + - CMake: Configure the tree normally first, then use + "cmake -LH ." to list the cache variables. + + The default is to build all supported encoders. If LIST is empty or --disable-encoders is used, no filter encoders will be built and also the code shared between @@ -237,10 +276,12 @@ XZ Utils Installation --enable-decoders=LIST --disable-decoders + XZ_DECODERS=LIST This is like --enable-encoders but for decoders. The default is to build all supported decoders. --enable-match-finders=LIST + XZ_MATCH_FINDERS=LIST liblzma includes two categories of match finders: hash chains and binary trees. Hash chains (hc3 and hc4) are quite fast but they don't provide the best compression @@ -257,9 +298,11 @@ XZ Utils Installation or LZMA2 filter encoders are being built. --enable-checks=LIST + XZ_CHECKS=LIST liblzma support multiple integrity checks. CRC32 is - mandatory, and cannot be omitted. See "./configure --help" - for exact list of available integrity check types. + mandatory, and cannot be omitted. Supported check + types are "crc32", "crc64", and "sha256". By default + all supported check types are enabled. liblzma and the command line tools can decompress files which use unsupported integrity check type, but naturally @@ -270,6 +313,7 @@ XZ Utils Installation it is known to not cause problems. --enable-external-sha256 + XZ_EXTERNAL_SHA256=ON Try to use SHA-256 code from the operating system libc or similar base system libraries. This doesn't try to use OpenSSL or libgcrypt or such libraries. @@ -306,6 +350,8 @@ XZ Utils Installation time xz --test foo.xz --disable-microlzma + XZ_MICROLZMA_ENCODER=OFF + XZ_MICROLZMA_DECODER=OFF Don't build MicroLZMA encoder and decoder. This omits lzma_microlzma_encoder() and lzma_microlzma_decoder() API functions from liblzma. These functions are needed @@ -313,6 +359,7 @@ XZ Utils Installation erofs-utils but they may be used by others too. --disable-lzip-decoder + XZ_LZIP_DECODER=OFF Disable decompression support for .lz (lzip) files. This omits the API function lzma_lzip_decoder() from liblzma and .lz support from the xz tool. @@ -321,6 +368,10 @@ XZ Utils Installation --disable-xzdec --disable-lzmadec --disable-lzmainfo + XZ_TOOL_XZ=OFF + XZ_TOOL_XZDEC=OFF + XZ_TOOL_LZMADEC=OFF + XZ_TOOL_LZMAINFO=OFF Don't build and install the command line tool mentioned in the option name. @@ -330,29 +381,40 @@ XZ Utils Installation a dangling man page symlink lzmadec.1 -> xzdec.1 is created. + XZ_TOOL_SYMLINKS=OFF + Don't create the unxz and xzcat symlinks. (There is + no "configure" option to disable these symlinks.) + --disable-lzma-links + XZ_TOOL_SYMLINKS_LZMA=OFF Don't create symlinks for LZMA Utils compatibility. This includes lzma, unlzma, and lzcat. If scripts are installed, also lzdiff, lzcmp, lzgrep, lzegrep, lzfgrep, lzmore, and lzless will be omitted if this option is used. --disable-scripts + XZ_TOOL_SCRIPTS=OFF Don't install the scripts xzdiff, xzgrep, xzmore, xzless, and their symlinks. --disable-doc + XZ_DOC=OFF Don't install the documentation files to $docdir (often /usr/doc/xz or /usr/local/doc/xz). Man pages will still be installed. The $docdir can be changed with --docdir=DIR. --enable-doxygen + XZ_DOXYGEN=ON Enable generation of the HTML version of the liblzma API documentation using Doxygen. The resulting files are installed to $docdir/api. This option assumes that the 'doxygen' tool is available. + NOTE: --disable-doc or XZ_DOC=OFF don't affect this. + --disable-assembler + XZ_ASM_I386=OFF This disables CRC32 and CRC64 assembly code on 32-bit x86. This option currently does nothing on other architectures (not even on x86-64). @@ -365,7 +427,16 @@ XZ Utils Installation pre-i686 systems, you may want to disable the assembler code. + The assembly code is compatible with only certain OSes + and toolchains (it's not compatible with MSVC). + + Since XZ Utils 5.7.1alpha, the 32-bit x86 assembly code + co-exists with the modern CLMUL code: CLMUL is used if + support for it is detected at runtime. On old processors + the assembly code is used. + --disable-clmul-crc + XZ_CLMUL_CRC=OFF Disable the use of carryless multiplication for CRC calculation even if compiler support for it is detected. The code uses runtime detection of SSSE3, SSE4.1, and @@ -378,6 +449,7 @@ XZ Utils Installation detection isn't used and the generic code is omitted. --disable-arm64-crc32 + XZ_ARM64_CRC32=OFF Disable the use of the ARM64 CRC32 instruction extension even if compiler support for it is detected. The code will detect support for the instruction at runtime. @@ -387,7 +459,16 @@ XZ Utils Installation and later) then runtime detection isn't used and the generic code is omitted. + --disable-loongarch-crc32 + XZ_LOONGARCH_CRC32=OFF + Disable the use of the 64-bit LoongArch CRC32 + instruction extension even if compiler support for + it is detected. There is no runtime detection because + all 64-bit LoongArch processors should support + the CRC32 instructions. + --enable-unaligned-access + TUKLIB_FAST_UNALIGNED_ACCESS=ON Allow liblzma to use unaligned memory access for 16-bit, 32-bit, and 64-bit loads and stores. This should be enabled only when the hardware supports this, that is, @@ -435,6 +516,7 @@ XZ Utils Installation how unaligned access is done in the C code. --enable-unsafe-type-punning + TUKLIB_USE_UNSAFE_TYPE_PUNNING=ON This enables use of code like uint8_t *buf8 = ...; @@ -451,6 +533,7 @@ XZ Utils Installation GCC 3 and early 4.x on x86, GCC < 6 on ARMv6 and ARMv7). --enable-small + XZ_SMALL=ON Reduce the size of liblzma by selecting smaller but semantically equivalent version of some functions, and omit precomputed lookup tables. This option tends to @@ -467,6 +550,7 @@ XZ Utils Installation flag(s) to CFLAGS manually. --enable-assume-ram=SIZE + XZ_ASSUME_RAM=SIZE On the most common operating systems, XZ Utils is able to detect the amount of physical memory on the system. This information is used by the options --memlimit-compress, @@ -483,6 +567,7 @@ XZ Utils Installation src/common/tuklib_physmem.c for details. --enable-threads=METHOD + XZ_THREADS=METHOD Threading support is enabled by default so normally there is no need to specify this option. @@ -519,6 +604,7 @@ XZ Utils Installation one thread, something bad may happen. --enable-sandbox=METHOD + XZ_SANDBOX=METHOD There is limited sandboxing support in the xz and xzdec tools. If built with sandbox support, xz uses it automatically when (de)compressing exactly one file to @@ -554,6 +640,7 @@ XZ Utils Installation is found, configure will give an error. --enable-symbol-versions[=VARIANT] + XZ_SYMBOL_VERSIONING=VARIANT Use symbol versioning for liblzma shared library. This is enabled by default on GNU/Linux (glibc only), other GNU-based systems, and FreeBSD. @@ -598,13 +685,25 @@ XZ Utils Installation run-time consistency checks. It makes the code slower, so you normally don't want to have this enabled. + In CMake, the build type (CMAKE_BUILD_TYPE) controls if + -DNDEBUG is passed to the compiler. *In this package*, + an empty build type disables debugging code too. + Non-standard build types like "None" do NOT disable + debugging code! + + To enable debugging code with empty build type in CMake, + use -UNDEBUG in the CFLAGS environment variable or in + the CMAKE_C_FLAGS CMake variable to override -DNDEBUG. + --enable-werror + CMAKE_COMPILE_WARNING_AS_ERROR=ON (CMake >= 3.24) If building with GCC, make all compiler warnings an error, that abort the compilation. This may help catching bugs, and should work on most systems. This has no effect on the resulting binaries. --enable-path-for-scripts=PREFIX + (CMake determines this from the path of XZ_POSIX_SHELL) If PREFIX isn't empty, PATH=PREFIX:$PATH will be set in the beginning of the scripts (xzgrep and others). The default is empty except on Solaris the default is @@ -621,6 +720,36 @@ XZ Utils Installation the PATH for the scripts. It is described in section 3.2 and is supported in this xz version too. + gl_cv_posix_shell=/path/to/bin/sh + XZ_POSIX_SHELL=/path/to/bin/sh + POSIX shell to use for xzgrep and other scripts. + + - configure should autodetect this well enough. + Typically it's /bin/sh but in some cases, like + Solaris, something else is used. + + - CMake build uses /bin/sh except on Solaris the + default is /usr/xpg4/bin/sh. + + CMAKE_DLL_NAME_WITH_SOVERSION=ON + CMake on native Windows (not Cygwin) only: + + This changes the filename liblzma.dll to liblzma-5.dll. + + The unversioned filename liblzma.dll has been used + since XZ Utils 5.0.0 when creating binary packages + using the included windows/build.bash. The same + unversioned filename is the default with CMake. + However, there are popular builds that, very + understandably and reasonably, use the versioned + filename produced by GNU Libtool. + + This option should usually be left to its default value + (OFF). It can be set to ON if the liblzma DLL filename + must be compatible with the versioned filename + produced by GNU Libtool. For example, binaries + distributed in MSYS2 use a versioned DLL filename. + 2.1. Static vs. dynamic linking of liblzma diff --git a/contrib/libs/lzma/NEWS b/contrib/libs/lzma/NEWS index f260a332f7..978ef54b91 100644 --- a/contrib/libs/lzma/NEWS +++ b/contrib/libs/lzma/NEWS @@ -2,6 +2,240 @@ XZ Utils Release Notes ====================== +5.8.1 (2025-04-03) + + IMPORTANT: This includes a security fix for CVE-2025-31115 which + affects XZ Utils from 5.3.3alpha to 5.8.0. No new 5.4.x or 5.6.x + releases will be made, but the fix is in the v5.4 and v5.6 branches + in the xz Git repository. A standalone patch for all affected + versions is available as well. + + * Multithreaded .xz decoder (lzma_stream_decoder_mt()): + + - Fix a bug that could at least result in a crash with + invalid input. (CVE-2025-31115) + + - Fix a performance bug: Only one thread was used if the whole + input file was provided at once to lzma_code(), the output + buffer was big enough, timeout was disabled, and LZMA_FINISH + was used. There are no bug reports about this, thus it's + possible that no real-world application was affected. + + * Avoid <stdalign.h> even with C11/C17 compilers. This fixes the + build with Oracle Developer Studio 12.6 on Solaris 10 when the + compiler is in C11 mode (the header doesn't exist). + + * Autotools: Restore compatibility with GNU make versions older + than 4.0 by creating the package using GNU gettext 0.23.1 + infrastructure instead of 0.24. + + * Update Croatian translation. + + +5.8.0 (2025-03-25) + + This bumps the minor version of liblzma because new features were + added. The API and ABI are still backward compatible with liblzma + 5.6.x, 5.4.x, 5.2.x, and 5.0.x. + + * liblzma on 32/64-bit x86: When possible, use SSE2 intrinsics + instead of memcpy() in the LZMA/LZMA2 decoder. In typical cases, + this may reduce decompression time by 0-5 %. However, when built + against musl libc, over 15 % time reduction was observed with + highly compressed files. + + * CMake: Make the feature test macros match the Autotools-based + build on NetBSD, Darwin, and mingw-w64. + + * Update the Croatian, Italian, Portuguese, and Romanian + translations. + + * Update the German, Italian, Korean, Romanian, Serbian, and + Ukrainian man page translations. + + Summary of changes in the 5.7.x development releases: + + * Mark the following LZMA Utils script aliases as deprecated: + lzcmp, lzdiff, lzless, lzmore, lzgrep, lzegrep, and lzfgrep. + + * liblzma: + + - Improve LZMA/LZMA2 encoder speed on 64-bit PowerPC (both + endiannesses) and those 64-bit RISC-V processors that + support fast unaligned access. + + - Add low-level APIs for RISC-V, ARM64, and x86 BCJ filters + to lzma/bcj.h. These are primarily for erofs-utils. + + - x86/x86-64/E2K CLMUL CRC code was rewritten. + + - Use the CRC32 instructions on LoongArch. + + * xz: + + - Synchronize the output file and its directory using fsync() + before deleting the input file. No syncing is done when xz + isn't going to delete the input file. + + - Add --no-sync to disable the sync-before-delete behavior. + + - Make --single-stream imply --keep. + + * xz, xzdec, lzmainfo: When printing messages, replace + non-printable characters with question marks. + + * xz and xzdec on Linux: Support Landlock ABI versions 5 and 6. + + * CMake: Revise the configuration variables and some of their + options, and document them in the file INSTALL. CMake support + is no longer experimental. (It was already not experimental + when building for native Windows.) + + * Add build-aux/license-check.sh. + + +5.7.2beta (2025-03-08) + + * On the man pages, mark the following LZMA Utils script aliases as + deprecated: lzcmp, lzdiff, lzless, lzmore, lzgrep, lzegrep, and + lzfgrep. The commands that start with xz* instead of lz* have + identical behavior. + + The LZMA Utils aliases lzma, unlzma, and lzcat aren't deprecated + because some of these aliases are still in common use. lzmadec + and lzmainfo aren't deprecated either. + + * xz: In the ENVIRONMENT section of the man page, warn about + problems that some uses of XZ_DEFAULTS and XZ_OPT may create. + + * Windows (native builds, not Cygwin): In xz, xzdec, and lzmadec, + avoid an error message on broken pipe. + + * Autotools: Fix out-of-tree builds when using the bundled + getopt_long. + + * Translations: + + - Updated: Chinese (traditional), Croatian, Finnish, Georgian, + German, Korean, Polish, Romanian, Serbian, Spanish, Swedish, + Turkish, and Ukrainian + + - Added: Dutch + + * Man page translations: + + - Updated: German, Korean, Romanian, and Ukrainian + + - Added: Italian and Serbian + + +5.7.1alpha (2025-01-23) + + * All fixes from 5.6.4. + + * liblzma: + + - Improve LZMA/LZMA2 encoder speed on 64-bit PowerPC (both + endiannesses) and those 64-bit RISC-V processors that + support fast unaligned access. + + - x86/x86-64/E2K CLMUL CRC code was rewritten. It's faster and + doesn't cause false positives from sanitizers. Attributes + like __attribute__((__no_sanitize_address__)) are no longer + present. + + - On 32-bit x86, CLMUL CRC and the old (but still good) + assembly versions now co-exist with runtime detection. + Both Autotools and CMake build systems handle this + automatically now. + + - Use the CRC32 instructions on LoongArch to make CRC32 + calculation faster. + + - Add low-level APIs for RISC-V, ARM64, and x86 BCJ filters + to lzma/bcj.h. These are primarily for erofs-utils. + + - Minor tweaks to ARM64 CRC32 code and BCJ filters were made. + + * xz: + + - Synchronize the output file and its directory before deleting + the input file using fsync(). This reduces the probability of + data loss after a system crash. However, it can be a major + performance hit if processing many small files. + + NOTE: No syncing is done when xz isn't going to delete + the input file. + + - Add a new option --no-sync to disable the sync-before-delete + behavior. It's useful when compressing many small files and + one doesn't worry about data loss in case of a system crash. + + - Make --single-stream imply --keep. + + - Use automatic word wrapping for the text in --help and + similar situations to hopefully make the strings easier for + majority of translators (no need to count spaces anymore). + + * xz, xzdec, lzmainfo: When printing messages, replace + non-printable characters with question marks. This way + malicious filenames cannot be used to send escape sequences + to a terminal. This change is also applied to filenames shown + in "xz --robot --list". + + * xz and xzdec on Linux: Add support for Landlock ABI versions 5 + and 6. + + * CMake updates: + + - Increase the minimum required CMake version to 3.20. + + - Revise the configuration variables and some of their options. + Document them in the file INSTALL. + + - Attempt to produce liblzma.pc so that the paths are based on + ${prefix}, which makes it simpler to override the paths + if the liblzma files have been moved. + + - To enable translations, gettext-tools is now required. The + CMake build no longer supports installing pre-compiled + message catalog binary files (po/*.gmo). + + - Apple: Use Mach-O shared library versioning that is + compatible with GNU Libtool. This should make it easier to + switch between the build systems on Apple OSes that enforce + the correct compatibility_version (macOS >= 12 doesn't?). + This change is backward compatible: binaries linked against + old CMake-built liblzma will run with liblzma that uses + Libtool style versioning. + + - Windows (not Cygwin): Document CMAKE_DLL_NAME_WITH_SOVERSION + (CMake >= 3.27) in the file INSTALL. This option should + usually be left to its default value (OFF). It can be set + to ON if the liblzma DLL filename must be compatible with + the versioned filename produced by GNU Libtool. For example, + binaries distributed in MSYS2 use a versioned DLL filename. + + - CMake support is no longer experimental. (It was already + not experimental when building for native Windows.) + + * Windows: Building liblzma with Visual Studio 2013 is no longer + supported. Visual Studio 2015 or later (with CMake) can be used + to build liblzma and the command line tools. + + * Add preliminary Georgian translation. This already contains + translations of most of the strings that are now automatically + word wrapped. + + * Add build-aux/license-check.sh. Without arguments, it checks that + no license information has been forgotten. With the -v argument, + it shows the license info (or the lack of it) for each file. + + If the .git directory is available, only the files in the + repository are checked. Without the .git directory, a clean tree + from an extracted release tarball is expected. + + 5.6.4 (2025-01-23) * liblzma: Fix LZMA/LZMA2 encoder on big endian ARM64. diff --git a/contrib/libs/lzma/README b/contrib/libs/lzma/README index 9d097deff3..41671676a5 100644 --- a/contrib/libs/lzma/README +++ b/contrib/libs/lzma/README @@ -10,6 +10,7 @@ XZ Utils 2. Version numbering 3. Reporting bugs 4. Translations + 4.1. Testing translations 5. Other implementations of the .xz format 6. Contact information @@ -203,77 +204,47 @@ XZ Utils https://translationproject.org/html/translators.html - Below are notes and testing instructions specific to xz - translations. + Updates to translations won't be accepted by methods that bypass + the Translation Project because there is a risk of duplicate work: + translation updates made in the xz repository aren't seen by the + translators in the Translation Project. If you have found bugs in + a translation, please report them to the Language-Team address + which can be found near the beginning of the PO file. - Testing can be done by installing xz into a temporary directory: + If you find language problems in the original English strings, + feel free to suggest improvements. Ask if something is unclear. + + +4.1. Testing translations + + Testing can be done by installing xz into a temporary directory. + + If building from Git repository (not tarball), generate the + Autotools files: + + ./autogen.sh + + Create a subdirectory for the build files. The tmp-build directory + can be deleted after testing. + + mkdir tmp-build + cd tmp-build + ../configure --disable-shared --enable-debug --prefix=$PWD/inst + + Edit the .po file in the po directory. Then build and install to + the "tmp-build/inst" directory, and use translations.bash to see + how some of the messages look. Repeat these steps if needed: - ./configure --disable-shared --prefix=/tmp/xz-test - # <Edit the .po file in the po directory.> make -C po update-po - make install - bash debug/translation.bash | less - bash debug/translation.bash | less -S # For --list outputs - - Repeat the above as needed (no need to re-run configure though). - - Note especially the following: - - - The output of --help and --long-help must look nice on - an 80-column terminal. It's OK to add extra lines if needed. - - - In contrast, don't add extra lines to error messages and such. - They are often preceded with e.g. a filename on the same line, - so you have no way to predict where to put a \n. Let the terminal - do the wrapping even if it looks ugly. Adding new lines will be - even uglier in the generic case even if it looks nice in a few - limited examples. - - - Be careful with column alignment in tables and table-like output - (--list, --list --verbose --verbose, --info-memory, --help, and - --long-help): - - * All descriptions of options in --help should start in the - same column (but it doesn't need to be the same column as - in the English messages; just be consistent if you change it). - Check that both --help and --long-help look OK, since they - share several strings. - - * --list --verbose and --info-memory print lines that have - the format "Description: %s". If you need a longer - description, you can put extra space between the colon - and %s. Then you may need to add extra space to other - strings too so that the result as a whole looks good (all - values start at the same column). - - * The columns of the actual tables in --list --verbose --verbose - should be aligned properly. Abbreviate if necessary. It might - be good to keep at least 2 or 3 spaces between column headings - and avoid spaces in the headings so that the columns stand out - better, but this is a matter of opinion. Do what you think - looks best. - - - Be careful to put a period at the end of a sentence when the - original version has it, and don't put it when the original - doesn't have it. Similarly, be careful with \n characters - at the beginning and end of the strings. - - - Read the TRANSLATORS comments that have been extracted from the - source code and included in xz.pot. Some comments suggest - testing with a specific command which needs an .xz file. You - may use e.g. any tests/files/good-*.xz. However, these test - commands are included in translations.bash output, so reading - translations.bash output carefully can be enough. - - - If you find language problems in the original English strings, - feel free to suggest improvements. Ask if something is unclear. - - - The translated messages should be understandable (sometimes this - may be a problem with the original English messages too). Don't - make a direct word-by-word translation from English especially if - the result doesn't sound good in your language. - - Thanks for your help! + make -j"$(nproc)" install + bash ../debug/translation.bash | less + bash ../debug/translation.bash | less -S # For --list outputs + + To test other languages, set the LANGUAGE environment variable + before running translations.bash. The value should match the PO file + name without the .po suffix. Example: + + export LANGUAGE=fi 5. Other implementations of the .xz format diff --git a/contrib/libs/lzma/THANKS b/contrib/libs/lzma/THANKS index 3326e9712e..a6a7a67210 100644 --- a/contrib/libs/lzma/THANKS +++ b/contrib/libs/lzma/THANKS @@ -20,6 +20,7 @@ has been important. :-) In alphabetical order: - Jakub Bogusz - Adam Borowski - Maarten Bosmans + - Roel Bouckaert - Lukas Braune - Benjamin Buch - Trent W. Buck @@ -29,13 +30,18 @@ has been important. :-) In alphabetical order: - Frank Busse - Daniel Mealha Cabrita - Milo Casagrande + - Cristiano Ceglia - Marek Černocký - Tomer Chachamu - Vitaly Chikunov - Antoine Cœur + - Elijah Almeida Coimbra - Felix Collin + - Ryan Colyer - Marcus Comstedt + - Vincent Cruz - Gabi Davar + - Ron Desmond - İhsan Doğan - Chris Donawa - Andrew Dudman @@ -48,9 +54,11 @@ has been important. :-) In alphabetical order: - Denis Excoffier - Vincent Fazio - Michael Felt + - Sean Fenian - Michael Fox - Andres Freund - Mike Frysinger + - Collin Funk - Daniel Richard G. - Tomasz Gajc - Bjarni Ingi Gislason @@ -59,10 +67,14 @@ has been important. :-) In alphabetical order: - Matthew Good - Michał Górny - Jason Gorski + - Alexander M. Greenham - Juan Manuel Guerrero - Gabriela Gutierrez - Diederik de Haas + - Jan Terje Hansen + - Tobias Lahrmann Hansen - Joachim Henke + - Lizandro Heredia - Christian Hesse - Vincenzo Innocente - Peter Ivanov @@ -78,9 +90,11 @@ has been important. :-) In alphabetical order: - Per Øyvind Karlsen - Firas Khalil Khana - Iouri Kharon + - Kim Jinyeong - Thomas Klausner - Richard Koch - Anton Kochkov + - Harri K. Koskinen - Ville Koskinen - Sergey Kosukhin - Marcin Kowalczyk @@ -105,14 +119,20 @@ has been important. :-) In alphabetical order: - Chenxi Mao - Gregory Margo - Julien Marrec + - Pierre-Yves Martin - Ed Maste - Martin Matuška + - Scott McAllister + - Chris McCrohan + - Derwin McGeary - Ivan A. Melnikov - Jim Meyering - Arkadiusz Miskiewicz - Nathan Moinvaziri - Étienne Mollier - Conley Moorhous + - Dirk Müller + - Rainer Müller - Andrew Murray - Rafał Mużyło - Adrien Nader @@ -122,6 +142,7 @@ has been important. :-) In alphabetical order: - Jonathan Nieder - Asgeir Storesund Nilsen - Andre Noll + - Ruarí Ødegaard - Peter O'Gorman - Dimitri Papadopoulos Orfanos - Daniel Packard @@ -133,17 +154,20 @@ has been important. :-) In alphabetical order: - Igor Pavlov - Diego Elio Pettenò - Elbert Pol + - Guiorgy Potskhishvili - Mikko Pouru - Frank Prochnow - Rich Prohaska - Trần Ngọc Quân - Pavel Raiskup + - Matthieu Rakotojaona - Ole André Vadla Ravnås - Eric S. Raymond - Robert Readman - Bernhard Reutner-Fischer - Markus Rickert - Cristian Rodríguez + - Jeroen Roovers - Christian von Roques - Boud Roukema - Torsten Rupp @@ -160,6 +184,7 @@ has been important. :-) In alphabetical order: - Dan Shechter - Stuart Shelton - Sebastian Andrzej Siewior + - Andrej Skenderija - Ville Skyttä - Brad Smith - Bruce Stark @@ -191,15 +216,22 @@ has been important. :-) In alphabetical order: - Ralf Wildenhues - Charles Wilson - Lars Wirzenius + - Vincent Wixsom - Pilorz Wojciech - Chien Wong + - Xi Ruoyao - Ryan Young - Andreas Zieringer + - 榆柳松 (ZhengSen Wang) Companies: - Google - Sandfly Security +Other credits: + - cleemy desu wayo working with Trend Micro Zero Day Initiative + - Orange Tsai and splitline from DEVCORE Research Team + Also thanks to all the people who have participated in the Tukaani project. I have probably forgot to add some names to the above list. Sorry about diff --git a/contrib/libs/lzma/TODO b/contrib/libs/lzma/TODO index ad37f3f559..7a0bf16ed8 100644 --- a/contrib/libs/lzma/TODO +++ b/contrib/libs/lzma/TODO @@ -5,12 +5,7 @@ XZ Utils To-Do List Known bugs ---------- - The test suite is too incomplete. - - If the memory usage limit is less than about 13 MiB, xz is unable to - automatically scale down the compression settings enough even though - it would be possible by switching from BT2/BT3/BT4 match finder to - HC3/HC4. + The test suite is incomplete. XZ Utils compress some files significantly worse than LZMA Utils. This is due to faster compression presets used by XZ Utils, and @@ -19,9 +14,6 @@ Known bugs compress extremely well, so going from compression ratio of 0.003 to 0.004 means big relative increase in the compressed file size. - xz doesn't quote unprintable characters when it displays file names - given on the command line. - tuklib_exit() doesn't block signals => EINTR is possible. If liblzma has created threads and fork() gets called, liblzma @@ -41,9 +33,6 @@ Missing features be mostly useful when using a preset dictionary in LZMA2, but it may have other uses too. Compare to deflateCopy() in zlib. - Support LZMA_FINISH in raw decoder to indicate end of LZMA1 and - other streams that don't have an end of payload marker. - Adjust dictionary size when the input file size is known. Maybe do this only if an option is given. @@ -67,9 +56,9 @@ Missing features Support LZMA_FULL_FLUSH for lzma_stream_decoder() to stop at Block and Stream boundaries. - lzma_strerror() to convert lzma_ret to human readable form? - This is tricky, because the same error codes are used with - slightly different meanings, and this cannot be fixed anymore. + Error codes from lzma_code() aren't very specific. A more detailed + error message (string) could be provided too. It could be returned + by a new function or use a currently-reserved member of lzma_stream. Make it possible to adjust LZMA2 options in the middle of a Block so that the encoding speed vs. compression ratio can be optimized @@ -97,9 +86,3 @@ Documentation Document the LZMA1 and LZMA2 algorithms. - -Miscellaneous ------------- - - Try to get the media type for .xz registered at IANA. - diff --git a/contrib/libs/lzma/common/sysdefs.h b/contrib/libs/lzma/common/sysdefs.h index 1c2405dcd8..b10ffa7c3b 100644 --- a/contrib/libs/lzma/common/sysdefs.h +++ b/contrib/libs/lzma/common/sysdefs.h @@ -168,17 +168,26 @@ typedef unsigned char _Bool; # define __bool_true_false_are_defined 1 #endif +// We may need alignas from C11/C17/C23. +#if __STDC_VERSION__ >= 202311 + // alignas is a keyword in C23. Do nothing. +#elif __STDC_VERSION__ >= 201112 + // Oracle Developer Studio 12.6 lacks <stdalign.h>. + // For simplicity, avoid the header with all C11/C17 compilers. +# define alignas _Alignas +#elif defined(__GNUC__) || defined(__clang__) +# define alignas(n) __attribute__((__aligned__(n))) +#else +# define alignas(n) +#endif + #include <string.h> -// Visual Studio 2013 update 2 supports only __inline, not inline. -// MSVC v19.0 / VS 2015 and newer support both. +// MSVC v19.00 (VS 2015 version 14.0) and later should work. // // MSVC v19.27 (VS 2019 version 16.7) added support for restrict. // Older ones support only __restrict. #ifdef _MSC_VER -# if _MSC_VER < 1900 && !defined(inline) -# define inline __inline -# endif # if _MSC_VER < 1927 && !defined(restrict) # define restrict __restrict # endif @@ -208,4 +217,13 @@ typedef unsigned char _Bool; # define lzma_attr_alloc_size(x) #endif +#if __STDC_VERSION__ >= 202311 +# define FALLTHROUGH [[__fallthrough__]] +#elif (defined(__GNUC__) && __GNUC__ >= 7) \ + || (defined(__clang_major__) && __clang_major__ >= 10) +# define FALLTHROUGH __attribute__((__fallthrough__)) +#else +# define FALLTHROUGH ((void)0) +#endif + #endif diff --git a/contrib/libs/lzma/common/tuklib_common.h b/contrib/libs/lzma/common/tuklib_common.h index 7554dfc86f..d73f07255e 100644 --- a/contrib/libs/lzma/common/tuklib_common.h +++ b/contrib/libs/lzma/common/tuklib_common.h @@ -56,6 +56,13 @@ # define TUKLIB_GNUC_REQ(major, minor) 0 #endif +#if defined(__GNUC__) || defined(__clang__) +# define tuklib_attr_format_printf(fmt_index, args_index) \ + __attribute__((__format__(__printf__, fmt_index, args_index))) +#else +# define tuklib_attr_format_printf(fmt_index, args_index) +#endif + // tuklib_attr_noreturn attribute is used to mark functions as non-returning. // We cannot use "noreturn" as the macro name because then C23 code that // uses [[noreturn]] would break as it would expand to [[ [[noreturn]] ]]. @@ -68,9 +75,7 @@ // __attribute__((nonnull(1))) // extern void foo(const char *s); // -// FIXME: Update __STDC_VERSION__ for the final C23 version. 202000 is used -// by GCC 13 and Clang 15 with -std=c2x. -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000 +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311 # define tuklib_attr_noreturn [[noreturn]] #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112 # define tuklib_attr_noreturn _Noreturn diff --git a/contrib/libs/lzma/common/tuklib_physmem.c b/contrib/libs/lzma/common/tuklib_physmem.c index 0a4fcb3871..2b686d8658 100644 --- a/contrib/libs/lzma/common/tuklib_physmem.c +++ b/contrib/libs/lzma/common/tuklib_physmem.c @@ -91,18 +91,11 @@ tuklib_physmem(void) // supports reporting values greater than 4 GiB. To keep the // code working also on older Windows versions, use // GlobalMemoryStatusEx() conditionally. - HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); + HMODULE kernel32 = GetModuleHandleA("kernel32.dll"); if (kernel32 != NULL) { typedef BOOL (WINAPI *gmse_type)(LPMEMORYSTATUSEX); -#ifdef CAN_DISABLE_WCAST_FUNCTION_TYPE -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wcast-function-type" -#endif gmse_type gmse = (gmse_type)GetProcAddress( kernel32, "GlobalMemoryStatusEx"); -#ifdef CAN_DISABLE_WCAST_FUNCTION_TYPE -# pragma GCC diagnostic pop -#endif if (gmse != NULL) { MEMORYSTATUSEX meminfo; meminfo.dwLength = sizeof(meminfo); @@ -155,7 +148,7 @@ tuklib_physmem(void) ret += entries[i].end - entries[i].start + 1; #elif defined(TUKLIB_PHYSMEM_AIX) - ret = _system_configuration.physmem; + ret = (uint64_t)_system_configuration.physmem; #elif defined(TUKLIB_PHYSMEM_SYSCONF) const long pagesize = sysconf(_SC_PAGESIZE); diff --git a/contrib/libs/lzma/liblzma/api/lzma/bcj.h b/contrib/libs/lzma/liblzma/api/lzma/bcj.h index 7f6611feb3..fb737cbba4 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/bcj.h +++ b/contrib/libs/lzma/liblzma/api/lzma/bcj.h @@ -96,3 +96,100 @@ typedef struct { uint32_t start_offset; } lzma_options_bcj; + + +/** + * \brief Raw ARM64 BCJ encoder + * + * This is for special use cases only. + * + * \param start_offset The lowest 32 bits of the offset in the + * executable being filtered. For the ARM64 + * filter, this must be a multiple of four. + * For the very best results, this should also + * be in sync with 4096-byte page boundaries + * in the executable due to how ARM64's ADRP + * instruction works. + * \param buf Buffer to be filtered in place + * \param size Size of the buffer + * + * \return Number of bytes that were processed in `buf`. This is at most + * `size`. With the ARM64 filter, the return value is always + * a multiple of 4, and at most 3 bytes are left unfiltered. + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_arm64_encode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; + +/** + * \brief Raw ARM64 BCJ decoder + * + * See lzma_bcj_arm64_encode(). + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_arm64_decode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; + + +/** + * \brief Raw RISC-V BCJ encoder + * + * This is for special use cases only. + * + * \param start_offset The lowest 32 bits of the offset in the + * executable being filtered. For the RISC-V + * filter, this must be a multiple of 2. + * \param buf Buffer to be filtered in place + * \param size Size of the buffer + * + * \return Number of bytes that were processed in `buf`. This is at most + * `size`. With the RISC-V filter, the return value is always + * a multiple of 2, and at most 7 bytes are left unfiltered. + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_riscv_encode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; + +/** + * \brief Raw RISC-V BCJ decoder + * + * See lzma_bcj_riscv_encode(). + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_riscv_decode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; + + +/** + * \brief Raw x86 BCJ encoder + * + * This is for special use cases only. + * + * \param start_offset The lowest 32 bits of the offset in the + * executable being filtered. For the x86 + * filter, all values are valid. + * \param buf Buffer to be filtered in place + * \param size Size of the buffer + * + * \return Number of bytes that were processed in `buf`. This is at most + * `size`. For the x86 filter, the return value is always + * a multiple of 1, and at most 4 bytes are left unfiltered. + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_x86_encode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; + +/** + * \brief Raw x86 BCJ decoder + * + * See lzma_bcj_x86_encode(). + * + * \since 5.7.1alpha + */ +extern LZMA_API(size_t) lzma_bcj_x86_decode( + uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow; diff --git a/contrib/libs/lzma/liblzma/api/lzma/container.h b/contrib/libs/lzma/liblzma/api/lzma/container.h index ee5d77e4f1..dbd414cbf8 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/container.h +++ b/contrib/libs/lzma/liblzma/api/lzma/container.h @@ -573,7 +573,7 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( * The action argument must be LZMA_FINISH and the return value will never be * LZMA_OK. Thus the encoding is always done with a single lzma_code() after * the initialization. The benefit of the combination of initialization - * function and lzma_code() is that memory allocations can be re-used for + * function and lzma_code() is that memory allocations can be reused for * better performance. * * lzma_code() will try to encode as much input as is possible to fit into diff --git a/contrib/libs/lzma/liblzma/api/lzma/version.h b/contrib/libs/lzma/liblzma/api/lzma/version.h index 86c8b199f5..86b3556359 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/version.h +++ b/contrib/libs/lzma/liblzma/api/lzma/version.h @@ -19,10 +19,10 @@ #define LZMA_VERSION_MAJOR 5 /** \brief Minor version number of the liblzma release. */ -#define LZMA_VERSION_MINOR 6 +#define LZMA_VERSION_MINOR 8 /** \brief Patch version number of the liblzma release. */ -#define LZMA_VERSION_PATCH 4 +#define LZMA_VERSION_PATCH 1 /** * \brief Version stability marker diff --git a/contrib/libs/lzma/liblzma/check/check.h b/contrib/libs/lzma/liblzma/check/check.h index 08627e783a..724246570c 100644 --- a/contrib/libs/lzma/liblzma/check/check.h +++ b/contrib/libs/lzma/liblzma/check/check.h @@ -95,24 +95,6 @@ typedef struct { } lzma_check_state; -/// lzma_crc32_table[0] is needed by LZ encoder so we need to keep -/// the array two-dimensional. -#ifdef HAVE_SMALL -lzma_attr_visibility_hidden -extern uint32_t lzma_crc32_table[1][256]; - -extern void lzma_crc32_init(void); - -#else - -lzma_attr_visibility_hidden -extern const uint32_t lzma_crc32_table[8][256]; - -lzma_attr_visibility_hidden -extern const uint64_t lzma_crc64_table[4][256]; -#endif - - /// \brief Initialize *check depending on type extern void lzma_check_init(lzma_check_state *check, lzma_check type); diff --git a/contrib/libs/lzma/liblzma/check/crc32_fast.c b/contrib/libs/lzma/liblzma/check/crc32_fast.c index fce1af6119..caaa4710af 100644 --- a/contrib/libs/lzma/liblzma/check/crc32_fast.c +++ b/contrib/libs/lzma/liblzma/check/crc32_fast.c @@ -7,7 +7,6 @@ // // Authors: Lasse Collin // Ilya Kurdyukov -// Hans Jansen // /////////////////////////////////////////////////////////////////////////////// @@ -15,10 +14,12 @@ #include "crc_common.h" #if defined(CRC_X86_CLMUL) -# define BUILDING_CRC32_CLMUL +# define BUILDING_CRC_CLMUL 32 # include "crc_x86_clmul.h" #elif defined(CRC32_ARM64) # error #include "crc32_arm64.h" +#elif defined(CRC32_LOONGARCH) +# error #include "crc32_loongarch.h" #endif @@ -28,8 +29,19 @@ // Generic CRC32 // /////////////////// +#ifdef WORDS_BIGENDIAN +# error #include "crc32_table_be.h" +#else +# include "crc32_table_le.h" +#endif + + +#ifdef HAVE_CRC_X86_ASM +extern uint32_t lzma_crc32_generic( + const uint8_t *buf, size_t size, uint32_t crc); +#else static uint32_t -crc32_generic(const uint8_t *buf, size_t size, uint32_t crc) +lzma_crc32_generic(const uint8_t *buf, size_t size, uint32_t crc) { crc = ~crc; @@ -85,7 +97,8 @@ crc32_generic(const uint8_t *buf, size_t size, uint32_t crc) return ~crc; } -#endif +#endif // HAVE_CRC_X86_ASM +#endif // CRC32_GENERIC #if defined(CRC32_GENERIC) && defined(CRC32_ARCH_OPTIMIZED) @@ -119,7 +132,7 @@ static crc32_func_type crc32_resolve(void) { return is_arch_extension_supported() - ? &crc32_arch_optimized : &crc32_generic; + ? &crc32_arch_optimized : &lzma_crc32_generic; } @@ -164,27 +177,6 @@ extern LZMA_API(uint32_t) lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc) { #if defined(CRC32_GENERIC) && defined(CRC32_ARCH_OPTIMIZED) - // On x86-64, if CLMUL is available, it is the best for non-tiny - // inputs, being over twice as fast as the generic slice-by-four - // version. However, for size <= 16 it's different. In the extreme - // case of size == 1 the generic version can be five times faster. - // At size >= 8 the CLMUL starts to become reasonable. It - // varies depending on the alignment of buf too. - // - // The above doesn't include the overhead of mythread_once(). - // At least on x86-64 GNU/Linux, pthread_once() is very fast but - // it still makes lzma_crc32(buf, 1, crc) 50-100 % slower. When - // size reaches 12-16 bytes the overhead becomes negligible. - // - // So using the generic version for size <= 16 may give better - // performance with tiny inputs but if such inputs happen rarely - // it's not so obvious because then the lookup table of the - // generic version may not be in the processor cache. -#ifdef CRC_USE_GENERIC_FOR_SMALL_INPUTS - if (size <= 16) - return crc32_generic(buf, size, crc); -#endif - /* #ifndef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR // See crc32_dispatch(). This would be the alternative which uses @@ -199,6 +191,6 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc) return crc32_arch_optimized(buf, size, crc); #else - return crc32_generic(buf, size, crc); + return lzma_crc32_generic(buf, size, crc); #endif } diff --git a/contrib/libs/lzma/liblzma/check/crc32_table.c b/contrib/libs/lzma/liblzma/check/crc32_table.c deleted file mode 100644 index db8d9d5831..0000000000 --- a/contrib/libs/lzma/liblzma/check/crc32_table.c +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: 0BSD - -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc32_table.c -/// \brief Precalculated CRC32 table with correct endianness -// -// Author: Lasse Collin -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - - -// FIXME: Compared to crc_common.h this has to check for __x86_64__ too -// so that in 32-bit builds crc32_x86.S won't break due to a missing table. -#if defined(HAVE_USABLE_CLMUL) && ((defined(__x86_64__) && defined(__SSSE3__) \ - && defined(__SSE4_1__) && defined(__PCLMUL__)) \ - || (defined(__e2k__) && __iset__ >= 6)) -# define NO_CRC32_TABLE - -#elif defined(HAVE_ARM64_CRC32) \ - && !defined(WORDS_BIGENDIAN) \ - && defined(__ARM_FEATURE_CRC32) -# define NO_CRC32_TABLE -#endif - - -#if !defined(HAVE_ENCODERS) && defined(NO_CRC32_TABLE) -// No table needed. Use a typedef to avoid an empty translation unit. -typedef void lzma_crc32_dummy; - -#else -// Having the declaration here silences clang -Wmissing-variable-declarations. -extern const uint32_t lzma_crc32_table[8][256]; - -# ifdef WORDS_BIGENDIAN -# error #include "crc32_table_be.h" -# else -# include "crc32_table_le.h" -# endif -#endif diff --git a/contrib/libs/lzma/liblzma/check/crc64_fast.c b/contrib/libs/lzma/liblzma/check/crc64_fast.c index 0ce83fe4ad..2c767bdcfd 100644 --- a/contrib/libs/lzma/liblzma/check/crc64_fast.c +++ b/contrib/libs/lzma/liblzma/check/crc64_fast.c @@ -14,7 +14,7 @@ #include "crc_common.h" #if defined(CRC_X86_CLMUL) -# define BUILDING_CRC64_CLMUL +# define BUILDING_CRC_CLMUL 64 # include "crc_x86_clmul.h" #endif @@ -25,6 +25,18 @@ // Generic slice-by-four CRC64 // ///////////////////////////////// +#if defined(WORDS_BIGENDIAN) +# error #include "crc64_table_be.h" +#else +# include "crc64_table_le.h" +#endif + + +#ifdef HAVE_CRC_X86_ASM +extern uint64_t lzma_crc64_generic( + const uint8_t *buf, size_t size, uint64_t crc); +#else + #ifdef WORDS_BIGENDIAN # define A1(x) ((x) >> 56) #else @@ -34,7 +46,7 @@ // See the comments in crc32_fast.c. They aren't duplicated here. static uint64_t -crc64_generic(const uint8_t *buf, size_t size, uint64_t crc) +lzma_crc64_generic(const uint8_t *buf, size_t size, uint64_t crc) { crc = ~crc; @@ -78,7 +90,8 @@ crc64_generic(const uint8_t *buf, size_t size, uint64_t crc) return ~crc; } -#endif +#endif // HAVE_CRC_X86_ASM +#endif // CRC64_GENERIC #if defined(CRC64_GENERIC) && defined(CRC64_ARCH_OPTIMIZED) @@ -97,7 +110,7 @@ static crc64_func_type crc64_resolve(void) { return is_arch_extension_supported() - ? &crc64_arch_optimized : &crc64_generic; + ? &crc64_arch_optimized : &lzma_crc64_generic; } #ifdef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR @@ -133,24 +146,24 @@ crc64_dispatch(const uint8_t *buf, size_t size, uint64_t crc) extern LZMA_API(uint64_t) lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc) { -#if defined(CRC64_GENERIC) && defined(CRC64_ARCH_OPTIMIZED) - -#ifdef CRC_USE_GENERIC_FOR_SMALL_INPUTS - if (size <= 16) - return crc64_generic(buf, size, crc); +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \ + && defined(_M_IX86) && defined(CRC64_ARCH_OPTIMIZED) + // VS2015-2022 might corrupt the ebx register on 32-bit x86 when + // the CLMUL code is enabled. This hack forces MSVC to store and + // restore ebx. This is only needed here, not in lzma_crc32(). + __asm mov ebx, ebx #endif + +#if defined(CRC64_GENERIC) && defined(CRC64_ARCH_OPTIMIZED) return crc64_func(buf, size, crc); #elif defined(CRC64_ARCH_OPTIMIZED) // If arch-optimized version is used unconditionally without runtime // CPU detection then omitting the generic version and its 8 KiB // lookup table makes the library smaller. - // - // FIXME: Lookup table isn't currently omitted on 32-bit x86, - // see crc64_table.c. return crc64_arch_optimized(buf, size, crc); #else - return crc64_generic(buf, size, crc); + return lzma_crc64_generic(buf, size, crc); #endif } diff --git a/contrib/libs/lzma/liblzma/check/crc64_table.c b/contrib/libs/lzma/liblzma/check/crc64_table.c deleted file mode 100644 index e7ceb0276f..0000000000 --- a/contrib/libs/lzma/liblzma/check/crc64_table.c +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: 0BSD - -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc64_table.c -/// \brief Precalculated CRC64 table with correct endianness -// -// Author: Lasse Collin -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - - -// FIXME: Compared to crc_common.h this has to check for __x86_64__ too -// so that in 32-bit builds crc64_x86.S won't break due to a missing table. -#if defined(HAVE_USABLE_CLMUL) && ((defined(__x86_64__) && defined(__SSSE3__) \ - && defined(__SSE4_1__) && defined(__PCLMUL__)) \ - || (defined(__e2k__) && __iset__ >= 6)) -# define NO_CRC64_TABLE -#endif - - -#ifdef NO_CRC64_TABLE -// No table needed. Use a typedef to avoid an empty translation unit. -typedef void lzma_crc64_dummy; - -#else -// Having the declaration here silences clang -Wmissing-variable-declarations. -extern const uint64_t lzma_crc64_table[4][256]; - -# if defined(WORDS_BIGENDIAN) -# error #include "crc64_table_be.h" -# else -# include "crc64_table_le.h" -# endif -#endif diff --git a/contrib/libs/lzma/liblzma/check/crc_common.h b/contrib/libs/lzma/liblzma/check/crc_common.h index c15d4c675c..7ea1e60b04 100644 --- a/contrib/libs/lzma/liblzma/check/crc_common.h +++ b/contrib/libs/lzma/liblzma/check/crc_common.h @@ -3,11 +3,10 @@ /////////////////////////////////////////////////////////////////////////////// // /// \file crc_common.h -/// \brief Some functions and macros for CRC32 and CRC64 +/// \brief Macros and declarations for CRC32 and CRC64 // // Authors: Lasse Collin // Ilya Kurdyukov -// Hans Jansen // Jia Tan // /////////////////////////////////////////////////////////////////////////////// @@ -18,6 +17,10 @@ #include "common.h" +///////////// +// Generic // +///////////// + #ifdef WORDS_BIGENDIAN # define A(x) ((x) >> 24) # define B(x) (((x) >> 16) & 0xFF) @@ -38,43 +41,63 @@ #endif -// CRC CLMUL code needs this because accessing input buffers that aren't -// aligned to the vector size will inherently trip the address sanitizer. -#if lzma_has_attribute(__no_sanitize_address__) -# define crc_attr_no_sanitize_address \ - __attribute__((__no_sanitize_address__)) +/// lzma_crc32_table[0] is needed by LZ encoder so we need to keep +/// the array two-dimensional. +#ifdef HAVE_SMALL +lzma_attr_visibility_hidden +extern uint32_t lzma_crc32_table[1][256]; + +extern void lzma_crc32_init(void); + #else -# define crc_attr_no_sanitize_address -#endif -// Keep this in sync with changes to crc32_arm64.h -#if defined(_WIN32) || defined(HAVE_GETAUXVAL) \ - || defined(HAVE_ELF_AUX_INFO) \ - || (defined(__APPLE__) && defined(HAVE_SYSCTLBYNAME)) -# define ARM64_RUNTIME_DETECTION 1 +lzma_attr_visibility_hidden +extern const uint32_t lzma_crc32_table[8][256]; + +lzma_attr_visibility_hidden +extern const uint64_t lzma_crc64_table[4][256]; #endif +/////////////////// +// Configuration // +/////////////////// + +// NOTE: This config isn't used if HAVE_SMALL is defined! + +// These are defined if the generic slicing-by-n implementations and their +// lookup tables are built. #undef CRC32_GENERIC #undef CRC64_GENERIC +// These are defined if an arch-specific version is built. If both this +// and matching _GENERIC is defined then runtime detection must be used. #undef CRC32_ARCH_OPTIMIZED #undef CRC64_ARCH_OPTIMIZED // The x86 CLMUL is used for both CRC32 and CRC64. #undef CRC_X86_CLMUL +// Many ARM64 processor have CRC32 instructions. +// CRC64 could be done with CLMUL but it's not implemented yet. #undef CRC32_ARM64 -#undef CRC64_ARM64_CLMUL -#undef CRC_USE_GENERIC_FOR_SMALL_INPUTS +// 64-bit LoongArch has CRC32 instructions. +#undef CRC32_LOONGARCH + + +// ARM64 +// +// Keep this in sync with changes to crc32_arm64.h +#if defined(_WIN32) || defined(HAVE_GETAUXVAL) \ + || defined(HAVE_ELF_AUX_INFO) \ + || (defined(__APPLE__) && defined(HAVE_SYSCTLBYNAME)) +# define CRC_ARM64_RUNTIME_DETECTION 1 +#endif // ARM64 CRC32 instruction is only useful for CRC32. Currently, only // little endian is supported since we were unable to test on a big // endian machine. -// -// NOTE: Keep this and the next check in sync with the macro -// NO_CRC32_TABLE in crc32_table.c #if defined(HAVE_ARM64_CRC32) && !defined(WORDS_BIGENDIAN) // Allow ARM64 CRC32 instruction without a runtime check if // __ARM_FEATURE_CRC32 is defined. GCC and Clang only define @@ -82,21 +105,40 @@ # if defined(__ARM_FEATURE_CRC32) # define CRC32_ARCH_OPTIMIZED 1 # define CRC32_ARM64 1 -# elif defined(ARM64_RUNTIME_DETECTION) +# elif defined(CRC_ARM64_RUNTIME_DETECTION) # define CRC32_ARCH_OPTIMIZED 1 # define CRC32_ARM64 1 # define CRC32_GENERIC 1 # endif #endif -#if defined(HAVE_USABLE_CLMUL) -// If CLMUL is allowed unconditionally in the compiler options then the -// generic version can be omitted. Note that this doesn't work with MSVC -// as I don't know how to detect the features here. + +// LoongArch // -// NOTE: Keep this in sync with the NO_CRC32_TABLE macro in crc32_table.c -// and NO_CRC64_TABLE in crc64_table.c. -# if (defined(__SSSE3__) && defined(__SSE4_1__) && defined(__PCLMUL__)) \ +// Only 64-bit LoongArch is supported for now. No runtime detection +// is needed because the LoongArch specification says that the CRC32 +// instructions are a part of the Basic Integer Instructions and +// they shall be implemented by 64-bit LoongArch implementations. +#ifdef HAVE_LOONGARCH_CRC32 +# define CRC32_ARCH_OPTIMIZED 1 +# define CRC32_LOONGARCH 1 +#endif + + +// x86 and E2K +#if defined(HAVE_USABLE_CLMUL) + // If CLMUL is allowed unconditionally in the compiler options then + // the generic version and the tables can be omitted. Exceptions: + // + // - If 32-bit x86 assembly files are enabled then those are always + // built and runtime detection is used even if compiler flags + // were set to allow CLMUL unconditionally. + // + // - This doesn't work with MSVC as I don't know how to detect + // the features here. + // +# if (defined(__SSSE3__) && defined(__SSE4_1__) && defined(__PCLMUL__) \ + && !defined(HAVE_CRC_X86_ASM)) \ || (defined(__e2k__) && __iset__ >= 6) # define CRC32_ARCH_OPTIMIZED 1 # define CRC64_ARCH_OPTIMIZED 1 @@ -107,21 +149,12 @@ # define CRC32_ARCH_OPTIMIZED 1 # define CRC64_ARCH_OPTIMIZED 1 # define CRC_X86_CLMUL 1 - -/* - // The generic code is much faster with 1-8-byte inputs and - // has similar performance up to 16 bytes at least in - // microbenchmarks (it depends on input buffer alignment - // too). If both versions are built, this #define will use - // the generic version for inputs up to 16 bytes and CLMUL - // for bigger inputs. It saves a little in code size since - // the special cases for 0-16-byte inputs will be omitted - // from the CLMUL code. -# define CRC_USE_GENERIC_FOR_SMALL_INPUTS 1 -*/ # endif #endif + +// Fallback configuration +// // For CRC32 use the generic slice-by-eight implementation if no optimized // version is available. #if !defined(CRC32_ARCH_OPTIMIZED) && !defined(CRC32_GENERIC) diff --git a/contrib/libs/lzma/liblzma/check/crc_x86_clmul.h b/contrib/libs/lzma/liblzma/check/crc_x86_clmul.h index 50306e49a7..b302d6cf7f 100644 --- a/contrib/libs/lzma/liblzma/check/crc_x86_clmul.h +++ b/contrib/libs/lzma/liblzma/check/crc_x86_clmul.h @@ -8,26 +8,20 @@ /// The CRC32 and CRC64 implementations use 32/64-bit x86 SSSE3, SSE4.1, and /// CLMUL instructions. This is compatible with Elbrus 2000 (E2K) too. /// -/// They were derived from +/// See the Intel white paper "Fast CRC Computation for Generic Polynomials +/// Using PCLMULQDQ Instruction" from 2009. The original file seems to be +/// gone from Intel's website but a version is available here: /// https://www.researchgate.net/publication/263424619_Fast_CRC_computation -/// and the public domain code from https://github.com/rawrunprotected/crc -/// (URLs were checked on 2023-10-14). +/// (The link was checked on 2024-06-11.) /// /// While this file has both CRC32 and CRC64 implementations, only one -/// should be built at a time to ensure that crc_simd_body() is inlined -/// even with compilers with which lzma_always_inline expands to plain inline. -/// The version to build is selected by defining BUILDING_CRC32_CLMUL or -/// BUILDING_CRC64_CLMUL before including this file. +/// can be built at a time. The version to build is selected by defining +/// BUILDING_CRC_CLMUL to 32 or 64 before including this file. /// -/// FIXME: Builds for 32-bit x86 use the assembly .S files by default -/// unless configured with --disable-assembler. Even then the lookup table -/// isn't omitted in crc64_table.c since it doesn't know that assembly -/// code has been disabled. +/// NOTE: The x86 CLMUL CRC implementation was rewritten for XZ Utils 5.8.0. // -// Authors: Ilya Kurdyukov -// Hans Jansen -// Lasse Collin -// Jia Tan +// Authors: Lasse Collin +// Ilya Kurdyukov // /////////////////////////////////////////////////////////////////////////////// @@ -37,6 +31,10 @@ #endif #define LZMA_CRC_X86_CLMUL_H +#if BUILDING_CRC_CLMUL != 32 && BUILDING_CRC_CLMUL != 64 +# error BUILDING_CRC_CLMUL is undefined or has an invalid value +#endif + #include <immintrin.h> #if defined(_MSC_VER) @@ -59,330 +57,277 @@ #endif -#define MASK_L(in, mask, r) r = _mm_shuffle_epi8(in, mask) +// GCC and Clang would produce good code with _mm_set_epi64x +// but MSVC needs _mm_cvtsi64_si128 on x86-64. +#if defined(__i386__) || defined(_M_IX86) +# define my_set_low64(a) _mm_set_epi64x(0, (a)) +#else +# define my_set_low64(a) _mm_cvtsi64_si128(a) +#endif -#define MASK_H(in, mask, r) \ - r = _mm_shuffle_epi8(in, _mm_xor_si128(mask, vsign)) -#define MASK_LH(in, mask, low, high) \ - MASK_L(in, mask, low); \ - MASK_H(in, mask, high) +// Align it so that the whole array is within the same cache line. +// More than one unaligned load can be done from this during the +// same CRC function call. +// +// The bytes [0] to [31] are used with AND to clear the low bytes. (With ANDN +// those could be used to clear the high bytes too but it's not needed here.) +// +// The bytes [16] to [47] are for left shifts. +// The bytes [32] to [63] are for right shifts. +alignas(64) +static uint8_t vmasks[64] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + + +// *Unaligned* 128-bit load +crc_attr_target +static inline __m128i +my_load128(const uint8_t *p) +{ + return _mm_loadu_si128((const __m128i *)p); +} +// Keep the highest "count" bytes as is and clear the remaining low bytes. crc_attr_target -crc_attr_no_sanitize_address -static lzma_always_inline void -crc_simd_body(const uint8_t *buf, const size_t size, __m128i *v0, __m128i *v1, - const __m128i vfold16, const __m128i initial_crc) +static inline __m128i +keep_high_bytes(__m128i v, size_t count) { - // Create a vector with 8-bit values 0 to 15. This is used to - // construct control masks for _mm_blendv_epi8 and _mm_shuffle_epi8. - const __m128i vramp = _mm_setr_epi32( - 0x03020100, 0x07060504, 0x0b0a0908, 0x0f0e0d0c); - - // This is used to inverse the control mask of _mm_shuffle_epi8 - // so that bytes that wouldn't be picked with the original mask - // will be picked and vice versa. - const __m128i vsign = _mm_set1_epi8(-0x80); + return _mm_and_si128(my_load128((vmasks + count)), v); +} - // Memory addresses A to D and the distances between them: - // - // A B C D - // [skip_start][size][skip_end] - // [ size2 ] - // - // A and D are 16-byte aligned. B and C are 1-byte aligned. - // skip_start and skip_end are 0-15 bytes. size is at least 1 byte. - // - // A = aligned_buf will initially point to this address. - // B = The address pointed by the caller-supplied buf. - // C = buf + size == aligned_buf + size2 - // D = buf + size + skip_end == aligned_buf + size2 + skip_end - const size_t skip_start = (size_t)((uintptr_t)buf & 15); - const size_t skip_end = (size_t)((0U - (uintptr_t)(buf + size)) & 15); - const __m128i *aligned_buf = (const __m128i *)( - (uintptr_t)buf & ~(uintptr_t)15); - - // If size2 <= 16 then the whole input fits into a single 16-byte - // vector. If size2 > 16 then at least two 16-byte vectors must - // be processed. If size2 > 16 && size <= 16 then there is only - // one 16-byte vector's worth of input but it is unaligned in memory. - // - // NOTE: There is no integer overflow here if the arguments - // are valid. If this overflowed, buf + size would too. - const size_t size2 = skip_start + size; - - // Masks to be used with _mm_blendv_epi8 and _mm_shuffle_epi8: - // The first skip_start or skip_end bytes in the vectors will have - // the high bit (0x80) set. _mm_blendv_epi8 and _mm_shuffle_epi8 - // will produce zeros for these positions. (Bitwise-xor of these - // masks with vsign will produce the opposite behavior.) - const __m128i mask_start - = _mm_sub_epi8(vramp, _mm_set1_epi8((char)skip_start)); - const __m128i mask_end - = _mm_sub_epi8(vramp, _mm_set1_epi8((char)skip_end)); - - // Get the first 1-16 bytes into data0. If loading less than 16 - // bytes, the bytes are loaded to the high bits of the vector and - // the least significant positions are filled with zeros. - const __m128i data0 = _mm_blendv_epi8(_mm_load_si128(aligned_buf), - _mm_setzero_si128(), mask_start); - aligned_buf++; - - __m128i v2, v3; - -#ifndef CRC_USE_GENERIC_FOR_SMALL_INPUTS - if (size <= 16) { - // Right-shift initial_crc by 1-16 bytes based on "size" - // and store the result in v1 (high bytes) and v0 (low bytes). - // - // NOTE: The highest 8 bytes of initial_crc are zeros so - // v1 will be filled with zeros if size >= 8. The highest - // 8 bytes of v1 will always become zeros. - // - // [ v1 ][ v0 ] - // [ initial_crc ] size == 1 - // [ initial_crc ] size == 2 - // [ initial_crc ] size == 15 - // [ initial_crc ] size == 16 (all in v0) - const __m128i mask_low = _mm_add_epi8( - vramp, _mm_set1_epi8((char)(size - 16))); - MASK_LH(initial_crc, mask_low, *v0, *v1); - - if (size2 <= 16) { - // There are 1-16 bytes of input and it is all - // in data0. Copy the input bytes to v3. If there - // are fewer than 16 bytes, the low bytes in v3 - // will be filled with zeros. That is, the input - // bytes are stored to the same position as - // (part of) initial_crc is in v0. - MASK_L(data0, mask_end, v3); - } else { - // There are 2-16 bytes of input but not all bytes - // are in data0. - const __m128i data1 = _mm_load_si128(aligned_buf); - - // Collect the 2-16 input bytes from data0 and data1 - // to v2 and v3, and bitwise-xor them with the - // low bits of initial_crc in v0. Note that the - // the second xor is below this else-block as it - // is shared with the other branch. - MASK_H(data0, mask_end, v2); - MASK_L(data1, mask_end, v3); - *v0 = _mm_xor_si128(*v0, v2); - } - *v0 = _mm_xor_si128(*v0, v3); - *v1 = _mm_alignr_epi8(*v1, *v0, 8); - } else -#endif - { - // There is more than 16 bytes of input. - const __m128i data1 = _mm_load_si128(aligned_buf); - const __m128i *end = (const __m128i*)( - (const char *)aligned_buf - 16 + size2); - aligned_buf++; - - MASK_LH(initial_crc, mask_start, *v0, *v1); - *v0 = _mm_xor_si128(*v0, data0); - *v1 = _mm_xor_si128(*v1, data1); - - while (aligned_buf < end) { - *v1 = _mm_xor_si128(*v1, _mm_clmulepi64_si128( - *v0, vfold16, 0x00)); - *v0 = _mm_xor_si128(*v1, _mm_clmulepi64_si128( - *v0, vfold16, 0x11)); - *v1 = _mm_load_si128(aligned_buf++); - } +// Shift the 128-bit value left by "amount" bytes (not bits). +crc_attr_target +static inline __m128i +shift_left(__m128i v, size_t amount) +{ + return _mm_shuffle_epi8(v, my_load128((vmasks + 32 - amount))); +} - if (aligned_buf != end) { - MASK_H(*v0, mask_end, v2); - MASK_L(*v0, mask_end, *v0); - MASK_L(*v1, mask_end, v3); - *v1 = _mm_or_si128(v2, v3); - } - *v1 = _mm_xor_si128(*v1, _mm_clmulepi64_si128( - *v0, vfold16, 0x00)); - *v0 = _mm_xor_si128(*v1, _mm_clmulepi64_si128( - *v0, vfold16, 0x11)); - *v1 = _mm_srli_si128(*v0, 8); - } +// Shift the 128-bit value right by "amount" bytes (not bits). +crc_attr_target +static inline __m128i +shift_right(__m128i v, size_t amount) +{ + return _mm_shuffle_epi8(v, my_load128((vmasks + 32 + amount))); } -///////////////////// -// x86 CLMUL CRC32 // -///////////////////// - -/* -// These functions were used to generate the constants -// at the top of crc32_arch_optimized(). -static uint64_t -calc_lo(uint64_t p, uint64_t a, int n) +crc_attr_target +static inline __m128i +fold(__m128i v, __m128i k) { - uint64_t b = 0; int i; - for (i = 0; i < n; i++) { - b = b >> 1 | (a & 1) << (n - 1); - a = (a >> 1) ^ ((0 - (a & 1)) & p); - } - return b; + __m128i a = _mm_clmulepi64_si128(v, k, 0x00); + __m128i b = _mm_clmulepi64_si128(v, k, 0x11); + return _mm_xor_si128(a, b); } -// same as ~crc(&a, sizeof(a), ~0) -static uint64_t -calc_hi(uint64_t p, uint64_t a, int n) + +crc_attr_target +static inline __m128i +fold_xor(__m128i v, __m128i k, const uint8_t *buf) { - int i; - for (i = 0; i < n; i++) - a = (a >> 1) ^ ((0 - (a & 1)) & p); - return a; + return _mm_xor_si128(my_load128(buf), fold(v, k)); } -*/ -#ifdef BUILDING_CRC32_CLMUL +#if BUILDING_CRC_CLMUL == 32 crc_attr_target -crc_attr_no_sanitize_address static uint32_t crc32_arch_optimized(const uint8_t *buf, size_t size, uint32_t crc) +#else +crc_attr_target +static uint64_t +crc64_arch_optimized(const uint8_t *buf, size_t size, uint64_t crc) +#endif { -#ifndef CRC_USE_GENERIC_FOR_SMALL_INPUTS - // The code assumes that there is at least one byte of input. + // We will assume that there is at least one byte of input. if (size == 0) return crc; -#endif - // uint32_t poly = 0xedb88320; - const int64_t p = 0x1db710640; // p << 1 - const int64_t mu = 0x1f7011641; // calc_lo(p, p, 32) << 1 | 1 - const int64_t k5 = 0x163cd6124; // calc_hi(p, p, 32) << 1 - const int64_t k4 = 0x0ccaa009e; // calc_hi(p, p, 64) << 1 - const int64_t k3 = 0x1751997d0; // calc_hi(p, p, 128) << 1 - - const __m128i vfold4 = _mm_set_epi64x(mu, p); - const __m128i vfold8 = _mm_set_epi64x(0, k5); - const __m128i vfold16 = _mm_set_epi64x(k4, k3); - - __m128i v0, v1, v2; - - crc_simd_body(buf, size, &v0, &v1, vfold16, - _mm_cvtsi32_si128((int32_t)~crc)); - - v1 = _mm_xor_si128( - _mm_clmulepi64_si128(v0, vfold16, 0x10), v1); // xxx0 - v2 = _mm_shuffle_epi32(v1, 0xe7); // 0xx0 - v0 = _mm_slli_epi64(v1, 32); // [0] - v0 = _mm_clmulepi64_si128(v0, vfold8, 0x00); - v0 = _mm_xor_si128(v0, v2); // [1] [2] - v2 = _mm_clmulepi64_si128(v0, vfold4, 0x10); - v2 = _mm_clmulepi64_si128(v2, vfold4, 0x00); - v0 = _mm_xor_si128(v0, v2); // [2] - return ~(uint32_t)_mm_extract_epi32(v0, 2); -} -#endif // BUILDING_CRC32_CLMUL + // See crc_clmul_consts_gen.c. +#if BUILDING_CRC_CLMUL == 32 + const __m128i fold512 = _mm_set_epi64x(0x1d9513d7, 0x8f352d95); + const __m128i fold128 = _mm_set_epi64x(0xccaa009e, 0xae689191); + const __m128i mu_p = _mm_set_epi64x( + (int64_t)0xb4e5b025f7011641, 0x1db710640); +#else + const __m128i fold512 = _mm_set_epi64x( + (int64_t)0x081f6054a7842df4, (int64_t)0x6ae3efbb9dd441f3); + const __m128i fold128 = _mm_set_epi64x( + (int64_t)0xdabe95afc7875f40, (int64_t)0xe05dd497ca393ae4); -///////////////////// -// x86 CLMUL CRC64 // -///////////////////// + const __m128i mu_p = _mm_set_epi64x( + (int64_t)0x9c3e466c172963d5, (int64_t)0x92d8af2baf0e1e84); +#endif -/* -// These functions were used to generate the constants -// at the top of crc64_arch_optimized(). -static uint64_t -calc_lo(uint64_t poly) -{ - uint64_t a = poly; - uint64_t b = 0; + __m128i v0, v1, v2, v3; - for (unsigned i = 0; i < 64; ++i) { - b = (b >> 1) | (a << 63); - a = (a >> 1) ^ (a & 1 ? poly : 0); - } + crc = ~crc; - return b; -} + if (size < 8) { + uint64_t x = crc; + size_t i = 0; -static uint64_t -calc_hi(uint64_t poly, uint64_t a) -{ - for (unsigned i = 0; i < 64; ++i) - a = (a >> 1) ^ (a & 1 ? poly : 0); + // Checking the bit instead of comparing the size means + // that we don't need to update the size between the steps. + if (size & 4) { + x ^= read32le(buf); + buf += 4; + i = 32; + } - return a; -} -*/ + if (size & 2) { + x ^= (uint64_t)read16le(buf) << i; + buf += 2; + i += 16; + } -#ifdef BUILDING_CRC64_CLMUL + if (size & 1) + x ^= (uint64_t)*buf << i; -// MSVC (VS2015 - VS2022) produces bad 32-bit x86 code from the CLMUL CRC -// code when optimizations are enabled (release build). According to the bug -// report, the ebx register is corrupted and the calculated result is wrong. -// Trying to workaround the problem with "__asm mov ebx, ebx" didn't help. -// The following pragma works and performance is still good. x86-64 builds -// and CRC32 CLMUL aren't affected by this problem. The problem does not -// happen in crc_simd_body() either (which is shared with CRC32 CLMUL anyway). -// -// NOTE: Another pragma after crc64_arch_optimized() restores -// the optimizations. If the #if condition here is updated, -// the other one must be updated too. -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \ - && defined(_M_IX86) -# pragma optimize("g", off) -#endif + v0 = my_set_low64((int64_t)x); + v0 = shift_left(v0, 8 - size); -crc_attr_target -crc_attr_no_sanitize_address -static uint64_t -crc64_arch_optimized(const uint8_t *buf, size_t size, uint64_t crc) -{ -#ifndef CRC_USE_GENERIC_FOR_SMALL_INPUTS - // The code assumes that there is at least one byte of input. - if (size == 0) - return crc; -#endif - - // const uint64_t poly = 0xc96c5795d7870f42; // CRC polynomial - const uint64_t p = 0x92d8af2baf0e1e85; // (poly << 1) | 1 - const uint64_t mu = 0x9c3e466c172963d5; // (calc_lo(poly) << 1) | 1 - const uint64_t k2 = 0xdabe95afc7875f40; // calc_hi(poly, 1) - const uint64_t k1 = 0xe05dd497ca393ae4; // calc_hi(poly, k2) + } else if (size < 16) { + v0 = my_set_low64((int64_t)(crc ^ read64le(buf))); - const __m128i vfold8 = _mm_set_epi64x((int64_t)p, (int64_t)mu); - const __m128i vfold16 = _mm_set_epi64x((int64_t)k2, (int64_t)k1); + // NOTE: buf is intentionally left 8 bytes behind so that + // we can read the last 1-7 bytes with read64le(buf + size). + size -= 8; - __m128i v0, v1, v2; + // Handling 8-byte input specially is a speed optimization + // as the clmul can be skipped. A branch is also needed to + // avoid a too high shift amount. + if (size > 0) { + const size_t padding = 8 - size; + uint64_t high = read64le(buf + size) >> (padding * 8); #if defined(__i386__) || defined(_M_IX86) - crc_simd_body(buf, size, &v0, &v1, vfold16, - _mm_set_epi64x(0, (int64_t)~crc)); + // Simple but likely not the best code for 32-bit x86. + v0 = _mm_insert_epi32(v0, (int32_t)high, 2); + v0 = _mm_insert_epi32(v0, (int32_t)(high >> 32), 3); #else - // GCC and Clang would produce good code with _mm_set_epi64x - // but MSVC needs _mm_cvtsi64_si128 on x86-64. - crc_simd_body(buf, size, &v0, &v1, vfold16, - _mm_cvtsi64_si128((int64_t)~crc)); + v0 = _mm_insert_epi64(v0, (int64_t)high, 1); #endif - v1 = _mm_xor_si128(_mm_clmulepi64_si128(v0, vfold16, 0x10), v1); - v0 = _mm_clmulepi64_si128(v1, vfold8, 0x00); - v2 = _mm_clmulepi64_si128(v0, vfold8, 0x10); - v0 = _mm_xor_si128(_mm_xor_si128(v1, _mm_slli_si128(v0, 8)), v2); + v0 = shift_left(v0, padding); + + v1 = _mm_srli_si128(v0, 8); + v0 = _mm_clmulepi64_si128(v0, fold128, 0x10); + v0 = _mm_xor_si128(v0, v1); + } + } else { + v0 = my_set_low64((int64_t)crc); + + // To align or not to align the buf pointer? If the end of + // the buffer isn't aligned, aligning the pointer here would + // make us do an extra folding step with the associated byte + // shuffling overhead. The cost of that would need to be + // lower than the benefit of aligned reads. Testing on an old + // Intel Ivy Bridge processor suggested that aligning isn't + // worth the cost but it likely depends on the processor and + // buffer size. Unaligned loads (MOVDQU) should be fast on + // x86 processors that support PCLMULQDQ, so we don't align + // the buf pointer here. + + // Read the first (and possibly the only) full 16 bytes. + v0 = _mm_xor_si128(v0, my_load128(buf)); + buf += 16; + size -= 16; + + if (size >= 48) { + v1 = my_load128(buf); + v2 = my_load128(buf + 16); + v3 = my_load128(buf + 32); + buf += 48; + size -= 48; + + while (size >= 64) { + v0 = fold_xor(v0, fold512, buf); + v1 = fold_xor(v1, fold512, buf + 16); + v2 = fold_xor(v2, fold512, buf + 32); + v3 = fold_xor(v3, fold512, buf + 48); + buf += 64; + size -= 64; + } + + v0 = _mm_xor_si128(v1, fold(v0, fold128)); + v0 = _mm_xor_si128(v2, fold(v0, fold128)); + v0 = _mm_xor_si128(v3, fold(v0, fold128)); + } + + while (size >= 16) { + v0 = fold_xor(v0, fold128, buf); + buf += 16; + size -= 16; + } + + if (size > 0) { + // We want the last "size" number of input bytes to + // be at the high bits of v1. First do a full 16-byte + // load and then mask the low bytes to zeros. + v1 = my_load128(buf + size - 16); + v1 = keep_high_bytes(v1, size); + + // Shift high bytes from v0 to the low bytes of v1. + // + // Alternatively we could replace the combination + // keep_high_bytes + shift_right + _mm_or_si128 with + // _mm_shuffle_epi8 + _mm_blendv_epi8 but that would + // require larger tables for the masks. Now there are + // three loads (instead of two) from the mask tables + // but they all are from the same cache line. + v1 = _mm_or_si128(v1, shift_right(v0, size)); + + // Shift high bytes of v0 away, padding the + // low bytes with zeros. + v0 = shift_left(v0, 16 - size); + + v0 = _mm_xor_si128(v1, fold(v0, fold128)); + } + v1 = _mm_srli_si128(v0, 8); + v0 = _mm_clmulepi64_si128(v0, fold128, 0x10); + v0 = _mm_xor_si128(v0, v1); + } + + // Barrett reduction + +#if BUILDING_CRC_CLMUL == 32 + v1 = _mm_clmulepi64_si128(v0, mu_p, 0x10); // v0 * mu + v1 = _mm_clmulepi64_si128(v1, mu_p, 0x00); // v1 * p + v0 = _mm_xor_si128(v0, v1); + return ~(uint32_t)_mm_extract_epi32(v0, 2); +#else + // Because p is 65 bits but one bit doesn't fit into the 64-bit + // half of __m128i, finish the second clmul by shifting v1 left + // by 64 bits and xorring it to the final result. + v1 = _mm_clmulepi64_si128(v0, mu_p, 0x10); // v0 * mu + v2 = _mm_slli_si128(v1, 8); + v1 = _mm_clmulepi64_si128(v1, mu_p, 0x00); // v1 * p + v0 = _mm_xor_si128(v0, v2); + v0 = _mm_xor_si128(v0, v1); #if defined(__i386__) || defined(_M_IX86) return ~(((uint64_t)(uint32_t)_mm_extract_epi32(v0, 3) << 32) | (uint64_t)(uint32_t)_mm_extract_epi32(v0, 2)); #else return ~(uint64_t)_mm_extract_epi64(v0, 1); #endif -} - -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \ - && defined(_M_IX86) -# pragma optimize("", on) #endif - -#endif // BUILDING_CRC64_CLMUL +} // Even though this is an inline function, compile it only when needed. diff --git a/contrib/libs/lzma/liblzma/common/alone_decoder.c b/contrib/libs/lzma/liblzma/common/alone_decoder.c index 78af651578..e2b58e1f37 100644 --- a/contrib/libs/lzma/liblzma/common/alone_decoder.c +++ b/contrib/libs/lzma/liblzma/common/alone_decoder.c @@ -134,8 +134,7 @@ alone_decode(void *coder_ptr, const lzma_allocator *allocator, coder->pos = 0; coder->sequence = SEQ_CODER_INIT; - - // Fall through + FALLTHROUGH; case SEQ_CODER_INIT: { if (coder->memusage > coder->memlimit) diff --git a/contrib/libs/lzma/liblzma/common/auto_decoder.c b/contrib/libs/lzma/liblzma/common/auto_decoder.c index fdd520f905..da49345f90 100644 --- a/contrib/libs/lzma/liblzma/common/auto_decoder.c +++ b/contrib/libs/lzma/liblzma/common/auto_decoder.c @@ -79,7 +79,7 @@ auto_decode(void *coder_ptr, const lzma_allocator *allocator, return LZMA_GET_CHECK; } - // Fall through + FALLTHROUGH; case SEQ_CODE: { const lzma_ret ret = coder->next.code( @@ -91,10 +91,9 @@ auto_decode(void *coder_ptr, const lzma_allocator *allocator, return ret; coder->sequence = SEQ_FINISH; + FALLTHROUGH; } - // Fall through - case SEQ_FINISH: // When LZMA_CONCATENATED was used and we were decoding // a LZMA_Alone file, we need to check that there is no diff --git a/contrib/libs/lzma/liblzma/common/block_decoder.c b/contrib/libs/lzma/liblzma/common/block_decoder.c index 2e369d316b..bbc9f5566c 100644 --- a/contrib/libs/lzma/liblzma/common/block_decoder.c +++ b/contrib/libs/lzma/liblzma/common/block_decoder.c @@ -146,10 +146,9 @@ block_decode(void *coder_ptr, const lzma_allocator *allocator, coder->block->uncompressed_size = coder->uncompressed_size; coder->sequence = SEQ_PADDING; + FALLTHROUGH; } - // Fall through - case SEQ_PADDING: // Compressed Data is padded to a multiple of four bytes. while (coder->compressed_size & 3) { @@ -173,8 +172,7 @@ block_decode(void *coder_ptr, const lzma_allocator *allocator, lzma_check_finish(&coder->check, coder->block->check); coder->sequence = SEQ_CHECK; - - // Fall through + FALLTHROUGH; case SEQ_CHECK: { const size_t check_size = lzma_check_size(coder->block->check); diff --git a/contrib/libs/lzma/liblzma/common/block_encoder.c b/contrib/libs/lzma/liblzma/common/block_encoder.c index ce8c1de694..eb7997a72a 100644 --- a/contrib/libs/lzma/liblzma/common/block_encoder.c +++ b/contrib/libs/lzma/liblzma/common/block_encoder.c @@ -94,10 +94,9 @@ block_encode(void *coder_ptr, const lzma_allocator *allocator, coder->block->uncompressed_size = coder->uncompressed_size; coder->sequence = SEQ_PADDING; + FALLTHROUGH; } - // Fall through - case SEQ_PADDING: // Pad Compressed Data to a multiple of four bytes. We can // use coder->compressed_size for this since we don't need @@ -117,8 +116,7 @@ block_encode(void *coder_ptr, const lzma_allocator *allocator, lzma_check_finish(&coder->check, coder->block->check); coder->sequence = SEQ_CHECK; - - // Fall through + FALLTHROUGH; case SEQ_CHECK: { const size_t check_size = lzma_check_size(coder->block->check); diff --git a/contrib/libs/lzma/liblzma/common/common.c b/contrib/libs/lzma/liblzma/common/common.c index cc0e06a51b..6e031a56c8 100644 --- a/contrib/libs/lzma/liblzma/common/common.c +++ b/contrib/libs/lzma/liblzma/common/common.c @@ -96,6 +96,12 @@ lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size) { + assert(in != NULL || *in_pos == in_size); + assert(out != NULL || *out_pos == out_size); + + assert(*in_pos <= in_size); + assert(*out_pos <= out_size); + const size_t in_avail = in_size - *in_pos; const size_t out_avail = out_size - *out_pos; const size_t copy_size = my_min(in_avail, out_avail); @@ -348,7 +354,7 @@ lzma_code(lzma_stream *strm, lzma_action action) else strm->internal->sequence = ISEQ_END; - // Fall through + FALLTHROUGH; case LZMA_NO_CHECK: case LZMA_UNSUPPORTED_CHECK: diff --git a/contrib/libs/lzma/liblzma/common/file_info.c b/contrib/libs/lzma/liblzma/common/file_info.c index 7c85084a70..4b2eb5d040 100644 --- a/contrib/libs/lzma/liblzma/common/file_info.c +++ b/contrib/libs/lzma/liblzma/common/file_info.c @@ -298,15 +298,13 @@ file_info_decode(void *coder_ptr, const lzma_allocator *allocator, // Start looking for Stream Padding and Stream Footer // at the end of the file. coder->file_target_pos = coder->file_size; - - // Fall through + FALLTHROUGH; case SEQ_PADDING_SEEK: coder->sequence = SEQ_PADDING_DECODE; return_if_error(reverse_seek( coder, in_start, in_pos, in_size)); - - // Fall through + FALLTHROUGH; case SEQ_PADDING_DECODE: { // Copy to coder->temp first. This keeps the code simpler if @@ -356,9 +354,9 @@ file_info_decode(void *coder_ptr, const lzma_allocator *allocator, if (coder->temp_size < LZMA_STREAM_HEADER_SIZE) return_if_error(reverse_seek( coder, in_start, in_pos, in_size)); - } - // Fall through + FALLTHROUGH; + } case SEQ_FOOTER: // Copy the Stream Footer field into coder->temp. @@ -414,7 +412,7 @@ file_info_decode(void *coder_ptr, const lzma_allocator *allocator, return LZMA_SEEK_NEEDED; } - // Fall through + FALLTHROUGH; case SEQ_INDEX_INIT: { // Calculate the amount of memory already used by the earlier @@ -444,10 +442,9 @@ file_info_decode(void *coder_ptr, const lzma_allocator *allocator, coder->index_remaining = coder->footer_flags.backward_size; coder->sequence = SEQ_INDEX_DECODE; + FALLTHROUGH; } - // Fall through - case SEQ_INDEX_DECODE: { // Decode (a part of) the Index. If the whole Index is already // in coder->temp, read it from there. Otherwise read from @@ -574,9 +571,9 @@ file_info_decode(void *coder_ptr, const lzma_allocator *allocator, return_if_error(reverse_seek(coder, in_start, in_pos, in_size)); } - } - // Fall through + FALLTHROUGH; + } case SEQ_HEADER_DECODE: // Copy the Stream Header field into coder->temp. @@ -596,8 +593,7 @@ file_info_decode(void *coder_ptr, const lzma_allocator *allocator, coder->temp + coder->temp_size))); coder->sequence = SEQ_HEADER_COMPARE; - - // Fall through + FALLTHROUGH; case SEQ_HEADER_COMPARE: // Compare Stream Header against Stream Footer. They must diff --git a/contrib/libs/lzma/liblzma/common/index_decoder.c b/contrib/libs/lzma/liblzma/common/index_decoder.c index 4bcb306921..4eab56d942 100644 --- a/contrib/libs/lzma/liblzma/common/index_decoder.c +++ b/contrib/libs/lzma/liblzma/common/index_decoder.c @@ -93,8 +93,7 @@ index_decode(void *coder_ptr, const lzma_allocator *allocator, coder->pos = 0; coder->sequence = SEQ_MEMUSAGE; - - // Fall through + FALLTHROUGH; case SEQ_MEMUSAGE: if (lzma_index_memusage(1, coder->count) > coder->memlimit) { @@ -153,8 +152,7 @@ index_decode(void *coder_ptr, const lzma_allocator *allocator, case SEQ_PADDING_INIT: coder->pos = lzma_index_padding_size(coder->index); coder->sequence = SEQ_PADDING; - - // Fall through + FALLTHROUGH; case SEQ_PADDING: if (coder->pos > 0) { @@ -170,8 +168,7 @@ index_decode(void *coder_ptr, const lzma_allocator *allocator, *in_pos - in_start, coder->crc32); coder->sequence = SEQ_CRC32; - - // Fall through + FALLTHROUGH; case SEQ_CRC32: do { diff --git a/contrib/libs/lzma/liblzma/common/index_encoder.c b/contrib/libs/lzma/liblzma/common/index_encoder.c index ecc299c015..80f1be1e3a 100644 --- a/contrib/libs/lzma/liblzma/common/index_encoder.c +++ b/contrib/libs/lzma/liblzma/common/index_encoder.c @@ -93,8 +93,7 @@ index_encode(void *coder_ptr, } coder->sequence = SEQ_UNPADDED; - - // Fall through + FALLTHROUGH; case SEQ_UNPADDED: case SEQ_UNCOMPRESSED: { @@ -127,8 +126,7 @@ index_encode(void *coder_ptr, *out_pos - out_start, coder->crc32); coder->sequence = SEQ_CRC32; - - // Fall through + FALLTHROUGH; case SEQ_CRC32: // We don't use the main loop, because we don't want diff --git a/contrib/libs/lzma/liblzma/common/index_hash.c b/contrib/libs/lzma/liblzma/common/index_hash.c index caa5967ca4..b7f1b6b58d 100644 --- a/contrib/libs/lzma/liblzma/common/index_hash.c +++ b/contrib/libs/lzma/liblzma/common/index_hash.c @@ -267,9 +267,9 @@ lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in, index_hash->pos = (LZMA_VLI_C(4) - index_size_unpadded( index_hash->records.count, index_hash->records.index_list_size)) & 3; - index_hash->sequence = SEQ_PADDING; - // Fall through + index_hash->sequence = SEQ_PADDING; + FALLTHROUGH; case SEQ_PADDING: if (index_hash->pos > 0) { @@ -302,8 +302,7 @@ lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in, *in_pos - in_start, index_hash->crc32); index_hash->sequence = SEQ_CRC32; - - // Fall through + FALLTHROUGH; case SEQ_CRC32: do { diff --git a/contrib/libs/lzma/liblzma/common/lzip_decoder.c b/contrib/libs/lzma/liblzma/common/lzip_decoder.c index 651a0ae712..4dff2d5889 100644 --- a/contrib/libs/lzma/liblzma/common/lzip_decoder.c +++ b/contrib/libs/lzma/liblzma/common/lzip_decoder.c @@ -150,10 +150,9 @@ lzip_decode(void *coder_ptr, const lzma_allocator *allocator, coder->member_size = sizeof(lzip_id_string); coder->sequence = SEQ_VERSION; + FALLTHROUGH; } - // Fall through - case SEQ_VERSION: if (*in_pos >= in_size) return LZMA_OK; @@ -173,7 +172,7 @@ lzip_decode(void *coder_ptr, const lzma_allocator *allocator, if (coder->tell_any_check) return LZMA_GET_CHECK; - // Fall through + FALLTHROUGH; case SEQ_DICT_SIZE: { if (*in_pos >= in_size) @@ -220,10 +219,9 @@ lzip_decode(void *coder_ptr, const lzma_allocator *allocator, // LZMA_MEMLIMIT_ERROR we need to be able to restart after // the memlimit has been increased. coder->sequence = SEQ_CODER_INIT; + FALLTHROUGH; } - // Fall through - case SEQ_CODER_INIT: { if (coder->memusage > coder->memlimit) return LZMA_MEMLIMIT_ERROR; @@ -243,10 +241,9 @@ lzip_decode(void *coder_ptr, const lzma_allocator *allocator, coder->crc32 = 0; coder->sequence = SEQ_LZMA_STREAM; + FALLTHROUGH; } - // Fall through - case SEQ_LZMA_STREAM: { const size_t in_start = *in_pos; const size_t out_start = *out_pos; @@ -273,10 +270,9 @@ lzip_decode(void *coder_ptr, const lzma_allocator *allocator, return ret; coder->sequence = SEQ_MEMBER_FOOTER; + FALLTHROUGH; } - // Fall through - case SEQ_MEMBER_FOOTER: { // The footer of .lz version 0 lacks the Member size field. // This is the only difference between version 0 and diff --git a/contrib/libs/lzma/liblzma/common/memcmplen.h b/contrib/libs/lzma/liblzma/common/memcmplen.h index 86b5d6f37e..82e9085422 100644 --- a/contrib/libs/lzma/liblzma/common/memcmplen.h +++ b/contrib/libs/lzma/liblzma/common/memcmplen.h @@ -58,8 +58,7 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, #if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ && (((TUKLIB_GNUC_REQ(3, 4) || defined(__clang__)) \ - && (defined(__x86_64__) \ - || defined(__aarch64__))) \ + && SIZE_MAX == UINT64_MAX) \ || (defined(__INTEL_COMPILER) && defined(__x86_64__)) \ || (defined(__INTEL_COMPILER) && defined(_M_X64)) \ || (defined(_MSC_VER) && (defined(_M_X64) \ diff --git a/contrib/libs/lzma/liblzma/common/stream_decoder.c b/contrib/libs/lzma/liblzma/common/stream_decoder.c index 7f42684136..94004b74a1 100644 --- a/contrib/libs/lzma/liblzma/common/stream_decoder.c +++ b/contrib/libs/lzma/liblzma/common/stream_decoder.c @@ -154,9 +154,9 @@ stream_decode(void *coder_ptr, const lzma_allocator *allocator, if (coder->tell_any_check) return LZMA_GET_CHECK; - } - // Fall through + FALLTHROUGH; + } case SEQ_BLOCK_HEADER: { if (*in_pos >= in_size) @@ -187,10 +187,9 @@ stream_decode(void *coder_ptr, const lzma_allocator *allocator, coder->pos = 0; coder->sequence = SEQ_BLOCK_INIT; + FALLTHROUGH; } - // Fall through - case SEQ_BLOCK_INIT: { // Checking memusage and doing the initialization needs // its own sequence point because we need to be able to @@ -252,10 +251,9 @@ stream_decode(void *coder_ptr, const lzma_allocator *allocator, return ret; coder->sequence = SEQ_BLOCK_RUN; + FALLTHROUGH; } - // Fall through - case SEQ_BLOCK_RUN: { const lzma_ret ret = coder->block_decoder.code( coder->block_decoder.coder, allocator, @@ -291,10 +289,9 @@ stream_decode(void *coder_ptr, const lzma_allocator *allocator, return ret; coder->sequence = SEQ_STREAM_FOOTER; + FALLTHROUGH; } - // Fall through - case SEQ_STREAM_FOOTER: { // Copy the Stream Footer to the internal buffer. lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos, @@ -331,10 +328,9 @@ stream_decode(void *coder_ptr, const lzma_allocator *allocator, return LZMA_STREAM_END; coder->sequence = SEQ_STREAM_PADDING; + FALLTHROUGH; } - // Fall through - case SEQ_STREAM_PADDING: assert(coder->concatenated); diff --git a/contrib/libs/lzma/liblzma/common/stream_decoder_mt.c b/contrib/libs/lzma/liblzma/common/stream_decoder_mt.c index 244624a479..271f9b07c4 100644 --- a/contrib/libs/lzma/liblzma/common/stream_decoder_mt.c +++ b/contrib/libs/lzma/liblzma/common/stream_decoder_mt.c @@ -23,15 +23,10 @@ typedef enum { THR_IDLE, /// Decoding is in progress. - /// Main thread may change this to THR_STOP or THR_EXIT. + /// Main thread may change this to THR_IDLE or THR_EXIT. /// The worker thread may change this to THR_IDLE. THR_RUN, - /// The main thread wants the thread to stop whatever it was doing - /// but not exit. Main thread may change this to THR_EXIT. - /// The worker thread may change this to THR_IDLE. - THR_STOP, - /// The main thread wants the thread to exit. THR_EXIT, @@ -346,27 +341,6 @@ worker_enable_partial_update(void *thr_ptr) } -/// Things do to at THR_STOP or when finishing a Block. -/// This is called with thr->mutex locked. -static void -worker_stop(struct worker_thread *thr) -{ - // Update memory usage counters. - thr->coder->mem_in_use -= thr->in_size; - thr->in_size = 0; // thr->in was freed above. - - thr->coder->mem_in_use -= thr->mem_filters; - thr->coder->mem_cached += thr->mem_filters; - - // Put this thread to the stack of free threads. - thr->next = thr->coder->threads_free; - thr->coder->threads_free = thr; - - mythread_cond_signal(&thr->coder->cond); - return; -} - - static MYTHREAD_RET_TYPE worker_decoder(void *thr_ptr) { @@ -397,17 +371,6 @@ next_loop_unlocked: return MYTHREAD_RET_VALUE; } - if (thr->state == THR_STOP) { - thr->state = THR_IDLE; - mythread_mutex_unlock(&thr->mutex); - - mythread_sync(thr->coder->mutex) { - worker_stop(thr); - } - - goto next_loop_lock; - } - assert(thr->state == THR_RUN); // Update progress info for get_progress(). @@ -472,8 +435,7 @@ next_loop_unlocked: } // Either we finished successfully (LZMA_STREAM_END) or an error - // occurred. Both cases are handled almost identically. The error - // case requires updating thr->coder->thread_error. + // occurred. // // The sizes are in the Block Header and the Block decoder // checks that they match, thus we know these: @@ -481,16 +443,30 @@ next_loop_unlocked: assert(ret != LZMA_STREAM_END || thr->out_pos == thr->block_options.uncompressed_size); - // Free the input buffer. Don't update in_size as we need - // it later to update thr->coder->mem_in_use. - lzma_free(thr->in, thr->allocator); - thr->in = NULL; - mythread_sync(thr->mutex) { + // Block decoder ensures this, but do a sanity check anyway + // because thr->in_filled < thr->in_size means that the main + // thread is still writing to thr->in. + if (ret == LZMA_STREAM_END && thr->in_filled != thr->in_size) { + assert(0); + ret = LZMA_PROG_ERROR; + } + if (thr->state != THR_EXIT) thr->state = THR_IDLE; } + // Free the input buffer. Don't update in_size as we need + // it later to update thr->coder->mem_in_use. + // + // This step is skipped if an error occurred because the main thread + // might still be writing to thr->in. The memory will be freed after + // threads_end() sets thr->state = THR_EXIT. + if (ret == LZMA_STREAM_END) { + lzma_free(thr->in, thr->allocator); + thr->in = NULL; + } + mythread_sync(thr->coder->mutex) { // Move our progress info to the main thread. thr->coder->progress_in += thr->in_pos; @@ -510,7 +486,20 @@ next_loop_unlocked: && thr->coder->thread_error == LZMA_OK) thr->coder->thread_error = ret; - worker_stop(thr); + // Return the worker thread to the stack of available + // threads only if no errors occurred. + if (ret == LZMA_STREAM_END) { + // Update memory usage counters. + thr->coder->mem_in_use -= thr->in_size; + thr->coder->mem_in_use -= thr->mem_filters; + thr->coder->mem_cached += thr->mem_filters; + + // Put this thread to the stack of free threads. + thr->next = thr->coder->threads_free; + thr->coder->threads_free = thr; + } + + mythread_cond_signal(&thr->coder->cond); } goto next_loop_lock; @@ -544,17 +533,22 @@ threads_end(struct lzma_stream_coder *coder, const lzma_allocator *allocator) } +/// Tell worker threads to stop without doing any cleaning up. +/// The clean up will be done when threads_exit() is called; +/// it's not possible to reuse the threads after threads_stop(). +/// +/// This is called before returning an unrecoverable error code +/// to the application. It would be waste of processor time +/// to keep the threads running in such a situation. static void threads_stop(struct lzma_stream_coder *coder) { for (uint32_t i = 0; i < coder->threads_initialized; ++i) { + // The threads that are in the THR_RUN state will stop + // when they check the state the next time. There's no + // need to signal coder->threads[i].cond. mythread_sync(coder->threads[i].mutex) { - // The state must be changed conditionally because - // THR_IDLE -> THR_STOP is not a valid state change. - if (coder->threads[i].state != THR_IDLE) { - coder->threads[i].state = THR_STOP; - mythread_cond_signal(&coder->threads[i].cond); - } + coder->threads[i].state = THR_IDLE; } } @@ -1077,9 +1071,9 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, if (coder->tell_any_check) return LZMA_GET_CHECK; - } - // Fall through + FALLTHROUGH; + } case SEQ_BLOCK_HEADER: { const size_t in_old = *in_pos; @@ -1214,10 +1208,9 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, } coder->sequence = SEQ_BLOCK_INIT; + FALLTHROUGH; } - // Fall through - case SEQ_BLOCK_INIT: { // Check if decoding is possible at all with the current // memlimit_stop which we must never exceed. @@ -1303,10 +1296,9 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, } coder->sequence = SEQ_BLOCK_THR_INIT; + FALLTHROUGH; } - // Fall through - case SEQ_BLOCK_THR_INIT: { // We need to wait for a multiple conditions to become true // until we can initialize the Block decoder and let a worker @@ -1508,10 +1500,9 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, } coder->sequence = SEQ_BLOCK_THR_RUN; + FALLTHROUGH; } - // Fall through - case SEQ_BLOCK_THR_RUN: { if (action == LZMA_FINISH && coder->fail_fast) { // We know that we won't get more input and that @@ -1549,10 +1540,17 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, // Read output from the output queue. Just like in // SEQ_BLOCK_HEADER, we wait to fill the output buffer // only if waiting_allowed was set to true in the beginning - // of this function (see the comment there). + // of this function (see the comment there) and there is + // no input available. In SEQ_BLOCK_HEADER, there is never + // input available when read_output_and_wait() is called, + // but here there can be when LZMA_FINISH is used, thus we + // need to check if *in_pos == in_size. Otherwise we would + // wait here instead of using the available input to start + // a new thread. return_if_error(read_output_and_wait(coder, allocator, out, out_pos, out_size, - NULL, waiting_allowed, + NULL, + waiting_allowed && *in_pos == in_size, &wait_abs, &has_blocked)); if (coder->pending_error != LZMA_OK) { @@ -1561,6 +1559,10 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, } // Return if the input didn't contain the whole Block. + // + // NOTE: When we updated coder->thr->in_filled a few lines + // above, the worker thread might by now have finished its + // work and returned itself back to the stack of free threads. if (coder->thr->in_filled < coder->thr->in_size) { assert(*in_pos == in_size); return LZMA_OK; @@ -1613,10 +1615,9 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, coder->mem_direct_mode = coder->mem_next_filters; coder->sequence = SEQ_BLOCK_DIRECT_RUN; + FALLTHROUGH; } - // Fall through - case SEQ_BLOCK_DIRECT_RUN: { const size_t in_old = *in_pos; const size_t out_old = *out_pos; @@ -1652,8 +1653,7 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, return LZMA_OK; coder->sequence = SEQ_INDEX_DECODE; - - // Fall through + FALLTHROUGH; case SEQ_INDEX_DECODE: { // If we don't have any input, don't call @@ -1672,10 +1672,9 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, return ret; coder->sequence = SEQ_STREAM_FOOTER; + FALLTHROUGH; } - // Fall through - case SEQ_STREAM_FOOTER: { // Copy the Stream Footer to the internal buffer. const size_t in_old = *in_pos; @@ -1714,10 +1713,9 @@ stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator, return LZMA_STREAM_END; coder->sequence = SEQ_STREAM_PADDING; + FALLTHROUGH; } - // Fall through - case SEQ_STREAM_PADDING: assert(coder->concatenated); @@ -1948,7 +1946,7 @@ stream_decoder_mt_init(lzma_next_coder *next, const lzma_allocator *allocator, // accounting from scratch, too. Changes in filter and block sizes may // affect number of threads. // - // FIXME? Reusing should be easy but unlike the single-threaded + // Reusing threads doesn't seem worth it. Unlike the single-threaded // decoder, with some types of input file combinations reusing // could leave quite a lot of memory allocated but unused (first // file could allocate a lot, the next files could use fewer diff --git a/contrib/libs/lzma/liblzma/common/stream_encoder_mt.c b/contrib/libs/lzma/liblzma/common/stream_encoder_mt.c index f0fef15233..fd0eb98df6 100644 --- a/contrib/libs/lzma/liblzma/common/stream_encoder_mt.c +++ b/contrib/libs/lzma/liblzma/common/stream_encoder_mt.c @@ -731,8 +731,7 @@ stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator, coder->header_pos = 0; coder->sequence = SEQ_BLOCK; - - // Fall through + FALLTHROUGH; case SEQ_BLOCK: { // Initialized to silence warnings. @@ -851,9 +850,9 @@ stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator, // to be ready to be copied out. coder->progress_out += lzma_index_size(coder->index) + LZMA_STREAM_HEADER_SIZE; - } - // Fall through + FALLTHROUGH; + } case SEQ_INDEX: { // Call the Index encoder. It doesn't take any input, so @@ -873,10 +872,9 @@ stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator, return LZMA_PROG_ERROR; coder->sequence = SEQ_STREAM_FOOTER; + FALLTHROUGH; } - // Fall through - case SEQ_STREAM_FOOTER: lzma_bufcpy(coder->header, &coder->header_pos, sizeof(coder->header), diff --git a/contrib/libs/lzma/liblzma/common/string_conversion.c b/contrib/libs/lzma/liblzma/common/string_conversion.c index 3a08486a1f..015acf2258 100644 --- a/contrib/libs/lzma/liblzma/common/string_conversion.c +++ b/contrib/libs/lzma/liblzma/common/string_conversion.c @@ -12,6 +12,11 @@ #include "filter_common.h" +// liblzma itself doesn't use gettext to translate messages. +// Mark the strings still so that xz can translate them. +#define N_(msgid) msgid + + ///////////////////// // String building // ///////////////////// @@ -319,7 +324,7 @@ parse_lzma12_preset(const char **const str, const char *str_end, assert(*str < str_end); if (!(**str >= '0' && **str <= '9')) - return "Unsupported preset"; + return N_("Unsupported preset"); *preset = (uint32_t)(**str - '0'); @@ -331,7 +336,7 @@ parse_lzma12_preset(const char **const str, const char *str_end, break; default: - return "Unsupported preset flag"; + return N_("Unsupported flag in the preset"); } } @@ -350,7 +355,7 @@ set_lzma12_preset(const char **const str, const char *str_end, lzma_options_lzma *opts = filter_options; if (lzma_lzma_preset(opts, preset)) - return "Unsupported preset"; + return N_("Unsupported preset"); return NULL; } @@ -442,7 +447,7 @@ parse_lzma12(const char **const str, const char *str_end, void *filter_options) return errmsg; if (opts->lc + opts->lp > LZMA_LCLP_MAX) - return "The sum of lc and lp must not exceed 4"; + return N_("The sum of lc and lp must not exceed 4"); return NULL; } @@ -578,21 +583,21 @@ parse_options(const char **const str, const char *str_end, // Fail if the '=' wasn't found or the option name is missing // (the first char is '='). if (equals_sign == NULL || **str == '=') - return "Options must be 'name=value' pairs separated " - "with commas"; + return N_("Options must be 'name=value' pairs " + "separated with commas"); // Reject a too long option name so that the memcmp() // in the loop below won't read past the end of the // string in optmap[i].name. const size_t name_len = (size_t)(equals_sign - *str); if (name_len > NAME_LEN_MAX) - return "Unknown option name"; + return N_("Unknown option name"); // Find the option name from optmap[]. size_t i = 0; while (true) { if (i == optmap_size) - return "Unknown option name"; + return N_("Unknown option name"); if (memcmp(*str, optmap[i].name, name_len) == 0 && optmap[i].name[name_len] == '\0') @@ -609,7 +614,7 @@ parse_options(const char **const str, const char *str_end, // string so check it here. const size_t value_len = (size_t)(name_eq_value_end - *str); if (value_len == 0) - return "Option value cannot be empty"; + return N_("Option value cannot be empty"); // LZMA1/2 preset has its own parsing function. if (optmap[i].type == OPTMAP_TYPE_LZMA_PRESET) { @@ -630,14 +635,14 @@ parse_options(const char **const str, const char *str_end, // in the loop below won't read past the end of the // string in optmap[i].u.map[j].name. if (value_len > NAME_LEN_MAX) - return "Invalid option value"; + return N_("Invalid option value"); const name_value_map *map = optmap[i].u.map; size_t j = 0; while (true) { // The array is terminated with an empty name. if (map[j].name[0] == '\0') - return "Invalid option value"; + return N_("Invalid option value"); if (memcmp(*str, map[j].name, value_len) == 0 && map[j].name[value_len] @@ -651,7 +656,8 @@ parse_options(const char **const str, const char *str_end, } else if (**str < '0' || **str > '9') { // Note that "max" isn't supported while it is // supported in xz. It's not useful here. - return "Value is not a non-negative decimal integer"; + return N_("Value is not a non-negative " + "decimal integer"); } else { // strtoul() has locale-specific behavior so it cannot // be relied on to get reproducible results since we @@ -665,13 +671,13 @@ parse_options(const char **const str, const char *str_end, v = 0; do { if (v > UINT32_MAX / 10) - return "Value out of range"; + return N_("Value out of range"); v *= 10; const uint32_t add = (uint32_t)(*p - '0'); if (UINT32_MAX - add < v) - return "Value out of range"; + return N_("Value out of range"); v += add; ++p; @@ -696,8 +702,9 @@ parse_options(const char **const str, const char *str_end, if ((optmap[i].flags & OPTMAP_USE_BYTE_SUFFIX) == 0) { *str = multiplier_start; - return "This option does not support " - "any integer suffixes"; + return N_("This option does not " + "support any multiplier " + "suffixes"); } uint32_t shift; @@ -720,8 +727,13 @@ parse_options(const char **const str, const char *str_end, default: *str = multiplier_start; - return "Invalid multiplier suffix " - "(KiB, MiB, or GiB)"; + + // TRANSLATORS: Don't translate the + // suffixes "KiB", "MiB", or "GiB" + // because a user can only specify + // untranslated suffixes. + return N_("Invalid multiplier suffix " + "(KiB, MiB, or GiB)"); } ++p; @@ -740,19 +752,19 @@ parse_options(const char **const str, const char *str_end, // Now we must have no chars remaining. if (p < name_eq_value_end) { *str = multiplier_start; - return "Invalid multiplier suffix " - "(KiB, MiB, or GiB)"; + return N_("Invalid multiplier suffix " + "(KiB, MiB, or GiB)"); } if (v > (UINT32_MAX >> shift)) - return "Value out of range"; + return N_("Value out of range"); v <<= shift; } if (v < optmap[i].u.range.min || v > optmap[i].u.range.max) - return "Value out of range"; + return N_("Value out of range"); } // Set the value in filter_options. Enums are handled @@ -814,15 +826,15 @@ parse_filter(const char **const str, const char *str_end, lzma_filter *filter, // string in filter_name_map[i].name. const size_t name_len = (size_t)(name_end - *str); if (name_len > NAME_LEN_MAX) - return "Unknown filter name"; + return N_("Unknown filter name"); for (size_t i = 0; i < ARRAY_SIZE(filter_name_map); ++i) { if (memcmp(*str, filter_name_map[i].name, name_len) == 0 && filter_name_map[i].name[name_len] == '\0') { if (only_xz && filter_name_map[i].id >= LZMA_FILTER_RESERVED_START) - return "This filter cannot be used in " - "the .xz format"; + return N_("This filter cannot be used in " + "the .xz format"); // Allocate the filter-specific options and // initialize the memory with zeros. @@ -830,7 +842,7 @@ parse_filter(const char **const str, const char *str_end, lzma_filter *filter, filter_name_map[i].opts_size, allocator); if (options == NULL) - return "Memory allocation failed"; + return N_("Memory allocation failed"); // Filter name was found so the input string is good // at least this far. @@ -850,7 +862,7 @@ parse_filter(const char **const str, const char *str_end, lzma_filter *filter, } } - return "Unknown filter name"; + return N_("Unknown filter name"); } @@ -869,8 +881,8 @@ str_to_filters(const char **const str, lzma_filter *filters, uint32_t flags, ++*str; if (**str == '\0') - return "Empty string is not allowed, " - "try \"6\" if a default value is needed"; + return N_("Empty string is not allowed, " + "try '6' if a default value is needed"); // Detect the type of the string. // @@ -893,7 +905,7 @@ str_to_filters(const char **const str, lzma_filter *filters, uint32_t flags, // there are no chars other than spaces. for (size_t i = 1; str_end[i] != '\0'; ++i) if (str_end[i] != ' ') - return "Unsupported preset"; + return N_("Unsupported preset"); } else { // There are no trailing spaces. Use the whole string. str_end = *str + str_len; @@ -906,11 +918,11 @@ str_to_filters(const char **const str, lzma_filter *filters, uint32_t flags, lzma_options_lzma *opts = lzma_alloc(sizeof(*opts), allocator); if (opts == NULL) - return "Memory allocation failed"; + return N_("Memory allocation failed"); if (lzma_lzma_preset(opts, preset)) { lzma_free(opts, allocator); - return "Unsupported preset"; + return N_("Unsupported preset"); } filters[0].id = LZMA_FILTER_LZMA2; @@ -934,7 +946,7 @@ str_to_filters(const char **const str, lzma_filter *filters, uint32_t flags, size_t i = 0; do { if (i == LZMA_FILTERS_MAX) { - errmsg = "The maximum number of filters is four"; + errmsg = N_("The maximum number of filters is four"); goto error; } @@ -956,7 +968,7 @@ str_to_filters(const char **const str, lzma_filter *filters, uint32_t flags, // Inputs that have "--" at the end or "-- " in the middle // will result in an empty filter name. if (filter_end == *str) { - errmsg = "Filter name is missing"; + errmsg = N_("Filter name is missing"); goto error; } @@ -983,8 +995,8 @@ str_to_filters(const char **const str, lzma_filter *filters, uint32_t flags, const lzma_ret ret = lzma_validate_chain(temp_filters, &dummy); assert(ret == LZMA_OK || ret == LZMA_OPTIONS_ERROR); if (ret != LZMA_OK) { - errmsg = "Invalid filter chain " - "('lzma2' missing at the end?)"; + errmsg = N_("Invalid filter chain " + "('lzma2' missing at the end?)"); goto error; } } @@ -1012,17 +1024,26 @@ lzma_str_to_filters(const char *str, int *error_pos, lzma_filter *filters, if (error_pos != NULL) *error_pos = 0; - if (str == NULL || filters == NULL) + if (str == NULL || filters == NULL) { + // Don't translate this because it's only shown in case of + // a programming error. return "Unexpected NULL pointer argument(s) " "to lzma_str_to_filters()"; + } // Validate the flags. const uint32_t supported_flags = LZMA_STR_ALL_FILTERS | LZMA_STR_NO_VALIDATION; - if (flags & ~supported_flags) + if (flags & ~supported_flags) { + // This message is possible only if the caller uses flags + // that are only supported in a newer liblzma version (or + // the flags are simply buggy). Don't translate this at least + // when liblzma itself doesn't use gettext; xz and liblzma + // are usually upgraded at the same time. return "Unsupported flags to lzma_str_to_filters()"; + } const char *used = str; const char *errmsg = str_to_filters(&used, filters, flags, allocator); diff --git a/contrib/libs/lzma/liblzma/liblzma_linux.map b/contrib/libs/lzma/liblzma/liblzma_linux.map index 7e4b25e176..50f1571de2 100644 --- a/contrib/libs/lzma/liblzma/liblzma_linux.map +++ b/contrib/libs/lzma/liblzma/liblzma_linux.map @@ -141,3 +141,13 @@ XZ_5.6.0 { global: lzma_mt_block_size; } XZ_5.4; + +XZ_5.8 { +global: + lzma_bcj_arm64_encode; + lzma_bcj_arm64_decode; + lzma_bcj_riscv_encode; + lzma_bcj_riscv_decode; + lzma_bcj_x86_encode; + lzma_bcj_x86_decode; +} XZ_5.6.0; diff --git a/contrib/libs/lzma/liblzma/lz/lz_decoder.c b/contrib/libs/lzma/liblzma/lz/lz_decoder.c index 92913f225a..1cb120ab3b 100644 --- a/contrib/libs/lzma/liblzma/lz/lz_decoder.c +++ b/contrib/libs/lzma/liblzma/lz/lz_decoder.c @@ -53,9 +53,9 @@ typedef struct { static void lz_decoder_reset(lzma_coder *coder) { - coder->dict.pos = 2 * LZ_DICT_REPEAT_MAX; + coder->dict.pos = LZ_DICT_INIT_POS; coder->dict.full = 0; - coder->dict.buf[2 * LZ_DICT_REPEAT_MAX - 1] = '\0'; + coder->dict.buf[LZ_DICT_INIT_POS - 1] = '\0'; coder->dict.has_wrapped = false; coder->dict.need_reset = false; return; @@ -261,10 +261,12 @@ lzma_lz_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, // recommended to give aligned buffers to liblzma. // // Reserve 2 * LZ_DICT_REPEAT_MAX bytes of extra space which is - // needed for alloc_size. + // needed for alloc_size. Reserve also LZ_DICT_EXTRA bytes of extra + // space which is *not* counted in alloc_size or coder->dict.size. // // Avoid integer overflow. - if (lz_options.dict_size > SIZE_MAX - 15 - 2 * LZ_DICT_REPEAT_MAX) + if (lz_options.dict_size > SIZE_MAX - 15 - 2 * LZ_DICT_REPEAT_MAX + - LZ_DICT_EXTRA) return LZMA_MEM_ERROR; lz_options.dict_size = (lz_options.dict_size + 15) & ~((size_t)(15)); @@ -277,7 +279,13 @@ lzma_lz_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, // Allocate and initialize the dictionary. if (coder->dict.size != alloc_size) { lzma_free(coder->dict.buf, allocator); - coder->dict.buf = lzma_alloc(alloc_size, allocator); + + // The LZ_DICT_EXTRA bytes at the end of the buffer aren't + // included in alloc_size. These extra bytes allow + // dict_repeat() to read and write more data than requested. + // Otherwise this extra space is ignored. + coder->dict.buf = lzma_alloc(alloc_size + LZ_DICT_EXTRA, + allocator); if (coder->dict.buf == NULL) return LZMA_MEM_ERROR; @@ -320,5 +328,6 @@ lzma_lz_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, extern uint64_t lzma_lz_decoder_memusage(size_t dictionary_size) { - return sizeof(lzma_coder) + (uint64_t)(dictionary_size); + return sizeof(lzma_coder) + (uint64_t)(dictionary_size) + + 2 * LZ_DICT_REPEAT_MAX + LZ_DICT_EXTRA; } diff --git a/contrib/libs/lzma/liblzma/lz/lz_decoder.h b/contrib/libs/lzma/liblzma/lz/lz_decoder.h index cb61b6e24c..2698e0167f 100644 --- a/contrib/libs/lzma/liblzma/lz/lz_decoder.h +++ b/contrib/libs/lzma/liblzma/lz/lz_decoder.h @@ -15,10 +15,40 @@ #include "common.h" +#ifdef HAVE_IMMINTRIN_H +# include <immintrin.h> +#endif + + +// dict_repeat() implementation variant: +// 0 = Byte-by-byte copying only. +// 1 = Use memcpy() for non-overlapping copies. +// 2 = Use x86 SSE2 for non-overlapping copies. +#ifndef LZMA_LZ_DECODER_CONFIG +# if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ + && defined(HAVE_IMMINTRIN_H) \ + && (defined(__SSE2__) || defined(_M_X64) \ + || (defined(_M_IX86_FP) && _M_IX86_FP >= 2)) +# define LZMA_LZ_DECODER_CONFIG 2 +# else +# define LZMA_LZ_DECODER_CONFIG 1 +# endif +#endif -/// Maximum length of a match rounded up to a nice power of 2 which is -/// a good size for aligned memcpy(). The allocated dictionary buffer will -/// be 2 * LZ_DICT_REPEAT_MAX bytes larger than the actual dictionary size: +/// Byte-by-byte and memcpy() copy exactly the amount needed. Other methods +/// can copy up to LZ_DICT_EXTRA bytes more than requested, and this amount +/// of extra space is needed at the end of the allocated dictionary buffer. +/// +/// NOTE: If this is increased, update LZMA_DICT_REPEAT_MAX too. +#if LZMA_LZ_DECODER_CONFIG >= 2 +# define LZ_DICT_EXTRA 32 +#else +# define LZ_DICT_EXTRA 0 +#endif + +/// Maximum number of bytes that dict_repeat() may copy. The allocated +/// dictionary buffer will be 2 * LZ_DICT_REPEAT_MAX + LZMA_DICT_EXTRA bytes +/// larger than the actual dictionary size: /// /// (1) Every time the decoder reaches the end of the dictionary buffer, /// the last LZ_DICT_REPEAT_MAX bytes will be copied to the beginning. @@ -27,14 +57,26 @@ /// /// (2) The other LZ_DICT_REPEAT_MAX bytes is kept as a buffer between /// the oldest byte still in the dictionary and the current write -/// position. This way dict_repeat(dict, dict->size - 1, &len) +/// position. This way dict_repeat() with the maximum valid distance /// won't need memmove() as the copying cannot overlap. /// +/// (3) LZ_DICT_EXTRA bytes are required at the end of the dictionary buffer +/// so that extra copying done by dict_repeat() won't write or read past +/// the end of the allocated buffer. This amount is *not* counted as part +/// of lzma_dict.size. +/// /// Note that memcpy() still cannot be used if distance < len. /// -/// LZMA's longest match length is 273 so pick a multiple of 16 above that. +/// LZMA's longest match length is 273 bytes. The LZMA decoder looks at +/// the lowest four bits of the dictionary position, thus 273 must be +/// rounded up to the next multiple of 16 (288). In addition, optimized +/// dict_repeat() copies 32 bytes at a time, thus this must also be +/// a multiple of 32. #define LZ_DICT_REPEAT_MAX 288 +/// Initial position in lzma_dict.buf when the dictionary is empty. +#define LZ_DICT_INIT_POS (2 * LZ_DICT_REPEAT_MAX) + typedef struct { /// Pointer to the dictionary buffer. @@ -158,7 +200,8 @@ dict_is_distance_valid(const lzma_dict *const dict, const size_t distance) /// Repeat *len bytes at distance. static inline bool -dict_repeat(lzma_dict *dict, uint32_t distance, uint32_t *len) +dict_repeat(lzma_dict *restrict dict, + uint32_t distance, uint32_t *restrict len) { // Don't write past the end of the dictionary. const size_t dict_avail = dict->limit - dict->pos; @@ -169,9 +212,17 @@ dict_repeat(lzma_dict *dict, uint32_t distance, uint32_t *len) if (distance >= dict->pos) back += dict->size - LZ_DICT_REPEAT_MAX; - // Repeat a block of data from the history. Because memcpy() is faster - // than copying byte by byte in a loop, the copying process gets split - // into two cases. +#if LZMA_LZ_DECODER_CONFIG == 0 + // Minimal byte-by-byte method. This might be the least bad choice + // if memcpy() isn't fast and there's no replacement for it below. + while (left-- > 0) { + dict->buf[dict->pos++] = dict->buf[back++]; + } + +#else + // Because memcpy() or a similar method can be faster than copying + // byte by byte in a loop, the copying process is split into + // two cases. if (distance < left) { // Source and target areas overlap, thus we can't use // memcpy() nor even memmove() safely. @@ -179,32 +230,56 @@ dict_repeat(lzma_dict *dict, uint32_t distance, uint32_t *len) dict->buf[dict->pos++] = dict->buf[back++]; } while (--left > 0); } else { +# if LZMA_LZ_DECODER_CONFIG == 1 memcpy(dict->buf + dict->pos, dict->buf + back, left); dict->pos += left; + +# elif LZMA_LZ_DECODER_CONFIG == 2 + // This can copy up to 32 bytes more than required. + // (If left == 0, we still copy 32 bytes.) + size_t pos = dict->pos; + dict->pos += left; + do { + const __m128i x0 = _mm_loadu_si128( + (__m128i *)(dict->buf + back)); + const __m128i x1 = _mm_loadu_si128( + (__m128i *)(dict->buf + back + 16)); + back += 32; + _mm_storeu_si128( + (__m128i *)(dict->buf + pos), x0); + _mm_storeu_si128( + (__m128i *)(dict->buf + pos + 16), x1); + pos += 32; + } while (pos < dict->pos); + +# else +# error "Invalid LZMA_LZ_DECODER_CONFIG value" +# endif } +#endif // Update how full the dictionary is. if (!dict->has_wrapped) - dict->full = dict->pos - 2 * LZ_DICT_REPEAT_MAX; + dict->full = dict->pos - LZ_DICT_INIT_POS; return *len != 0; } static inline void -dict_put(lzma_dict *dict, uint8_t byte) +dict_put(lzma_dict *restrict dict, uint8_t byte) { dict->buf[dict->pos++] = byte; if (!dict->has_wrapped) - dict->full = dict->pos - 2 * LZ_DICT_REPEAT_MAX; + dict->full = dict->pos - LZ_DICT_INIT_POS; } /// Puts one byte into the dictionary. Returns true if the dictionary was /// already full and the byte couldn't be added. static inline bool -dict_put_safe(lzma_dict *dict, uint8_t byte) +dict_put_safe(lzma_dict *restrict dict, uint8_t byte) { if (unlikely(dict->pos == dict->limit)) return true; @@ -234,7 +309,7 @@ dict_write(lzma_dict *restrict dict, const uint8_t *restrict in, dict->buf, &dict->pos, dict->limit); if (!dict->has_wrapped) - dict->full = dict->pos - 2 * LZ_DICT_REPEAT_MAX; + dict->full = dict->pos - LZ_DICT_INIT_POS; return; } diff --git a/contrib/libs/lzma/liblzma/lz/lz_encoder.c b/contrib/libs/lzma/liblzma/lz/lz_encoder.c index 9e34ab4cd7..d2c179d9ec 100644 --- a/contrib/libs/lzma/liblzma/lz/lz_encoder.c +++ b/contrib/libs/lzma/liblzma/lz/lz_encoder.c @@ -15,7 +15,7 @@ // See lz_encoder_hash.h. This is a bit hackish but avoids making // endianness a conditional in makefiles. -#if defined(WORDS_BIGENDIAN) && !defined(HAVE_SMALL) +#ifdef LZMA_LZ_HASH_TABLE_IS_NEEDED # error #include "lz_encoder_hash_table.h" #endif diff --git a/contrib/libs/lzma/liblzma/lz/lz_encoder_hash.h b/contrib/libs/lzma/liblzma/lz/lz_encoder_hash.h index 8ace82b04c..6d4bf837fd 100644 --- a/contrib/libs/lzma/liblzma/lz/lz_encoder_hash.h +++ b/contrib/libs/lzma/liblzma/lz/lz_encoder_hash.h @@ -5,23 +5,37 @@ /// \file lz_encoder_hash.h /// \brief Hash macros for match finders // -// Author: Igor Pavlov +// Authors: Igor Pavlov +// Lasse Collin // /////////////////////////////////////////////////////////////////////////////// #ifndef LZMA_LZ_ENCODER_HASH_H #define LZMA_LZ_ENCODER_HASH_H -#if defined(WORDS_BIGENDIAN) && !defined(HAVE_SMALL) - // This is to make liblzma produce the same output on big endian - // systems that it does on little endian systems. lz_encoder.c - // takes care of including the actual table. +// We need to know if CRC32_GENERIC is defined and we may need the declaration +// of lzma_crc32_table[][]. +#include "crc_common.h" + +// If HAVE_SMALL is defined, then lzma_crc32_table[][] exists and +// it's little endian even on big endian systems. +// +// If HAVE_SMALL isn't defined, lzma_crc32_table[][] is in native endian +// but we want a little endian one so that the compressed output won't +// depend on the processor endianness. Big endian systems are less common +// so those get the burden of an extra 1 KiB table. +// +// If HAVE_SMALL isn't defined and CRC32_GENERIC isn't defined either, +// then lzma_crc32_table[][] doesn't exist. +#if defined(HAVE_SMALL) \ + || (defined(CRC32_GENERIC) && !defined(WORDS_BIGENDIAN)) +# define hash_table lzma_crc32_table[0] +#else + // lz_encoder.c takes care of including the actual table. lzma_attr_visibility_hidden extern const uint32_t lzma_lz_hash_table[256]; # define hash_table lzma_lz_hash_table -#else -# include "check.h" -# define hash_table lzma_crc32_table[0] +# define LZMA_LZ_HASH_TABLE_IS_NEEDED 1 #endif #define HASH_2_SIZE (UINT32_C(1) << 10) diff --git a/contrib/libs/lzma/liblzma/lzma/lzma2_encoder.c b/contrib/libs/lzma/liblzma/lzma/lzma2_encoder.c index e20b75b300..71cfd9b411 100644 --- a/contrib/libs/lzma/liblzma/lzma/lzma2_encoder.c +++ b/contrib/libs/lzma/liblzma/lzma/lzma2_encoder.c @@ -159,8 +159,7 @@ lzma2_encode(void *coder_ptr, lzma_mf *restrict mf, coder->uncompressed_size = 0; coder->compressed_size = 0; coder->sequence = SEQ_LZMA_ENCODE; - - // Fall through + FALLTHROUGH; case SEQ_LZMA_ENCODE: { // Calculate how much more uncompressed data this chunk @@ -219,10 +218,9 @@ lzma2_encode(void *coder_ptr, lzma_mf *restrict mf, lzma2_header_lzma(coder); coder->sequence = SEQ_LZMA_COPY; + FALLTHROUGH; } - // Fall through - case SEQ_LZMA_COPY: // Copy the compressed chunk along its headers to the // output buffer. @@ -244,8 +242,7 @@ lzma2_encode(void *coder_ptr, lzma_mf *restrict mf, return LZMA_OK; coder->sequence = SEQ_UNCOMPRESSED_COPY; - - // Fall through + FALLTHROUGH; case SEQ_UNCOMPRESSED_COPY: // Copy the uncompressed data as is from the dictionary diff --git a/contrib/libs/lzma/liblzma/simple/arm.c b/contrib/libs/lzma/liblzma/simple/arm.c index 58acb2d11a..f9d9c08b3c 100644 --- a/contrib/libs/lzma/liblzma/simple/arm.c +++ b/contrib/libs/lzma/liblzma/simple/arm.c @@ -18,8 +18,10 @@ arm_code(void *simple lzma_attribute((__unused__)), uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { + size &= ~(size_t)3; + size_t i; - for (i = 0; i + 4 <= size; i += 4) { + for (i = 0; i < size; i += 4) { if (buffer[i + 3] == 0xEB) { uint32_t src = ((uint32_t)(buffer[i + 2]) << 16) | ((uint32_t)(buffer[i + 1]) << 8) diff --git a/contrib/libs/lzma/liblzma/simple/arm64.c b/contrib/libs/lzma/liblzma/simple/arm64.c index 16c2f565f7..2ec10d937f 100644 --- a/contrib/libs/lzma/liblzma/simple/arm64.c +++ b/contrib/libs/lzma/liblzma/simple/arm64.c @@ -28,6 +28,8 @@ arm64_code(void *simple lzma_attribute((__unused__)), uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { + size &= ~(size_t)3; + size_t i; // Clang 14.0.6 on x86-64 makes this four times bigger and 40 % slower @@ -37,7 +39,7 @@ arm64_code(void *simple lzma_attribute((__unused__)), #ifdef __clang__ # pragma clang loop vectorize(disable) #endif - for (i = 0; i + 4 <= size; i += 4) { + for (i = 0; i < size; i += 4) { uint32_t pc = (uint32_t)(now_pos + i); uint32_t instr = read32le(buffer + i); @@ -122,6 +124,15 @@ lzma_simple_arm64_encoder_init(lzma_next_coder *next, { return arm64_coder_init(next, allocator, filters, true); } + + +extern LZMA_API(size_t) +lzma_bcj_arm64_encode(uint32_t start_offset, uint8_t *buf, size_t size) +{ + // start_offset must be a multiple of four. + start_offset &= ~UINT32_C(3); + return arm64_code(NULL, start_offset, true, buf, size); +} #endif @@ -133,4 +144,13 @@ lzma_simple_arm64_decoder_init(lzma_next_coder *next, { return arm64_coder_init(next, allocator, filters, false); } + + +extern LZMA_API(size_t) +lzma_bcj_arm64_decode(uint32_t start_offset, uint8_t *buf, size_t size) +{ + // start_offset must be a multiple of four. + start_offset &= ~UINT32_C(3); + return arm64_code(NULL, start_offset, false, buf, size); +} #endif diff --git a/contrib/libs/lzma/liblzma/simple/armthumb.c b/contrib/libs/lzma/liblzma/simple/armthumb.c index f1eeca9b80..368b51c7fe 100644 --- a/contrib/libs/lzma/liblzma/simple/armthumb.c +++ b/contrib/libs/lzma/liblzma/simple/armthumb.c @@ -18,8 +18,13 @@ armthumb_code(void *simple lzma_attribute((__unused__)), uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { + if (size < 4) + return 0; + + size -= 4; + size_t i; - for (i = 0; i + 4 <= size; i += 2) { + for (i = 0; i <= size; i += 2) { if ((buffer[i + 1] & 0xF8) == 0xF0 && (buffer[i + 3] & 0xF8) == 0xF8) { uint32_t src = (((uint32_t)(buffer[i + 1]) & 7) << 19) diff --git a/contrib/libs/lzma/liblzma/simple/ia64.c b/contrib/libs/lzma/liblzma/simple/ia64.c index 5025014099..2a4aaebb47 100644 --- a/contrib/libs/lzma/liblzma/simple/ia64.c +++ b/contrib/libs/lzma/liblzma/simple/ia64.c @@ -25,8 +25,10 @@ ia64_code(void *simple lzma_attribute((__unused__)), 4, 4, 0, 0, 4, 4, 0, 0 }; + size &= ~(size_t)15; + size_t i; - for (i = 0; i + 16 <= size; i += 16) { + for (i = 0; i < size; i += 16) { const uint32_t instr_template = buffer[i] & 0x1F; const uint32_t mask = BRANCH_TABLE[instr_template]; uint32_t bit_pos = 5; diff --git a/contrib/libs/lzma/liblzma/simple/powerpc.c b/contrib/libs/lzma/liblzma/simple/powerpc.c index ba6cfbef3a..ea47d14d4c 100644 --- a/contrib/libs/lzma/liblzma/simple/powerpc.c +++ b/contrib/libs/lzma/liblzma/simple/powerpc.c @@ -18,8 +18,10 @@ powerpc_code(void *simple lzma_attribute((__unused__)), uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { + size &= ~(size_t)3; + size_t i; - for (i = 0; i + 4 <= size; i += 4) { + for (i = 0; i < size; i += 4) { // PowerPC branch 6(48) 24(Offset) 1(Abs) 1(Link) if ((buffer[i] >> 2) == 0x12 && ((buffer[i + 3] & 3) == 1)) { diff --git a/contrib/libs/lzma/liblzma/simple/riscv.c b/contrib/libs/lzma/liblzma/simple/riscv.c index b18df8b637..bc97ebdbb0 100644 --- a/contrib/libs/lzma/liblzma/simple/riscv.c +++ b/contrib/libs/lzma/liblzma/simple/riscv.c @@ -617,6 +617,15 @@ lzma_simple_riscv_encoder_init(lzma_next_coder *next, return lzma_simple_coder_init(next, allocator, filters, &riscv_encode, 0, 8, 2, true); } + + +extern LZMA_API(size_t) +lzma_bcj_riscv_encode(uint32_t start_offset, uint8_t *buf, size_t size) +{ + // start_offset must be a multiple of two. + start_offset &= ~UINT32_C(1); + return riscv_encode(NULL, start_offset, true, buf, size); +} #endif @@ -752,4 +761,13 @@ lzma_simple_riscv_decoder_init(lzma_next_coder *next, return lzma_simple_coder_init(next, allocator, filters, &riscv_decode, 0, 8, 2, false); } + + +extern LZMA_API(size_t) +lzma_bcj_riscv_decode(uint32_t start_offset, uint8_t *buf, size_t size) +{ + // start_offset must be a multiple of two. + start_offset &= ~UINT32_C(1); + return riscv_decode(NULL, start_offset, false, buf, size); +} #endif diff --git a/contrib/libs/lzma/liblzma/simple/sparc.c b/contrib/libs/lzma/liblzma/simple/sparc.c index e8ad285a19..1fa4850458 100644 --- a/contrib/libs/lzma/liblzma/simple/sparc.c +++ b/contrib/libs/lzma/liblzma/simple/sparc.c @@ -18,9 +18,10 @@ sparc_code(void *simple lzma_attribute((__unused__)), uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size) { - size_t i; - for (i = 0; i + 4 <= size; i += 4) { + size &= ~(size_t)3; + size_t i; + for (i = 0; i < size; i += 4) { if ((buffer[i] == 0x40 && (buffer[i + 1] & 0xC0) == 0x00) || (buffer[i] == 0x7F && (buffer[i + 1] & 0xC0) == 0xC0)) { diff --git a/contrib/libs/lzma/liblzma/simple/x86.c b/contrib/libs/lzma/liblzma/simple/x86.c index f216231f2d..dffa786313 100644 --- a/contrib/libs/lzma/liblzma/simple/x86.c +++ b/contrib/libs/lzma/liblzma/simple/x86.c @@ -143,6 +143,18 @@ lzma_simple_x86_encoder_init(lzma_next_coder *next, { return x86_coder_init(next, allocator, filters, true); } + + +extern LZMA_API(size_t) +lzma_bcj_x86_encode(uint32_t start_offset, uint8_t *buf, size_t size) +{ + lzma_simple_x86 simple = { + .prev_mask = 0, + .prev_pos = (uint32_t)(-5), + }; + + return x86_code(&simple, start_offset, true, buf, size); +} #endif @@ -154,4 +166,16 @@ lzma_simple_x86_decoder_init(lzma_next_coder *next, { return x86_coder_init(next, allocator, filters, false); } + + +extern LZMA_API(size_t) +lzma_bcj_x86_decode(uint32_t start_offset, uint8_t *buf, size_t size) +{ + lzma_simple_x86 simple = { + .prev_mask = 0, + .prev_pos = (uint32_t)(-5), + }; + + return x86_code(&simple, start_offset, false, buf, size); +} #endif diff --git a/contrib/libs/lzma/ya.make b/contrib/libs/lzma/ya.make index 60d612bae1..b49400efaa 100644 --- a/contrib/libs/lzma/ya.make +++ b/contrib/libs/lzma/ya.make @@ -1,19 +1,18 @@ -# Generated by devtools/yamaker from nixpkgs 22.11. +# Generated by devtools/yamaker from nixpkgs 24.05. LIBRARY() LICENSE( 0BSD AND - BSD-2-Clause AND BSD-3-Clause AND Public-Domain ) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(5.6.4) +VERSION(5.8.1) -ORIGINAL_SOURCE(https://github.com/tukaani-project/xz/archive/v5.6.4.tar.gz) +ORIGINAL_SOURCE(https://github.com/tukaani-project/xz/archive/v5.8.1.tar.gz) ADDINCL( GLOBAL contrib/libs/lzma/liblzma/api @@ -43,9 +42,7 @@ SRCS( common/tuklib_physmem.c liblzma/check/check.c liblzma/check/crc32_fast.c - liblzma/check/crc32_table.c liblzma/check/crc64_fast.c - liblzma/check/crc64_table.c liblzma/check/sha256.c liblzma/common/alone_decoder.c liblzma/common/alone_encoder.c diff --git a/contrib/libs/protobuf-mutator/.yandex_meta/__init__.py b/contrib/libs/protobuf-mutator/.yandex_meta/__init__.py new file mode 100644 index 0000000000..beef929495 --- /dev/null +++ b/contrib/libs/protobuf-mutator/.yandex_meta/__init__.py @@ -0,0 +1,20 @@ +from devtools.yamaker import fileutil +from devtools.yamaker.project import CMakeNinjaNixProject + + +def post_install(self): + fileutil.re_sub_dir( + self.dstdir, + r"\bstd::string\b", + "TProtoStringType", + ) + + +protobuf_mutator = CMakeNinjaNixProject( + nixattr="protobuf_mutator", + arcdir="contrib/libs/protobuf-mutator", + owners=["g:cpp-contrib"], + addincl_global={".": ["."]}, + put_with={"protobuf-mutator": ["protobuf-mutator-libfuzzer"]}, + post_install=post_install, +) diff --git a/contrib/libs/protobuf-mutator/.yandex_meta/default.nix b/contrib/libs/protobuf-mutator/.yandex_meta/default.nix new file mode 100644 index 0000000000..cdbc64e152 --- /dev/null +++ b/contrib/libs/protobuf-mutator/.yandex_meta/default.nix @@ -0,0 +1,21 @@ +self: super: with self; { + protobuf_mutator = stdenv.mkDerivation rec { + pname = "protobuf_mutator"; + version = "1.5"; + + src = fetchFromGitHub { + owner = "google"; + repo = "libprotobuf-mutator"; + rev = "v${version}"; + hash = "sha256-0iohTyYcV76OOaq9zBpQ6FB+ipxlK/fm/4N7Gp8vnwA="; + }; + + buildInputs = [ pkgs.protobuf ]; + + nativeBuildInputs = [ cmake ]; + + cmakeFlags = [ + "-DLIB_PROTO_MUTATOR_TESTING=OFF" + ]; + }; +} diff --git a/contrib/libs/protobuf-mutator/README.md b/contrib/libs/protobuf-mutator/README.md index ef780604fb..e87f96e9e0 100644 --- a/contrib/libs/protobuf-mutator/README.md +++ b/contrib/libs/protobuf-mutator/README.md @@ -1,6 +1,6 @@ # libprotobuf-mutator -[](https://travis-ci.org/google/libprotobuf-mutator) +[](https://github.com/google/libprotobuf-mutator/actions/workflows/cmake-multi-platform.yml?query=event%3Apush) [](https://oss-fuzz-build-logs.storage.googleapis.com/index.html#libprotobuf-mutator) ## Overview @@ -8,11 +8,16 @@ libprotobuf-mutator is a library to randomly mutate [protobuffers](https://github.com/google/protobuf). <BR> It could be used together with guided fuzzing engines, such as [libFuzzer](http://libfuzzer.info). +The core of libprotobuf-mutator has the following dependencies: + +- Protobuf >=3.6.1.3 (library and compiler) +- Clang >=12.0.0 including libFuzzer + ## Quick start on Debian/Ubuntu Install prerequisites: -``` +```sh sudo apt-get update sudo apt-get install protobuf-compiler libprotobuf-dev binutils cmake \ ninja-build liblzma-dev libz-dev pkg-config autoconf libtool @@ -20,7 +25,7 @@ sudo apt-get install protobuf-compiler libprotobuf-dev binutils cmake \ Compile and test everything: -``` +```sh mkdir build cd build cmake .. -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug @@ -36,7 +41,7 @@ build a working version of protobuf. Installation: -``` +```sh ninja sudo ninja install ``` @@ -59,7 +64,7 @@ using [libFuzzer](http://libfuzzer.info)'s mutators. To apply one mutation to a protobuf object do the following: -``` +```c++ class MyProtobufMutator : public protobuf_mutator::Mutator { public: // Optionally redefine the Mutate* methods to perform more sophisticated mutations. @@ -77,7 +82,7 @@ See also the `ProtobufMutatorMessagesTest.UsageExample` test from ## Integrating with libFuzzer LibFuzzerProtobufMutator can help to integrate with libFuzzer. For example -``` +```c++ #include "src/libfuzzer/libfuzzer_macro.h" DEFINE_PROTO_FUZZER(const MyMessageType& input) { @@ -97,7 +102,7 @@ for fuzzer even if it's capable of inserting acceptable values with time. PostProcessorRegistration can be used to avoid such issue and guide your fuzzer towards interesting code. It registers callback which will be called for each message of particular type after each mutation. -``` +```c++ static protobuf_mutator::libfuzzer::PostProcessorRegistration<MyMessageType> reg = { [](MyMessageType* message, unsigned int seed) { TweakMyMessage(message, seed); @@ -117,7 +122,7 @@ may corrupt the reproducer so it stops triggering the bug. Note: You can add callback for any nested message and you can add multiple callbacks for the same message type. -``` +```c++ static PostProcessorRegistration<MyMessageType> reg1 = { [](MyMessageType* message, unsigned int seed) { TweakMyMessage(message, seed); @@ -155,6 +160,24 @@ cleanup/initialize the message as workaround. * [Envoy](https://github.com/envoyproxy/envoy/search?q=DEFINE_TEXT_PROTO_FUZZER+OR+DEFINE_PROTO_FUZZER+OR+DEFINE_BINARY_PROTO_FUZZER&unscoped_q=DEFINE_TEXT_PROTO_FUZZER+OR+DEFINE_PROTO_FUZZER+OR+DEFINE_BINARY_PROTO_FUZZER&type=Code) * [LLVM](https://github.com/llvm-mirror/clang/search?q=DEFINE_TEXT_PROTO_FUZZER+OR+DEFINE_PROTO_FUZZER+OR+DEFINE_BINARY_PROTO_FUZZER&unscoped_q=DEFINE_TEXT_PROTO_FUZZER+OR+DEFINE_PROTO_FUZZER+OR+DEFINE_BINARY_PROTO_FUZZER&type=Code) +## Grammars +* GIF, https://github.com/google/oss-fuzz/tree/master/projects/giflib +* JSON + * https://github.com/google/oss-fuzz/tree/master/projects/jsoncpp + * https://github.com/officialcjunior/fuzzrtos/tree/c72e6670e566672ccf8023265cbfad616e75790d/protobufv2 +* Lua 5.1 Language, + * https://github.com/ligurio/lua-c-api-tests/tree/master/tests/luaL_loadbuffer_proto + * https://github.com/Spoookyyy/luaj/tree/main/fuzz +* PNG, https://github.com/google/oss-fuzz/tree/master/projects/libpng-proto +* SQL + * https://github.com/tarantool/tarantool/tree/master/test/fuzz/sql_fuzzer + * https://chromium.googlesource.com/chromium/src/third_party/+/refs/heads/main/sqlite/fuzz +* Solidity Language, https://github.com/ethereum/solidity/tree/develop/test/tools/ossfuzz +* XML + * https://github.com/google/oss-fuzz/tree/master/projects/xerces-c + * https://github.com/google/libprotobuf-mutator/tree/master/examples/xml +* JPEG, https://source.chromium.org/chromium/chromium/src/+/main:media/gpu/vaapi/fuzzers/jpeg_decoder/ + ## Bugs found with help of the library ### Chromium diff --git a/contrib/libs/protobuf-mutator/patches/support-tstring.patch b/contrib/libs/protobuf-mutator/patches/support-tstring.patch new file mode 100644 index 0000000000..8324791d76 --- /dev/null +++ b/contrib/libs/protobuf-mutator/patches/support-tstring.patch @@ -0,0 +1,11 @@ +--- a/src/utf8_fix.h ++++ b/src/utf8_fix.h +@@ -17,6 +17,8 @@ + + #include <string> + ++#include <google/protobuf/stubs/port.h> ++ + #include "src/random.h" + + namespace protobuf_mutator { diff --git a/contrib/libs/protobuf-mutator/port/protobuf.h b/contrib/libs/protobuf-mutator/port/protobuf.h index c13d1017d1..4fd7d74344 100644 --- a/contrib/libs/protobuf-mutator/port/protobuf.h +++ b/contrib/libs/protobuf-mutator/port/protobuf.h @@ -20,16 +20,91 @@ #include "google/protobuf/any.pb.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/message.h" +#include "google/protobuf/stubs/common.h" // for GOOGLE_PROTOBUF_VERSION #include "google/protobuf/text_format.h" #include "google/protobuf/util/message_differencer.h" #include "google/protobuf/wire_format.h" +namespace google { +namespace protobuf { +#if GOOGLE_PROTOBUF_VERSION < 4025000 + +template <typename T> +const T* DownCastMessage(const Message* message) { + return static_cast<const T*>(message); +} + +template <typename T> +T* DownCastMessage(Message* message) { + const Message* message_const = message; + return const_cast<T*>(DownCastMessage<T>(message_const)); +} + +#elif GOOGLE_PROTOBUF_VERSION < 5029000 + +template <typename T> +const T* DownCastMessage(const Message* message) { + return DownCastToGenerated<T>(message); +} + +template <typename T> +T* DownCastMessage(Message* message) { + return DownCastToGenerated<T>(message); +} + +#endif // GOOGLE_PROTOBUF_VERSION +} // namespace protobuf +} // namespace google + namespace protobuf_mutator { namespace protobuf = google::protobuf; -// String type used by google::protobuf. -using String = TProtoStringType; +inline bool RequiresUtf8Validation( + const google::protobuf::FieldDescriptor& descriptor) { + // commit d85c9944c55fb38f4eae149979a0f680ea125ecb of >= v3(!).22.0 +#if GOOGLE_PROTOBUF_VERSION >= 4022000 + return descriptor.requires_utf8_validation(); +#else + return descriptor.type() == google::protobuf::FieldDescriptor::TYPE_STRING && + descriptor.file()->syntax() == + google::protobuf::FileDescriptor::SYNTAX_PROTO3; +#endif +} + +inline bool HasPresence(const google::protobuf::FieldDescriptor& descriptor) { + // commit bb30225f06c36399757dc698b409d5f79738e8d1 of >=3.12.0 +#if GOOGLE_PROTOBUF_VERSION >= 3012000 + return descriptor.has_presence(); +#else + // NOTE: This mimics Protobuf 3.21.12 ("3021012") + return !descriptor.is_repeated() && + (descriptor.cpp_type() == + google::protobuf::FieldDescriptor::CppType::CPPTYPE_MESSAGE || + descriptor.containing_oneof() || + descriptor.file()->syntax() == + google::protobuf::FileDescriptor::SYNTAX_PROTO2); +#endif +} + +inline void PrepareTextParser(google::protobuf::TextFormat::Parser& parser) { + // commit d8c2501b43c1b56e3efa74048a18f8ce06ba07fe of >=3.8.0 for .SetRecursionLimit + // commit 176f7db11d8242b36a3ea6abb1cc436fca5bf75d of >=3.8.0 for .AllowUnknownField +#if GOOGLE_PROTOBUF_VERSION >= 3008000 + parser.SetRecursionLimit(100); + parser.AllowUnknownField(true); +#endif +} + +constexpr bool TextParserCanSetRecursionLimit() { + // commit d8c2501b43c1b56e3efa74048a18f8ce06ba07fe of >=3.8.0 + return GOOGLE_PROTOBUF_VERSION >= 3008000; +} + +constexpr bool TextParserCanAllowUnknownField() { + // commit 176f7db11d8242b36a3ea6abb1cc436fca5bf75d of >=3.8.0 + return GOOGLE_PROTOBUF_VERSION >= 3008000; +} } // namespace protobuf_mutator diff --git a/contrib/libs/protobuf-mutator/src/binary_format.cc b/contrib/libs/protobuf-mutator/src/binary_format.cc index 33ec77dba3..49008c6d93 100644 --- a/contrib/libs/protobuf-mutator/src/binary_format.cc +++ b/contrib/libs/protobuf-mutator/src/binary_format.cc @@ -43,8 +43,8 @@ size_t SaveMessageAsBinary(const Message& message, uint8_t* data, } TProtoStringType SaveMessageAsBinary(const protobuf::Message& message) { - String tmp; - if (!message.SerializePartialToString(&tmp)) return {}; + TProtoStringType tmp; + if (!message.SerializePartialToString(&tmp)) tmp.clear(); return tmp; } diff --git a/contrib/libs/protobuf-mutator/src/field_instance.h b/contrib/libs/protobuf-mutator/src/field_instance.h index 11ab465e8a..e2f6482690 100644 --- a/contrib/libs/protobuf-mutator/src/field_instance.h +++ b/contrib/libs/protobuf-mutator/src/field_instance.h @@ -176,7 +176,7 @@ class ConstFieldInstance { WireFormatLite::PARSE, ""); } - TProtoStringType name() const { return descriptor_->name(); } + TProtoStringType name() const { return TProtoStringType(descriptor_->name()); } protobuf::FieldDescriptor::CppType cpp_type() const { return descriptor_->cpp_type(); @@ -190,11 +190,7 @@ class ConstFieldInstance { return descriptor_->message_type(); } - bool EnforceUtf8() const { - return descriptor_->type() == protobuf::FieldDescriptor::TYPE_STRING && - descriptor()->file()->syntax() == - protobuf::FileDescriptor::SYNTAX_PROTO3; - } + bool EnforceUtf8() const { return RequiresUtf8Validation(*descriptor_); } const protobuf::FieldDescriptor* descriptor() const { return descriptor_; } diff --git a/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.cc b/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.cc index 4e506cbe94..2004df62ef 100644 --- a/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.cc +++ b/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.cc @@ -235,7 +235,7 @@ void RegisterPostProcessor( const protobuf::Descriptor* desc, std::function<void(protobuf::Message* message, unsigned int seed)> callback) { - GetMutator()->RegisterPostProcessor(desc, callback); + GetMutator()->RegisterPostProcessor(desc, std::move(callback)); } } // namespace libfuzzer diff --git a/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.h b/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.h index b5cb201810..8907326586 100644 --- a/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.h +++ b/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_macro.h @@ -119,7 +119,7 @@ struct PostProcessorRegistration { RegisterPostProcessor( Proto::descriptor(), [callback](protobuf::Message* message, unsigned int seed) { - callback(static_cast<Proto*>(message), seed); + callback(protobuf::DownCastMessage<Proto>(message), seed); }); } }; diff --git a/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_mutator.cc b/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_mutator.cc index 9c3be921e6..cacc83191a 100644 --- a/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_mutator.cc +++ b/contrib/libs/protobuf-mutator/src/libfuzzer/libfuzzer_mutator.cc @@ -14,6 +14,11 @@ #include "src/libfuzzer/libfuzzer_mutator.h" +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) +#include <sanitizer/msan_interface.h> +#endif +#endif #include <string.h> #include <algorithm> @@ -65,6 +70,12 @@ T MutateValue(T v) { size_t size = LLVMFuzzerMutate(reinterpret_cast<uint8_t*>(&v), sizeof(v), sizeof(v)); memset(reinterpret_cast<uint8_t*>(&v) + size, 0, sizeof(v) - size); + // The value from LLVMFuzzerMutate needs to be treated as initialized. +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) + __msan_unpoison(&v, sizeof(v)); +#endif +#endif return v; } @@ -93,6 +104,12 @@ TProtoStringType Mutator::MutateString(const TProtoStringType& value, result.resize(std::max(1, new_size)); result.resize(LLVMFuzzerMutate(reinterpret_cast<uint8_t*>(&result[0]), value.size(), result.size())); + // The value from LLVMFuzzerMutate needs to be treated as initialized. +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) + __msan_unpoison(&result[0], result.size()); +#endif +#endif return result; } diff --git a/contrib/libs/protobuf-mutator/src/mutator.cc b/contrib/libs/protobuf-mutator/src/mutator.cc index 98f443e301..c22e871cac 100644 --- a/contrib/libs/protobuf-mutator/src/mutator.cc +++ b/contrib/libs/protobuf-mutator/src/mutator.cc @@ -87,11 +87,7 @@ bool GetRandomBool(RandomEngine* random, size_t n = 2) { } bool IsProto3SimpleField(const FieldDescriptor& field) { - assert(field.file()->syntax() == FileDescriptor::SYNTAX_PROTO3 || - field.file()->syntax() == FileDescriptor::SYNTAX_PROTO2); - return field.file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && - field.cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE && - !field.containing_oneof() && !field.is_repeated(); + return !field.is_repeated() && !HasPresence(field); } struct CreateDefaultField : public FieldFunction<CreateDefaultField> { @@ -384,14 +380,14 @@ std::unique_ptr<Message> UnpackAny(const Any& any) { } const Any* CastToAny(const Message* message) { - return Any::GetDescriptor() == message->GetDescriptor() - ? static_cast<const Any*>(message) + return Any::descriptor() == message->GetDescriptor() + ? protobuf::DownCastMessage<Any>(message) : nullptr; } Any* CastToAny(Message* message) { - return Any::GetDescriptor() == message->GetDescriptor() - ? static_cast<Any*>(message) + return Any::descriptor() == message->GetDescriptor() + ? protobuf::DownCastMessage<Any>(message) : nullptr; } @@ -486,7 +482,7 @@ class PostProcessing { Run(It->second.get(), max_depth); TProtoStringType value; It->second->SerializePartialToString(&value); - *any->mutable_value() = value; + *any->mutable_value() = std::move(value); } } } diff --git a/contrib/libs/protobuf-mutator/src/mutator.h b/contrib/libs/protobuf-mutator/src/mutator.h index 2f1d3a833c..5b75fa12bf 100644 --- a/contrib/libs/protobuf-mutator/src/mutator.h +++ b/contrib/libs/protobuf-mutator/src/mutator.h @@ -32,7 +32,8 @@ namespace protobuf_mutator { // Randomly makes incremental change in the given protobuf. // Usage example: -// protobuf_mutator::Mutator mutator(1); +// protobuf_mutator::Mutator mutator; +// mutator.Seed(1); // MyMessage message; // message.ParseFromString(encoded_message); // mutator.Mutate(&message, 10000); @@ -44,7 +45,6 @@ namespace protobuf_mutator { // library like libFuzzer. class Mutator { public: - // seed: value to initialize random number generator. Mutator() = default; virtual ~Mutator() = default; diff --git a/contrib/libs/protobuf-mutator/src/text_format.cc b/contrib/libs/protobuf-mutator/src/text_format.cc index d8a8342b19..2ac7ae3a58 100644 --- a/contrib/libs/protobuf-mutator/src/text_format.cc +++ b/contrib/libs/protobuf-mutator/src/text_format.cc @@ -28,9 +28,8 @@ bool ParseTextMessage(const uint8_t* data, size_t size, Message* output) { bool ParseTextMessage(const TProtoStringType& data, protobuf::Message* output) { output->Clear(); TextFormat::Parser parser; - parser.SetRecursionLimit(100); parser.AllowPartialMessage(true); - parser.AllowUnknownField(true); + PrepareTextParser(parser); if (!parser.ParseFromString(data, output)) { output->Clear(); return false; @@ -49,8 +48,8 @@ size_t SaveMessageAsText(const Message& message, uint8_t* data, } TProtoStringType SaveMessageAsText(const protobuf::Message& message) { - String tmp; - if (!protobuf::TextFormat::PrintToString(message, &tmp)) return {}; + TProtoStringType tmp; + if (!protobuf::TextFormat::PrintToString(message, &tmp)) tmp.clear(); return tmp; } diff --git a/contrib/libs/protobuf-mutator/src/utf8_fix.cc b/contrib/libs/protobuf-mutator/src/utf8_fix.cc index 845de1cdd3..5e8af4e3b2 100644 --- a/contrib/libs/protobuf-mutator/src/utf8_fix.cc +++ b/contrib/libs/protobuf-mutator/src/utf8_fix.cc @@ -14,7 +14,7 @@ #include "src/utf8_fix.h" -#include <google/protobuf/stubs/port.h> +#include <stdint.h> #include <algorithm> #include <cassert> diff --git a/contrib/libs/protobuf-mutator/src/utf8_fix.h b/contrib/libs/protobuf-mutator/src/utf8_fix.h index 8ec7e44285..dd38b68521 100644 --- a/contrib/libs/protobuf-mutator/src/utf8_fix.h +++ b/contrib/libs/protobuf-mutator/src/utf8_fix.h @@ -17,7 +17,7 @@ #include <string> -#include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/port.h> #include "src/random.h" diff --git a/contrib/libs/protobuf-mutator/ya.make b/contrib/libs/protobuf-mutator/ya.make index e7f5abf770..09776c3507 100644 --- a/contrib/libs/protobuf-mutator/ya.make +++ b/contrib/libs/protobuf-mutator/ya.make @@ -1,4 +1,4 @@ -# Generated by devtools/yamaker from nixpkgs 22.05. +# Generated by devtools/yamaker from nixpkgs 22.11. LIBRARY() @@ -6,9 +6,9 @@ LICENSE(Apache-2.0) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(1.1) +VERSION(1.5) -ORIGINAL_SOURCE(https://github.com/google/libprotobuf-mutator/archive/v1.1.tar.gz) +ORIGINAL_SOURCE(https://github.com/google/libprotobuf-mutator/archive/v1.5.tar.gz) PEERDIR( contrib/libs/protobuf diff --git a/contrib/libs/simdjson/.yandex_meta/devtools.licenses.report b/contrib/libs/simdjson/.yandex_meta/devtools.licenses.report index e29fcfdfcb..2aad6abcfa 100644 --- a/contrib/libs/simdjson/.yandex_meta/devtools.licenses.report +++ b/contrib/libs/simdjson/.yandex_meta/devtools.licenses.report @@ -42,7 +42,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 Files with this license: - README.md [234:234] + README.md [235:235] KEEP MIT 0a00f0d66f4f37595306dd8c6a25c63c BELONGS ya.make @@ -54,7 +54,7 @@ BELONGS ya.make Match type : NOTICE Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT Files with this license: - README.md [230:230] + README.md [231:231] SKIP LicenseRef-scancode-unknown-license-reference 0d48e0b09865a98a90db20ea37b36bb8 BELONGS ya.make @@ -66,7 +66,7 @@ BELONGS ya.make Match type : INTRO Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE Files with this license: - README.md [238:238] + README.md [239:239] KEEP Apache-2.0 13ec3cccf3036f38df47d2051a825972 BELONGS ya.make @@ -102,7 +102,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 Files with this license: - README.md [214:214] + README.md [215:215] SKIP BSL-1.0 2a9212d785cde4078c2f6803e544de21 BELONGS ya.make @@ -113,7 +113,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 Files with this license: - README.md [234:234] + README.md [235:235] KEEP MIT 3e1ede6948a97e7ee3d75e0204a567f3 BELONGS ya.make @@ -125,7 +125,7 @@ BELONGS ya.make Match type : TAG Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT Files with this license: - README.md [218:218] + README.md [219:219] SKIP Apache-2.0 500a503129337bb5adf5977ce11879cd BELONGS ya.make @@ -137,7 +137,7 @@ BELONGS ya.make Match type : NOTICE Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 Files with this license: - README.md [230:230] + README.md [231:231] SKIP BSL-1.0 77dd56e30840a227692d435b4aecdb95 BELONGS ya.make @@ -148,11 +148,11 @@ BELONGS ya.make Match type : REFERENCE Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 Files with this license: - README.md [234:234] + README.md [235:235] KEEP MIT 7f0bdbc0a0545831259b66259ac6b604 BELONGS ya.make -FILE_INCLUDE LICENSE-MIT found in files: README.md at line 217 +FILE_INCLUDE LICENSE-MIT found in files: README.md at line 218 License text: [licensemit]: LICENSE-MIT Scancode info: @@ -161,7 +161,7 @@ FILE_INCLUDE LICENSE-MIT found in files: README.md at line 217 Match type : TAG Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT Files with this license: - README.md [217:217] + README.md [218:218] KEEP Apache-2.0 82e76bbc1841bd5886297e795c72bfa5 BELONGS ya.make @@ -173,7 +173,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 Files with this license: - README.md [230:230] + README.md [231:231] KEEP MIT a6e9f2d79eb73e6e422759b53da6152a BELONGS ya.make @@ -208,7 +208,7 @@ BELONGS ya.make Match type : NOTICE Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT Files with this license: - README.md [236:236] + README.md [237:237] SKIP Apache-2.0 c23a044f4165feb9568f486ca3b30fc8 BELONGS ya.make @@ -219,7 +219,7 @@ BELONGS ya.make Match type : NOTICE Links : http://www.apache.org/licenses/, http://www.apache.org/licenses/LICENSE-2.0, https://spdx.org/licenses/Apache-2.0 Files with this license: - README.md [234:234] + README.md [235:235] SKIP BSD-3-Clause d77bd60dc7ee5f9c3b221f6edd94bbac BELONGS ya.make @@ -231,7 +231,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause Files with this license: - README.md [238:238] + README.md [239:239] SKIP MIT dd09705e3ec59af63c705c8f5f3eadb2 BELONGS ya.make @@ -243,7 +243,7 @@ BELONGS ya.make Match type : REFERENCE Links : http://opensource.org/licenses/mit-license.php, https://spdx.org/licenses/MIT Files with this license: - README.md [232:232] + README.md [233:233] KEEP MIT f0fe4686586f118327c3bc63fe4027de BELONGS ya.make diff --git a/contrib/libs/simdjson/.yandex_meta/override.nix b/contrib/libs/simdjson/.yandex_meta/override.nix index a3e6ea867c..a34855ca87 100644 --- a/contrib/libs/simdjson/.yandex_meta/override.nix +++ b/contrib/libs/simdjson/.yandex_meta/override.nix @@ -1,11 +1,11 @@ pkgs: attrs: with pkgs; rec { - version = "3.12.2"; + version = "3.12.3"; src = fetchFromGitHub { owner = "simdjson"; repo = "simdjson"; rev = "v${version}"; - hash = "sha256-TjUPySFwwTlD4fLpHoUywAeWvVvi7Hg1wxzgE9vohrs="; + hash = "sha256-/FfaM5BTWKrt2m70+VcUXz//RiZuzxnUOaHOjPJWsGw="; }; cmakeFlags = attrs.cmakeFlags ++ [ diff --git a/contrib/libs/simdjson/CONTRIBUTING.md b/contrib/libs/simdjson/CONTRIBUTING.md index a6b70a0bf2..a9cf186e45 100644 --- a/contrib/libs/simdjson/CONTRIBUTING.md +++ b/contrib/libs/simdjson/CONTRIBUTING.md @@ -92,7 +92,7 @@ We welcome contributions from women and less represented groups. If you need hel Consider the following points when engaging with the project: -- We discourage arguments from authority: ideas are discusssed on their own merits and not based on who stated it. +- We discourage arguments from authority: ideas are discussed on their own merits and not based on who stated it. - Be mindful that what you may view as an aggression is maybe merely a difference of opinion or a misunderstanding. - Be mindful that a collection of small aggressions, even if mild in isolation, can become harmful. diff --git a/contrib/libs/simdjson/README.md b/contrib/libs/simdjson/README.md index a9ca9a08da..d187a54b41 100644 --- a/contrib/libs/simdjson/README.md +++ b/contrib/libs/simdjson/README.md @@ -173,7 +173,8 @@ We distinguish between "bindings" (which just wrap the C++ code) and a port to a - [simdjsone](https://github.com/saleyn/simdjsone): erlang bindings. - [lua-simdjson](https://github.com/FourierTransformer/lua-simdjson): lua bindings. - [hermes-json](https://hackage.haskell.org/package/hermes-json): haskell bindings. -- [simdjzon](https://github.com/travisstaloch/simdjzon): zig port. +- [zimdjson](https://github.com/EzequielRamis/zimdjson): Zig port. +- [simdjzon](https://github.com/travisstaloch/simdjzon): Zig port. - [JSON-Simd](https://github.com/rawleyfowler/JSON-simd): Raku bindings. - [JSON::SIMD](https://metacpan.org/pod/JSON::SIMD): Perl bindings; fully-featured JSON module that uses simdjson for decoding. - [gemmaJSON](https://github.com/sainttttt/gemmaJSON): Nim JSON parser based on simdjson bindings. diff --git a/contrib/libs/simdjson/include/simdjson/concepts.h b/contrib/libs/simdjson/include/simdjson/concepts.h index 649314bc1b..ffe344c072 100644 --- a/contrib/libs/simdjson/include/simdjson/concepts.h +++ b/contrib/libs/simdjson/include/simdjson/concepts.h @@ -32,14 +32,30 @@ SIMDJSON_IMPL_CONCEPT(op_append, operator+=) #undef SIMDJSON_IMPL_CONCEPT } // namespace details + +template <typename T> +concept string_view_like = std::is_convertible_v<T, std::string_view> && + !std::is_convertible_v<T, const char*>; + +template<typename T> +concept constructible_from_string_view = std::is_constructible_v<T, std::string_view> + && !std::is_same_v<T, std::string_view> + && std::is_default_constructible_v<T>; + +template<typename M> +concept string_view_keyed_map = string_view_like<typename M::key_type> + && requires(std::remove_cvref_t<M>& m, typename M::key_type sv, typename M::mapped_type v) { + { m.emplace(sv, v) } -> std::same_as<std::pair<typename M::iterator, bool>>; +}; + /// Check if T is a container that we can append to, including: /// std::vector, std::deque, std::list, std::string, ... template <typename T> concept appendable_containers = - details::supports_emplace_back<T> || details::supports_emplace<T> || + (details::supports_emplace_back<T> || details::supports_emplace<T> || details::supports_push_back<T> || details::supports_push<T> || details::supports_add<T> || details::supports_append<T> || - details::supports_insert<T>; + details::supports_insert<T>) && !string_view_keyed_map<T>; /// Insert into the container however possible template <appendable_containers T, typename... Args> @@ -107,6 +123,8 @@ concept optional_type = requires(std::remove_cvref_t<T> obj) { { static_cast<bool>(obj) } -> std::same_as<bool>; // convertible to bool }; + + } // namespace concepts } // namespace simdjson #endif // SIMDJSON_SUPPORTS_DESERIALIZATION diff --git a/contrib/libs/simdjson/include/simdjson/dom/document.h b/contrib/libs/simdjson/include/simdjson/dom/document.h index 6c5e284bb4..67fd584736 100644 --- a/contrib/libs/simdjson/include/simdjson/dom/document.h +++ b/contrib/libs/simdjson/include/simdjson/dom/document.h @@ -70,7 +70,7 @@ public: * The memory allocation is strict: you * can you use this function to increase * or lower the amount of allocated memory. - * Passsing zero clears the memory. + * Passing zero clears the memory. */ error_code allocate(size_t len) noexcept; /** @private Capacity in bytes, in terms diff --git a/contrib/libs/simdjson/include/simdjson/dom/parser.h b/contrib/libs/simdjson/include/simdjson/dom/parser.h index 7c28a712f0..0b69091d6f 100644 --- a/contrib/libs/simdjson/include/simdjson/dom/parser.h +++ b/contrib/libs/simdjson/include/simdjson/dom/parser.h @@ -340,7 +340,7 @@ public: * arrays or objects) MUST be separated with whitespace. * * The documents must not exceed batch_size bytes (by default 1MB) or they will fail to parse. - * Setting batch_size to excessively large or excesively small values may impact negatively the + * Setting batch_size to excessively large or excessively small values may impact negatively the * performance. * * ### Error Handling @@ -434,7 +434,7 @@ public: * arrays or objects) MUST be separated with whitespace. * * The documents must not exceed batch_size bytes (by default 1MB) or they will fail to parse. - * Setting batch_size to excessively large or excesively small values may impact negatively the + * Setting batch_size to excessively large or excessively small values may impact negatively the * performance. * * ### Error Handling diff --git a/contrib/libs/simdjson/include/simdjson/error-inl.h b/contrib/libs/simdjson/include/simdjson/error-inl.h index 5cf61d9c30..fe6bf66db0 100644 --- a/contrib/libs/simdjson/include/simdjson/error-inl.h +++ b/contrib/libs/simdjson/include/simdjson/error-inl.h @@ -6,6 +6,11 @@ #include <iostream> namespace simdjson { + +inline bool is_fatal(error_code error) noexcept { + return error == TAPE_ERROR || error == INCOMPLETE_ARRAY_OR_OBJECT; +} + namespace internal { // We store the error code so we can validate the error message is associated with the right code struct error_code_info { diff --git a/contrib/libs/simdjson/include/simdjson/error.h b/contrib/libs/simdjson/include/simdjson/error.h index 2f3443d9b6..4d963d4c24 100644 --- a/contrib/libs/simdjson/include/simdjson/error.h +++ b/contrib/libs/simdjson/include/simdjson/error.h @@ -20,7 +20,7 @@ enum error_code { SUCCESS = 0, ///< No error CAPACITY, ///< This parser can't support a document that big MEMALLOC, ///< Error allocating memory, most likely out of memory - TAPE_ERROR, ///< Something went wrong, this is a generic error + TAPE_ERROR, ///< Something went wrong, this is a generic error. Fatal/unrecoverable error. DEPTH_ERROR, ///< Your document exceeds the user-specified depth limitation STRING_ERROR, ///< Problem while parsing a string T_ATOM_ERROR, ///< Problem while parsing an atom starting with the letter 't' @@ -45,7 +45,7 @@ enum error_code { PARSER_IN_USE, ///< parser is already in use. OUT_OF_ORDER_ITERATION, ///< tried to iterate an array or object out of order (checked when SIMDJSON_DEVELOPMENT_CHECKS=1) INSUFFICIENT_PADDING, ///< The JSON doesn't have enough padding for simdjson to safely parse it. - INCOMPLETE_ARRAY_OR_OBJECT, ///< The document ends early. + INCOMPLETE_ARRAY_OR_OBJECT, ///< The document ends early. Fatal/unrecoverable error. SCALAR_DOCUMENT_AS_VALUE, ///< A scalar document is treated as a value. OUT_OF_BOUNDS, ///< Attempted to access location outside of document. TRAILING_CONTENT, ///< Unexpected trailing content in the JSON input @@ -53,6 +53,14 @@ enum error_code { }; /** + * Some errors are fatal and invalidate the document. This function returns true if the + * error is fatal. It returns true for TAPE_ERROR and INCOMPLETE_ARRAY_OR_OBJECT. + * Once a fatal error is encountered, the on-demand document is no longer valid and + * processing should stop. + */ + inline bool is_fatal(error_code error) noexcept; + +/** * It is the convention throughout the code that the macro SIMDJSON_DEVELOPMENT_CHECKS determines whether * we check for OUT_OF_ORDER_ITERATION. The logic behind it is that these errors only occurs when the code * that was written while breaking some simdjson::ondemand requirement. They should not occur in released diff --git a/contrib/libs/simdjson/include/simdjson/generic/numberparsing.h b/contrib/libs/simdjson/include/simdjson/generic/numberparsing.h index 5b8fdfcd78..a6d96d0ba9 100644 --- a/contrib/libs/simdjson/include/simdjson/generic/numberparsing.h +++ b/contrib/libs/simdjson/include/simdjson/generic/numberparsing.h @@ -137,7 +137,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative, // floor(log(5**power)/log(2)) // // Note that this is not magic: 152170/(1<<16) is - // approximatively equal to log(5)/log(2). + // approximately equal to log(5)/log(2). // The 1<<16 value is a power of two; we could use a // larger power of 2 if we wanted to. // diff --git a/contrib/libs/simdjson/include/simdjson/generic/ondemand/document.h b/contrib/libs/simdjson/include/simdjson/generic/ondemand/document.h index c109f15b8b..50d3523ffc 100644 --- a/contrib/libs/simdjson/include/simdjson/generic/ondemand/document.h +++ b/contrib/libs/simdjson/include/simdjson/generic/ondemand/document.h @@ -239,20 +239,27 @@ public: if constexpr (custom_deserializable<T, document>) { return deserialize(*this, out); } else { -#endif // SIMDJSON_SUPPORTS_DESERIALIZATION - // Unless the simdjson library or the user provides an inline implementation, calling this method should - // immediately fail. - static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library. " - "The supported types are ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, " - "int64_t, double, and bool. We recommend you use get_double(), get_bool(), get_uint64(), get_int64(), " - " get_object(), get_array(), get_raw_json_string(), or get_string() instead of the get template." - " You may also add support for custom types, see our documentation."); + static_assert(!sizeof(T), "The get<T> method with type T is not implemented by the simdjson library. " + "And you do not seem to have added support for it. Indeed, we have that " + "simdjson::custom_deserializable<T> is false and the type T is not a default type " + "such as ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, " + "int64_t, double, or bool."); static_cast<void>(out); // to get rid of unused errors return UNINITIALIZED; -#if SIMDJSON_SUPPORTS_DESERIALIZATION } -#endif +#else // SIMDJSON_SUPPORTS_DESERIALIZATION + // Unless the simdjson library or the user provides an inline implementation, calling this method should + // immediately fail. + static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library. " + "The supported types are ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, " + "int64_t, double, and bool. We recommend you use get_double(), get_bool(), get_uint64(), get_int64(), " + " get_object(), get_array(), get_raw_json_string(), or get_string() instead of the get template." + " You may also add support for custom types, see our documentation."); + static_cast<void>(out); // to get rid of unused errors + return UNINITIALIZED; +#endif // SIMDJSON_SUPPORTS_DESERIALIZATION } + /** @overload template<typename T> error_code get(T &out) & noexcept */ template<typename T> simdjson_deprecated simdjson_inline error_code get(T &out) && noexcept; @@ -814,20 +821,27 @@ public: if constexpr (custom_deserializable<T, document_reference>) { return deserialize(*this, out); } else { -#endif // SIMDJSON_SUPPORTS_DESERIALIZATION - // Unless the simdjson library or the user provides an inline implementation, calling this method should - // immediately fail. - static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library. " - "The supported types are ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, " - "int64_t, double, and bool. We recommend you use get_double(), get_bool(), get_uint64(), get_int64(), " - " get_object(), get_array(), get_raw_json_string(), or get_string() instead of the get template." - " You may also add support for custom types, see our documentation."); + static_assert(!sizeof(T), "The get<T> method with type T is not implemented by the simdjson library. " + "And you do not seem to have added support for it. Indeed, we have that " + "simdjson::custom_deserializable<T> is false and the type T is not a default type " + "such as ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, " + "int64_t, double, or bool."); static_cast<void>(out); // to get rid of unused errors return UNINITIALIZED; -#if SIMDJSON_SUPPORTS_DESERIALIZATION } -#endif +#else // SIMDJSON_SUPPORTS_DESERIALIZATION + // Unless the simdjson library or the user provides an inline implementation, calling this method should + // immediately fail. + static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library. " + "The supported types are ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, " + "int64_t, double, and bool. We recommend you use get_double(), get_bool(), get_uint64(), get_int64(), " + " get_object(), get_array(), get_raw_json_string(), or get_string() instead of the get template." + " You may also add support for custom types, see our documentation."); + static_cast<void>(out); // to get rid of unused errors + return UNINITIALIZED; +#endif // SIMDJSON_SUPPORTS_DESERIALIZATION } + /** @overload template<typename T> error_code get(T &out) & noexcept */ template<typename T> simdjson_inline error_code get(T &out) && noexcept; simdjson_inline simdjson_result<std::string_view> raw_json() noexcept; diff --git a/contrib/libs/simdjson/include/simdjson/generic/ondemand/std_deserialize.h b/contrib/libs/simdjson/include/simdjson/generic/ondemand/std_deserialize.h index ce8b9fa3fe..1a9bf1128a 100644 --- a/contrib/libs/simdjson/include/simdjson/generic/ondemand/std_deserialize.h +++ b/contrib/libs/simdjson/include/simdjson/generic/ondemand/std_deserialize.h @@ -55,6 +55,16 @@ error_code tag_invoke(deserialize_tag, auto &val, T &out) noexcept { return SUCCESS; } +template <concepts::constructible_from_string_view T, typename ValT> + requires(!require_custom_serialization<T>) +error_code tag_invoke(deserialize_tag, ValT &val, T &out) noexcept(std::is_nothrow_constructible_v<T, std::string_view>) { + std::string_view str; + SIMDJSON_TRY(val.get_string().get(str)); + out = T{str}; + return SUCCESS; +} + + /** * STL containers have several constructors including one that takes a single * size argument. Thus, some compilers (Visual Studio) will not be able to @@ -100,6 +110,39 @@ error_code tag_invoke(deserialize_tag, ValT &val, T &out) noexcept(false) { } +/** + * We want to support std::map and std::unordered_map but only for + * string-keyed types. + */ + template <concepts::string_view_keyed_map T, typename ValT> + requires(!require_custom_serialization<T>) +error_code tag_invoke(deserialize_tag, ValT &val, T &out) noexcept(false) { + using value_type = typename std::remove_cvref_t<T>::mapped_type; + static_assert( + deserializable<value_type, ValT>, + "The specified value type inside the container must itself be deserializable"); + static_assert( + std::is_default_constructible_v<value_type>, + "The specified value type inside the container must default constructible."); + SIMDJSON_IMPLEMENTATION::ondemand::object obj; + SIMDJSON_TRY(val.get_object().get(obj)); + for (auto field : obj) { + std::string_view key; + SIMDJSON_TRY(field.unescaped_key().get(key)); + value_type this_value; + SIMDJSON_TRY(field.value().get<value_type>().get(this_value)); + [[maybe_unused]] std::pair<typename T::iterator, bool> result = out.emplace(key, this_value); + // unclear what to do if the key already exists + // if (result.second == false) { + // // key already exists + // } + } + (void)out; + return SUCCESS; +} + + + /** * This CPO (Customization Point Object) will help deserialize into diff --git a/contrib/libs/simdjson/include/simdjson/generic/ondemand/value.h b/contrib/libs/simdjson/include/simdjson/generic/ondemand/value.h index 7fa9d1ad25..3ecc786f76 100644 --- a/contrib/libs/simdjson/include/simdjson/generic/ondemand/value.h +++ b/contrib/libs/simdjson/include/simdjson/generic/ondemand/value.h @@ -70,22 +70,28 @@ public: noexcept #endif { -#if SIMDJSON_SUPPORTS_DESERIALIZATION - if constexpr (custom_deserializable<T, value>) { + #if SIMDJSON_SUPPORTS_DESERIALIZATION + if constexpr (custom_deserializable<T, value>) { return deserialize(*this, out); - } else { -#endif // SIMDJSON_SUPPORTS_DESERIALIZATION - // Unless the simdjson library or the user provides an inline implementation, calling this method should - // immediately fail. - static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library. " - "The supported types are ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, " - "int64_t, double, and bool. We recommend you use get_double(), get_bool(), get_uint64(), get_int64(), " - " get_object(), get_array(), get_raw_json_string(), or get_string() instead of the get template." - " You may also add support for custom types, see our documentation."); - static_cast<void>(out); // to get rid of unused errors - return UNINITIALIZED; -#if SIMDJSON_SUPPORTS_DESERIALIZATION - } + } else { + static_assert(!sizeof(T), "The get<T> method with type T is not implemented by the simdjson library. " + "And you do not seem to have added support for it. Indeed, we have that " + "simdjson::custom_deserializable<T> is false and the type T is not a default type " + "such as ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, " + "int64_t, double, or bool."); + static_cast<void>(out); // to get rid of unused errors + return UNINITIALIZED; + } +#else // SIMDJSON_SUPPORTS_DESERIALIZATION + // Unless the simdjson library or the user provides an inline implementation, calling this method should + // immediately fail. + static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library. " + "The supported types are ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, " + "int64_t, double, and bool. We recommend you use get_double(), get_bool(), get_uint64(), get_int64(), " + " get_object(), get_array(), get_raw_json_string(), or get_string() instead of the get template." + " You may also add support for custom types, see our documentation."); + static_cast<void>(out); // to get rid of unused errors + return UNINITIALIZED; #endif } diff --git a/contrib/libs/simdjson/include/simdjson/generic/ondemand/value_iterator-inl.h b/contrib/libs/simdjson/include/simdjson/generic/ondemand/value_iterator-inl.h index 21016f8b97..56d5d6e436 100644 --- a/contrib/libs/simdjson/include/simdjson/generic/ondemand/value_iterator-inl.h +++ b/contrib/libs/simdjson/include/simdjson/generic/ondemand/value_iterator-inl.h @@ -778,19 +778,23 @@ simdjson_warn_unused simdjson_inline simdjson_result<double> value_iterator::get } return result; } + simdjson_warn_unused simdjson_inline simdjson_result<bool> value_iterator::get_root_bool(bool check_trailing) noexcept { auto max_len = peek_root_length(); auto json = peek_root_scalar("bool"); - uint8_t tmpbuf[5+1+1]; // +1 for null termination - tmpbuf[5+1] = '\0'; // make sure that buffer is always null terminated. - if (!_json_iter->copy_to_buffer(json, max_len, tmpbuf, 5+1)) { return incorrect_type_error("Not a boolean"); } - auto result = parse_bool(tmpbuf); - if(result.error() == SUCCESS) { - if (check_trailing && !_json_iter->is_single_token()) { return TRAILING_CONTENT; } - advance_root_scalar("bool"); - } - return result; + // We have a boolean if we have either "true" or "false" and the next character is either + // a structural character or whitespace. We also check that the length is correct: + // "true" and "false" are 4 and 5 characters long, respectively. + bool value_true = (max_len >= 4 && !atomparsing::str4ncmp(json, "true") && + (max_len == 4 || jsoncharutils::is_structural_or_whitespace(json[4]))); + bool value_false = (max_len >= 5 && !atomparsing::str4ncmp(json, "false") && + (max_len == 5 || jsoncharutils::is_structural_or_whitespace(json[5]))); + if(value_true == false && value_false == false) { return incorrect_type_error("Not a boolean"); } + if (check_trailing && !_json_iter->is_single_token()) { return TRAILING_CONTENT; } + advance_root_scalar("bool"); + return value_true; } + simdjson_inline simdjson_result<bool> value_iterator::is_root_null(bool check_trailing) noexcept { auto max_len = peek_root_length(); auto json = peek_root_scalar("null"); diff --git a/contrib/libs/simdjson/include/simdjson/generic/ondemand/value_iterator.h b/contrib/libs/simdjson/include/simdjson/generic/ondemand/value_iterator.h index a01a8fb09e..7ae38bd4fe 100644 --- a/contrib/libs/simdjson/include/simdjson/generic/ondemand/value_iterator.h +++ b/contrib/libs/simdjson/include/simdjson/generic/ondemand/value_iterator.h @@ -125,7 +125,8 @@ public: * * @returns Whether the object had any fields (returns false for empty). * @error INCOMPLETE_ARRAY_OR_OBJECT If there are no more tokens (implying the *parent* - * array or object is incomplete). + * array or object is incomplete). An INCOMPLETE_ARRAY_OR_OBJECT is an unrecoverable error that + * invalidates the document. */ simdjson_warn_unused simdjson_inline simdjson_result<bool> started_object() noexcept; /** @@ -135,7 +136,8 @@ public: * * @returns Whether the object had any fields (returns false for empty). * @error INCOMPLETE_ARRAY_OR_OBJECT If there are no more tokens (implying the *parent* - * array or object is incomplete). + * array or object is incomplete). An INCOMPLETE_ARRAY_OR_OBJECT is an unrecoverable error that + * invalidates the document. */ simdjson_warn_unused simdjson_inline simdjson_result<bool> started_root_object() noexcept; @@ -257,7 +259,8 @@ public: * * @returns Whether the array had any elements (returns false for empty). * @error INCOMPLETE_ARRAY_OR_OBJECT If there are no more tokens (implying the *parent* - * array or object is incomplete). + * array or object is incomplete). An INCOMPLETE_ARRAY_OR_OBJECT is an unrecoverable error that + * invalidates the document. */ simdjson_warn_unused simdjson_inline simdjson_result<bool> started_array() noexcept; /** @@ -267,7 +270,8 @@ public: * * @returns Whether the array had any elements (returns false for empty). * @error INCOMPLETE_ARRAY_OR_OBJECT If there are no more tokens (implying the *parent* - * array or object is incomplete). + * array or object is incomplete). An INCOMPLETE_ARRAY_OR_OBJECT is an unrecoverable error that + * invalidates the document. */ simdjson_warn_unused simdjson_inline simdjson_result<bool> started_root_array() noexcept; diff --git a/contrib/libs/simdjson/include/simdjson/simdjson_version.h b/contrib/libs/simdjson/include/simdjson/simdjson_version.h index d61c07c01f..d71abe4523 100644 --- a/contrib/libs/simdjson/include/simdjson/simdjson_version.h +++ b/contrib/libs/simdjson/include/simdjson/simdjson_version.h @@ -4,7 +4,7 @@ #define SIMDJSON_SIMDJSON_VERSION_H /** The version of simdjson being used (major.minor.revision) */ -#define SIMDJSON_VERSION "3.12.2" +#define SIMDJSON_VERSION "3.12.3" namespace simdjson { enum { @@ -19,7 +19,7 @@ enum { /** * The revision (major.minor.REVISION) of simdjson being used. */ - SIMDJSON_VERSION_REVISION = 2 + SIMDJSON_VERSION_REVISION = 3 }; } // namespace simdjson diff --git a/contrib/libs/simdjson/src/internal/error_tables.cpp b/contrib/libs/simdjson/src/internal/error_tables.cpp index 43499bbab0..7f86e56718 100644 --- a/contrib/libs/simdjson/src/internal/error_tables.cpp +++ b/contrib/libs/simdjson/src/internal/error_tables.cpp @@ -11,7 +11,7 @@ namespace internal { { SUCCESS, "SUCCESS: No error" }, { CAPACITY, "CAPACITY: This parser can't support a document that big" }, { MEMALLOC, "MEMALLOC: Error allocating memory, we're most likely out of memory" }, - { TAPE_ERROR, "TAPE_ERROR: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc." }, + { TAPE_ERROR, "TAPE_ERROR: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. This is a fatal and unrecoverable error." }, { DEPTH_ERROR, "DEPTH_ERROR: The JSON document was too deep (too many nested objects and arrays)" }, { STRING_ERROR, "STRING_ERROR: Problem while parsing a string" }, { T_ATOM_ERROR, "T_ATOM_ERROR: Problem while parsing an atom starting with the letter 't'" }, @@ -36,7 +36,7 @@ namespace internal { { PARSER_IN_USE, "PARSER_IN_USE: Cannot parse a new document while a document is still in use." }, { OUT_OF_ORDER_ITERATION, "OUT_OF_ORDER_ITERATION: Objects and arrays can only be iterated when they are first encountered." }, { INSUFFICIENT_PADDING, "INSUFFICIENT_PADDING: simdjson requires the input JSON string to have at least SIMDJSON_PADDING extra bytes allocated, beyond the string's length. Consider using the simdjson::padded_string class if needed." }, - { INCOMPLETE_ARRAY_OR_OBJECT, "INCOMPLETE_ARRAY_OR_OBJECT: JSON document ended early in the middle of an object or array." }, + { INCOMPLETE_ARRAY_OR_OBJECT, "INCOMPLETE_ARRAY_OR_OBJECT: JSON document ended early in the middle of an object or array. This is a fatal and unrecoverable error." }, { SCALAR_DOCUMENT_AS_VALUE, "SCALAR_DOCUMENT_AS_VALUE: A JSON document made of a scalar (number, Boolean, null or string) is treated as a value. Use get_bool(), get_double(), etc. on the document instead. "}, { OUT_OF_BOUNDS, "OUT_OF_BOUNDS: Attempt to access location outside of document."}, { TRAILING_CONTENT, "TRAILING_CONTENT: Unexpected trailing content in the JSON input."} diff --git a/contrib/libs/simdjson/ya.make b/contrib/libs/simdjson/ya.make index 1f2e8bb1ea..70ff7467fa 100644 --- a/contrib/libs/simdjson/ya.make +++ b/contrib/libs/simdjson/ya.make @@ -10,9 +10,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(3.12.2) +VERSION(3.12.3) -ORIGINAL_SOURCE(https://github.com/simdjson/simdjson/archive/v3.12.2.tar.gz) +ORIGINAL_SOURCE(https://github.com/simdjson/simdjson/archive/v3.12.3.tar.gz) ADDINCL( GLOBAL contrib/libs/simdjson/include diff --git a/contrib/libs/snappy/.yandex_meta/override.nix b/contrib/libs/snappy/.yandex_meta/override.nix index 4ec7e2a3fc..45b24b0a1a 100644 --- a/contrib/libs/snappy/.yandex_meta/override.nix +++ b/contrib/libs/snappy/.yandex_meta/override.nix @@ -1,11 +1,11 @@ pkgs: attrs: with pkgs; with attrs; rec { - version = "1.2.1"; + version = "1.2.2"; src = fetchFromGitHub { owner = "google"; repo = "snappy"; rev = version; - hash = "sha256-IzKzrMDjh+Weor+OrKdX62cAKYTdDXgldxCgNE2/8vk="; + hash = "sha256-bMZD8EI9dvDGupfos4hi/0ShBkrJlI5Np9FxE6FfrNE="; }; patches = []; diff --git a/contrib/libs/snappy/NEWS b/contrib/libs/snappy/NEWS index 792a578001..ef935ba52f 100644 --- a/contrib/libs/snappy/NEWS +++ b/contrib/libs/snappy/NEWS @@ -1,3 +1,18 @@ +Snappy v1.2.2, Mar 26th 2025: + + * We added a new compression level in v1.2.1 which compresses a bit + denser but slower. Decompression speed should be even faster with it. + + * We fixed a very old issue of data corruption when compressed size + exceeds 4GB. This can happen when you compress data close to 4GB + and it's incompressible, for example, random data. + + * Started to use minimum CMake 3.10 because older ones are not + planned to be supported. + + * Various other small fixes and performance improvements (especially + for clang). + Snappy v1.1.10, Mar 8th 2023: * Performance improvements diff --git a/contrib/libs/snappy/README.md b/contrib/libs/snappy/README.md index 398be7d58a..9b4a49405c 100644 --- a/contrib/libs/snappy/README.md +++ b/contrib/libs/snappy/README.md @@ -140,10 +140,10 @@ explicitly supports the following: 1. C++11 2. Clang (gcc and MSVC are best-effort). 3. Low level optimizations (e.g. assembly or equivalent intrinsics) for: - 1. [x86](https://en.wikipedia.org/wiki/X86) - 2. [x86-64](https://en.wikipedia.org/wiki/X86-64) - 3. ARMv7 (32-bit) - 4. ARMv8 (AArch64) + - [x86](https://en.wikipedia.org/wiki/X86) + - [x86-64](https://en.wikipedia.org/wiki/X86-64) + - ARMv7 (32-bit) + - ARMv8 (AArch64) 4. Supports only the Snappy compression scheme as described in [format_description.txt](format_description.txt). 5. CMake for building diff --git a/contrib/libs/snappy/snappy-stubs-public.h b/contrib/libs/snappy/snappy-stubs-public.h index bc2a26a56c..a2dec74dcc 100644 --- a/contrib/libs/snappy/snappy-stubs-public.h +++ b/contrib/libs/snappy/snappy-stubs-public.h @@ -44,7 +44,7 @@ #define SNAPPY_MAJOR 1 #define SNAPPY_MINOR 2 -#define SNAPPY_PATCHLEVEL 1 +#define SNAPPY_PATCHLEVEL 2 #define SNAPPY_VERSION \ ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL) diff --git a/contrib/libs/snappy/snappy.cc b/contrib/libs/snappy/snappy.cc index a7b93f0f78..5a326eb408 100644 --- a/contrib/libs/snappy/snappy.cc +++ b/contrib/libs/snappy/snappy.cc @@ -74,6 +74,7 @@ #include <cstdint> #include <cstdio> #include <cstring> +#include <functional> #include <memory> #include <string> #include <utility> @@ -1499,7 +1500,7 @@ class SnappyDecompressor { // If ip < ip_limit_min_maxtaglen_ it's safe to read kMaxTagLength from // buffer. const char* ip_limit_min_maxtaglen_; - uint32_t peeked_; // Bytes peeked from reader (need to skip) + uint64_t peeked_; // Bytes peeked from reader (need to skip) bool eof_; // Hit end of input without an error? char scratch_[kMaximumTagLength]; // See RefillTag(). @@ -1690,7 +1691,8 @@ constexpr uint32_t CalculateNeeded(uint8_t tag) { #if __cplusplus >= 201402L constexpr bool VerifyCalculateNeeded() { for (int i = 0; i < 1; i++) { - if (CalculateNeeded(i) != (char_table[i] >> 11) + 1) return false; + if (CalculateNeeded(i) != static_cast<uint32_t>((char_table[i] >> 11)) + 1) + return false; } return true; } @@ -1726,7 +1728,7 @@ bool SnappyDecompressor::RefillTag() { assert(needed <= sizeof(scratch_)); // Read more bytes from reader if needed - uint32_t nbuf = ip_limit_ - ip; + uint64_t nbuf = ip_limit_ - ip; if (nbuf < needed) { // Stitch together bytes from ip and reader to form the word // contents. We store the needed bytes in "scratch_". They @@ -1739,7 +1741,7 @@ bool SnappyDecompressor::RefillTag() { size_t length; const char* src = reader_->Peek(&length); if (length == 0) return false; - uint32_t to_add = std::min<uint32_t>(needed - nbuf, length); + uint64_t to_add = std::min<uint64_t>(needed - nbuf, length); std::memcpy(scratch_ + nbuf, src, to_add); nbuf += to_add; reader_->Skip(to_add); @@ -1802,6 +1804,7 @@ size_t Compress(Source* reader, Sink* writer, CompressionOptions options) { int token = 0; size_t written = 0; size_t N = reader->Available(); + assert(N <= 0xFFFFFFFFu); const size_t uncompressed_size = N; char ulength[Varint::kMax32]; char* p = Varint::Encode32(ulength, N); diff --git a/contrib/libs/snappy/ya.make b/contrib/libs/snappy/ya.make index f2bc4c7f1a..ff6546925f 100644 --- a/contrib/libs/snappy/ya.make +++ b/contrib/libs/snappy/ya.make @@ -6,9 +6,9 @@ LICENSE(BSD-3-Clause) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(1.2.1) +VERSION(1.2.2) -ORIGINAL_SOURCE(https://github.com/google/snappy/archive/1.2.1.tar.gz) +ORIGINAL_SOURCE(https://github.com/google/snappy/archive/1.2.2.tar.gz) PEERDIR( library/cpp/sanitizer/include |