diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index af74b108e04e..f85c04df4f6c 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -1,774 +1,774 @@ //===--- Linux.h - Linux ToolChain Implementations --------------*- 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 // //===----------------------------------------------------------------------===// #include "Linux.h" #include "Arch/ARM.h" #include "Arch/Mips.h" #include "Arch/PPC.h" #include "Arch/RISCV.h" #include "CommonArgs.h" #include "clang/Config/config.h" #include "clang/Driver/Distro.h" #include "clang/Driver/Driver.h" #include "clang/Driver/Options.h" #include "clang/Driver/SanitizerArgs.h" #include "llvm/Option/ArgList.h" #include "llvm/ProfileData/InstrProf.h" #include "llvm/Support/Path.h" #include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/VirtualFileSystem.h" #include using namespace clang::driver; using namespace clang::driver::toolchains; using namespace clang; using namespace llvm::opt; using tools::addPathIfExists; /// Get our best guess at the multiarch triple for a target. /// /// Debian-based systems are starting to use a multiarch setup where they use /// a target-triple directory in the library and header search paths. /// Unfortunately, this triple does not align with the vanilla target triple, /// so we provide a rough mapping here. std::string Linux::getMultiarchTriple(const Driver &D, const llvm::Triple &TargetTriple, StringRef SysRoot) const { llvm::Triple::EnvironmentType TargetEnvironment = TargetTriple.getEnvironment(); bool IsAndroid = TargetTriple.isAndroid(); bool IsMipsR6 = TargetTriple.getSubArch() == llvm::Triple::MipsSubArch_r6; bool IsMipsN32Abi = TargetTriple.getEnvironment() == llvm::Triple::GNUABIN32; // For most architectures, just use whatever we have rather than trying to be // clever. switch (TargetTriple.getArch()) { default: break; // We use the existence of '/lib/' as a directory to detect some // common linux triples that don't quite match the Clang triple for both // 32-bit and 64-bit targets. Multiarch fixes its install triples to these // regardless of what the actual target triple is. case llvm::Triple::arm: case llvm::Triple::thumb: if (IsAndroid) return "arm-linux-androideabi"; if (TargetEnvironment == llvm::Triple::GNUEABIHF) return "arm-linux-gnueabihf"; return "arm-linux-gnueabi"; case llvm::Triple::armeb: case llvm::Triple::thumbeb: if (TargetEnvironment == llvm::Triple::GNUEABIHF) return "armeb-linux-gnueabihf"; return "armeb-linux-gnueabi"; case llvm::Triple::x86: if (IsAndroid) return "i686-linux-android"; return "i386-linux-gnu"; case llvm::Triple::x86_64: if (IsAndroid) return "x86_64-linux-android"; if (TargetEnvironment == llvm::Triple::GNUX32) return "x86_64-linux-gnux32"; return "x86_64-linux-gnu"; case llvm::Triple::aarch64: if (IsAndroid) return "aarch64-linux-android"; return "aarch64-linux-gnu"; case llvm::Triple::aarch64_be: return "aarch64_be-linux-gnu"; case llvm::Triple::m68k: return "m68k-linux-gnu"; case llvm::Triple::mips: return IsMipsR6 ? "mipsisa32r6-linux-gnu" : "mips-linux-gnu"; case llvm::Triple::mipsel: if (IsAndroid) return "mipsel-linux-android"; return IsMipsR6 ? "mipsisa32r6el-linux-gnu" : "mipsel-linux-gnu"; case llvm::Triple::mips64: { std::string MT = std::string(IsMipsR6 ? "mipsisa64r6" : "mips64") + "-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64"); if (D.getVFS().exists(SysRoot + "/lib/" + MT)) return MT; if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnu")) return "mips64-linux-gnu"; break; } case llvm::Triple::mips64el: { if (IsAndroid) return "mips64el-linux-android"; std::string MT = std::string(IsMipsR6 ? "mipsisa64r6el" : "mips64el") + "-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64"); if (D.getVFS().exists(SysRoot + "/lib/" + MT)) return MT; if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnu")) return "mips64el-linux-gnu"; break; } case llvm::Triple::ppc: if (D.getVFS().exists(SysRoot + "/lib/powerpc-linux-gnuspe")) return "powerpc-linux-gnuspe"; return "powerpc-linux-gnu"; case llvm::Triple::ppcle: return "powerpcle-linux-gnu"; case llvm::Triple::ppc64: return "powerpc64-linux-gnu"; case llvm::Triple::ppc64le: return "powerpc64le-linux-gnu"; case llvm::Triple::sparc: return "sparc-linux-gnu"; case llvm::Triple::sparcv9: return "sparc64-linux-gnu"; case llvm::Triple::systemz: return "s390x-linux-gnu"; } return TargetTriple.str(); } static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) { if (Triple.isMIPS()) { if (Triple.isAndroid()) { StringRef CPUName; StringRef ABIName; tools::mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName); if (CPUName == "mips32r6") return "libr6"; if (CPUName == "mips32r2") return "libr2"; } // lib32 directory has a special meaning on MIPS targets. // It contains N32 ABI binaries. Use this folder if produce // code for N32 ABI only. if (tools::mips::hasMipsAbiArg(Args, "n32")) return "lib32"; return Triple.isArch32Bit() ? "lib" : "lib64"; } // It happens that only x86, PPC and SPARC use the 'lib32' variant of // oslibdir, and using that variant while targeting other architectures causes // problems because the libraries are laid out in shared system roots that // can't cope with a 'lib32' library search path being considered. So we only // enable them when we know we may need it. // // FIXME: This is a bit of a hack. We should really unify this code for // reasoning about oslibdir spellings with the lib dir spellings in the // GCCInstallationDetector, but that is a more significant refactoring. if (Triple.getArch() == llvm::Triple::x86 || Triple.isPPC32() || Triple.getArch() == llvm::Triple::sparc) return "lib32"; if (Triple.getArch() == llvm::Triple::x86_64 && Triple.isX32()) return "libx32"; if (Triple.getArch() == llvm::Triple::riscv32) return "lib32"; return Triple.isArch32Bit() ? "lib" : "lib64"; } Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) : Generic_ELF(D, Triple, Args) { GCCInstallation.init(Triple, Args); Multilibs = GCCInstallation.getMultilibs(); SelectedMultilib = GCCInstallation.getMultilib(); llvm::Triple::ArchType Arch = Triple.getArch(); std::string SysRoot = computeSysRoot(); ToolChain::path_list &PPaths = getProgramPaths(); Generic_GCC::PushPPaths(PPaths); Distro Distro(D.getVFS(), Triple); if (Distro.IsAlpineLinux() || Triple.isAndroid()) { ExtraOpts.push_back("-z"); ExtraOpts.push_back("now"); } if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() || Triple.isAndroid()) { ExtraOpts.push_back("-z"); ExtraOpts.push_back("relro"); } // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld // from 11 onwards default max-page-size to 65536 for both ARM and AArch64. if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) { ExtraOpts.push_back("-z"); ExtraOpts.push_back("max-page-size=4096"); } if (GCCInstallation.getParentLibPath().contains("opt/rh/")) // With devtoolset on RHEL, we want to add a bin directory that is relative // to the detected gcc install, because if we are using devtoolset gcc then // we want to use other tools from devtoolset (e.g. ld) instead of the // standard system tools. PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../bin").str()); if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb) ExtraOpts.push_back("-X"); const bool IsAndroid = Triple.isAndroid(); const bool IsMips = Triple.isMIPS(); const bool IsHexagon = Arch == llvm::Triple::hexagon; const bool IsRISCV = Triple.isRISCV(); if (IsMips && !SysRoot.empty()) ExtraOpts.push_back("--sysroot=" + SysRoot); // Do not use 'gnu' hash style for Mips targets because .gnu.hash // and the MIPS ABI require .dynsym to be sorted in different ways. // .gnu.hash needs symbols to be grouped by hash code whereas the MIPS // ABI requires a mapping between the GOT and the symbol table. // Android loader does not support .gnu.hash until API 23. // Hexagon linker/loader does not support .gnu.hash if (!IsMips && !IsHexagon) { if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() || (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick) || (IsAndroid && !Triple.isAndroidVersionLT(23))) ExtraOpts.push_back("--hash-style=gnu"); if (Distro.IsDebian() || Distro.IsOpenSUSE() || Distro == Distro::UbuntuLucid || Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic || (IsAndroid && Triple.isAndroidVersionLT(23))) ExtraOpts.push_back("--hash-style=both"); } #ifdef ENABLE_LINKER_BUILD_ID ExtraOpts.push_back("--build-id"); #endif if (IsAndroid || Distro.IsOpenSUSE()) ExtraOpts.push_back("--enable-new-dtags"); // The selection of paths to try here is designed to match the patterns which // the GCC driver itself uses, as this is part of the GCC-compatible driver. // This was determined by running GCC in a fake filesystem, creating all // possible permutations of these directories, and seeing which ones it added // to the link paths. path_list &Paths = getFilePaths(); const std::string OSLibDir = std::string(getOSLibDir(Triple, Args)); const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot); // mips32: Debian multilib, we use /libo32, while in other case, /lib is // used. We need add both libo32 and /lib. if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel) { Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, Paths); addPathIfExists(D, SysRoot + "/libo32", Paths); addPathIfExists(D, SysRoot + "/usr/libo32", Paths); } Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths); addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths); addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths); if (IsAndroid) { // Android sysroots contain a library directory for each supported OS // version as well as some unversioned libraries in the usual multiarch // directory. addPathIfExists( D, SysRoot + "/usr/lib/" + MultiarchTriple + "/" + llvm::to_string(Triple.getEnvironmentVersion().getMajor()), Paths); } addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths); // 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot // find /usr/lib64 as it is referenced as /usr/lib/../lib64. So we handle // this here. if (Triple.getVendor() == llvm::Triple::OpenEmbedded && Triple.isArch64Bit()) addPathIfExists(D, SysRoot + "/usr/" + OSLibDir, Paths); else addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths); if (IsRISCV) { StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple); addPathIfExists(D, SysRoot + "/" + OSLibDir + "/" + ABIName, Paths); addPathIfExists(D, SysRoot + "/usr/" + OSLibDir + "/" + ABIName, Paths); } Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths); // Similar to the logic for GCC above, if we are currently running Clang // inside of the requested system root, add its parent library path to those // searched. // FIXME: It's not clear whether we should use the driver's installed // directory ('Dir' below) or the ResourceDir. if (StringRef(D.Dir).startswith(SysRoot)) { // Even if OSLibDir != "lib", this is needed for Clang in the build // directory (not installed) to find libc++. addPathIfExists(D, D.Dir + "/../lib", Paths); if (OSLibDir != "lib") addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths); } addPathIfExists(D, SysRoot + "/lib", Paths); addPathIfExists(D, SysRoot + "/usr/lib", Paths); } ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const { if (getTriple().isAndroid()) return ToolChain::RLT_CompilerRT; return Generic_ELF::GetDefaultRuntimeLibType(); } unsigned Linux::GetDefaultDwarfVersion() const { if (getTriple().isAndroid()) return 4; return ToolChain::GetDefaultDwarfVersion(); } ToolChain::CXXStdlibType Linux::GetDefaultCXXStdlibType() const { if (getTriple().isAndroid()) return ToolChain::CST_Libcxx; return ToolChain::CST_Libstdcxx; } bool Linux::HasNativeLLVMSupport() const { return true; } Tool *Linux::buildLinker() const { return new tools::gnutools::Linker(*this); } Tool *Linux::buildStaticLibTool() const { return new tools::gnutools::StaticLibTool(*this); } Tool *Linux::buildAssembler() const { return new tools::gnutools::Assembler(*this); } std::string Linux::computeSysRoot() const { if (!getDriver().SysRoot.empty()) return getDriver().SysRoot; if (getTriple().isAndroid()) { // Android toolchains typically include a sysroot at ../sysroot relative to // the clang binary. const StringRef ClangDir = getDriver().getInstalledDir(); std::string AndroidSysRootPath = (ClangDir + "/../sysroot").str(); if (getVFS().exists(AndroidSysRootPath)) return AndroidSysRootPath; } if (!GCCInstallation.isValid() || !getTriple().isMIPS()) return std::string(); // Standalone MIPS toolchains use different names for sysroot folder // and put it into different places. Here we try to check some known // variants. const StringRef InstallDir = GCCInstallation.getInstallPath(); const StringRef TripleStr = GCCInstallation.getTriple().str(); const Multilib &Multilib = GCCInstallation.getMultilib(); std::string Path = (InstallDir + "/../../../../" + TripleStr + "/libc" + Multilib.osSuffix()) .str(); if (getVFS().exists(Path)) return Path; Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str(); if (getVFS().exists(Path)) return Path; return std::string(); } std::string Linux::getDynamicLinker(const ArgList &Args) const { const llvm::Triple::ArchType Arch = getArch(); const llvm::Triple &Triple = getTriple(); const Distro Distro(getDriver().getVFS(), Triple); if (Triple.isAndroid()) return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker"; if (Triple.isMusl()) { std::string ArchName; bool IsArm = false; switch (Arch) { case llvm::Triple::arm: case llvm::Triple::thumb: ArchName = "arm"; IsArm = true; break; case llvm::Triple::armeb: case llvm::Triple::thumbeb: ArchName = "armeb"; IsArm = true; break; case llvm::Triple::x86: ArchName = "i386"; break; case llvm::Triple::x86_64: ArchName = Triple.isX32() ? "x32" : Triple.getArchName().str(); break; default: ArchName = Triple.getArchName().str(); } if (IsArm && (Triple.getEnvironment() == llvm::Triple::MuslEABIHF || tools::arm::getARMFloatABI(*this, Args) == tools::arm::FloatABI::Hard)) ArchName += "hf"; if (Arch == llvm::Triple::ppc && Triple.getSubArch() == llvm::Triple::PPCSubArch_spe) ArchName = "powerpc-sf"; return "/lib/ld-musl-" + ArchName + ".so.1"; } std::string LibDir; std::string Loader; switch (Arch) { default: llvm_unreachable("unsupported architecture"); case llvm::Triple::aarch64: LibDir = "lib"; Loader = "ld-linux-aarch64.so.1"; break; case llvm::Triple::aarch64_be: LibDir = "lib"; Loader = "ld-linux-aarch64_be.so.1"; break; case llvm::Triple::arm: case llvm::Triple::thumb: case llvm::Triple::armeb: case llvm::Triple::thumbeb: { const bool HF = Triple.getEnvironment() == llvm::Triple::GNUEABIHF || tools::arm::getARMFloatABI(*this, Args) == tools::arm::FloatABI::Hard; LibDir = "lib"; Loader = HF ? "ld-linux-armhf.so.3" : "ld-linux.so.3"; break; } case llvm::Triple::m68k: LibDir = "lib"; Loader = "ld.so.1"; break; case llvm::Triple::mips: case llvm::Triple::mipsel: case llvm::Triple::mips64: case llvm::Triple::mips64el: { bool IsNaN2008 = tools::mips::isNaN2008(getDriver(), Args, Triple); LibDir = "lib" + tools::mips::getMipsABILibSuffix(Args, Triple); if (tools::mips::isUCLibc(Args)) Loader = IsNaN2008 ? "ld-uClibc-mipsn8.so.0" : "ld-uClibc.so.0"; else if (!Triple.hasEnvironment() && Triple.getVendor() == llvm::Triple::VendorType::MipsTechnologies) Loader = Triple.isLittleEndian() ? "ld-musl-mipsel.so.1" : "ld-musl-mips.so.1"; else Loader = IsNaN2008 ? "ld-linux-mipsn8.so.1" : "ld.so.1"; break; } case llvm::Triple::ppc: LibDir = "lib"; Loader = "ld.so.1"; break; case llvm::Triple::ppcle: LibDir = "lib"; Loader = "ld.so.1"; break; case llvm::Triple::ppc64: LibDir = "lib64"; Loader = (tools::ppc::hasPPCAbiArg(Args, "elfv2")) ? "ld64.so.2" : "ld64.so.1"; break; case llvm::Triple::ppc64le: LibDir = "lib64"; Loader = (tools::ppc::hasPPCAbiArg(Args, "elfv1")) ? "ld64.so.1" : "ld64.so.2"; break; case llvm::Triple::riscv32: { StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple); LibDir = "lib"; Loader = ("ld-linux-riscv32-" + ABIName + ".so.1").str(); break; } case llvm::Triple::riscv64: { StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple); LibDir = "lib"; Loader = ("ld-linux-riscv64-" + ABIName + ".so.1").str(); break; } case llvm::Triple::sparc: case llvm::Triple::sparcel: LibDir = "lib"; Loader = "ld-linux.so.2"; break; case llvm::Triple::sparcv9: LibDir = "lib64"; Loader = "ld-linux.so.2"; break; case llvm::Triple::systemz: LibDir = "lib"; Loader = "ld64.so.1"; break; case llvm::Triple::x86: LibDir = "lib"; Loader = "ld-linux.so.2"; break; case llvm::Triple::x86_64: { bool X32 = Triple.isX32(); LibDir = X32 ? "libx32" : "lib64"; Loader = X32 ? "ld-linux-x32.so.2" : "ld-linux-x86-64.so.2"; break; } case llvm::Triple::ve: return "/opt/nec/ve/lib/ld-linux-ve.so.1"; } if (Distro == Distro::Exherbo && (Triple.getVendor() == llvm::Triple::UnknownVendor || Triple.getVendor() == llvm::Triple::PC)) return "/usr/" + Triple.str() + "/lib/" + Loader; return "/" + LibDir + "/" + Loader; } void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, ArgStringList &CC1Args) const { const Driver &D = getDriver(); std::string SysRoot = computeSysRoot(); if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc)) return; // Add 'include' in the resource directory, which is similar to // GCC_INCLUDE_DIR (private headers) in GCC. Note: the include directory // contains some files conflicting with system /usr/include. musl systems // prefer the /usr/include copies which are more relevant. SmallString<128> ResourceDirInclude(D.ResourceDir); llvm::sys::path::append(ResourceDirInclude, "include"); if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && (!getTriple().isMusl() || DriverArgs.hasArg(options::OPT_nostdlibinc))) addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude); if (DriverArgs.hasArg(options::OPT_nostdlibinc)) return; // LOCAL_INCLUDE_DIR addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include"); // TOOL_INCLUDE_DIR AddMultilibIncludeArgs(DriverArgs, CC1Args); // Check for configure-time C include directories. StringRef CIncludeDirs(C_INCLUDE_DIRS); if (CIncludeDirs != "") { SmallVector dirs; CIncludeDirs.split(dirs, ":"); for (StringRef dir : dirs) { StringRef Prefix = llvm::sys::path::is_absolute(dir) ? "" : StringRef(SysRoot); addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir); } return; } // On systems using multiarch and Android, add /usr/include/$triple before // /usr/include. std::string MultiarchIncludeDir = getMultiarchTriple(D, getTriple(), SysRoot); if (!MultiarchIncludeDir.empty() && D.getVFS().exists(SysRoot + "/usr/include/" + MultiarchIncludeDir)) addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include/" + MultiarchIncludeDir); if (getTriple().getOS() == llvm::Triple::RTEMS) return; // Add an include of '/include' directly. This isn't provided by default by // system GCCs, but is often used with cross-compiling GCCs, and harmless to // add even when Clang is acting as-if it were a system compiler. addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include"); addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && getTriple().isMusl()) addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude); } void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const { // We need a detected GCC installation on Linux to provide libstdc++'s // headers in odd Linuxish places. if (!GCCInstallation.isValid()) return; // Detect Debian g++-multiarch-incdir.diff. StringRef TripleStr = GCCInstallation.getTriple().str(); StringRef DebianMultiarch = GCCInstallation.getTriple().getArch() == llvm::Triple::x86 ? "i386-linux-gnu" : TripleStr; // Try generic GCC detection first. if (Generic_GCC::addGCCLibStdCxxIncludePaths(DriverArgs, CC1Args, DebianMultiarch)) return; StringRef LibDir = GCCInstallation.getParentLibPath(); const Multilib &Multilib = GCCInstallation.getMultilib(); const GCCVersion &Version = GCCInstallation.getVersion(); const std::string LibStdCXXIncludePathCandidates[] = { // Android standalone toolchain has C++ headers in yet another place. LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text, // Freescale SDK C++ headers are directly in /usr/include/c++, // without a subdirectory corresponding to the gcc version. LibDir.str() + "/../include/c++", // Cray's gcc installation puts headers under "g++" without a // version suffix. LibDir.str() + "/../include/g++", }; for (const auto &IncludePath : LibStdCXXIncludePathCandidates) { if (addLibStdCXXIncludePaths(IncludePath, TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args)) break; } } void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs, ArgStringList &CC1Args) const { CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args); } void Linux::AddHIPIncludeArgs(const ArgList &DriverArgs, ArgStringList &CC1Args) const { RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args); } void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs, ArgStringList &CC1Args) const { if (GCCInstallation.isValid()) { CC1Args.push_back("-isystem"); CC1Args.push_back(DriverArgs.MakeArgString( GCCInstallation.getParentLibPath() + "/../" + GCCInstallation.getTriple().str() + "/include")); } } bool Linux::isPIEDefault(const llvm::opt::ArgList &Args) const { return CLANG_DEFAULT_PIE_ON_LINUX || getTriple().isAndroid() || getTriple().isMusl() || getSanitizerArgs(Args).requiresPIE(); } bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList &Args) const { // Outline atomics for AArch64 are supported by compiler-rt // and libgcc since 9.3.1 assert(getTriple().isAArch64() && "expected AArch64 target!"); ToolChain::RuntimeLibType RtLib = GetRuntimeLibType(Args); if (RtLib == ToolChain::RLT_CompilerRT) return true; assert(RtLib == ToolChain::RLT_Libgcc && "unexpected runtime library type!"); if (GCCInstallation.getVersion().isOlderThan(9, 3, 1)) return false; return true; } bool Linux::IsMathErrnoDefault() const { - if (getTriple().isAndroid()) + if (getTriple().isAndroid() || getTriple().isMusl()) return false; return Generic_ELF::IsMathErrnoDefault(); } SanitizerMask Linux::getSupportedSanitizers() const { const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; const bool IsMIPS = getTriple().isMIPS32(); const bool IsMIPS64 = getTriple().isMIPS64(); const bool IsPowerPC64 = getTriple().getArch() == llvm::Triple::ppc64 || getTriple().getArch() == llvm::Triple::ppc64le; const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 || getTriple().getArch() == llvm::Triple::aarch64_be; const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm || getTriple().getArch() == llvm::Triple::thumb || getTriple().getArch() == llvm::Triple::armeb || getTriple().getArch() == llvm::Triple::thumbeb; const bool IsRISCV64 = getTriple().getArch() == llvm::Triple::riscv64; const bool IsSystemZ = getTriple().getArch() == llvm::Triple::systemz; const bool IsHexagon = getTriple().getArch() == llvm::Triple::hexagon; SanitizerMask Res = ToolChain::getSupportedSanitizers(); Res |= SanitizerKind::Address; Res |= SanitizerKind::PointerCompare; Res |= SanitizerKind::PointerSubtract; Res |= SanitizerKind::Fuzzer; Res |= SanitizerKind::FuzzerNoLink; Res |= SanitizerKind::KernelAddress; Res |= SanitizerKind::Memory; Res |= SanitizerKind::Vptr; Res |= SanitizerKind::SafeStack; if (IsX86_64 || IsMIPS64 || IsAArch64) Res |= SanitizerKind::DataFlow; if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64 || IsRISCV64 || IsSystemZ || IsHexagon) Res |= SanitizerKind::Leak; if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64 || IsSystemZ) Res |= SanitizerKind::Thread; if (IsX86_64) Res |= SanitizerKind::KernelMemory; if (IsX86 || IsX86_64) Res |= SanitizerKind::Function; if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch || IsPowerPC64 || IsHexagon) Res |= SanitizerKind::Scudo; if (IsX86_64 || IsAArch64) { Res |= SanitizerKind::HWAddress; Res |= SanitizerKind::KernelHWAddress; } return Res; } void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const { // Add linker option -u__llvm_profile_runtime to cause runtime // initialization module to be linked in. if (needsProfileRT(Args)) CmdArgs.push_back(Args.MakeArgString( Twine("-u", llvm::getInstrProfRuntimeHookVarName()))); ToolChain::addProfileRTLibs(Args, CmdArgs); } llvm::DenormalMode Linux::getDefaultDenormalModeForType(const llvm::opt::ArgList &DriverArgs, const JobAction &JA, const llvm::fltSemantics *FPType) const { switch (getTriple().getArch()) { case llvm::Triple::x86: case llvm::Triple::x86_64: { std::string Unused; // DAZ and FTZ are turned on in crtfastmath.o if (!DriverArgs.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) && isFastMathRuntimeAvailable(DriverArgs, Unused)) return llvm::DenormalMode::getPreserveSign(); return llvm::DenormalMode::getIEEE(); } default: return llvm::DenormalMode::getIEEE(); } } void Linux::addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const { for (const auto &Opt : ExtraOpts) CmdArgs.push_back(Opt.c_str()); } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp index 82048f0eae2e..32b8f47ed633 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp @@ -1,1308 +1,1308 @@ //===-- sanitizer_platform_limits_posix.cpp -------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // // This file is a part of Sanitizer common code. // // Sizes and layouts of platform-specific POSIX data structures. //===----------------------------------------------------------------------===// #if defined(__linux__) || defined(__APPLE__) // Tests in this file assume that off_t-dependent data structures match the // libc ABI. For example, struct dirent here is what readdir() function (as // exported from libc) returns, and not the user-facing "dirent", which // depends on _FILE_OFFSET_BITS setting. // To get this "true" dirent definition, we undefine _FILE_OFFSET_BITS below. #undef _FILE_OFFSET_BITS #endif // Must go after undef _FILE_OFFSET_BITS. #include "sanitizer_platform.h" #if SANITIZER_LINUX || SANITIZER_MAC // Must go after undef _FILE_OFFSET_BITS. #include "sanitizer_glibc_version.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if !SANITIZER_MAC #include #endif #if !SANITIZER_IOS #include #endif #if !SANITIZER_ANDROID #include #include #include #endif #if SANITIZER_LINUX #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif #if SANITIZER_IOS #undef IOC_DIRMASK #endif #if SANITIZER_LINUX # include # include # if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \ defined(__hexagon__) || SANITIZER_RISCV64 # include # ifdef __arm__ typedef struct user_fpregs elf_fpregset_t; # define ARM_VFPREGS_SIZE_ASAN (32 * 8 /*fpregs*/ + 4 /*fpscr*/) # if !defined(ARM_VFPREGS_SIZE) # define ARM_VFPREGS_SIZE ARM_VFPREGS_SIZE_ASAN # endif # endif # endif # include #endif #if !SANITIZER_ANDROID #include #include #include #endif #if SANITIZER_LINUX #if SANITIZER_GLIBC #include #include #include #include #include #include #if HAVE_RPC_XDR_H # include #endif #include #else #include #include #include #endif // SANITIZER_GLIBC #if SANITIZER_ANDROID #include #else #include #include #include #include #include #include #include #if defined(__mips64) # include #endif #include #include #include #include #include #include #include #include #include #include #include #endif // SANITIZER_ANDROID #include #include #include #include #else #include #endif // SANITIZER_LINUX #if SANITIZER_MAC #include #include #include #endif // Include these after system headers to avoid name clashes and ambiguities. # include "sanitizer_common.h" # include "sanitizer_internal_defs.h" # include "sanitizer_platform_limits_posix.h" namespace __sanitizer { unsigned struct_utsname_sz = sizeof(struct utsname); unsigned struct_stat_sz = sizeof(struct stat); #if !SANITIZER_IOS && !(SANITIZER_MAC && TARGET_CPU_ARM64) unsigned struct_stat64_sz = sizeof(struct stat64); #endif // !SANITIZER_IOS && !(SANITIZER_MAC && TARGET_CPU_ARM64) unsigned struct_rusage_sz = sizeof(struct rusage); unsigned struct_tm_sz = sizeof(struct tm); unsigned struct_passwd_sz = sizeof(struct passwd); unsigned struct_group_sz = sizeof(struct group); unsigned siginfo_t_sz = sizeof(siginfo_t); unsigned struct_sigaction_sz = sizeof(struct sigaction); unsigned struct_stack_t_sz = sizeof(stack_t); unsigned struct_itimerval_sz = sizeof(struct itimerval); unsigned pthread_t_sz = sizeof(pthread_t); unsigned pthread_mutex_t_sz = sizeof(pthread_mutex_t); unsigned pthread_cond_t_sz = sizeof(pthread_cond_t); unsigned pid_t_sz = sizeof(pid_t); unsigned timeval_sz = sizeof(timeval); unsigned uid_t_sz = sizeof(uid_t); unsigned gid_t_sz = sizeof(gid_t); unsigned mbstate_t_sz = sizeof(mbstate_t); unsigned sigset_t_sz = sizeof(sigset_t); unsigned struct_timezone_sz = sizeof(struct timezone); unsigned struct_tms_sz = sizeof(struct tms); unsigned struct_sigevent_sz = sizeof(struct sigevent); unsigned struct_sched_param_sz = sizeof(struct sched_param); unsigned struct_regex_sz = sizeof(regex_t); unsigned struct_regmatch_sz = sizeof(regmatch_t); #if (SANITIZER_MAC && !TARGET_CPU_ARM64) && !SANITIZER_IOS unsigned struct_statfs64_sz = sizeof(struct statfs64); #endif // (SANITIZER_MAC && !TARGET_CPU_ARM64) && !SANITIZER_IOS #if SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD || SANITIZER_MAC unsigned struct_fstab_sz = sizeof(struct fstab); #endif // SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD || // SANITIZER_MAC #if !SANITIZER_ANDROID unsigned struct_statfs_sz = sizeof(struct statfs); unsigned struct_sockaddr_sz = sizeof(struct sockaddr); unsigned ucontext_t_sz(void *ctx) { -# if SANITIZER_LINUX && SANITIZER_X64 +# if SANITIZER_GLIBC && SANITIZER_X64 // See kernel arch/x86/kernel/fpu/signal.c for details. const auto *fpregs = static_cast(ctx)->uc_mcontext.fpregs; // The member names differ across header versions, but the actual layout // is always the same. So avoid using members, just use arithmetic. const uint32_t *after_xmm = reinterpret_cast(fpregs + 1) - 24; if (after_xmm[12] == FP_XSTATE_MAGIC1) return reinterpret_cast(fpregs) + after_xmm[13] - static_cast(ctx); # endif return sizeof(ucontext_t); } # endif // !SANITIZER_ANDROID # if SANITIZER_LINUX unsigned struct_epoll_event_sz = sizeof(struct epoll_event); unsigned struct_sysinfo_sz = sizeof(struct sysinfo); unsigned __user_cap_header_struct_sz = sizeof(struct __user_cap_header_struct); unsigned __user_cap_data_struct_sz = sizeof(struct __user_cap_data_struct); unsigned struct_new_utsname_sz = sizeof(struct new_utsname); unsigned struct_old_utsname_sz = sizeof(struct old_utsname); unsigned struct_oldold_utsname_sz = sizeof(struct oldold_utsname); #endif // SANITIZER_LINUX #if SANITIZER_LINUX unsigned struct_rlimit_sz = sizeof(struct rlimit); unsigned struct_timespec_sz = sizeof(struct timespec); unsigned struct_utimbuf_sz = sizeof(struct utimbuf); unsigned struct_itimerspec_sz = sizeof(struct itimerspec); #endif // SANITIZER_LINUX #if SANITIZER_LINUX && !SANITIZER_ANDROID // Use pre-computed size of struct ustat to avoid which // has been removed from glibc 2.28. #if defined(__aarch64__) || defined(__s390x__) || defined(__mips64) || \ defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) || \ defined(__x86_64__) || SANITIZER_RISCV64 #define SIZEOF_STRUCT_USTAT 32 # elif defined(__arm__) || defined(__i386__) || defined(__mips__) || \ defined(__powerpc__) || defined(__s390__) || defined(__sparc__) || \ defined(__hexagon__) # define SIZEOF_STRUCT_USTAT 20 # else # error Unknown size of struct ustat # endif unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT; unsigned struct_rlimit64_sz = sizeof(struct rlimit64); unsigned struct_statvfs64_sz = sizeof(struct statvfs64); unsigned struct_crypt_data_sz = sizeof(struct crypt_data); #endif // SANITIZER_LINUX && !SANITIZER_ANDROID #if SANITIZER_LINUX && !SANITIZER_ANDROID unsigned struct_timex_sz = sizeof(struct timex); unsigned struct_msqid_ds_sz = sizeof(struct msqid_ds); unsigned struct_mq_attr_sz = sizeof(struct mq_attr); unsigned struct_statvfs_sz = sizeof(struct statvfs); #endif // SANITIZER_LINUX && !SANITIZER_ANDROID const uptr sig_ign = (uptr)SIG_IGN; const uptr sig_dfl = (uptr)SIG_DFL; const uptr sig_err = (uptr)SIG_ERR; const uptr sa_siginfo = (uptr)SA_SIGINFO; #if SANITIZER_LINUX int e_tabsz = (int)E_TABSZ; #endif #if SANITIZER_LINUX && !SANITIZER_ANDROID unsigned struct_shminfo_sz = sizeof(struct shminfo); unsigned struct_shm_info_sz = sizeof(struct shm_info); int shmctl_ipc_stat = (int)IPC_STAT; int shmctl_ipc_info = (int)IPC_INFO; int shmctl_shm_info = (int)SHM_INFO; int shmctl_shm_stat = (int)SHM_STAT; #endif #if !SANITIZER_MAC && !SANITIZER_FREEBSD unsigned struct_utmp_sz = sizeof(struct utmp); #endif #if !SANITIZER_ANDROID unsigned struct_utmpx_sz = sizeof(struct utmpx); #endif int map_fixed = MAP_FIXED; int af_inet = (int)AF_INET; int af_inet6 = (int)AF_INET6; uptr __sanitizer_in_addr_sz(int af) { if (af == AF_INET) return sizeof(struct in_addr); else if (af == AF_INET6) return sizeof(struct in6_addr); else return 0; } #if SANITIZER_LINUX unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); #elif SANITIZER_FREEBSD unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); #endif #if SANITIZER_GLIBC int glob_nomatch = GLOB_NOMATCH; int glob_altdirfunc = GLOB_ALTDIRFUNC; #endif # if !SANITIZER_ANDROID const int wordexp_wrde_dooffs = WRDE_DOOFFS; # endif // !SANITIZER_ANDROID #if SANITIZER_LINUX && !SANITIZER_ANDROID && \ (defined(__i386) || defined(__x86_64) || defined(__mips64) || \ defined(__powerpc64__) || defined(__aarch64__) || defined(__arm__) || \ defined(__s390__) || SANITIZER_RISCV64) #if defined(__mips64) || defined(__powerpc64__) || defined(__arm__) unsigned struct_user_regs_struct_sz = sizeof(struct pt_regs); unsigned struct_user_fpregs_struct_sz = sizeof(elf_fpregset_t); #elif SANITIZER_RISCV64 unsigned struct_user_regs_struct_sz = sizeof(struct user_regs_struct); unsigned struct_user_fpregs_struct_sz = sizeof(struct __riscv_q_ext_state); #elif defined(__aarch64__) unsigned struct_user_regs_struct_sz = sizeof(struct user_pt_regs); unsigned struct_user_fpregs_struct_sz = sizeof(struct user_fpsimd_state); #elif defined(__s390__) unsigned struct_user_regs_struct_sz = sizeof(struct _user_regs_struct); unsigned struct_user_fpregs_struct_sz = sizeof(struct _user_fpregs_struct); #else unsigned struct_user_regs_struct_sz = sizeof(struct user_regs_struct); unsigned struct_user_fpregs_struct_sz = sizeof(struct user_fpregs_struct); #endif // __mips64 || __powerpc64__ || __aarch64__ #if defined(__x86_64) || defined(__mips64) || defined(__powerpc64__) || \ defined(__aarch64__) || defined(__arm__) || defined(__s390__) || \ SANITIZER_RISCV64 unsigned struct_user_fpxregs_struct_sz = 0; #else unsigned struct_user_fpxregs_struct_sz = sizeof(struct user_fpxregs_struct); #endif // __x86_64 || __mips64 || __powerpc64__ || __aarch64__ || __arm__ // || __s390__ #ifdef __arm__ unsigned struct_user_vfpregs_struct_sz = ARM_VFPREGS_SIZE; #else unsigned struct_user_vfpregs_struct_sz = 0; #endif int ptrace_peektext = PTRACE_PEEKTEXT; int ptrace_peekdata = PTRACE_PEEKDATA; int ptrace_peekuser = PTRACE_PEEKUSER; #if (defined(PTRACE_GETREGS) && defined(PTRACE_SETREGS)) || \ (defined(PT_GETREGS) && defined(PT_SETREGS)) int ptrace_getregs = PTRACE_GETREGS; int ptrace_setregs = PTRACE_SETREGS; #else int ptrace_getregs = -1; int ptrace_setregs = -1; #endif #if (defined(PTRACE_GETFPREGS) && defined(PTRACE_SETFPREGS)) || \ (defined(PT_GETFPREGS) && defined(PT_SETFPREGS)) int ptrace_getfpregs = PTRACE_GETFPREGS; int ptrace_setfpregs = PTRACE_SETFPREGS; #else int ptrace_getfpregs = -1; int ptrace_setfpregs = -1; #endif #if (defined(PTRACE_GETFPXREGS) && defined(PTRACE_SETFPXREGS)) || \ (defined(PT_GETFPXREGS) && defined(PT_SETFPXREGS)) int ptrace_getfpxregs = PTRACE_GETFPXREGS; int ptrace_setfpxregs = PTRACE_SETFPXREGS; #else int ptrace_getfpxregs = -1; int ptrace_setfpxregs = -1; #endif // PTRACE_GETFPXREGS/PTRACE_SETFPXREGS #if defined(PTRACE_GETVFPREGS) && defined(PTRACE_SETVFPREGS) int ptrace_getvfpregs = PTRACE_GETVFPREGS; int ptrace_setvfpregs = PTRACE_SETVFPREGS; #else int ptrace_getvfpregs = -1; int ptrace_setvfpregs = -1; #endif int ptrace_geteventmsg = PTRACE_GETEVENTMSG; #if (defined(PTRACE_GETSIGINFO) && defined(PTRACE_SETSIGINFO)) || \ (defined(PT_GETSIGINFO) && defined(PT_SETSIGINFO)) int ptrace_getsiginfo = PTRACE_GETSIGINFO; int ptrace_setsiginfo = PTRACE_SETSIGINFO; #else int ptrace_getsiginfo = -1; int ptrace_setsiginfo = -1; #endif // PTRACE_GETSIGINFO/PTRACE_SETSIGINFO #if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET) int ptrace_getregset = PTRACE_GETREGSET; int ptrace_setregset = PTRACE_SETREGSET; #else int ptrace_getregset = -1; int ptrace_setregset = -1; #endif // PTRACE_GETREGSET/PTRACE_SETREGSET #endif unsigned path_max = PATH_MAX; // ioctl arguments unsigned struct_ifreq_sz = sizeof(struct ifreq); unsigned struct_termios_sz = sizeof(struct termios); unsigned struct_winsize_sz = sizeof(struct winsize); #if SANITIZER_LINUX unsigned struct_arpreq_sz = sizeof(struct arpreq); unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); unsigned struct_cdrom_read_audio_sz = sizeof(struct cdrom_read_audio); unsigned struct_cdrom_subchnl_sz = sizeof(struct cdrom_subchnl); unsigned struct_cdrom_ti_sz = sizeof(struct cdrom_ti); unsigned struct_cdrom_tocentry_sz = sizeof(struct cdrom_tocentry); unsigned struct_cdrom_tochdr_sz = sizeof(struct cdrom_tochdr); unsigned struct_cdrom_volctrl_sz = sizeof(struct cdrom_volctrl); unsigned struct_ff_effect_sz = sizeof(struct ff_effect); unsigned struct_floppy_drive_params_sz = sizeof(struct floppy_drive_params); unsigned struct_floppy_drive_struct_sz = sizeof(struct floppy_drive_struct); unsigned struct_floppy_fdc_state_sz = sizeof(struct floppy_fdc_state); unsigned struct_floppy_max_errors_sz = sizeof(struct floppy_max_errors); unsigned struct_floppy_raw_cmd_sz = sizeof(struct floppy_raw_cmd); unsigned struct_floppy_struct_sz = sizeof(struct floppy_struct); unsigned struct_floppy_write_errors_sz = sizeof(struct floppy_write_errors); unsigned struct_format_descr_sz = sizeof(struct format_descr); unsigned struct_hd_driveid_sz = sizeof(struct hd_driveid); unsigned struct_hd_geometry_sz = sizeof(struct hd_geometry); unsigned struct_input_absinfo_sz = sizeof(struct input_absinfo); unsigned struct_input_id_sz = sizeof(struct input_id); unsigned struct_mtpos_sz = sizeof(struct mtpos); unsigned struct_rtentry_sz = sizeof(struct rtentry); #if SANITIZER_GLIBC || SANITIZER_ANDROID unsigned struct_termio_sz = sizeof(struct termio); #endif unsigned struct_vt_consize_sz = sizeof(struct vt_consize); unsigned struct_vt_sizes_sz = sizeof(struct vt_sizes); unsigned struct_vt_stat_sz = sizeof(struct vt_stat); #endif // SANITIZER_LINUX #if SANITIZER_LINUX #if SOUND_VERSION >= 0x040000 unsigned struct_copr_buffer_sz = 0; unsigned struct_copr_debug_buf_sz = 0; unsigned struct_copr_msg_sz = 0; #else unsigned struct_copr_buffer_sz = sizeof(struct copr_buffer); unsigned struct_copr_debug_buf_sz = sizeof(struct copr_debug_buf); unsigned struct_copr_msg_sz = sizeof(struct copr_msg); #endif unsigned struct_midi_info_sz = sizeof(struct midi_info); unsigned struct_mtget_sz = sizeof(struct mtget); unsigned struct_mtop_sz = sizeof(struct mtop); unsigned struct_sbi_instrument_sz = sizeof(struct sbi_instrument); unsigned struct_seq_event_rec_sz = sizeof(struct seq_event_rec); unsigned struct_synth_info_sz = sizeof(struct synth_info); unsigned struct_vt_mode_sz = sizeof(struct vt_mode); #endif // SANITIZER_LINUX #if SANITIZER_GLIBC unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); #if EV_VERSION > (0x010000) unsigned struct_input_keymap_entry_sz = sizeof(struct input_keymap_entry); #else unsigned struct_input_keymap_entry_sz = 0; #endif unsigned struct_ipx_config_data_sz = sizeof(struct ipx_config_data); unsigned struct_kbdiacrs_sz = sizeof(struct kbdiacrs); unsigned struct_kbentry_sz = sizeof(struct kbentry); unsigned struct_kbkeycode_sz = sizeof(struct kbkeycode); unsigned struct_kbsentry_sz = sizeof(struct kbsentry); unsigned struct_mtconfiginfo_sz = sizeof(struct mtconfiginfo); unsigned struct_nr_parms_struct_sz = sizeof(struct nr_parms_struct); unsigned struct_scc_modem_sz = sizeof(struct scc_modem); unsigned struct_scc_stat_sz = sizeof(struct scc_stat); unsigned struct_serial_multiport_struct_sz = sizeof(struct serial_multiport_struct); unsigned struct_serial_struct_sz = sizeof(struct serial_struct); unsigned struct_sockaddr_ax25_sz = sizeof(struct sockaddr_ax25); unsigned struct_unimapdesc_sz = sizeof(struct unimapdesc); unsigned struct_unimapinit_sz = sizeof(struct unimapinit); unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info); unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats); #endif // SANITIZER_GLIBC #if !SANITIZER_ANDROID && !SANITIZER_MAC unsigned struct_sioc_sg_req_sz = sizeof(struct sioc_sg_req); unsigned struct_sioc_vif_req_sz = sizeof(struct sioc_vif_req); #endif const unsigned long __sanitizer_bufsiz = BUFSIZ; const unsigned IOCTL_NOT_PRESENT = 0; unsigned IOCTL_FIOASYNC = FIOASYNC; unsigned IOCTL_FIOCLEX = FIOCLEX; unsigned IOCTL_FIOGETOWN = FIOGETOWN; unsigned IOCTL_FIONBIO = FIONBIO; unsigned IOCTL_FIONCLEX = FIONCLEX; unsigned IOCTL_FIOSETOWN = FIOSETOWN; unsigned IOCTL_SIOCADDMULTI = SIOCADDMULTI; unsigned IOCTL_SIOCATMARK = SIOCATMARK; unsigned IOCTL_SIOCDELMULTI = SIOCDELMULTI; unsigned IOCTL_SIOCGIFADDR = SIOCGIFADDR; unsigned IOCTL_SIOCGIFBRDADDR = SIOCGIFBRDADDR; unsigned IOCTL_SIOCGIFCONF = SIOCGIFCONF; unsigned IOCTL_SIOCGIFDSTADDR = SIOCGIFDSTADDR; unsigned IOCTL_SIOCGIFFLAGS = SIOCGIFFLAGS; unsigned IOCTL_SIOCGIFMETRIC = SIOCGIFMETRIC; unsigned IOCTL_SIOCGIFMTU = SIOCGIFMTU; unsigned IOCTL_SIOCGIFNETMASK = SIOCGIFNETMASK; unsigned IOCTL_SIOCGPGRP = SIOCGPGRP; unsigned IOCTL_SIOCSIFADDR = SIOCSIFADDR; unsigned IOCTL_SIOCSIFBRDADDR = SIOCSIFBRDADDR; unsigned IOCTL_SIOCSIFDSTADDR = SIOCSIFDSTADDR; unsigned IOCTL_SIOCSIFFLAGS = SIOCSIFFLAGS; unsigned IOCTL_SIOCSIFMETRIC = SIOCSIFMETRIC; unsigned IOCTL_SIOCSIFMTU = SIOCSIFMTU; unsigned IOCTL_SIOCSIFNETMASK = SIOCSIFNETMASK; unsigned IOCTL_SIOCSPGRP = SIOCSPGRP; unsigned IOCTL_TIOCCONS = TIOCCONS; unsigned IOCTL_TIOCEXCL = TIOCEXCL; unsigned IOCTL_TIOCGETD = TIOCGETD; unsigned IOCTL_TIOCGPGRP = TIOCGPGRP; unsigned IOCTL_TIOCGWINSZ = TIOCGWINSZ; unsigned IOCTL_TIOCMBIC = TIOCMBIC; unsigned IOCTL_TIOCMBIS = TIOCMBIS; unsigned IOCTL_TIOCMGET = TIOCMGET; unsigned IOCTL_TIOCMSET = TIOCMSET; unsigned IOCTL_TIOCNOTTY = TIOCNOTTY; unsigned IOCTL_TIOCNXCL = TIOCNXCL; unsigned IOCTL_TIOCOUTQ = TIOCOUTQ; unsigned IOCTL_TIOCPKT = TIOCPKT; unsigned IOCTL_TIOCSCTTY = TIOCSCTTY; unsigned IOCTL_TIOCSETD = TIOCSETD; unsigned IOCTL_TIOCSPGRP = TIOCSPGRP; unsigned IOCTL_TIOCSTI = TIOCSTI; unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ; #if SANITIZER_LINUX && !SANITIZER_ANDROID unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT; unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT; #endif #if SANITIZER_LINUX unsigned IOCTL_EVIOCGABS = EVIOCGABS(0); unsigned IOCTL_EVIOCGBIT = EVIOCGBIT(0, 0); unsigned IOCTL_EVIOCGEFFECTS = EVIOCGEFFECTS; unsigned IOCTL_EVIOCGID = EVIOCGID; unsigned IOCTL_EVIOCGKEY = EVIOCGKEY(0); unsigned IOCTL_EVIOCGKEYCODE = EVIOCGKEYCODE; unsigned IOCTL_EVIOCGLED = EVIOCGLED(0); unsigned IOCTL_EVIOCGNAME = EVIOCGNAME(0); unsigned IOCTL_EVIOCGPHYS = EVIOCGPHYS(0); unsigned IOCTL_EVIOCGRAB = EVIOCGRAB; unsigned IOCTL_EVIOCGREP = EVIOCGREP; unsigned IOCTL_EVIOCGSND = EVIOCGSND(0); unsigned IOCTL_EVIOCGSW = EVIOCGSW(0); unsigned IOCTL_EVIOCGUNIQ = EVIOCGUNIQ(0); unsigned IOCTL_EVIOCGVERSION = EVIOCGVERSION; unsigned IOCTL_EVIOCRMFF = EVIOCRMFF; unsigned IOCTL_EVIOCSABS = EVIOCSABS(0); unsigned IOCTL_EVIOCSFF = EVIOCSFF; unsigned IOCTL_EVIOCSKEYCODE = EVIOCSKEYCODE; unsigned IOCTL_EVIOCSREP = EVIOCSREP; unsigned IOCTL_BLKFLSBUF = BLKFLSBUF; unsigned IOCTL_BLKGETSIZE = BLKGETSIZE; unsigned IOCTL_BLKRAGET = BLKRAGET; unsigned IOCTL_BLKRASET = BLKRASET; unsigned IOCTL_BLKROGET = BLKROGET; unsigned IOCTL_BLKROSET = BLKROSET; unsigned IOCTL_BLKRRPART = BLKRRPART; unsigned IOCTL_CDROMAUDIOBUFSIZ = CDROMAUDIOBUFSIZ; unsigned IOCTL_CDROMEJECT = CDROMEJECT; unsigned IOCTL_CDROMEJECT_SW = CDROMEJECT_SW; unsigned IOCTL_CDROMMULTISESSION = CDROMMULTISESSION; unsigned IOCTL_CDROMPAUSE = CDROMPAUSE; unsigned IOCTL_CDROMPLAYMSF = CDROMPLAYMSF; unsigned IOCTL_CDROMPLAYTRKIND = CDROMPLAYTRKIND; unsigned IOCTL_CDROMREADAUDIO = CDROMREADAUDIO; unsigned IOCTL_CDROMREADCOOKED = CDROMREADCOOKED; unsigned IOCTL_CDROMREADMODE1 = CDROMREADMODE1; unsigned IOCTL_CDROMREADMODE2 = CDROMREADMODE2; unsigned IOCTL_CDROMREADRAW = CDROMREADRAW; unsigned IOCTL_CDROMREADTOCENTRY = CDROMREADTOCENTRY; unsigned IOCTL_CDROMREADTOCHDR = CDROMREADTOCHDR; unsigned IOCTL_CDROMRESET = CDROMRESET; unsigned IOCTL_CDROMRESUME = CDROMRESUME; unsigned IOCTL_CDROMSEEK = CDROMSEEK; unsigned IOCTL_CDROMSTART = CDROMSTART; unsigned IOCTL_CDROMSTOP = CDROMSTOP; unsigned IOCTL_CDROMSUBCHNL = CDROMSUBCHNL; unsigned IOCTL_CDROMVOLCTRL = CDROMVOLCTRL; unsigned IOCTL_CDROMVOLREAD = CDROMVOLREAD; unsigned IOCTL_CDROM_GET_UPC = CDROM_GET_UPC; unsigned IOCTL_FDCLRPRM = FDCLRPRM; unsigned IOCTL_FDDEFPRM = FDDEFPRM; unsigned IOCTL_FDFLUSH = FDFLUSH; unsigned IOCTL_FDFMTBEG = FDFMTBEG; unsigned IOCTL_FDFMTEND = FDFMTEND; unsigned IOCTL_FDFMTTRK = FDFMTTRK; unsigned IOCTL_FDGETDRVPRM = FDGETDRVPRM; unsigned IOCTL_FDGETDRVSTAT = FDGETDRVSTAT; unsigned IOCTL_FDGETDRVTYP = FDGETDRVTYP; unsigned IOCTL_FDGETFDCSTAT = FDGETFDCSTAT; unsigned IOCTL_FDGETMAXERRS = FDGETMAXERRS; unsigned IOCTL_FDGETPRM = FDGETPRM; unsigned IOCTL_FDMSGOFF = FDMSGOFF; unsigned IOCTL_FDMSGON = FDMSGON; unsigned IOCTL_FDPOLLDRVSTAT = FDPOLLDRVSTAT; unsigned IOCTL_FDRAWCMD = FDRAWCMD; unsigned IOCTL_FDRESET = FDRESET; unsigned IOCTL_FDSETDRVPRM = FDSETDRVPRM; unsigned IOCTL_FDSETEMSGTRESH = FDSETEMSGTRESH; unsigned IOCTL_FDSETMAXERRS = FDSETMAXERRS; unsigned IOCTL_FDSETPRM = FDSETPRM; unsigned IOCTL_FDTWADDLE = FDTWADDLE; unsigned IOCTL_FDWERRORCLR = FDWERRORCLR; unsigned IOCTL_FDWERRORGET = FDWERRORGET; unsigned IOCTL_HDIO_DRIVE_CMD = HDIO_DRIVE_CMD; unsigned IOCTL_HDIO_GETGEO = HDIO_GETGEO; unsigned IOCTL_HDIO_GET_32BIT = HDIO_GET_32BIT; unsigned IOCTL_HDIO_GET_DMA = HDIO_GET_DMA; unsigned IOCTL_HDIO_GET_IDENTITY = HDIO_GET_IDENTITY; unsigned IOCTL_HDIO_GET_KEEPSETTINGS = HDIO_GET_KEEPSETTINGS; unsigned IOCTL_HDIO_GET_MULTCOUNT = HDIO_GET_MULTCOUNT; unsigned IOCTL_HDIO_GET_NOWERR = HDIO_GET_NOWERR; unsigned IOCTL_HDIO_GET_UNMASKINTR = HDIO_GET_UNMASKINTR; unsigned IOCTL_HDIO_SET_32BIT = HDIO_SET_32BIT; unsigned IOCTL_HDIO_SET_DMA = HDIO_SET_DMA; unsigned IOCTL_HDIO_SET_KEEPSETTINGS = HDIO_SET_KEEPSETTINGS; unsigned IOCTL_HDIO_SET_MULTCOUNT = HDIO_SET_MULTCOUNT; unsigned IOCTL_HDIO_SET_NOWERR = HDIO_SET_NOWERR; unsigned IOCTL_HDIO_SET_UNMASKINTR = HDIO_SET_UNMASKINTR; unsigned IOCTL_MTIOCPOS = MTIOCPOS; unsigned IOCTL_PPPIOCGASYNCMAP = PPPIOCGASYNCMAP; unsigned IOCTL_PPPIOCGDEBUG = PPPIOCGDEBUG; unsigned IOCTL_PPPIOCGFLAGS = PPPIOCGFLAGS; unsigned IOCTL_PPPIOCGUNIT = PPPIOCGUNIT; unsigned IOCTL_PPPIOCGXASYNCMAP = PPPIOCGXASYNCMAP; unsigned IOCTL_PPPIOCSASYNCMAP = PPPIOCSASYNCMAP; unsigned IOCTL_PPPIOCSDEBUG = PPPIOCSDEBUG; unsigned IOCTL_PPPIOCSFLAGS = PPPIOCSFLAGS; unsigned IOCTL_PPPIOCSMAXCID = PPPIOCSMAXCID; unsigned IOCTL_PPPIOCSMRU = PPPIOCSMRU; unsigned IOCTL_PPPIOCSXASYNCMAP = PPPIOCSXASYNCMAP; unsigned IOCTL_SIOCADDRT = SIOCADDRT; unsigned IOCTL_SIOCDARP = SIOCDARP; unsigned IOCTL_SIOCDELRT = SIOCDELRT; unsigned IOCTL_SIOCDRARP = SIOCDRARP; unsigned IOCTL_SIOCGARP = SIOCGARP; unsigned IOCTL_SIOCGIFENCAP = SIOCGIFENCAP; unsigned IOCTL_SIOCGIFHWADDR = SIOCGIFHWADDR; unsigned IOCTL_SIOCGIFMAP = SIOCGIFMAP; unsigned IOCTL_SIOCGIFMEM = SIOCGIFMEM; unsigned IOCTL_SIOCGIFNAME = SIOCGIFNAME; unsigned IOCTL_SIOCGIFSLAVE = SIOCGIFSLAVE; unsigned IOCTL_SIOCGRARP = SIOCGRARP; unsigned IOCTL_SIOCGSTAMP = SIOCGSTAMP; unsigned IOCTL_SIOCSARP = SIOCSARP; unsigned IOCTL_SIOCSIFENCAP = SIOCSIFENCAP; unsigned IOCTL_SIOCSIFHWADDR = SIOCSIFHWADDR; unsigned IOCTL_SIOCSIFLINK = SIOCSIFLINK; unsigned IOCTL_SIOCSIFMAP = SIOCSIFMAP; unsigned IOCTL_SIOCSIFMEM = SIOCSIFMEM; unsigned IOCTL_SIOCSIFSLAVE = SIOCSIFSLAVE; unsigned IOCTL_SIOCSRARP = SIOCSRARP; # if SOUND_VERSION >= 0x040000 unsigned IOCTL_SNDCTL_COPR_HALT = IOCTL_NOT_PRESENT; unsigned IOCTL_SNDCTL_COPR_LOAD = IOCTL_NOT_PRESENT; unsigned IOCTL_SNDCTL_COPR_RCODE = IOCTL_NOT_PRESENT; unsigned IOCTL_SNDCTL_COPR_RCVMSG = IOCTL_NOT_PRESENT; unsigned IOCTL_SNDCTL_COPR_RDATA = IOCTL_NOT_PRESENT; unsigned IOCTL_SNDCTL_COPR_RESET = IOCTL_NOT_PRESENT; unsigned IOCTL_SNDCTL_COPR_RUN = IOCTL_NOT_PRESENT; unsigned IOCTL_SNDCTL_COPR_SENDMSG = IOCTL_NOT_PRESENT; unsigned IOCTL_SNDCTL_COPR_WCODE = IOCTL_NOT_PRESENT; unsigned IOCTL_SNDCTL_COPR_WDATA = IOCTL_NOT_PRESENT; unsigned IOCTL_SOUND_PCM_READ_BITS = IOCTL_NOT_PRESENT; unsigned IOCTL_SOUND_PCM_READ_CHANNELS = IOCTL_NOT_PRESENT; unsigned IOCTL_SOUND_PCM_READ_FILTER = IOCTL_NOT_PRESENT; unsigned IOCTL_SOUND_PCM_READ_RATE = IOCTL_NOT_PRESENT; unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS = IOCTL_NOT_PRESENT; unsigned IOCTL_SOUND_PCM_WRITE_FILTER = IOCTL_NOT_PRESENT; # else // SOUND_VERSION unsigned IOCTL_SNDCTL_COPR_HALT = SNDCTL_COPR_HALT; unsigned IOCTL_SNDCTL_COPR_LOAD = SNDCTL_COPR_LOAD; unsigned IOCTL_SNDCTL_COPR_RCODE = SNDCTL_COPR_RCODE; unsigned IOCTL_SNDCTL_COPR_RCVMSG = SNDCTL_COPR_RCVMSG; unsigned IOCTL_SNDCTL_COPR_RDATA = SNDCTL_COPR_RDATA; unsigned IOCTL_SNDCTL_COPR_RESET = SNDCTL_COPR_RESET; unsigned IOCTL_SNDCTL_COPR_RUN = SNDCTL_COPR_RUN; unsigned IOCTL_SNDCTL_COPR_SENDMSG = SNDCTL_COPR_SENDMSG; unsigned IOCTL_SNDCTL_COPR_WCODE = SNDCTL_COPR_WCODE; unsigned IOCTL_SNDCTL_COPR_WDATA = SNDCTL_COPR_WDATA; unsigned IOCTL_SOUND_PCM_READ_BITS = SOUND_PCM_READ_BITS; unsigned IOCTL_SOUND_PCM_READ_CHANNELS = SOUND_PCM_READ_CHANNELS; unsigned IOCTL_SOUND_PCM_READ_FILTER = SOUND_PCM_READ_FILTER; unsigned IOCTL_SOUND_PCM_READ_RATE = SOUND_PCM_READ_RATE; unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS = SOUND_PCM_WRITE_CHANNELS; unsigned IOCTL_SOUND_PCM_WRITE_FILTER = SOUND_PCM_WRITE_FILTER; #endif // SOUND_VERSION unsigned IOCTL_TCFLSH = TCFLSH; unsigned IOCTL_TCGETA = TCGETA; unsigned IOCTL_TCGETS = TCGETS; unsigned IOCTL_TCSBRK = TCSBRK; unsigned IOCTL_TCSBRKP = TCSBRKP; unsigned IOCTL_TCSETA = TCSETA; unsigned IOCTL_TCSETAF = TCSETAF; unsigned IOCTL_TCSETAW = TCSETAW; unsigned IOCTL_TCSETS = TCSETS; unsigned IOCTL_TCSETSF = TCSETSF; unsigned IOCTL_TCSETSW = TCSETSW; unsigned IOCTL_TCXONC = TCXONC; unsigned IOCTL_TIOCGLCKTRMIOS = TIOCGLCKTRMIOS; unsigned IOCTL_TIOCGSOFTCAR = TIOCGSOFTCAR; unsigned IOCTL_TIOCINQ = TIOCINQ; unsigned IOCTL_TIOCLINUX = TIOCLINUX; unsigned IOCTL_TIOCSERCONFIG = TIOCSERCONFIG; unsigned IOCTL_TIOCSERGETLSR = TIOCSERGETLSR; unsigned IOCTL_TIOCSERGWILD = TIOCSERGWILD; unsigned IOCTL_TIOCSERSWILD = TIOCSERSWILD; unsigned IOCTL_TIOCSLCKTRMIOS = TIOCSLCKTRMIOS; unsigned IOCTL_TIOCSSOFTCAR = TIOCSSOFTCAR; unsigned IOCTL_VT_DISALLOCATE = VT_DISALLOCATE; unsigned IOCTL_VT_GETSTATE = VT_GETSTATE; unsigned IOCTL_VT_RESIZE = VT_RESIZE; unsigned IOCTL_VT_RESIZEX = VT_RESIZEX; unsigned IOCTL_VT_SENDSIG = VT_SENDSIG; unsigned IOCTL_MTIOCGET = MTIOCGET; unsigned IOCTL_MTIOCTOP = MTIOCTOP; unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE = SNDCTL_DSP_GETBLKSIZE; unsigned IOCTL_SNDCTL_DSP_GETFMTS = SNDCTL_DSP_GETFMTS; unsigned IOCTL_SNDCTL_DSP_NONBLOCK = SNDCTL_DSP_NONBLOCK; unsigned IOCTL_SNDCTL_DSP_POST = SNDCTL_DSP_POST; unsigned IOCTL_SNDCTL_DSP_RESET = SNDCTL_DSP_RESET; unsigned IOCTL_SNDCTL_DSP_SETFMT = SNDCTL_DSP_SETFMT; unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT = SNDCTL_DSP_SETFRAGMENT; unsigned IOCTL_SNDCTL_DSP_SPEED = SNDCTL_DSP_SPEED; unsigned IOCTL_SNDCTL_DSP_STEREO = SNDCTL_DSP_STEREO; unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE = SNDCTL_DSP_SUBDIVIDE; unsigned IOCTL_SNDCTL_DSP_SYNC = SNDCTL_DSP_SYNC; unsigned IOCTL_SNDCTL_FM_4OP_ENABLE = SNDCTL_FM_4OP_ENABLE; unsigned IOCTL_SNDCTL_FM_LOAD_INSTR = SNDCTL_FM_LOAD_INSTR; unsigned IOCTL_SNDCTL_MIDI_INFO = SNDCTL_MIDI_INFO; unsigned IOCTL_SNDCTL_MIDI_PRETIME = SNDCTL_MIDI_PRETIME; unsigned IOCTL_SNDCTL_SEQ_CTRLRATE = SNDCTL_SEQ_CTRLRATE; unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT = SNDCTL_SEQ_GETINCOUNT; unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT = SNDCTL_SEQ_GETOUTCOUNT; unsigned IOCTL_SNDCTL_SEQ_NRMIDIS = SNDCTL_SEQ_NRMIDIS; unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS = SNDCTL_SEQ_NRSYNTHS; unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND = SNDCTL_SEQ_OUTOFBAND; unsigned IOCTL_SNDCTL_SEQ_PANIC = SNDCTL_SEQ_PANIC; unsigned IOCTL_SNDCTL_SEQ_PERCMODE = SNDCTL_SEQ_PERCMODE; unsigned IOCTL_SNDCTL_SEQ_RESET = SNDCTL_SEQ_RESET; unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES = SNDCTL_SEQ_RESETSAMPLES; unsigned IOCTL_SNDCTL_SEQ_SYNC = SNDCTL_SEQ_SYNC; unsigned IOCTL_SNDCTL_SEQ_TESTMIDI = SNDCTL_SEQ_TESTMIDI; unsigned IOCTL_SNDCTL_SEQ_THRESHOLD = SNDCTL_SEQ_THRESHOLD; unsigned IOCTL_SNDCTL_SYNTH_INFO = SNDCTL_SYNTH_INFO; unsigned IOCTL_SNDCTL_SYNTH_MEMAVL = SNDCTL_SYNTH_MEMAVL; unsigned IOCTL_SNDCTL_TMR_CONTINUE = SNDCTL_TMR_CONTINUE; unsigned IOCTL_SNDCTL_TMR_METRONOME = SNDCTL_TMR_METRONOME; unsigned IOCTL_SNDCTL_TMR_SELECT = SNDCTL_TMR_SELECT; unsigned IOCTL_SNDCTL_TMR_SOURCE = SNDCTL_TMR_SOURCE; unsigned IOCTL_SNDCTL_TMR_START = SNDCTL_TMR_START; unsigned IOCTL_SNDCTL_TMR_STOP = SNDCTL_TMR_STOP; unsigned IOCTL_SNDCTL_TMR_TEMPO = SNDCTL_TMR_TEMPO; unsigned IOCTL_SNDCTL_TMR_TIMEBASE = SNDCTL_TMR_TIMEBASE; unsigned IOCTL_SOUND_MIXER_READ_ALTPCM = SOUND_MIXER_READ_ALTPCM; unsigned IOCTL_SOUND_MIXER_READ_BASS = SOUND_MIXER_READ_BASS; unsigned IOCTL_SOUND_MIXER_READ_CAPS = SOUND_MIXER_READ_CAPS; unsigned IOCTL_SOUND_MIXER_READ_CD = SOUND_MIXER_READ_CD; unsigned IOCTL_SOUND_MIXER_READ_DEVMASK = SOUND_MIXER_READ_DEVMASK; unsigned IOCTL_SOUND_MIXER_READ_ENHANCE = SOUND_MIXER_READ_ENHANCE; unsigned IOCTL_SOUND_MIXER_READ_IGAIN = SOUND_MIXER_READ_IGAIN; unsigned IOCTL_SOUND_MIXER_READ_IMIX = SOUND_MIXER_READ_IMIX; unsigned IOCTL_SOUND_MIXER_READ_LINE = SOUND_MIXER_READ_LINE; unsigned IOCTL_SOUND_MIXER_READ_LINE1 = SOUND_MIXER_READ_LINE1; unsigned IOCTL_SOUND_MIXER_READ_LINE2 = SOUND_MIXER_READ_LINE2; unsigned IOCTL_SOUND_MIXER_READ_LINE3 = SOUND_MIXER_READ_LINE3; unsigned IOCTL_SOUND_MIXER_READ_LOUD = SOUND_MIXER_READ_LOUD; unsigned IOCTL_SOUND_MIXER_READ_MIC = SOUND_MIXER_READ_MIC; unsigned IOCTL_SOUND_MIXER_READ_MUTE = SOUND_MIXER_READ_MUTE; unsigned IOCTL_SOUND_MIXER_READ_OGAIN = SOUND_MIXER_READ_OGAIN; unsigned IOCTL_SOUND_MIXER_READ_PCM = SOUND_MIXER_READ_PCM; unsigned IOCTL_SOUND_MIXER_READ_RECLEV = SOUND_MIXER_READ_RECLEV; unsigned IOCTL_SOUND_MIXER_READ_RECMASK = SOUND_MIXER_READ_RECMASK; unsigned IOCTL_SOUND_MIXER_READ_RECSRC = SOUND_MIXER_READ_RECSRC; unsigned IOCTL_SOUND_MIXER_READ_SPEAKER = SOUND_MIXER_READ_SPEAKER; unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS = SOUND_MIXER_READ_STEREODEVS; unsigned IOCTL_SOUND_MIXER_READ_SYNTH = SOUND_MIXER_READ_SYNTH; unsigned IOCTL_SOUND_MIXER_READ_TREBLE = SOUND_MIXER_READ_TREBLE; unsigned IOCTL_SOUND_MIXER_READ_VOLUME = SOUND_MIXER_READ_VOLUME; unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM = SOUND_MIXER_WRITE_ALTPCM; unsigned IOCTL_SOUND_MIXER_WRITE_BASS = SOUND_MIXER_WRITE_BASS; unsigned IOCTL_SOUND_MIXER_WRITE_CD = SOUND_MIXER_WRITE_CD; unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE = SOUND_MIXER_WRITE_ENHANCE; unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN = SOUND_MIXER_WRITE_IGAIN; unsigned IOCTL_SOUND_MIXER_WRITE_IMIX = SOUND_MIXER_WRITE_IMIX; unsigned IOCTL_SOUND_MIXER_WRITE_LINE = SOUND_MIXER_WRITE_LINE; unsigned IOCTL_SOUND_MIXER_WRITE_LINE1 = SOUND_MIXER_WRITE_LINE1; unsigned IOCTL_SOUND_MIXER_WRITE_LINE2 = SOUND_MIXER_WRITE_LINE2; unsigned IOCTL_SOUND_MIXER_WRITE_LINE3 = SOUND_MIXER_WRITE_LINE3; unsigned IOCTL_SOUND_MIXER_WRITE_LOUD = SOUND_MIXER_WRITE_LOUD; unsigned IOCTL_SOUND_MIXER_WRITE_MIC = SOUND_MIXER_WRITE_MIC; unsigned IOCTL_SOUND_MIXER_WRITE_MUTE = SOUND_MIXER_WRITE_MUTE; unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN = SOUND_MIXER_WRITE_OGAIN; unsigned IOCTL_SOUND_MIXER_WRITE_PCM = SOUND_MIXER_WRITE_PCM; unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV = SOUND_MIXER_WRITE_RECLEV; unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC = SOUND_MIXER_WRITE_RECSRC; unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER = SOUND_MIXER_WRITE_SPEAKER; unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH = SOUND_MIXER_WRITE_SYNTH; unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE = SOUND_MIXER_WRITE_TREBLE; unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME = SOUND_MIXER_WRITE_VOLUME; unsigned IOCTL_VT_ACTIVATE = VT_ACTIVATE; unsigned IOCTL_VT_GETMODE = VT_GETMODE; unsigned IOCTL_VT_OPENQRY = VT_OPENQRY; unsigned IOCTL_VT_RELDISP = VT_RELDISP; unsigned IOCTL_VT_SETMODE = VT_SETMODE; unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; #endif // SANITIZER_LINUX #if SANITIZER_LINUX && !SANITIZER_ANDROID unsigned IOCTL_EQL_EMANCIPATE = EQL_EMANCIPATE; unsigned IOCTL_EQL_ENSLAVE = EQL_ENSLAVE; unsigned IOCTL_EQL_GETMASTRCFG = EQL_GETMASTRCFG; unsigned IOCTL_EQL_GETSLAVECFG = EQL_GETSLAVECFG; unsigned IOCTL_EQL_SETMASTRCFG = EQL_SETMASTRCFG; unsigned IOCTL_EQL_SETSLAVECFG = EQL_SETSLAVECFG; #if EV_VERSION > (0x010000) unsigned IOCTL_EVIOCGKEYCODE_V2 = EVIOCGKEYCODE_V2; unsigned IOCTL_EVIOCGPROP = EVIOCGPROP(0); unsigned IOCTL_EVIOCSKEYCODE_V2 = EVIOCSKEYCODE_V2; #else unsigned IOCTL_EVIOCGKEYCODE_V2 = IOCTL_NOT_PRESENT; unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT; unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT; #endif unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS; unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION; unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS; unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION; unsigned IOCTL_GIO_CMAP = GIO_CMAP; unsigned IOCTL_GIO_FONT = GIO_FONT; unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP; unsigned IOCTL_GIO_UNISCRNMAP = GIO_UNISCRNMAP; unsigned IOCTL_KDADDIO = KDADDIO; unsigned IOCTL_KDDELIO = KDDELIO; unsigned IOCTL_KDGETKEYCODE = KDGETKEYCODE; unsigned IOCTL_KDGKBDIACR = KDGKBDIACR; unsigned IOCTL_KDGKBENT = KDGKBENT; unsigned IOCTL_KDGKBLED = KDGKBLED; unsigned IOCTL_KDGKBMETA = KDGKBMETA; unsigned IOCTL_KDGKBSENT = KDGKBSENT; unsigned IOCTL_KDMAPDISP = KDMAPDISP; unsigned IOCTL_KDSETKEYCODE = KDSETKEYCODE; unsigned IOCTL_KDSIGACCEPT = KDSIGACCEPT; unsigned IOCTL_KDSKBDIACR = KDSKBDIACR; unsigned IOCTL_KDSKBENT = KDSKBENT; unsigned IOCTL_KDSKBLED = KDSKBLED; unsigned IOCTL_KDSKBMETA = KDSKBMETA; unsigned IOCTL_KDSKBSENT = KDSKBSENT; unsigned IOCTL_KDUNMAPDISP = KDUNMAPDISP; unsigned IOCTL_LPABORT = LPABORT; unsigned IOCTL_LPABORTOPEN = LPABORTOPEN; unsigned IOCTL_LPCAREFUL = LPCAREFUL; unsigned IOCTL_LPCHAR = LPCHAR; unsigned IOCTL_LPGETIRQ = LPGETIRQ; unsigned IOCTL_LPGETSTATUS = LPGETSTATUS; unsigned IOCTL_LPRESET = LPRESET; unsigned IOCTL_LPSETIRQ = LPSETIRQ; unsigned IOCTL_LPTIME = LPTIME; unsigned IOCTL_LPWAIT = LPWAIT; unsigned IOCTL_MTIOCGETCONFIG = MTIOCGETCONFIG; unsigned IOCTL_MTIOCSETCONFIG = MTIOCSETCONFIG; unsigned IOCTL_PIO_CMAP = PIO_CMAP; unsigned IOCTL_PIO_FONT = PIO_FONT; unsigned IOCTL_PIO_UNIMAP = PIO_UNIMAP; unsigned IOCTL_PIO_UNIMAPCLR = PIO_UNIMAPCLR; unsigned IOCTL_PIO_UNISCRNMAP = PIO_UNISCRNMAP; #if SANITIZER_GLIBC unsigned IOCTL_SCSI_IOCTL_GET_IDLUN = SCSI_IOCTL_GET_IDLUN; unsigned IOCTL_SCSI_IOCTL_PROBE_HOST = SCSI_IOCTL_PROBE_HOST; unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE = SCSI_IOCTL_TAGGED_DISABLE; unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE = SCSI_IOCTL_TAGGED_ENABLE; unsigned IOCTL_SIOCAIPXITFCRT = SIOCAIPXITFCRT; unsigned IOCTL_SIOCAIPXPRISLT = SIOCAIPXPRISLT; unsigned IOCTL_SIOCAX25ADDUID = SIOCAX25ADDUID; unsigned IOCTL_SIOCAX25DELUID = SIOCAX25DELUID; unsigned IOCTL_SIOCAX25GETPARMS = SIOCAX25GETPARMS; unsigned IOCTL_SIOCAX25GETUID = SIOCAX25GETUID; unsigned IOCTL_SIOCAX25NOUID = SIOCAX25NOUID; unsigned IOCTL_SIOCAX25SETPARMS = SIOCAX25SETPARMS; unsigned IOCTL_SIOCDEVPLIP = SIOCDEVPLIP; unsigned IOCTL_SIOCIPXCFGDATA = SIOCIPXCFGDATA; unsigned IOCTL_SIOCNRDECOBS = SIOCNRDECOBS; unsigned IOCTL_SIOCNRGETPARMS = SIOCNRGETPARMS; unsigned IOCTL_SIOCNRRTCTL = SIOCNRRTCTL; unsigned IOCTL_SIOCNRSETPARMS = SIOCNRSETPARMS; #endif unsigned IOCTL_TIOCGSERIAL = TIOCGSERIAL; unsigned IOCTL_TIOCSERGETMULTI = TIOCSERGETMULTI; unsigned IOCTL_TIOCSERSETMULTI = TIOCSERSETMULTI; unsigned IOCTL_TIOCSSERIAL = TIOCSSERIAL; #endif // SANITIZER_LINUX && !SANITIZER_ANDROID #if SANITIZER_LINUX && !SANITIZER_ANDROID unsigned IOCTL_GIO_SCRNMAP = GIO_SCRNMAP; unsigned IOCTL_KDDISABIO = KDDISABIO; unsigned IOCTL_KDENABIO = KDENABIO; unsigned IOCTL_KDGETLED = KDGETLED; unsigned IOCTL_KDGETMODE = KDGETMODE; unsigned IOCTL_KDGKBMODE = KDGKBMODE; unsigned IOCTL_KDGKBTYPE = KDGKBTYPE; unsigned IOCTL_KDMKTONE = KDMKTONE; unsigned IOCTL_KDSETLED = KDSETLED; unsigned IOCTL_KDSETMODE = KDSETMODE; unsigned IOCTL_KDSKBMODE = KDSKBMODE; unsigned IOCTL_KIOCSOUND = KIOCSOUND; unsigned IOCTL_PIO_SCRNMAP = PIO_SCRNMAP; unsigned IOCTL_SNDCTL_DSP_GETISPACE = SNDCTL_DSP_GETISPACE; unsigned IOCTL_SNDCTL_DSP_GETOSPACE = SNDCTL_DSP_GETOSPACE; #endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID const int si_SEGV_MAPERR = SEGV_MAPERR; const int si_SEGV_ACCERR = SEGV_ACCERR; } // namespace __sanitizer using namespace __sanitizer; COMPILER_CHECK(sizeof(__sanitizer_pthread_attr_t) >= sizeof(pthread_attr_t)); COMPILER_CHECK(sizeof(socklen_t) == sizeof(unsigned)); CHECK_TYPE_SIZE(pthread_key_t); #if SANITIZER_LINUX // FIXME: We define those on Linux and Mac, but only check on Linux. COMPILER_CHECK(IOC_NRBITS == _IOC_NRBITS); COMPILER_CHECK(IOC_TYPEBITS == _IOC_TYPEBITS); COMPILER_CHECK(IOC_SIZEBITS == _IOC_SIZEBITS); COMPILER_CHECK(IOC_DIRBITS == _IOC_DIRBITS); COMPILER_CHECK(IOC_NRMASK == _IOC_NRMASK); COMPILER_CHECK(IOC_TYPEMASK == _IOC_TYPEMASK); COMPILER_CHECK(IOC_SIZEMASK == _IOC_SIZEMASK); COMPILER_CHECK(IOC_DIRMASK == _IOC_DIRMASK); COMPILER_CHECK(IOC_NRSHIFT == _IOC_NRSHIFT); COMPILER_CHECK(IOC_TYPESHIFT == _IOC_TYPESHIFT); COMPILER_CHECK(IOC_SIZESHIFT == _IOC_SIZESHIFT); COMPILER_CHECK(IOC_DIRSHIFT == _IOC_DIRSHIFT); COMPILER_CHECK(IOC_NONE == _IOC_NONE); COMPILER_CHECK(IOC_WRITE == _IOC_WRITE); COMPILER_CHECK(IOC_READ == _IOC_READ); COMPILER_CHECK(EVIOC_ABS_MAX == ABS_MAX); COMPILER_CHECK(EVIOC_EV_MAX == EV_MAX); COMPILER_CHECK(IOC_SIZE(0x12345678) == _IOC_SIZE(0x12345678)); COMPILER_CHECK(IOC_DIR(0x12345678) == _IOC_DIR(0x12345678)); COMPILER_CHECK(IOC_NR(0x12345678) == _IOC_NR(0x12345678)); COMPILER_CHECK(IOC_TYPE(0x12345678) == _IOC_TYPE(0x12345678)); #endif // SANITIZER_LINUX #if SANITIZER_LINUX || SANITIZER_FREEBSD // There are more undocumented fields in dl_phdr_info that we are not interested // in. COMPILER_CHECK(sizeof(__sanitizer_dl_phdr_info) <= sizeof(dl_phdr_info)); CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_addr); CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_name); CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); #endif // SANITIZER_LINUX || SANITIZER_FREEBSD #if SANITIZER_GLIBC || SANITIZER_FREEBSD CHECK_TYPE_SIZE(glob_t); CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); CHECK_SIZE_AND_OFFSET(glob_t, gl_offs); CHECK_SIZE_AND_OFFSET(glob_t, gl_flags); CHECK_SIZE_AND_OFFSET(glob_t, gl_closedir); CHECK_SIZE_AND_OFFSET(glob_t, gl_readdir); CHECK_SIZE_AND_OFFSET(glob_t, gl_opendir); CHECK_SIZE_AND_OFFSET(glob_t, gl_lstat); CHECK_SIZE_AND_OFFSET(glob_t, gl_stat); #endif // SANITIZER_GLIBC || SANITIZER_FREEBSD CHECK_TYPE_SIZE(addrinfo); CHECK_SIZE_AND_OFFSET(addrinfo, ai_flags); CHECK_SIZE_AND_OFFSET(addrinfo, ai_family); CHECK_SIZE_AND_OFFSET(addrinfo, ai_socktype); CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol); CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol); CHECK_SIZE_AND_OFFSET(addrinfo, ai_addrlen); CHECK_SIZE_AND_OFFSET(addrinfo, ai_canonname); CHECK_SIZE_AND_OFFSET(addrinfo, ai_addr); CHECK_TYPE_SIZE(hostent); CHECK_SIZE_AND_OFFSET(hostent, h_name); CHECK_SIZE_AND_OFFSET(hostent, h_aliases); CHECK_SIZE_AND_OFFSET(hostent, h_addrtype); CHECK_SIZE_AND_OFFSET(hostent, h_length); CHECK_SIZE_AND_OFFSET(hostent, h_addr_list); CHECK_TYPE_SIZE(iovec); CHECK_SIZE_AND_OFFSET(iovec, iov_base); CHECK_SIZE_AND_OFFSET(iovec, iov_len); // In POSIX, int msg_iovlen; socklen_t msg_controllen; socklen_t cmsg_len; but // many implementations don't conform to the standard. Since we pick the // non-conforming glibc definition, exclude the checks for musl (incompatible // sizes but compatible offsets). CHECK_TYPE_SIZE(msghdr); CHECK_SIZE_AND_OFFSET(msghdr, msg_name); CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); CHECK_SIZE_AND_OFFSET(msghdr, msg_iov); #if SANITIZER_GLIBC || SANITIZER_ANDROID CHECK_SIZE_AND_OFFSET(msghdr, msg_iovlen); #endif CHECK_SIZE_AND_OFFSET(msghdr, msg_control); #if SANITIZER_GLIBC || SANITIZER_ANDROID CHECK_SIZE_AND_OFFSET(msghdr, msg_controllen); #endif CHECK_SIZE_AND_OFFSET(msghdr, msg_flags); CHECK_TYPE_SIZE(cmsghdr); #if SANITIZER_GLIBC || SANITIZER_ANDROID CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); #endif CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); #if SANITIZER_LINUX && (__ANDROID_API__ >= 21 || __GLIBC_PREREQ (2, 14)) CHECK_TYPE_SIZE(mmsghdr); CHECK_SIZE_AND_OFFSET(mmsghdr, msg_hdr); CHECK_SIZE_AND_OFFSET(mmsghdr, msg_len); #endif COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent)); CHECK_SIZE_AND_OFFSET(dirent, d_ino); #if SANITIZER_MAC CHECK_SIZE_AND_OFFSET(dirent, d_seekoff); #elif SANITIZER_FREEBSD // There is no 'd_off' field on FreeBSD. #else CHECK_SIZE_AND_OFFSET(dirent, d_off); #endif CHECK_SIZE_AND_OFFSET(dirent, d_reclen); #if SANITIZER_LINUX && !SANITIZER_ANDROID COMPILER_CHECK(sizeof(__sanitizer_dirent64) <= sizeof(dirent64)); CHECK_SIZE_AND_OFFSET(dirent64, d_ino); CHECK_SIZE_AND_OFFSET(dirent64, d_off); CHECK_SIZE_AND_OFFSET(dirent64, d_reclen); #endif CHECK_TYPE_SIZE(ifconf); CHECK_SIZE_AND_OFFSET(ifconf, ifc_len); CHECK_SIZE_AND_OFFSET(ifconf, ifc_ifcu); CHECK_TYPE_SIZE(pollfd); CHECK_SIZE_AND_OFFSET(pollfd, fd); CHECK_SIZE_AND_OFFSET(pollfd, events); CHECK_SIZE_AND_OFFSET(pollfd, revents); CHECK_TYPE_SIZE(nfds_t); CHECK_TYPE_SIZE(sigset_t); COMPILER_CHECK(sizeof(__sanitizer_sigaction) == sizeof(struct sigaction)); // Can't write checks for sa_handler and sa_sigaction due to them being // preprocessor macros. CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask); #if !defined(__s390x__) || __GLIBC_PREREQ (2, 20) // On s390x glibc 2.19 and earlier sa_flags was unsigned long, and sa_resv // didn't exist. CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags); #endif #if SANITIZER_LINUX && (!SANITIZER_ANDROID || !SANITIZER_MIPS32) CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer); #endif #if SANITIZER_LINUX CHECK_TYPE_SIZE(__sysctl_args); CHECK_SIZE_AND_OFFSET(__sysctl_args, name); CHECK_SIZE_AND_OFFSET(__sysctl_args, nlen); CHECK_SIZE_AND_OFFSET(__sysctl_args, oldval); CHECK_SIZE_AND_OFFSET(__sysctl_args, oldlenp); CHECK_SIZE_AND_OFFSET(__sysctl_args, newval); CHECK_SIZE_AND_OFFSET(__sysctl_args, newlen); CHECK_TYPE_SIZE(__kernel_uid_t); CHECK_TYPE_SIZE(__kernel_gid_t); #if SANITIZER_USES_UID16_SYSCALLS CHECK_TYPE_SIZE(__kernel_old_uid_t); CHECK_TYPE_SIZE(__kernel_old_gid_t); #endif CHECK_TYPE_SIZE(__kernel_off_t); CHECK_TYPE_SIZE(__kernel_loff_t); CHECK_TYPE_SIZE(__kernel_fd_set); #endif #if !SANITIZER_ANDROID CHECK_TYPE_SIZE(wordexp_t); CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc); CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv); CHECK_SIZE_AND_OFFSET(wordexp_t, we_offs); #endif CHECK_TYPE_SIZE(tm); CHECK_SIZE_AND_OFFSET(tm, tm_sec); CHECK_SIZE_AND_OFFSET(tm, tm_min); CHECK_SIZE_AND_OFFSET(tm, tm_hour); CHECK_SIZE_AND_OFFSET(tm, tm_mday); CHECK_SIZE_AND_OFFSET(tm, tm_mon); CHECK_SIZE_AND_OFFSET(tm, tm_year); CHECK_SIZE_AND_OFFSET(tm, tm_wday); CHECK_SIZE_AND_OFFSET(tm, tm_yday); CHECK_SIZE_AND_OFFSET(tm, tm_isdst); CHECK_SIZE_AND_OFFSET(tm, tm_gmtoff); CHECK_SIZE_AND_OFFSET(tm, tm_zone); #if SANITIZER_LINUX CHECK_TYPE_SIZE(mntent); CHECK_SIZE_AND_OFFSET(mntent, mnt_fsname); CHECK_SIZE_AND_OFFSET(mntent, mnt_dir); CHECK_SIZE_AND_OFFSET(mntent, mnt_type); CHECK_SIZE_AND_OFFSET(mntent, mnt_opts); CHECK_SIZE_AND_OFFSET(mntent, mnt_freq); CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); #endif CHECK_TYPE_SIZE(ether_addr); #if SANITIZER_GLIBC || SANITIZER_FREEBSD CHECK_TYPE_SIZE(ipc_perm); # if SANITIZER_FREEBSD CHECK_SIZE_AND_OFFSET(ipc_perm, key); CHECK_SIZE_AND_OFFSET(ipc_perm, seq); # else CHECK_SIZE_AND_OFFSET(ipc_perm, __key); CHECK_SIZE_AND_OFFSET(ipc_perm, __seq); # endif CHECK_SIZE_AND_OFFSET(ipc_perm, uid); CHECK_SIZE_AND_OFFSET(ipc_perm, gid); CHECK_SIZE_AND_OFFSET(ipc_perm, cuid); CHECK_SIZE_AND_OFFSET(ipc_perm, cgid); #if !SANITIZER_LINUX || __GLIBC_PREREQ (2, 31) /* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit on many architectures. */ CHECK_SIZE_AND_OFFSET(ipc_perm, mode); #endif CHECK_TYPE_SIZE(shmid_ds); CHECK_SIZE_AND_OFFSET(shmid_ds, shm_perm); CHECK_SIZE_AND_OFFSET(shmid_ds, shm_segsz); CHECK_SIZE_AND_OFFSET(shmid_ds, shm_atime); CHECK_SIZE_AND_OFFSET(shmid_ds, shm_dtime); CHECK_SIZE_AND_OFFSET(shmid_ds, shm_ctime); CHECK_SIZE_AND_OFFSET(shmid_ds, shm_cpid); CHECK_SIZE_AND_OFFSET(shmid_ds, shm_lpid); CHECK_SIZE_AND_OFFSET(shmid_ds, shm_nattch); #endif CHECK_TYPE_SIZE(clock_t); #if SANITIZER_LINUX CHECK_TYPE_SIZE(clockid_t); #endif #if !SANITIZER_ANDROID CHECK_TYPE_SIZE(ifaddrs); CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_next); CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_name); CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_addr); CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_netmask); #if SANITIZER_LINUX || SANITIZER_FREEBSD // Compare against the union, because we can't reach into the union in a // compliant way. #ifdef ifa_dstaddr #undef ifa_dstaddr #endif # if SANITIZER_FREEBSD CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); # else COMPILER_CHECK(sizeof(((__sanitizer_ifaddrs *)nullptr)->ifa_dstaddr) == sizeof(((ifaddrs *)nullptr)->ifa_ifu)); COMPILER_CHECK(offsetof(__sanitizer_ifaddrs, ifa_dstaddr) == offsetof(ifaddrs, ifa_ifu)); # endif // SANITIZER_FREEBSD #else CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); #endif // SANITIZER_LINUX CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); #endif #if SANITIZER_GLIBC || SANITIZER_ANDROID COMPILER_CHECK(sizeof(__sanitizer_struct_mallinfo) == sizeof(struct mallinfo)); #endif #if !SANITIZER_ANDROID CHECK_TYPE_SIZE(timeb); CHECK_SIZE_AND_OFFSET(timeb, time); CHECK_SIZE_AND_OFFSET(timeb, millitm); CHECK_SIZE_AND_OFFSET(timeb, timezone); CHECK_SIZE_AND_OFFSET(timeb, dstflag); #endif CHECK_TYPE_SIZE(passwd); CHECK_SIZE_AND_OFFSET(passwd, pw_name); CHECK_SIZE_AND_OFFSET(passwd, pw_passwd); CHECK_SIZE_AND_OFFSET(passwd, pw_uid); CHECK_SIZE_AND_OFFSET(passwd, pw_gid); CHECK_SIZE_AND_OFFSET(passwd, pw_dir); CHECK_SIZE_AND_OFFSET(passwd, pw_shell); #if !SANITIZER_ANDROID CHECK_SIZE_AND_OFFSET(passwd, pw_gecos); #endif #if SANITIZER_MAC CHECK_SIZE_AND_OFFSET(passwd, pw_change); CHECK_SIZE_AND_OFFSET(passwd, pw_expire); CHECK_SIZE_AND_OFFSET(passwd, pw_class); #endif CHECK_TYPE_SIZE(group); CHECK_SIZE_AND_OFFSET(group, gr_name); CHECK_SIZE_AND_OFFSET(group, gr_passwd); CHECK_SIZE_AND_OFFSET(group, gr_gid); CHECK_SIZE_AND_OFFSET(group, gr_mem); #if HAVE_RPC_XDR_H CHECK_TYPE_SIZE(XDR); CHECK_SIZE_AND_OFFSET(XDR, x_op); CHECK_SIZE_AND_OFFSET(XDR, x_ops); CHECK_SIZE_AND_OFFSET(XDR, x_public); CHECK_SIZE_AND_OFFSET(XDR, x_private); CHECK_SIZE_AND_OFFSET(XDR, x_base); CHECK_SIZE_AND_OFFSET(XDR, x_handy); COMPILER_CHECK(__sanitizer_XDR_ENCODE == XDR_ENCODE); COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); #endif #if SANITIZER_GLIBC COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); CHECK_SIZE_AND_OFFSET(FILE, _flags); CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); CHECK_SIZE_AND_OFFSET(FILE, _IO_read_end); CHECK_SIZE_AND_OFFSET(FILE, _IO_read_base); CHECK_SIZE_AND_OFFSET(FILE, _IO_write_ptr); CHECK_SIZE_AND_OFFSET(FILE, _IO_write_end); CHECK_SIZE_AND_OFFSET(FILE, _IO_write_base); CHECK_SIZE_AND_OFFSET(FILE, _IO_buf_base); CHECK_SIZE_AND_OFFSET(FILE, _IO_buf_end); CHECK_SIZE_AND_OFFSET(FILE, _IO_save_base); CHECK_SIZE_AND_OFFSET(FILE, _IO_backup_base); CHECK_SIZE_AND_OFFSET(FILE, _IO_save_end); CHECK_SIZE_AND_OFFSET(FILE, _markers); CHECK_SIZE_AND_OFFSET(FILE, _chain); CHECK_SIZE_AND_OFFSET(FILE, _fileno); COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); CHECK_TYPE_SIZE(obstack); CHECK_SIZE_AND_OFFSET(obstack, chunk_size); CHECK_SIZE_AND_OFFSET(obstack, chunk); CHECK_SIZE_AND_OFFSET(obstack, object_base); CHECK_SIZE_AND_OFFSET(obstack, next_free); CHECK_TYPE_SIZE(cookie_io_functions_t); CHECK_SIZE_AND_OFFSET(cookie_io_functions_t, read); CHECK_SIZE_AND_OFFSET(cookie_io_functions_t, write); CHECK_SIZE_AND_OFFSET(cookie_io_functions_t, seek); CHECK_SIZE_AND_OFFSET(cookie_io_functions_t, close); #endif // SANITIZER_GLIBC #if SANITIZER_LINUX || SANITIZER_FREEBSD CHECK_TYPE_SIZE(sem_t); #endif #if SANITIZER_LINUX && defined(__arm__) COMPILER_CHECK(ARM_VFPREGS_SIZE == ARM_VFPREGS_SIZE_ASAN); #endif #endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC diff --git a/libcxx/include/__algorithm/in_in_out_result.h b/libcxx/include/__algorithm/in_in_out_result.h index e365eb58eb62..a492d2735229 100644 --- a/libcxx/include/__algorithm/in_in_out_result.h +++ b/libcxx/include/__algorithm/in_in_out_result.h @@ -1,48 +1,54 @@ // -*- 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___ALGORITHM_IN_IN_OUT_RESULT_H #define _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H #include <__concepts/convertible_to.h> #include <__config> #include <__utility/move.h> +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_CONCEPTS +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { + template struct in_in_out_result { [[no_unique_address]] _I1 in1; [[no_unique_address]] _I2 in2; [[no_unique_address]] _O1 out; template requires convertible_to && convertible_to && convertible_to _LIBCPP_HIDE_FROM_ABI constexpr operator in_in_out_result<_II1, _II2, _OO1>() const& { return {in1, in2, out}; } template requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> && convertible_to<_O1, _OO1> _LIBCPP_HIDE_FROM_ABI constexpr operator in_in_out_result<_II1, _II2, _OO1>() && { return {_VSTD::move(in1), _VSTD::move(in2), _VSTD::move(out)}; } }; + } // namespace ranges -#endif // _LIBCPP_HAS_NO_CONCEPTS +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP___ALGORITHM_IN_IN_RESULT_H +#endif // _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H diff --git a/libcxx/include/__algorithm/in_in_result.h b/libcxx/include/__algorithm/in_in_result.h index ed14ecedbbdf..c8fe43d039dc 100644 --- a/libcxx/include/__algorithm/in_in_result.h +++ b/libcxx/include/__algorithm/in_in_result.h @@ -1,45 +1,51 @@ // -*- 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___ALGORITHM_IN_IN_RESULT_H #define _LIBCPP___ALGORITHM_IN_IN_RESULT_H #include <__concepts/convertible_to.h> #include <__config> #include <__utility/move.h> +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_CONCEPTS +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { + template struct in_in_result { [[no_unique_address]] _I1 in1; [[no_unique_address]] _I2 in2; template requires convertible_to && convertible_to _LIBCPP_HIDE_FROM_ABI constexpr operator in_in_result<_II1, _II2>() const & { return {in1, in2}; } template requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> _LIBCPP_HIDE_FROM_ABI constexpr operator in_in_result<_II1, _II2>() && { return {_VSTD::move(in1), _VSTD::move(in2)}; } }; + } // namespace ranges -#endif // _LIBCPP_HAS_NO_CONCEPTS +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___ALGORITHM_IN_IN_RESULT_H diff --git a/libcxx/include/__algorithm/in_out_result.h b/libcxx/include/__algorithm/in_out_result.h index 8a58d6ada10c..d3c16e4acd45 100644 --- a/libcxx/include/__algorithm/in_out_result.h +++ b/libcxx/include/__algorithm/in_out_result.h @@ -1,52 +1,54 @@ // -*- 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___ALGORITHM_IN_OUT_RESULT_H #define _LIBCPP___ALGORITHM_IN_OUT_RESULT_H #include <__concepts/convertible_to.h> #include <__config> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD #if !defined(_LIBCPP_HAS_NO_CONCEPTS) + namespace ranges { template struct in_out_result { [[no_unique_address]] _InputIterator in; [[no_unique_address]] _OutputIterator out; template requires convertible_to && convertible_to _LIBCPP_HIDE_FROM_ABI constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() const & { return {in, out}; } template requires convertible_to<_InputIterator, _InputIterator2> && convertible_to<_OutputIterator, _OutputIterator2> _LIBCPP_HIDE_FROM_ABI constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() && { return {_VSTD::move(in), _VSTD::move(out)}; } }; } // namespace ranges + #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___ALGORITHM_IN_OUT_RESULT_H diff --git a/libcxx/include/__chrono/duration.h b/libcxx/include/__chrono/duration.h index 24801772ec5d..b7d88cb52ea8 100644 --- a/libcxx/include/__chrono/duration.h +++ b/libcxx/include/__chrono/duration.h @@ -1,615 +1,615 @@ // -*- 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___CHRONO_DURATION_H #define _LIBCPP___CHRONO_DURATION_H #include <__config> #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_PUSH_MACROS #include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD namespace chrono { template > class _LIBCPP_TEMPLATE_VIS duration; template struct __is_duration : false_type {}; template struct __is_duration > : true_type {}; template struct __is_duration > : true_type {}; template struct __is_duration > : true_type {}; template struct __is_duration > : true_type {}; } // namespace chrono template struct _LIBCPP_TEMPLATE_VIS common_type, chrono::duration<_Rep2, _Period2> > { typedef chrono::duration::type, typename __ratio_gcd<_Period1, _Period2>::type> type; }; namespace chrono { // duration_cast template ::type, bool = _Period::num == 1, bool = _Period::den == 1> struct __duration_cast; template struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const { return _ToDuration(static_cast(__fd.count())); } }; template struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const { typedef typename common_type::type _Ct; return _ToDuration(static_cast( static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den))); } }; template struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const { typedef typename common_type::type _Ct; return _ToDuration(static_cast( static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num))); } }; template struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _ToDuration operator()(const _FromDuration& __fd) const { typedef typename common_type::type _Ct; return _ToDuration(static_cast( static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num) / static_cast<_Ct>(_Period::den))); } }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < __is_duration<_ToDuration>::value, _ToDuration >::type duration_cast(const duration<_Rep, _Period>& __fd) { return __duration_cast, _ToDuration>()(__fd); } template struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; #if _LIBCPP_STD_VER > 14 template inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value; #endif template struct _LIBCPP_TEMPLATE_VIS duration_values { public: _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT {return _Rep(0);} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT {return numeric_limits<_Rep>::max();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT {return numeric_limits<_Rep>::lowest();} }; #if _LIBCPP_STD_VER > 14 template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < __is_duration<_ToDuration>::value, _ToDuration >::type floor(const duration<_Rep, _Period>& __d) { _ToDuration __t = duration_cast<_ToDuration>(__d); if (__t > __d) __t = __t - _ToDuration{1}; return __t; } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < __is_duration<_ToDuration>::value, _ToDuration >::type ceil(const duration<_Rep, _Period>& __d) { _ToDuration __t = duration_cast<_ToDuration>(__d); if (__t < __d) __t = __t + _ToDuration{1}; return __t; } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < __is_duration<_ToDuration>::value, _ToDuration >::type round(const duration<_Rep, _Period>& __d) { _ToDuration __lower = floor<_ToDuration>(__d); _ToDuration __upper = __lower + _ToDuration{1}; auto __lowerDiff = __d - __lower; auto __upperDiff = __upper - __d; if (__lowerDiff < __upperDiff) return __lower; if (__lowerDiff > __upperDiff) return __upper; return __lower.count() & 1 ? __upper : __lower; } #endif // duration template class _LIBCPP_TEMPLATE_VIS duration { static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); static_assert(_Period::num > 0, "duration period must be positive"); template struct __no_overflow { private: static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; static const intmax_t __n1 = _R1::num / __gcd_n1_n2; static const intmax_t __d1 = _R1::den / __gcd_d1_d2; static const intmax_t __n2 = _R2::num / __gcd_n1_n2; static const intmax_t __d2 = _R2::den / __gcd_d1_d2; static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1); template struct __mul // __overflow == false { static const intmax_t value = _Xp * _Yp; }; template struct __mul<_Xp, _Yp, true> { static const intmax_t value = 1; }; public: static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1); typedef ratio<__mul<__n1, __d2, !value>::value, __mul<__n2, __d1, !value>::value> type; }; public: typedef _Rep rep; typedef typename _Period::type period; private: rep __rep_; public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR #ifndef _LIBCPP_CXX03_LANG duration() = default; #else duration() {} #endif template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit duration(const _Rep2& __r, typename enable_if < - is_convertible<_Rep2, rep>::value && + is_convertible::value && (treat_as_floating_point::value || !treat_as_floating_point<_Rep2>::value) >::type* = nullptr) : __rep_(__r) {} // conversions template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration(const duration<_Rep2, _Period2>& __d, typename enable_if < __no_overflow<_Period2, period>::value && ( treat_as_floating_point::value || (__no_overflow<_Period2, period>::type::den == 1 && !treat_as_floating_point<_Rep2>::value)) >::type* = nullptr) : __rep_(chrono::duration_cast(__d).count()) {} // observer _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;} // arithmetic _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type::type operator+() const {return typename common_type::type(*this);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type::type operator-() const {return typename common_type::type(-__rep_);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++() {++__rep_; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;} // special values _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {return duration(duration_values::zero());} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT {return duration(duration_values::min());} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT {return duration(duration_values::max());} }; typedef duration nanoseconds; typedef duration microseconds; typedef duration milliseconds; typedef duration seconds; typedef duration< long, ratio< 60> > minutes; typedef duration< long, ratio<3600> > hours; #if _LIBCPP_STD_VER > 17 typedef duration< int, ratio_multiply, hours::period>> days; typedef duration< int, ratio_multiply, days::period>> weeks; typedef duration< int, ratio_multiply, days::period>> years; typedef duration< int, ratio_divide>> months; #endif // Duration == template struct __duration_eq { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const { typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; return _Ct(__lhs).count() == _Ct(__rhs).count(); } }; template struct __duration_eq<_LhsDuration, _LhsDuration> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const {return __lhs.count() == __rhs.count();} }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return __duration_eq, duration<_Rep2, _Period2> >()(__lhs, __rhs); } // Duration != template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return !(__lhs == __rhs); } // Duration < template struct __duration_lt { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const { typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; return _Ct(__lhs).count() < _Ct(__rhs).count(); } }; template struct __duration_lt<_LhsDuration, _LhsDuration> { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const {return __lhs.count() < __rhs.count();} }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return __duration_lt, duration<_Rep2, _Period2> >()(__lhs, __rhs); } // Duration > template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return __rhs < __lhs; } // Duration <= template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return !(__rhs < __lhs); } // Duration >= template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { return !(__lhs < __rhs); } // Duration + template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type, duration<_Rep2, _Period2> >::type operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef typename common_type, duration<_Rep2, _Period2> >::type _Cd; return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count()); } // Duration - template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type, duration<_Rep2, _Period2> >::type operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef typename common_type, duration<_Rep2, _Period2> >::type _Cd; return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count()); } // Duration * template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, duration::type, _Period> >::type operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; typedef duration<_Cr, _Period> _Cd; return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s)); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, duration::type, _Period> >::type operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) { return __d * __s; } // Duration / template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < !__is_duration<_Rep2>::value && is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, duration::type, _Period> >::type operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; typedef duration<_Cr, _Period> _Cd; return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s)); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<_Rep1, _Rep2>::type operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef typename common_type, duration<_Rep2, _Period2> >::type _Ct; return _Ct(__lhs).count() / _Ct(__rhs).count(); } // Duration % template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename enable_if < !__is_duration<_Rep2>::value && is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, duration::type, _Period> >::type operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; typedef duration<_Cr, _Period> _Cd; return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s)); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type, duration<_Rep2, _Period2> >::type operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; typedef typename common_type, duration<_Rep2, _Period2> >::type _Cd; return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count())); } } // namespace chrono #if _LIBCPP_STD_VER > 11 // Suffixes for duration literals [time.duration.literals] inline namespace literals { inline namespace chrono_literals { constexpr chrono::hours operator""h(unsigned long long __h) { return chrono::hours(static_cast(__h)); } constexpr chrono::duration> operator""h(long double __h) { return chrono::duration>(__h); } constexpr chrono::minutes operator""min(unsigned long long __m) { return chrono::minutes(static_cast(__m)); } constexpr chrono::duration> operator""min(long double __m) { return chrono::duration> (__m); } constexpr chrono::seconds operator""s(unsigned long long __s) { return chrono::seconds(static_cast(__s)); } constexpr chrono::duration operator""s(long double __s) { return chrono::duration (__s); } constexpr chrono::milliseconds operator""ms(unsigned long long __ms) { return chrono::milliseconds(static_cast(__ms)); } constexpr chrono::duration operator""ms(long double __ms) { return chrono::duration(__ms); } constexpr chrono::microseconds operator""us(unsigned long long __us) { return chrono::microseconds(static_cast(__us)); } constexpr chrono::duration operator""us(long double __us) { return chrono::duration (__us); } constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) { return chrono::nanoseconds(static_cast(__ns)); } constexpr chrono::duration operator""ns(long double __ns) { return chrono::duration (__ns); } } // namespace chrono_literals } // namespace literals namespace chrono { // hoist the literals into namespace std::chrono using namespace literals::chrono_literals; } // namespace chrono #endif // _LIBCPP_STD_VER > 11 _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #endif // _LIBCPP___CHRONO_DURATION_H diff --git a/libcxx/include/__compare/compare_partial_order_fallback.h b/libcxx/include/__compare/compare_partial_order_fallback.h index 895523b38fb3..64937eaf37dd 100644 --- a/libcxx/include/__compare/compare_partial_order_fallback.h +++ b/libcxx/include/__compare/compare_partial_order_fallback.h @@ -1,73 +1,73 @@ //===----------------------------------------------------------------------===// // // 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___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK #define _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK #include <__compare/ordering.h> #include <__compare/partial_order.h> #include <__config> #include <__utility/forward.h> #include <__utility/priority_tag.h> #include #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [cmp.alg] namespace __compare_partial_order_fallback { struct __fn { template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept(noexcept(_VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) -> decltype( _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) { return _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : partial_ordering::unordered)) -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : partial_ordering::unordered) { return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : partial_ordering::unordered; } template _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } }; } // namespace __compare_partial_order_fallback inline namespace __cpo { inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{}; } // namespace __cpo -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK diff --git a/libcxx/include/__compare/compare_strong_order_fallback.h b/libcxx/include/__compare/compare_strong_order_fallback.h index 5fee7b478068..b7abef26e9d2 100644 --- a/libcxx/include/__compare/compare_strong_order_fallback.h +++ b/libcxx/include/__compare/compare_strong_order_fallback.h @@ -1,70 +1,70 @@ //===----------------------------------------------------------------------===// // // 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___COMPARE_COMPARE_STRONG_ORDER_FALLBACK #define _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK #include <__compare/ordering.h> #include <__compare/strong_order.h> #include <__config> #include <__utility/forward.h> #include <__utility/priority_tag.h> #include #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [cmp.alg] namespace __compare_strong_order_fallback { struct __fn { template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept(noexcept(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) -> decltype( _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) { return _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : strong_ordering::greater)) -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : strong_ordering::greater) { return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : strong_ordering::greater; } template _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } }; } // namespace __compare_strong_order_fallback inline namespace __cpo { inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{}; } // namespace __cpo -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK diff --git a/libcxx/include/__compare/compare_three_way.h b/libcxx/include/__compare/compare_three_way.h index d7f339eda992..ddd37890a467 100644 --- a/libcxx/include/__compare/compare_three_way.h +++ b/libcxx/include/__compare/compare_three_way.h @@ -1,41 +1,41 @@ // -*- 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___COMPARE_COMPARE_THREE_WAY_H #define _LIBCPP___COMPARE_COMPARE_THREE_WAY_H #include <__compare/three_way_comparable.h> #include <__config> #include <__utility/forward.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) struct _LIBCPP_TEMPLATE_VIS compare_three_way { template requires three_way_comparable_with<_T1, _T2> constexpr _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const noexcept(noexcept(_VSTD::forward<_T1>(__t) <=> _VSTD::forward<_T2>(__u))) { return _VSTD::forward<_T1>(__t) <=> _VSTD::forward<_T2>(__u); } using is_transparent = void; }; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_H diff --git a/libcxx/include/__compare/compare_weak_order_fallback.h b/libcxx/include/__compare/compare_weak_order_fallback.h index 0abd4f2dfbee..5a1807e69717 100644 --- a/libcxx/include/__compare/compare_weak_order_fallback.h +++ b/libcxx/include/__compare/compare_weak_order_fallback.h @@ -1,70 +1,70 @@ //===----------------------------------------------------------------------===// // // 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___COMPARE_COMPARE_WEAK_ORDER_FALLBACK #define _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK #include <__compare/ordering.h> #include <__compare/weak_order.h> #include <__config> #include <__utility/forward.h> #include <__utility/priority_tag.h> #include #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [cmp.alg] namespace __compare_weak_order_fallback { struct __fn { template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept(noexcept(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) -> decltype( _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) { return _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : weak_ordering::greater)) -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : weak_ordering::greater) { return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : weak_ordering::greater; } template _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } }; } // namespace __compare_weak_order_fallback inline namespace __cpo { inline constexpr auto compare_weak_order_fallback = __compare_weak_order_fallback::__fn{}; } // namespace __cpo -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK diff --git a/libcxx/include/__compare/partial_order.h b/libcxx/include/__compare/partial_order.h index ac8b405a4090..cbadfcde7396 100644 --- a/libcxx/include/__compare/partial_order.h +++ b/libcxx/include/__compare/partial_order.h @@ -1,71 +1,71 @@ //===----------------------------------------------------------------------===// // // 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___COMPARE_PARTIAL_ORDER #define _LIBCPP___COMPARE_PARTIAL_ORDER #include <__compare/compare_three_way.h> #include <__compare/ordering.h> #include <__compare/weak_order.h> #include <__config> #include <__utility/forward.h> #include <__utility/priority_tag.h> #include #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [cmp.alg] namespace __partial_order { struct __fn { template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) noexcept(noexcept(partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) -> decltype( partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { return partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept(noexcept(partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) -> decltype( partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { return partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept(partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) -> decltype( partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { return partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } template _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))) -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())) { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); } }; } // namespace __partial_order inline namespace __cpo { inline constexpr auto partial_order = __partial_order::__fn{}; } // namespace __cpo -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___COMPARE_PARTIAL_ORDER diff --git a/libcxx/include/__compare/strong_order.h b/libcxx/include/__compare/strong_order.h index 42f060387d59..a0dc077047f5 100644 --- a/libcxx/include/__compare/strong_order.h +++ b/libcxx/include/__compare/strong_order.h @@ -1,136 +1,136 @@ //===----------------------------------------------------------------------===// // // 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___COMPARE_STRONG_ORDER #define _LIBCPP___COMPARE_STRONG_ORDER #include <__bit/bit_cast.h> #include <__compare/compare_three_way.h> #include <__compare/ordering.h> #include <__config> #include <__utility/forward.h> #include <__utility/priority_tag.h> #include #include #include #include #ifndef _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 > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [cmp.alg] namespace __strong_order { struct __fn { template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) noexcept(noexcept(strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) -> decltype( strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { return strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } template> requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp> _LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept { if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int32_t)) { int32_t __rx = _VSTD::bit_cast(__t); int32_t __ry = _VSTD::bit_cast(__u); __rx = (__rx < 0) ? (numeric_limits::min() - __rx - 1) : __rx; __ry = (__ry < 0) ? (numeric_limits::min() - __ry - 1) : __ry; return (__rx <=> __ry); } else if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int64_t)) { int64_t __rx = _VSTD::bit_cast(__t); int64_t __ry = _VSTD::bit_cast(__u); __rx = (__rx < 0) ? (numeric_limits::min() - __rx - 1) : __rx; __ry = (__ry < 0) ? (numeric_limits::min() - __ry - 1) : __ry; return (__rx <=> __ry); } else if (__t < __u) { return strong_ordering::less; } else if (__t > __u) { return strong_ordering::greater; } else if (__t == __u) { if constexpr (numeric_limits<_Dp>::radix == 2) { return _VSTD::signbit(__u) <=> _VSTD::signbit(__t); } else { // This is bullet 3 of the IEEE754 algorithm, relevant // only for decimal floating-point; // see https://stackoverflow.com/questions/69068075/ if (__t == 0 || _VSTD::isinf(__t)) { return _VSTD::signbit(__u) <=> _VSTD::signbit(__t); } else { int __texp, __uexp; (void)_VSTD::frexp(__t, &__texp); (void)_VSTD::frexp(__u, &__uexp); return (__t < 0) ? (__texp <=> __uexp) : (__uexp <=> __texp); } } } else { // They're unordered, so one of them must be a NAN. // The order is -QNAN, -SNAN, numbers, +SNAN, +QNAN. bool __t_is_nan = _VSTD::isnan(__t); bool __u_is_nan = _VSTD::isnan(__u); bool __t_is_negative = _VSTD::signbit(__t); bool __u_is_negative = _VSTD::signbit(__u); using _IntType = conditional_t< sizeof(__t) == sizeof(int32_t), int32_t, conditional_t< sizeof(__t) == sizeof(int64_t), int64_t, void> >; if constexpr (is_same_v<_IntType, void>) { static_assert(sizeof(_Dp) == 0, "std::strong_order is unimplemented for this floating-point type"); } else if (__t_is_nan && __u_is_nan) { // Order by sign bit, then by "payload bits" (we'll just use bit_cast). if (__t_is_negative != __u_is_negative) { return (__u_is_negative <=> __t_is_negative); } else { return _VSTD::bit_cast<_IntType>(__t) <=> _VSTD::bit_cast<_IntType>(__u); } } else if (__t_is_nan) { return __t_is_negative ? strong_ordering::less : strong_ordering::greater; } else { return __u_is_negative ? strong_ordering::greater : strong_ordering::less; } } } template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept(strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) -> decltype( strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { return strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } template _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))) -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())) { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); } }; } // namespace __strong_order inline namespace __cpo { inline constexpr auto strong_order = __strong_order::__fn{}; } // namespace __cpo -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #endif // _LIBCPP___COMPARE_STRONG_ORDER diff --git a/libcxx/include/__compare/synth_three_way.h b/libcxx/include/__compare/synth_three_way.h index 0f302c0fa11f..b93d4932c57f 100644 --- a/libcxx/include/__compare/synth_three_way.h +++ b/libcxx/include/__compare/synth_three_way.h @@ -1,51 +1,51 @@ //===----------------------------------------------------------------------===// // // 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___COMPARE_SYNTH_THREE_WAY_H #define _LIBCPP___COMPARE_SYNTH_THREE_WAY_H #include <__compare/ordering.h> #include <__compare/three_way_comparable.h> #include <__concepts/boolean_testable.h> #include <__config> #include <__utility/declval.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [expos.only.func] _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = [](const _Tp& __t, const _Up& __u) requires requires { { __t < __u } -> __boolean_testable; { __u < __t } -> __boolean_testable; } { if constexpr (three_way_comparable_with<_Tp, _Up>) { return __t <=> __u; } else { if (__t < __u) return weak_ordering::less; if (__u < __t) return weak_ordering::greater; return weak_ordering::equivalent; } }; template using __synth_three_way_result = decltype(__synth_three_way(declval<_Tp&>(), declval<_Up&>())); -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___COMPARE_SYNTH_THREE_WAY_H diff --git a/libcxx/include/__compare/three_way_comparable.h b/libcxx/include/__compare/three_way_comparable.h index c4794949007b..548bf17f0feb 100644 --- a/libcxx/include/__compare/three_way_comparable.h +++ b/libcxx/include/__compare/three_way_comparable.h @@ -1,58 +1,58 @@ //===----------------------------------------------------------------------===// // // 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___COMPARE_THREE_WAY_COMPARABLE_H #define _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H #include <__compare/common_comparison_category.h> #include <__compare/ordering.h> #include <__concepts/common_reference_with.h> #include <__concepts/equality_comparable.h> #include <__concepts/same_as.h> #include <__concepts/totally_ordered.h> #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template concept __compares_as = same_as, _Cat>; template concept three_way_comparable = __weakly_equality_comparable_with<_Tp, _Tp> && __partially_ordered_with<_Tp, _Tp> && requires(__make_const_lvalue_ref<_Tp> __a, __make_const_lvalue_ref<_Tp> __b) { { __a <=> __b } -> __compares_as<_Cat>; }; template concept three_way_comparable_with = three_way_comparable<_Tp, _Cat> && three_way_comparable<_Up, _Cat> && common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> && three_way_comparable, __make_const_lvalue_ref<_Up>>, _Cat> && __weakly_equality_comparable_with<_Tp, _Up> && __partially_ordered_with<_Tp, _Up> && requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { { __t <=> __u } -> __compares_as<_Cat>; { __u <=> __t } -> __compares_as<_Cat>; }; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H diff --git a/libcxx/include/__compare/weak_order.h b/libcxx/include/__compare/weak_order.h index ce914b232108..1286f39b020c 100644 --- a/libcxx/include/__compare/weak_order.h +++ b/libcxx/include/__compare/weak_order.h @@ -1,100 +1,100 @@ //===----------------------------------------------------------------------===// // // 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___COMPARE_WEAK_ORDER #define _LIBCPP___COMPARE_WEAK_ORDER #include <__compare/compare_three_way.h> #include <__compare/ordering.h> #include <__compare/strong_order.h> #include <__config> #include <__utility/forward.h> #include <__utility/priority_tag.h> #include #include #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [cmp.alg] namespace __weak_order { struct __fn { template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<3>) noexcept(noexcept(weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) -> decltype( weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { return weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } template> requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp> _LIBCPP_HIDE_FROM_ABI static constexpr weak_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) noexcept { partial_ordering __po = (__t <=> __u); if (__po == partial_ordering::less) { return weak_ordering::less; } else if (__po == partial_ordering::equivalent) { return weak_ordering::equivalent; } else if (__po == partial_ordering::greater) { return weak_ordering::greater; } else { // Otherwise, at least one of them is a NaN. bool __t_is_nan = _VSTD::isnan(__t); bool __u_is_nan = _VSTD::isnan(__u); bool __t_is_negative = _VSTD::signbit(__t); bool __u_is_negative = _VSTD::signbit(__u); if (__t_is_nan && __u_is_nan) { return (__u_is_negative <=> __t_is_negative); } else if (__t_is_nan) { return __t_is_negative ? weak_ordering::less : weak_ordering::greater; } else { return __u_is_negative ? weak_ordering::greater : weak_ordering::less; } } } template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept(noexcept(weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) -> decltype( weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { return weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } template requires is_same_v, decay_t<_Up>> _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept(weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) -> decltype( weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { return weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } template _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>()))) -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>())) { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>()); } }; } // namespace __weak_order inline namespace __cpo { inline constexpr auto weak_order = __weak_order::__fn{}; } // namespace __cpo -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___COMPARE_WEAK_ORDER diff --git a/libcxx/include/__concepts/arithmetic.h b/libcxx/include/__concepts/arithmetic.h index 9a1383904db6..c2f94239a6c3 100644 --- a/libcxx/include/__concepts/arithmetic.h +++ b/libcxx/include/__concepts/arithmetic.h @@ -1,48 +1,48 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_ARITHMETIC_H #define _LIBCPP___CONCEPTS_ARITHMETIC_H #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concepts.arithmetic], arithmetic concepts template concept integral = is_integral_v<_Tp>; template concept signed_integral = integral<_Tp> && is_signed_v<_Tp>; template concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; template concept floating_point = is_floating_point_v<_Tp>; // Concept helpers for the internal type traits for the fundamental types. template concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value; template concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_ARITHMETIC_H diff --git a/libcxx/include/__concepts/assignable.h b/libcxx/include/__concepts/assignable.h index 9cfc7c0e8318..62f39f1c8cdd 100644 --- a/libcxx/include/__concepts/assignable.h +++ b/libcxx/include/__concepts/assignable.h @@ -1,40 +1,40 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_ASSIGNABLE_H #define _LIBCPP___CONCEPTS_ASSIGNABLE_H #include <__concepts/common_reference_with.h> #include <__concepts/same_as.h> #include <__config> #include <__utility/forward.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.assignable] template concept assignable_from = is_lvalue_reference_v<_Lhs> && common_reference_with<__make_const_lvalue_ref<_Lhs>, __make_const_lvalue_ref<_Rhs>> && requires (_Lhs __lhs, _Rhs&& __rhs) { { __lhs = _VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>; }; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_ASSIGNABLE_H diff --git a/libcxx/include/__concepts/boolean_testable.h b/libcxx/include/__concepts/boolean_testable.h index 638fc3b20330..c04c30429166 100644 --- a/libcxx/include/__concepts/boolean_testable.h +++ b/libcxx/include/__concepts/boolean_testable.h @@ -1,38 +1,38 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_BOOLEAN_TESTABLE_H #define _LIBCPP___CONCEPTS_BOOLEAN_TESTABLE_H #include <__concepts/convertible_to.h> #include <__config> #include <__utility/forward.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concepts.booleantestable] template concept __boolean_testable_impl = convertible_to<_Tp, bool>; template concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t) { { !_VSTD::forward<_Tp>(__t) } -> __boolean_testable_impl; }; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_BOOLEAN_TESTABLE_H diff --git a/libcxx/include/__concepts/class_or_enum.h b/libcxx/include/__concepts/class_or_enum.h index aa8606a21929..3d28a8ad984d 100644 --- a/libcxx/include/__concepts/class_or_enum.h +++ b/libcxx/include/__concepts/class_or_enum.h @@ -1,36 +1,36 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_CLASS_OR_ENUM_H #define _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // Whether a type is a class type or enumeration type according to the Core wording. template concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>; // Work around Clang bug https://llvm.org/PR52970 template concept __workaround_52970 = is_class_v<__uncvref_t<_Tp>> || is_union_v<__uncvref_t<_Tp>>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H diff --git a/libcxx/include/__concepts/common_reference_with.h b/libcxx/include/__concepts/common_reference_with.h index 3269e3ae89fe..119d8fd8deed 100644 --- a/libcxx/include/__concepts/common_reference_with.h +++ b/libcxx/include/__concepts/common_reference_with.h @@ -1,37 +1,37 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_COMMON_REFERENCE_WITH_H #define _LIBCPP___CONCEPTS_COMMON_REFERENCE_WITH_H #include <__concepts/convertible_to.h> #include <__concepts/same_as.h> #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.commonref] template concept common_reference_with = same_as, common_reference_t<_Up, _Tp>> && convertible_to<_Tp, common_reference_t<_Tp, _Up>> && convertible_to<_Up, common_reference_t<_Tp, _Up>>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_COMMON_REFERENCE_WITH_H diff --git a/libcxx/include/__concepts/common_with.h b/libcxx/include/__concepts/common_with.h index b575aea5f77f..ecaa23b63b22 100644 --- a/libcxx/include/__concepts/common_with.h +++ b/libcxx/include/__concepts/common_with.h @@ -1,47 +1,47 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_COMMON_WITH_H #define _LIBCPP___CONCEPTS_COMMON_WITH_H #include <__concepts/common_reference_with.h> #include <__concepts/same_as.h> #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.common] template concept common_with = same_as, common_type_t<_Up, _Tp>> && requires { static_cast>(declval<_Tp>()); static_cast>(declval<_Up>()); } && common_reference_with< add_lvalue_reference_t, add_lvalue_reference_t> && common_reference_with< add_lvalue_reference_t>, common_reference_t< add_lvalue_reference_t, add_lvalue_reference_t>>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_COMMON_WITH_H diff --git a/libcxx/include/__concepts/constructible.h b/libcxx/include/__concepts/constructible.h index 9bba8118b899..49986bb248d5 100644 --- a/libcxx/include/__concepts/constructible.h +++ b/libcxx/include/__concepts/constructible.h @@ -1,56 +1,56 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_CONSTRUCTIBLE_H #define _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H #include <__concepts/convertible_to.h> #include <__concepts/destructible.h> #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.constructible] template concept constructible_from = destructible<_Tp> && is_constructible_v<_Tp, _Args...>; // [concept.default.init] template concept __default_initializable = requires { ::new _Tp; }; template concept default_initializable = constructible_from<_Tp> && requires { _Tp{}; } && __default_initializable<_Tp>; // [concept.moveconstructible] template concept move_constructible = constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>; // [concept.copyconstructible] template concept copy_constructible = move_constructible<_Tp> && constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> && constructible_from<_Tp, const _Tp&> && convertible_to && constructible_from<_Tp, const _Tp> && convertible_to; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H diff --git a/libcxx/include/__concepts/convertible_to.h b/libcxx/include/__concepts/convertible_to.h index 795b0bd7494c..75f5da203c96 100644 --- a/libcxx/include/__concepts/convertible_to.h +++ b/libcxx/include/__concepts/convertible_to.h @@ -1,37 +1,37 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_CONVERTIBLE_TO_H #define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H #include <__config> #include <__utility/declval.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.convertible] template concept convertible_to = is_convertible_v<_From, _To> && requires { static_cast<_To>(declval<_From>()); }; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H diff --git a/libcxx/include/__concepts/copyable.h b/libcxx/include/__concepts/copyable.h index cfeeec86917e..c264b31a21ca 100644 --- a/libcxx/include/__concepts/copyable.h +++ b/libcxx/include/__concepts/copyable.h @@ -1,39 +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___CONCEPTS_COPYABLE_H #define _LIBCPP___CONCEPTS_COPYABLE_H #include <__concepts/assignable.h> #include <__concepts/constructible.h> #include <__concepts/movable.h> #include <__config> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concepts.object] template concept copyable = copy_constructible<_Tp> && movable<_Tp> && assignable_from<_Tp&, _Tp&> && assignable_from<_Tp&, const _Tp&> && assignable_from<_Tp&, const _Tp>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_COPYABLE_H diff --git a/libcxx/include/__concepts/derived_from.h b/libcxx/include/__concepts/derived_from.h index f7c83bf31fba..acd4ba473cdd 100644 --- a/libcxx/include/__concepts/derived_from.h +++ b/libcxx/include/__concepts/derived_from.h @@ -1,34 +1,34 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_DERIVED_FROM_H #define _LIBCPP___CONCEPTS_DERIVED_FROM_H #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.derived] template concept derived_from = is_base_of_v<_Bp, _Dp> && is_convertible_v; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_DERIVED_FROM_H diff --git a/libcxx/include/__concepts/destructible.h b/libcxx/include/__concepts/destructible.h index 800ee2d56f04..d57824be9e19 100644 --- a/libcxx/include/__concepts/destructible.h +++ b/libcxx/include/__concepts/destructible.h @@ -1,32 +1,32 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_DESTRUCTIBLE_H #define _LIBCPP___CONCEPTS_DESTRUCTIBLE_H #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.destructible] template concept destructible = is_nothrow_destructible_v<_Tp>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_DESTRUCTIBLE_H diff --git a/libcxx/include/__concepts/different_from.h b/libcxx/include/__concepts/different_from.h index 5def31e652a5..c8560baf8af4 100644 --- a/libcxx/include/__concepts/different_from.h +++ b/libcxx/include/__concepts/different_from.h @@ -1,31 +1,31 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_DIFFERENT_FROM_H #define _LIBCPP___CONCEPTS_DIFFERENT_FROM_H #include <__concepts/same_as.h> #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template concept __different_from = !same_as, remove_cvref_t<_Up>>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_DIFFERENT_FROM_H diff --git a/libcxx/include/__concepts/equality_comparable.h b/libcxx/include/__concepts/equality_comparable.h index 5df812c2600d..064143b89443 100644 --- a/libcxx/include/__concepts/equality_comparable.h +++ b/libcxx/include/__concepts/equality_comparable.h @@ -1,53 +1,53 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_EQUALITY_COMPARABLE_H #define _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H #include <__concepts/boolean_testable.h> #include <__concepts/common_reference_with.h> #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.equalitycomparable] template concept __weakly_equality_comparable_with = requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { { __t == __u } -> __boolean_testable; { __t != __u } -> __boolean_testable; { __u == __t } -> __boolean_testable; { __u != __t } -> __boolean_testable; }; template concept equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>; template concept equality_comparable_with = equality_comparable<_Tp> && equality_comparable<_Up> && common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> && equality_comparable< common_reference_t< __make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>>> && __weakly_equality_comparable_with<_Tp, _Up>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H diff --git a/libcxx/include/__concepts/invocable.h b/libcxx/include/__concepts/invocable.h index 0a8d9b7255ab..e528258e3583 100644 --- a/libcxx/include/__concepts/invocable.h +++ b/libcxx/include/__concepts/invocable.h @@ -1,41 +1,41 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_INVOCABLE_H #define _LIBCPP___CONCEPTS_INVOCABLE_H #include <__config> #include <__functional/invoke.h> #include <__utility/forward.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.invocable] template concept invocable = requires(_Fn&& __fn, _Args&&... __args) { _VSTD::invoke(_VSTD::forward<_Fn>(__fn), _VSTD::forward<_Args>(__args)...); // not required to be equality preserving }; // [concept.regular.invocable] template concept regular_invocable = invocable<_Fn, _Args...>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_INVOCABLE_H diff --git a/libcxx/include/__concepts/movable.h b/libcxx/include/__concepts/movable.h index dd0b8fb56d5b..fd8c2e7fa20e 100644 --- a/libcxx/include/__concepts/movable.h +++ b/libcxx/include/__concepts/movable.h @@ -1,39 +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___CONCEPTS_MOVABLE_H #define _LIBCPP___CONCEPTS_MOVABLE_H #include <__concepts/assignable.h> #include <__concepts/constructible.h> #include <__concepts/swappable.h> #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concepts.object] template concept movable = is_object_v<_Tp> && move_constructible<_Tp> && assignable_from<_Tp&, _Tp> && swappable<_Tp>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_MOVABLE_H diff --git a/libcxx/include/__concepts/predicate.h b/libcxx/include/__concepts/predicate.h index 8e885406316d..491a7d6c73ea 100644 --- a/libcxx/include/__concepts/predicate.h +++ b/libcxx/include/__concepts/predicate.h @@ -1,35 +1,35 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_PREDICATE_H #define _LIBCPP___CONCEPTS_PREDICATE_H #include <__concepts/boolean_testable.h> #include <__concepts/invocable.h> #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.predicate] template concept predicate = regular_invocable<_Fn, _Args...> && __boolean_testable>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_PREDICATE_H diff --git a/libcxx/include/__concepts/regular.h b/libcxx/include/__concepts/regular.h index d292e8d72dbe..e8a87c97febf 100644 --- a/libcxx/include/__concepts/regular.h +++ b/libcxx/include/__concepts/regular.h @@ -1,33 +1,33 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_REGULAR_H #define _LIBCPP___CONCEPTS_REGULAR_H #include <__concepts/equality_comparable.h> #include <__concepts/semiregular.h> #include <__config> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.object] template concept regular = semiregular<_Tp> && equality_comparable<_Tp>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_REGULAR_H diff --git a/libcxx/include/__concepts/relation.h b/libcxx/include/__concepts/relation.h index c6ff20d15195..fa7e5d17df88 100644 --- a/libcxx/include/__concepts/relation.h +++ b/libcxx/include/__concepts/relation.h @@ -1,44 +1,44 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_RELATION_H #define _LIBCPP___CONCEPTS_RELATION_H #include <__concepts/predicate.h> #include <__config> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.relation] template concept relation = predicate<_Rp, _Tp, _Tp> && predicate<_Rp, _Up, _Up> && predicate<_Rp, _Tp, _Up> && predicate<_Rp, _Up, _Tp>; // [concept.equiv] template concept equivalence_relation = relation<_Rp, _Tp, _Up>; // [concept.strictweakorder] template concept strict_weak_order = relation<_Rp, _Tp, _Up>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_RELATION_H diff --git a/libcxx/include/__concepts/same_as.h b/libcxx/include/__concepts/same_as.h index 5a912b6f41c8..ee86c44ea35d 100644 --- a/libcxx/include/__concepts/same_as.h +++ b/libcxx/include/__concepts/same_as.h @@ -1,35 +1,35 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_SAME_AS_H #define _LIBCPP___CONCEPTS_SAME_AS_H #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.same] template concept __same_as_impl = _IsSame<_Tp, _Up>::value; template concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_SAME_AS_H diff --git a/libcxx/include/__concepts/semiregular.h b/libcxx/include/__concepts/semiregular.h index 4b96fe6dfba6..4797fc7eaa64 100644 --- a/libcxx/include/__concepts/semiregular.h +++ b/libcxx/include/__concepts/semiregular.h @@ -1,33 +1,33 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_SEMIREGULAR_H #define _LIBCPP___CONCEPTS_SEMIREGULAR_H #include <__concepts/constructible.h> #include <__concepts/copyable.h> #include <__config> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.object] template concept semiregular = copyable<_Tp> && default_initializable<_Tp>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_SEMIREGULAR_H diff --git a/libcxx/include/__concepts/swappable.h b/libcxx/include/__concepts/swappable.h index d45249738535..6b8cf82b70ef 100644 --- a/libcxx/include/__concepts/swappable.h +++ b/libcxx/include/__concepts/swappable.h @@ -1,116 +1,116 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_SWAPPABLE_H #define _LIBCPP___CONCEPTS_SWAPPABLE_H #include <__concepts/assignable.h> #include <__concepts/class_or_enum.h> #include <__concepts/common_reference_with.h> #include <__concepts/constructible.h> #include <__config> #include <__utility/exchange.h> #include <__utility/forward.h> #include <__utility/move.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.swappable] namespace ranges { namespace __swap { template void swap(_Tp&, _Tp&) = delete; template concept __unqualified_swappable_with = (__class_or_enum> || __class_or_enum>) && requires(_Tp&& __t, _Up&& __u) { swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); }; struct __fn; template concept __swappable_arrays = !__unqualified_swappable_with<_Tp(&)[_Size], _Up(&)[_Size]> && extent_v<_Tp> == extent_v<_Up> && requires(_Tp(& __t)[_Size], _Up(& __u)[_Size], const __fn& __swap) { __swap(__t[0], __u[0]); }; template concept __exchangeable = !__unqualified_swappable_with<_Tp&, _Tp&> && move_constructible<_Tp> && assignable_from<_Tp&, _Tp>; struct __fn { // 2.1 `S` is `(void)swap(E1, E2)`* if `E1` or `E2` has class or enumeration type and... // *The name `swap` is used here unqualified. template requires __unqualified_swappable_with<_Tp, _Up> constexpr void operator()(_Tp&& __t, _Up&& __u) const noexcept(noexcept(swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) { swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } // 2.2 Otherwise, if `E1` and `E2` are lvalues of array types with equal extent and... template requires __swappable_arrays<_Tp, _Up, _Size> constexpr void operator()(_Tp(& __t)[_Size], _Up(& __u)[_Size]) const noexcept(noexcept((*this)(*__t, *__u))) { // TODO(cjdb): replace with `ranges::swap_ranges`. for (size_t __i = 0; __i < _Size; ++__i) { (*this)(__t[__i], __u[__i]); } } // 2.3 Otherwise, if `E1` and `E2` are lvalues of the same type `T` that models... template<__exchangeable _Tp> constexpr void operator()(_Tp& __x, _Tp& __y) const noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_assignable_v<_Tp>) { __y = _VSTD::exchange(__x, _VSTD::move(__y)); } }; } // namespace __swap inline namespace __cpo { inline constexpr auto swap = __swap::__fn{}; } // namespace __cpo } // namespace ranges template concept swappable = requires(_Tp& __a, _Tp& __b) { ranges::swap(__a, __b); }; template concept swappable_with = common_reference_with<_Tp, _Up> && requires(_Tp&& __t, _Up&& __u) { ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Tp>(__t)); ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Up>(__u)); ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Tp>(__t)); }; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_SWAPPABLE_H diff --git a/libcxx/include/__concepts/totally_ordered.h b/libcxx/include/__concepts/totally_ordered.h index d8dd4a4944d0..58dcb42be579 100644 --- a/libcxx/include/__concepts/totally_ordered.h +++ b/libcxx/include/__concepts/totally_ordered.h @@ -1,57 +1,57 @@ //===----------------------------------------------------------------------===// // // 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___CONCEPTS_TOTALLY_ORDERED_H #define _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H #include <__concepts/boolean_testable.h> #include <__concepts/equality_comparable.h> #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.totallyordered] template concept __partially_ordered_with = requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { { __t < __u } -> __boolean_testable; { __t > __u } -> __boolean_testable; { __t <= __u } -> __boolean_testable; { __t >= __u } -> __boolean_testable; { __u < __t } -> __boolean_testable; { __u > __t } -> __boolean_testable; { __u <= __t } -> __boolean_testable; { __u >= __t } -> __boolean_testable; }; template concept totally_ordered = equality_comparable<_Tp> && __partially_ordered_with<_Tp, _Tp>; template concept totally_ordered_with = totally_ordered<_Tp> && totally_ordered<_Up> && equality_comparable_with<_Tp, _Up> && totally_ordered< common_reference_t< __make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>>> && __partially_ordered_with<_Tp, _Up>; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H diff --git a/libcxx/include/__config b/libcxx/include/__config index 3c3d4b57c76e..d2d70c4ed769 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1,1433 +1,1433 @@ // -*- 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_CONFIG #define _LIBCPP_CONFIG #include <__config_site> #if defined(_MSC_VER) && !defined(__clang__) # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER # endif #endif #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif #ifdef __cplusplus #define _LIBCPP_VERSION 14000 #ifndef _LIBCPP_ABI_VERSION # define _LIBCPP_ABI_VERSION 1 #endif #if __STDC_HOSTED__ == 0 # define _LIBCPP_FREESTANDING #endif #ifndef _LIBCPP_STD_VER # if __cplusplus <= 201103L # define _LIBCPP_STD_VER 11 # elif __cplusplus <= 201402L # define _LIBCPP_STD_VER 14 # elif __cplusplus <= 201703L # define _LIBCPP_STD_VER 17 # elif __cplusplus <= 202002L # define _LIBCPP_STD_VER 20 # else # define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification # endif #endif // _LIBCPP_STD_VER #if defined(__ELF__) # define _LIBCPP_OBJECT_FORMAT_ELF 1 #elif defined(__MACH__) # define _LIBCPP_OBJECT_FORMAT_MACHO 1 #elif defined(_WIN32) # define _LIBCPP_OBJECT_FORMAT_COFF 1 #elif defined(__wasm__) # define _LIBCPP_OBJECT_FORMAT_WASM 1 #else // ... add new file formats here ... #endif #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 // Change short string representation so that string data starts at offset 0, // improving its alignment in some cases. # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT // Fix deque iterator type in order to support incomplete types. # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE // Fix undefined behavior in how std::list stores its linked nodes. # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB // Fix undefined behavior in how __tree stores its end and parent nodes. # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB // Fix undefined behavior in how __hash_table stores its pointer types. # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE // Define a key function for `bad_function_call` in the library, to centralize // its vtable and typeinfo to libc++ rather than having all other libraries // using that class define their own copies. # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION // Override the default return value of exception::what() for // bad_function_call::what() with a string that is specific to // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break // because it changes the vtable layout of bad_function_call. # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE // Enable optimized version of __do_get_(un)signed which avoids redundant copies. # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET // In C++20 and later, don't derive std::plus from std::binary_function, // nor std::negate from std::unary_function. # define _LIBCPP_ABI_NO_BINDER_BASES // Give reverse_iterator one data member of type T, not two. // Also, in C++17 and later, don't derive iterator types from std::iterator. # define _LIBCPP_ABI_NO_ITERATOR_BASES // Use the smallest possible integer type to represent the index of the variant. // Previously libc++ used "unsigned int" exclusively. # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION // Unstable attempt to provide a more optimized std::function # define _LIBCPP_ABI_OPTIMIZED_FUNCTION // All the regex constants must be distinct and nonzero. # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO // Use raw pointers, not wrapped ones, for std::span's iterator type. # define _LIBCPP_ABI_SPAN_POINTER_ITERATORS // Re-worked external template instantiations for std::string with a focus on // performance and fast-path inlining. # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION // Enable clang::trivial_abi on std::unique_ptr. # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI // std::random_device holds some state when it uses an implementation that gets // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this // implementation to another one on a platform that has already shipped // std::random_device, one needs to retain the same object layout to remain ABI // compatible. This switch removes these workarounds for platforms that don't care // about ABI compatibility. # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT // Remove basic_string common base -# define _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS +# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON #elif _LIBCPP_ABI_VERSION == 1 # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) // Enable compiling copies of now inline methods into the dylib to support // applications compiled against older libraries. This is unnecessary with // COFF dllexport semantics, since dllexport forces a non-inline definition // of inline functions to be emitted anyway. Our own non-inline copy would // conflict with the dllexport-emitted copy, so we disable it. # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS # endif // Feature macros for disabling pre ABI v1 features. All of these options // are deprecated. # if defined(__FreeBSD__) # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR # endif #endif // By default, don't use a nullptr_t emulation type in C++03. // // This is technically an ABI break from previous releases, however it is // very unlikely to impact anyone. If a user is impacted by this break, // they can return to using the C++03 nullptr emulation by defining // _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION. // // This switch will be removed entirely in favour of never providing a // C++03 emulation after one release. // // IMPORTANT: IF YOU ARE READING THIS AND YOU TURN THIS MACRO ON, PLEASE LEAVE // A COMMENT ON https://reviews.llvm.org/D109459 OR YOU WILL BE BROKEN // IN THE FUTURE WHEN WE REMOVE THE ABILITY TO USE THE C++03 EMULATION. #ifndef _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION # define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR #endif #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 // Enable additional explicit instantiations of iostreams components. This // reduces the number of weak definitions generated in programs that use // iostreams by providing a single strong definition in the shared library. # define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 // Define a key function for `bad_function_call` in the library, to centralize // its vtable and typeinfo to libc++ rather than having all other libraries // using that class define their own copies. # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION #endif #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) #ifndef _LIBCPP_ABI_NAMESPACE # define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) #endif #if __cplusplus < 201103L #define _LIBCPP_CXX03_LANG #endif #ifndef __has_attribute #define __has_attribute(__x) 0 #endif #ifndef __has_builtin #define __has_builtin(__x) 0 #endif #ifndef __has_extension #define __has_extension(__x) 0 #endif #ifndef __has_feature #define __has_feature(__x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(__x) 0 #endif // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by // the compiler and '1' otherwise. #ifndef __is_identifier #define __is_identifier(__x) 1 #endif #ifndef __has_declspec_attribute #define __has_declspec_attribute(__x) 0 #endif #define __has_keyword(__x) !(__is_identifier(__x)) #ifndef __has_include #define __has_include(...) 0 #endif #if defined(__apple_build_version__) # define _LIBCPP_COMPILER_CLANG_BASED # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) #elif defined(__clang__) # define _LIBCPP_COMPILER_CLANG_BASED # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) #elif defined(__GNUC__) # define _LIBCPP_COMPILER_GCC #elif defined(_MSC_VER) # define _LIBCPP_COMPILER_MSVC #elif defined(__IBMCPP__) # define _LIBCPP_COMPILER_IBM #endif #if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L #error "libc++ does not support using GCC with C++03. 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 // Need to detect which libc we're using if we're on Linux. #if defined(__linux__) # include # 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__) #if defined(__MVS__) # include // for __NATIVE_ASCII_F #endif #ifdef __LITTLE_ENDIAN__ # if __LITTLE_ENDIAN__ # define _LIBCPP_LITTLE_ENDIAN # endif // __LITTLE_ENDIAN__ #endif // __LITTLE_ENDIAN__ #ifdef __BIG_ENDIAN__ # if __BIG_ENDIAN__ # define _LIBCPP_BIG_ENDIAN # endif // __BIG_ENDIAN__ #endif // __BIG_ENDIAN__ #ifdef __BYTE_ORDER__ # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ # define _LIBCPP_LITTLE_ENDIAN # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # define _LIBCPP_BIG_ENDIAN # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #endif // __BYTE_ORDER__ #ifdef __FreeBSD__ # include # include # if _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN # else // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_BIG_ENDIAN # endif // _BYTE_ORDER == _LITTLE_ENDIAN #endif // __FreeBSD__ #if defined(__NetBSD__) || defined(__OpenBSD__) # include # if _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN # else // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_BIG_ENDIAN # endif // _BYTE_ORDER == _LITTLE_ENDIAN #endif // defined(__NetBSD__) || defined(__OpenBSD__) #if defined(_WIN32) # define _LIBCPP_WIN32API # define _LIBCPP_LITTLE_ENDIAN # define _LIBCPP_SHORT_WCHAR 1 // Both MinGW and native MSVC provide a "MSVC"-like environment # define _LIBCPP_MSVCRT_LIKE // If mingw not explicitly detected, assume using MS C runtime only if // a MS compatibility version is specified. # if defined(_MSC_VER) && !defined(__MINGW32__) # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library # endif # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) # define _LIBCPP_HAS_BITSCAN64 # endif # define _LIBCPP_HAS_OPEN_WITH_WCHAR # if defined(_LIBCPP_MSVCRT) # define _LIBCPP_HAS_QUICK_EXIT # endif // Some CRT APIs are unavailable to store apps # if defined(WINAPI_FAMILY) # include # if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \ (!defined(WINAPI_PARTITION_SYSTEM) || \ !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM)) # define _LIBCPP_WINDOWS_STORE_APP # endif # endif #endif // defined(_WIN32) #ifdef __sun__ # include # ifdef _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN # else # define _LIBCPP_BIG_ENDIAN # endif #endif // __sun__ #if defined(_AIX) && !defined(__64BIT__) // The size of wchar is 2 byte on 32-bit mode on AIX. # define _LIBCPP_SHORT_WCHAR 1 #endif // Libc++ supports various implementations of std::random_device. // // _LIBCPP_USING_DEV_RANDOM // Read entropy from the given file, by default `/dev/urandom`. // If a token is provided, it is assumed to be the path to a file // to read entropy from. This is the default behavior if nothing // else is specified. This implementation requires storing state // inside `std::random_device`. // // _LIBCPP_USING_ARC4_RANDOM // Use arc4random(). This allows obtaining random data even when // using sandboxing mechanisms. On some platforms like Apple, this // is the recommended source of entropy for user-space programs. // When this option is used, the token passed to `std::random_device`'s // constructor *must* be "/dev/urandom" -- anything else is an error. // // _LIBCPP_USING_GETENTROPY // Use getentropy(). // When this option is used, the token passed to `std::random_device`'s // constructor *must* be "/dev/urandom" -- anything else is an error. // // _LIBCPP_USING_FUCHSIA_CPRNG // Use Fuchsia's zx_cprng_draw() system call, which is specified to // deliver high-quality entropy and cannot fail. // When this option is used, the token passed to `std::random_device`'s // constructor *must* be "/dev/urandom" -- anything else is an error. // // _LIBCPP_USING_NACL_RANDOM // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, // including accesses to the special files under `/dev`. This implementation // uses the NaCL syscall `nacl_secure_random_init()` to get entropy. // When this option is used, the token passed to `std::random_device`'s // constructor *must* be "/dev/urandom" -- anything else is an error. // // _LIBCPP_USING_WIN32_RANDOM // Use rand_s(), for use on Windows. // When this option is used, the token passed to `std::random_device`'s // constructor *must* be "/dev/urandom" -- anything else is an error. #if defined(__OpenBSD__) || defined(__APPLE__) # define _LIBCPP_USING_ARC4_RANDOM #elif defined(__wasi__) # define _LIBCPP_USING_GETENTROPY #elif defined(__Fuchsia__) # define _LIBCPP_USING_FUCHSIA_CPRNG #elif defined(__native_client__) # define _LIBCPP_USING_NACL_RANDOM #elif defined(_LIBCPP_WIN32API) # define _LIBCPP_USING_WIN32_RANDOM #else # define _LIBCPP_USING_DEV_RANDOM #endif #if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) # include # if __BYTE_ORDER == __LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN # elif __BYTE_ORDER == __BIG_ENDIAN # define _LIBCPP_BIG_ENDIAN # else // __BYTE_ORDER == __BIG_ENDIAN # error unable to determine endian # endif #endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) #if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) #else # define _LIBCPP_NO_CFI #endif // If the compiler supports using_if_exists, pretend we have those functions and they'll // be picked up if the C library provides them. // // TODO: Once we drop support for Clang 12, we can assume the compiler supports using_if_exists // for platforms that don't have a conforming C11 library, so we can drop this whole thing. #if __has_attribute(using_if_exists) # define _LIBCPP_HAS_TIMESPEC_GET # define _LIBCPP_HAS_QUICK_EXIT # define _LIBCPP_HAS_ALIGNED_ALLOC #else #if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L # if defined(__FreeBSD__) # define _LIBCPP_HAS_ALIGNED_ALLOC # define _LIBCPP_HAS_QUICK_EXIT # if __FreeBSD_version >= 1300064 || \ (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000) # define _LIBCPP_HAS_TIMESPEC_GET # endif # elif defined(__BIONIC__) # if __ANDROID_API__ >= 21 # define _LIBCPP_HAS_QUICK_EXIT # endif # if __ANDROID_API__ >= 28 # define _LIBCPP_HAS_ALIGNED_ALLOC # endif # if __ANDROID_API__ >= 29 # define _LIBCPP_HAS_TIMESPEC_GET # endif # elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__) # define _LIBCPP_HAS_ALIGNED_ALLOC # define _LIBCPP_HAS_QUICK_EXIT # define _LIBCPP_HAS_TIMESPEC_GET # elif defined(__OpenBSD__) # define _LIBCPP_HAS_ALIGNED_ALLOC # define _LIBCPP_HAS_TIMESPEC_GET # elif defined(__linux__) # if !defined(_LIBCPP_HAS_MUSL_LIBC) # if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__) # define _LIBCPP_HAS_QUICK_EXIT # endif # if _LIBCPP_GLIBC_PREREQ(2, 17) # define _LIBCPP_HAS_ALIGNED_ALLOC # define _LIBCPP_HAS_TIMESPEC_GET # endif # else // defined(_LIBCPP_HAS_MUSL_LIBC) # define _LIBCPP_HAS_ALIGNED_ALLOC # define _LIBCPP_HAS_QUICK_EXIT # define _LIBCPP_HAS_TIMESPEC_GET # endif # elif defined(_LIBCPP_MSVCRT) // Using Microsoft's C Runtime library, not MinGW # define _LIBCPP_HAS_TIMESPEC_GET # elif defined(__APPLE__) // timespec_get and aligned_alloc were introduced in macOS 10.15 and // aligned releases # if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \ (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \ (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \ (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000)) # define _LIBCPP_HAS_ALIGNED_ALLOC # define _LIBCPP_HAS_TIMESPEC_GET # endif # endif // __APPLE__ #endif #endif // __has_attribute(using_if_exists) #ifndef _LIBCPP_CXX03_LANG # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) #elif defined(_LIBCPP_COMPILER_CLANG_BASED) # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) #else # error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang" #endif #define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) #if defined(_LIBCPP_COMPILER_CLANG_BASED) #if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) # error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead #endif #if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT #endif #if __has_feature(cxx_alignas) # define _ALIGNAS_TYPE(x) alignas(x) # define _ALIGNAS(x) alignas(x) #else # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) # define _ALIGNAS(x) __attribute__((__aligned__(x))) #endif #if __cplusplus < 201103L typedef __char16_t char16_t; typedef __char32_t char32_t; #endif #if !__has_feature(cxx_exceptions) # define _LIBCPP_NO_EXCEPTIONS #endif #if !(__has_feature(cxx_strong_enums)) #define _LIBCPP_HAS_NO_STRONG_ENUMS #endif #if __has_feature(cxx_attributes) # define _LIBCPP_NORETURN [[noreturn]] #else # define _LIBCPP_NORETURN __attribute__ ((noreturn)) #endif #if !(__has_feature(cxx_nullptr)) # if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR) # define nullptr __nullptr # else # define _LIBCPP_HAS_NO_NULLPTR # endif #endif // 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(cxx_noexcept)) #define _LIBCPP_HAS_NO_NOEXCEPT #endif #if !__has_feature(address_sanitizer) #define _LIBCPP_HAS_NO_ASAN #endif // Allow for build-time disabling of unsigned integer sanitization #if __has_attribute(no_sanitize) #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) #endif #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ #elif defined(_LIBCPP_COMPILER_GCC) #define _ALIGNAS(x) __attribute__((__aligned__(x))) #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) #define _LIBCPP_NORETURN __attribute__((noreturn)) #if !defined(__EXCEPTIONS) # define _LIBCPP_NO_EXCEPTIONS #endif #if !defined(__SANITIZE_ADDRESS__) #define _LIBCPP_HAS_NO_ASAN #endif #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ #elif defined(_LIBCPP_COMPILER_MSVC) #define _LIBCPP_TOSTRING2(x) #x #define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) #define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) #if _MSC_VER < 1900 #error "MSVC versions prior to Visual Studio 2015 are not supported" #endif #define __alignof__ __alignof #define _LIBCPP_NORETURN __declspec(noreturn) #define _ALIGNAS(x) __declspec(align(x)) #define _ALIGNAS_TYPE(x) alignas(x) #define _LIBCPP_WEAK #define _LIBCPP_HAS_NO_ASAN #define _LIBCPP_ALWAYS_INLINE __forceinline #define _LIBCPP_HAS_NO_VECTOR_EXTENSION #define _LIBCPP_DISABLE_EXTENSION_WARNING #elif defined(_LIBCPP_COMPILER_IBM) #define _ALIGNAS(x) __attribute__((__aligned__(x))) #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) #define _ATTRIBUTE(x) __attribute__((x)) #define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_HAS_NO_UNICODE_CHARS #if defined(_AIX) #define __MULTILOCALE_API #endif #define _LIBCPP_HAS_NO_ASAN #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) #define _LIBCPP_HAS_NO_VECTOR_EXTENSION #define _LIBCPP_DISABLE_EXTENSION_WARNING #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] #if defined(_LIBCPP_OBJECT_FORMAT_COFF) #ifdef _DLL # define _LIBCPP_CRT_FUNC __declspec(dllimport) #else # define _LIBCPP_CRT_FUNC #endif #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_DLL_VIS # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS # define _LIBCPP_OVERRIDABLE_FUNC_VIS # define _LIBCPP_EXPORTED_FROM_ABI #elif defined(_LIBCPP_BUILDING_LIBRARY) # define _LIBCPP_DLL_VIS __declspec(dllexport) # if defined(__MINGW32__) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS # else # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS # endif # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) #else # define _LIBCPP_DLL_VIS __declspec(dllimport) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS # define _LIBCPP_OVERRIDABLE_FUNC_VIS # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) #endif #define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS #define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS #define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS #define _LIBCPP_HIDDEN #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS #define _LIBCPP_TEMPLATE_VIS #define _LIBCPP_TEMPLATE_DATA_VIS #define _LIBCPP_ENUM_VIS #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) #ifndef _LIBCPP_HIDDEN # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) # else # define _LIBCPP_HIDDEN # endif #endif #ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) // The inline should be removed once PR32114 is resolved # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN # else # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS # endif #endif #ifndef _LIBCPP_FUNC_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) # else # define _LIBCPP_FUNC_VIS # endif #endif #ifndef _LIBCPP_TYPE_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) # else # define _LIBCPP_TYPE_VIS # endif #endif #ifndef _LIBCPP_TEMPLATE_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # if __has_attribute(__type_visibility__) # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default"))) # else # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default"))) # endif # else # define _LIBCPP_TEMPLATE_VIS # endif #endif #ifndef _LIBCPP_TEMPLATE_DATA_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default"))) # else # define _LIBCPP_TEMPLATE_DATA_VIS # endif #endif #ifndef _LIBCPP_EXPORTED_FROM_ABI # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) # else # define _LIBCPP_EXPORTED_FROM_ABI # endif #endif #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS #define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS #endif #ifndef _LIBCPP_EXCEPTION_ABI # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) # else # define _LIBCPP_EXCEPTION_ABI # endif #endif #ifndef _LIBCPP_ENUM_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) # define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default"))) # else # define _LIBCPP_ENUM_VIS # endif #endif #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) # else # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # endif #endif #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS #define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS #endif #if __has_attribute(internal_linkage) # define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage)) #else # define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE #endif #if __has_attribute(exclude_from_explicit_instantiation) # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__)) #else // Try to approximate the effect of exclude_from_explicit_instantiation // (which is that entities are not assumed to be provided by explicit // template instantiations in the dylib) by always inlining those entities. # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE #endif #ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU # ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT # define _LIBCPP_HIDE_FROM_ABI_PER_TU 0 # else # define _LIBCPP_HIDE_FROM_ABI_PER_TU 1 # endif #endif #ifndef _LIBCPP_HIDE_FROM_ABI # if _LIBCPP_HIDE_FROM_ABI_PER_TU # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE # else # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION # endif #endif #ifdef _LIBCPP_BUILDING_LIBRARY # if _LIBCPP_ABI_VERSION > 1 # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI # else # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 # endif #else # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI #endif // Just so we can migrate to the new macros gradually. #define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { #else #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { #endif #define _LIBCPP_END_NAMESPACE_FILESYSTEM \ _LIBCPP_END_NAMESPACE_STD } } #define _VSTD_FS _VSTD::__fs::filesystem #if __has_attribute(__enable_if__) # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) #endif #ifndef _LIBCPP_HAS_NO_NOEXCEPT # define _NOEXCEPT noexcept # define _NOEXCEPT_(x) noexcept(x) #else # define _NOEXCEPT throw() # define _NOEXCEPT_(x) #endif #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS typedef unsigned short char16_t; typedef unsigned int char32_t; #endif #ifndef __SIZEOF_INT128__ #define _LIBCPP_HAS_NO_INT128 #endif #ifdef _LIBCPP_CXX03_LANG # define static_assert(...) _Static_assert(__VA_ARGS__) # define decltype(...) __decltype(__VA_ARGS__) #endif // _LIBCPP_CXX03_LANG #ifdef _LIBCPP_CXX03_LANG # define _LIBCPP_CONSTEXPR #else # define _LIBCPP_CONSTEXPR constexpr #endif #ifndef __cpp_consteval # define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR #else # define _LIBCPP_CONSTEVAL consteval #endif #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_concepts) || __cpp_concepts < 201907L #define _LIBCPP_HAS_NO_CONCEPTS #endif #ifdef __GNUC__ # define _LIBCPP_NOALIAS __attribute__((__malloc__)) #else # define _LIBCPP_NOALIAS #endif #if __has_attribute(using_if_exists) # define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists)) #else # define _LIBCPP_USING_IF_EXISTS #endif #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS # define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ __lx __v_; \ _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \ }; #else // _LIBCPP_HAS_NO_STRONG_ENUMS # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) #endif // _LIBCPP_HAS_NO_STRONG_ENUMS // _LIBCPP_DEBUG potential values: // - undefined: No assertions. This is the default. // - 0: Basic assertions // - 1: Basic assertions + iterator validity checks + unspecified behavior randomization. # if !defined(_LIBCPP_DEBUG) # define _LIBCPP_DEBUG_LEVEL 0 # elif _LIBCPP_DEBUG == 0 # define _LIBCPP_DEBUG_LEVEL 1 # elif _LIBCPP_DEBUG == 1 # define _LIBCPP_DEBUG_LEVEL 2 # else # error Supported values for _LIBCPP_DEBUG are 0 and 1 # endif # if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG) # define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY # endif # if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) # if defined(_LIBCPP_CXX03_LANG) # error Support for unspecified stability is only for C++11 and higher # endif # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \ do { \ if (!__builtin_is_constant_evaluated()) \ _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \ } while (false) # else # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \ do { \ } while (false) # endif // Libc++ allows disabling extern template instantiation declarations by // means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE. // // Furthermore, when the Debug mode is enabled, we disable extern declarations // when building user code because we don't want to use the functions compiled // in the library, which might not have had the debug mode enabled when built. // However, some extern declarations need to be used, because code correctness // depends on it (several instances in ). Those special declarations // are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled // even when the debug mode is enabled. #if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE) # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */ # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */ #elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY) # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */ # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; #else # define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ defined(__sun__) || defined(__NetBSD__) #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 #endif // If we are getting operator new from the MSVC CRT, then allocation overloads // for align_val_t were added in 19.12, aka VS 2017 version 15.3. #if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION #elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) // We're deferring to Microsoft's STL to provide aligned new et al. We don't // have it unless the language feature test macro is defined. # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION #elif defined(__MVS__) # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION #endif #if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \ (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION #endif #if defined(__APPLE__) || defined(__FreeBSD__) #define _LIBCPP_HAS_DEFAULTRUNELOCALE #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) #define _LIBCPP_WCTYPE_IS_MASK #endif #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) #define _LIBCPP_HAS_NO_CHAR8_T #endif // Deprecation macros. // // Deprecations warnings are always enabled, except when users explicitly opt-out // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. #if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) # if __has_attribute(deprecated) # define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) # elif _LIBCPP_STD_VER > 11 # define _LIBCPP_DEPRECATED [[deprecated]] # else # define _LIBCPP_DEPRECATED # endif #else # define _LIBCPP_DEPRECATED #endif #if !defined(_LIBCPP_CXX03_LANG) # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED #else # define _LIBCPP_DEPRECATED_IN_CXX11 #endif #if _LIBCPP_STD_VER >= 14 # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED #else # define _LIBCPP_DEPRECATED_IN_CXX14 #endif #if _LIBCPP_STD_VER >= 17 # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED #else # define _LIBCPP_DEPRECATED_IN_CXX17 #endif #if _LIBCPP_STD_VER > 17 # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED #else # define _LIBCPP_DEPRECATED_IN_CXX20 #endif #if !defined(_LIBCPP_HAS_NO_CHAR8_T) # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED #else # define _LIBCPP_DEPRECATED_WITH_CHAR8_T #endif // Macros to enter and leave a state where deprecation warnings are suppressed. #if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") # define _LIBCPP_SUPPRESS_DEPRECATED_POP \ _Pragma("GCC diagnostic pop") #else # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH # define _LIBCPP_SUPPRESS_DEPRECATED_POP #endif #if _LIBCPP_STD_VER <= 11 # define _LIBCPP_EXPLICIT_AFTER_CXX11 #else # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit #endif #if _LIBCPP_STD_VER > 11 # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr #else # define _LIBCPP_CONSTEXPR_AFTER_CXX11 #endif #if _LIBCPP_STD_VER > 14 # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr #else # define _LIBCPP_CONSTEXPR_AFTER_CXX14 #endif #if _LIBCPP_STD_VER > 17 # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr #else # define _LIBCPP_CONSTEXPR_AFTER_CXX17 #endif #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) # define _LIBCPP_NODISCARD [[nodiscard]] #elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) # define _LIBCPP_NODISCARD [[clang::warn_unused_result]] #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 // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not // specified as such as an extension. #if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD #else # define _LIBCPP_NODISCARD_EXT #endif #if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \ (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD #else # define _LIBCPP_NODISCARD_AFTER_CXX17 #endif #if __has_attribute(no_destroy) # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) #else # define _LIBCPP_NO_DESTROY #endif #ifndef _LIBCPP_HAS_NO_ASAN extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( const void *, const void *, const void *, const void *); #endif // Try to find out if RTTI is disabled. #if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti) # define _LIBCPP_NO_RTTI #elif defined(__GNUC__) && !defined(__GXX_RTTI) # define _LIBCPP_NO_RTTI #elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) # define _LIBCPP_NO_RTTI #endif #ifndef _LIBCPP_WEAK #define _LIBCPP_WEAK __attribute__((__weak__)) #endif // Thread API #if !defined(_LIBCPP_HAS_NO_THREADS) && \ !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) # if defined(__FreeBSD__) || \ defined(__wasi__) || \ defined(__NetBSD__) || \ defined(__OpenBSD__) || \ defined(__NuttX__) || \ defined(__linux__) || \ defined(__GNU__) || \ defined(__APPLE__) || \ defined(__sun__) || \ defined(__MVS__) || \ defined(_AIX) # define _LIBCPP_HAS_THREAD_API_PTHREAD # elif defined(__Fuchsia__) // TODO(44575): Switch to C11 thread API when possible. # define _LIBCPP_HAS_THREAD_API_PTHREAD # elif defined(_LIBCPP_WIN32API) # define _LIBCPP_HAS_THREAD_API_WIN32 # else # error "No thread API" # endif // _LIBCPP_HAS_THREAD_API #endif // _LIBCPP_HAS_NO_THREADS #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) #if defined(__ANDROID__) && __ANDROID_API__ >= 30 #define _LIBCPP_HAS_COND_CLOCKWAIT #elif defined(_LIBCPP_GLIBC_PREREQ) #if _LIBCPP_GLIBC_PREREQ(2, 30) #define _LIBCPP_HAS_COND_CLOCKWAIT #endif #endif #endif #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) #error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ _LIBCPP_HAS_NO_THREADS is not defined. #endif #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) #error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ _LIBCPP_HAS_NO_THREADS is defined. #endif #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) #error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ _LIBCPP_HAS_NO_THREADS is defined. #endif #if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) #define __STDCPP_THREADS__ 1 #endif // The glibc and Bionic implementation of pthreads implements // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 // mutexes have no destroy mechanism. // // This optimization can't be performed on Apple platforms, where // pthread_mutex_destroy can allow the kernel to release resources. // See https://llvm.org/D64298 for details. // // TODO(EricWF): Enable this optimization on Bionic after speaking to their // respective stakeholders. #if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \ || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \ || defined(_LIBCPP_HAS_THREAD_API_WIN32) # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION #endif // Destroying a condvar is a nop on Windows. // // This optimization can't be performed on Apple platforms, where // pthread_cond_destroy can allow the kernel to release resources. // See https://llvm.org/D64298 for details. // // TODO(EricWF): This is potentially true for some pthread implementations // as well. #if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ defined(_LIBCPP_HAS_THREAD_API_WIN32) # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION #endif // Some systems do not provide gets() in their C library, for security reasons. #if defined(_LIBCPP_MSVCRT) || \ (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \ defined(__OpenBSD__) # define _LIBCPP_C_HAS_NO_GETS #endif #if defined(__BIONIC__) || defined(__NuttX__) || \ defined(__Fuchsia__) || defined(__wasi__) || \ defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE #endif #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) # define _LIBCPP_HAS_C_ATOMIC_IMP #elif defined(_LIBCPP_COMPILER_GCC) # define _LIBCPP_HAS_GCC_ATOMIC_IMP #endif #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) # define _LIBCPP_HAS_NO_ATOMIC_HEADER #else # ifndef _LIBCPP_ATOMIC_FLAG_TYPE # define _LIBCPP_ATOMIC_FLAG_TYPE bool # endif # ifdef _LIBCPP_FREESTANDING # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS # endif #endif #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK #endif #if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) # if defined(__clang__) && __has_attribute(acquire_capability) // Work around the attribute handling in clang. When both __declspec and // __attribute__ are present, the processing goes awry preventing the definition // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus // combining the two does work. # if !defined(_MSC_VER) # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS # endif # endif #endif #ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) #else # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) #endif #if __has_attribute(require_constant_initialization) # define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__)) #else # define _LIBCPP_SAFE_STATIC #endif #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) # define _LIBCPP_DIAGNOSE_WARNING(...) \ __attribute__((diagnose_if(__VA_ARGS__, "warning"))) # define _LIBCPP_DIAGNOSE_ERROR(...) \ __attribute__((diagnose_if(__VA_ARGS__, "error"))) #else # define _LIBCPP_DIAGNOSE_WARNING(...) # define _LIBCPP_DIAGNOSE_ERROR(...) #endif // Use a function like macro to imply that it must be followed by a semicolon #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) # define _LIBCPP_FALLTHROUGH() [[fallthrough]] #elif __has_cpp_attribute(clang::fallthrough) # define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] #elif __has_attribute(__fallthrough__) # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) #else # define _LIBCPP_FALLTHROUGH() ((void)0) #endif #if __has_attribute(__nodebug__) #define _LIBCPP_NODEBUG __attribute__((__nodebug__)) #else #define _LIBCPP_NODEBUG #endif #if __has_attribute(__standalone_debug__) #define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) #else #define _LIBCPP_STANDALONE_DEBUG #endif #if __has_attribute(__preferred_name__) #define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) #else #define _LIBCPP_PREFERRED_NAME(x) #endif // We often repeat things just for handling wide characters in the library. // When wide characters are disabled, it can be useful to have a quick way of // disabling it without having to resort to #if-#endif, which has a larger // impact on readability. #if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) # define _LIBCPP_IF_WIDE_CHARACTERS(...) #else # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ #endif #if defined(_LIBCPP_ABI_MICROSOFT) && \ (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) #else # define _LIBCPP_DECLSPEC_EMPTY_BASES #endif #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) #define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR #define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS #define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) #define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS #define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS #define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS #define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR #define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS #endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES #if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L #define _LIBCPP_HAS_NO_CXX20_COROUTINES #endif #if defined(_LIBCPP_COMPILER_IBM) #define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO #endif #if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) # define _LIBCPP_PUSH_MACROS # define _LIBCPP_POP_MACROS #else // Don't warn about macro conflicts when we can restore them at the // end of the header. # ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS # define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS # endif # if defined(_LIBCPP_COMPILER_MSVC) # define _LIBCPP_PUSH_MACROS \ __pragma(push_macro("min")) \ __pragma(push_macro("max")) # define _LIBCPP_POP_MACROS \ __pragma(pop_macro("min")) \ __pragma(pop_macro("max")) # else # define _LIBCPP_PUSH_MACROS \ _Pragma("push_macro(\"min\")") \ _Pragma("push_macro(\"max\")") # define _LIBCPP_POP_MACROS \ _Pragma("pop_macro(\"min\")") \ _Pragma("pop_macro(\"max\")") # endif #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) #ifndef _LIBCPP_NO_AUTO_LINK # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # pragma comment(lib, "c++.lib") # else # pragma comment(lib, "libc++.lib") # endif # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) #endif // _LIBCPP_NO_AUTO_LINK // Configures the fopen close-on-exec mode character, if any. This string will // be appended to any mode string used by fstream for fopen/fdopen. // // Not all platforms support this, but it helps avoid fd-leaks on platforms that // do. #if defined(__BIONIC__) # define _LIBCPP_FOPEN_CLOEXEC_MODE "e" #else # define _LIBCPP_FOPEN_CLOEXEC_MODE #endif // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set // of functions used in cstdio may not be available for low API levels when // using 64-bit file offsets on LP32. #if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 #define _LIBCPP_HAS_NO_FGETPOS_FSETPOS #endif #if __has_attribute(init_priority) // TODO: Remove this once we drop support for building libc++ with old Clangs # if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \ (defined(__apple_build_version__) && __apple_build_version__ < 13000000) # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) # else # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) # endif #else # define _LIBCPP_INIT_PRIORITY_MAX #endif #if defined(__GNUC__) || defined(__clang__) // The attribute uses 1-based indices for ordinary and static member functions. // The attribute uses 2-based indices for non-static member functions. # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) #else # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ #endif #endif // __cplusplus #endif // _LIBCPP_CONFIG diff --git a/libcxx/include/__iterator/distance.h b/libcxx/include/__iterator/distance.h index faab03492389..85309f8d47d6 100644 --- a/libcxx/include/__iterator/distance.h +++ b/libcxx/include/__iterator/distance.h @@ -1,107 +1,107 @@ // -*- 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___ITERATOR_DISTANCE_H #define _LIBCPP___ITERATOR_DISTANCE_H #include <__config> #include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> #include <__iterator/iterator_traits.h> #include <__ranges/access.h> #include <__ranges/concepts.h> #include <__ranges/size.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 typename iterator_traits<_InputIter>::difference_type __distance(_InputIter __first, _InputIter __last, input_iterator_tag) { typename iterator_traits<_InputIter>::difference_type __r(0); for (; __first != __last; ++__first) ++__r; return __r; } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 typename iterator_traits<_RandIter>::difference_type __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag) { return __last - __first; } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 typename iterator_traits<_InputIter>::difference_type distance(_InputIter __first, _InputIter __last) { return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); } -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [range.iter.op.distance] namespace ranges { namespace __distance { struct __fn { template _Sp> requires (!sized_sentinel_for<_Sp, _Ip>) _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const { iter_difference_t<_Ip> __n = 0; while (__first != __last) { ++__first; ++__n; } return __n; } template> _Sp> _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const { if constexpr (sized_sentinel_for<_Sp, __uncvref_t<_Ip>>) { return __last - __first; } else { return __last - decay_t<_Ip>(__first); } } template _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Rp> operator()(_Rp&& __r) const { if constexpr (sized_range<_Rp>) { return static_cast>(ranges::size(__r)); } else { return operator()(ranges::begin(__r), ranges::end(__r)); } } }; } // namespace __distance inline namespace __cpo { inline constexpr auto distance = __distance::__fn{}; } // namespace __cpo } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___ITERATOR_DISTANCE_H diff --git a/libcxx/include/__iterator/indirectly_comparable.h b/libcxx/include/__iterator/indirectly_comparable.h index 3bafc56f926f..ad5ff1a866d6 100644 --- a/libcxx/include/__iterator/indirectly_comparable.h +++ b/libcxx/include/__iterator/indirectly_comparable.h @@ -1,30 +1,30 @@ // -*- 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___ITERATOR_INDIRECTLY_COMPARABLE_H #define _LIBCPP___ITERATOR_INDIRECTLY_COMPARABLE_H #include <__config> #include <__functional/identity.h> #include <__iterator/concepts.h> #include <__iterator/projected.h> _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_CONCEPTS +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template concept indirectly_comparable = indirect_binary_predicate<_Rp, projected<_I1, _P1>, projected<_I2, _P2>>; -#endif // _LIBCPP_HAS_NO_CONCEPTS +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___ITERATOR_INDIRECTLY_COMPARABLE_H diff --git a/libcxx/include/__iterator/insert_iterator.h b/libcxx/include/__iterator/insert_iterator.h index 2f18f5f12162..d3cd5ad6f9c5 100644 --- a/libcxx/include/__iterator/insert_iterator.h +++ b/libcxx/include/__iterator/insert_iterator.h @@ -1,81 +1,81 @@ // -*- 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___ITERATOR_INSERT_ITERATOR_H #define _LIBCPP___ITERATOR_INSERT_ITERATOR_H #include <__config> #include <__iterator/iterator.h> #include <__iterator/iterator_traits.h> #include <__memory/addressof.h> #include <__ranges/access.h> #include <__utility/move.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template using __insert_iterator_iter_t = ranges::iterator_t<_Container>; #else template using __insert_iterator_iter_t = typename _Container::iterator; #endif _LIBCPP_SUPPRESS_DEPRECATED_PUSH template class _LIBCPP_TEMPLATE_VIS insert_iterator #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) : public iterator #endif { _LIBCPP_SUPPRESS_DEPRECATED_POP protected: _Container* container; __insert_iterator_iter_t<_Container> iter; public: typedef output_iterator_tag iterator_category; typedef void value_type; #if _LIBCPP_STD_VER > 17 typedef ptrdiff_t difference_type; #else typedef void difference_type; #endif typedef void pointer; typedef void reference; typedef _Container container_type; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i) : container(_VSTD::addressof(__x)), iter(__i) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_) {iter = container->insert(iter, __value_); ++iter; return *this;} #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value_) {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;} #endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++(int) {return *this;} }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator<_Container> inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i) { return insert_iterator<_Container>(__x, __i); } _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___ITERATOR_INSERT_ITERATOR_H diff --git a/libcxx/include/__iterator/reverse_iterator.h b/libcxx/include/__iterator/reverse_iterator.h index 449eb529aa98..af855a0a1e73 100644 --- a/libcxx/include/__iterator/reverse_iterator.h +++ b/libcxx/include/__iterator/reverse_iterator.h @@ -1,235 +1,235 @@ // -*- 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___ITERATOR_REVERSE_ITERATOR_H #define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H #include <__compare/compare_three_way_result.h> #include <__compare/three_way_comparable.h> #include <__config> #include <__iterator/iterator.h> #include <__iterator/iterator_traits.h> #include <__memory/addressof.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_SUPPRESS_DEPRECATED_PUSH template class _LIBCPP_TEMPLATE_VIS reverse_iterator #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) : public iterator::iterator_category, typename iterator_traits<_Iter>::value_type, typename iterator_traits<_Iter>::difference_type, typename iterator_traits<_Iter>::pointer, typename iterator_traits<_Iter>::reference> #endif { _LIBCPP_SUPPRESS_DEPRECATED_POP private: #ifndef _LIBCPP_ABI_NO_ITERATOR_BASES _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break #endif protected: _Iter current; public: typedef _Iter iterator_type; typedef typename iterator_traits<_Iter>::difference_type difference_type; typedef typename iterator_traits<_Iter>::reference reference; typedef typename iterator_traits<_Iter>::pointer pointer; typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, random_access_iterator_tag, typename iterator_traits<_Iter>::iterator_category> iterator_category; typedef typename iterator_traits<_Iter>::value_type value_type; #if _LIBCPP_STD_VER > 17 typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, random_access_iterator_tag, bidirectional_iterator_tag> iterator_concept; #endif #ifndef _LIBCPP_ABI_NO_ITERATOR_BASES _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator() : __t(), current() {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {} template ::value && is_convertible<_Up const&, _Iter>::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator(const reverse_iterator<_Up>& __u) : __t(__u.base()), current(__u.base()) { } template ::value && is_convertible<_Up const&, _Iter>::value && is_assignable<_Iter&, _Up const&>::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { __t = current = __u.base(); return *this; } #else _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator() : current() {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 explicit reverse_iterator(_Iter __x) : current(__x) {} template ::value && is_convertible<_Up const&, _Iter>::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator(const reverse_iterator<_Up>& __u) : current(__u.base()) { } template ::value && is_convertible<_Up const&, _Iter>::value && is_assignable<_Iter&, _Up const&>::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { current = __u.base(); return *this; } #endif _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return current;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference operator*() const {_Iter __tmp = current; return *--__tmp;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 pointer operator->() const {return _VSTD::addressof(operator*());} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator++() {--current; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator--() {++current; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference operator[](difference_type __n) const {return *(*this + __n);} }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { return __x.base() == __y.base(); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { return __x.base() > __y.base(); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { return __x.base() != __y.base(); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { return __x.base() < __y.base(); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { return __x.base() <= __y.base(); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { return __x.base() >= __y.base(); } -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template _Iter2> _LIBCPP_HIDE_FROM_ABI constexpr compare_three_way_result_t<_Iter1, _Iter2> operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { return __y.base() <=> __x.base(); } #endif #ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) -> decltype(__y.base() - __x.base()) { return __y.base() - __x.base(); } #else template inline _LIBCPP_INLINE_VISIBILITY typename reverse_iterator<_Iter1>::difference_type operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) { return __y.base() - __x.base(); } #endif template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<_Iter> operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x) { return reverse_iterator<_Iter>(__x.base() - __n); } #if _LIBCPP_STD_VER > 11 template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) { return reverse_iterator<_Iter>(__i); } #endif _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H diff --git a/libcxx/include/__random/uniform_random_bit_generator.h b/libcxx/include/__random/uniform_random_bit_generator.h index 7b2f0df868d7..8bcd20f42367 100644 --- a/libcxx/include/__random/uniform_random_bit_generator.h +++ b/libcxx/include/__random/uniform_random_bit_generator.h @@ -1,45 +1,45 @@ //===----------------------------------------------------------------------===// // // 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___RANDOM_UNIFORM_RANDOM_BIT_GENERATOR_H #define _LIBCPP___RANDOM_UNIFORM_RANDOM_BIT_GENERATOR_H #include <__concepts/arithmetic.h> #include <__concepts/invocable.h> #include <__concepts/same_as.h> #include <__config> #include #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 > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // [rand.req.urng] template concept uniform_random_bit_generator = invocable<_Gen&> && unsigned_integral> && requires { { _Gen::min() } -> same_as>; { _Gen::max() } -> same_as>; requires bool_constant<(_Gen::min() < _Gen::max())>::value; }; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #endif // _LIBCPP___RANDOM_UNIFORM_RANDOM_BIT_GENERATOR_H diff --git a/libcxx/include/__ranges/access.h b/libcxx/include/__ranges/access.h index 67c6c57bd81e..07a92d783475 100644 --- a/libcxx/include/__ranges/access.h +++ b/libcxx/include/__ranges/access.h @@ -1,220 +1,227 @@ // -*- 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___RANGES_ACCESS_H #define _LIBCPP___RANGES_ACCESS_H #include <__concepts/class_or_enum.h> #include <__config> #include <__iterator/concepts.h> #include <__iterator/readable_traits.h> #include <__ranges/enable_borrowed_range.h> #include <__utility/as_const.h> #include <__utility/auto_cast.h> #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD #if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { template concept __can_borrow = is_lvalue_reference_v<_Tp> || enable_borrowed_range>; } // namespace ranges // [range.access.begin] namespace ranges { namespace __begin { template concept __member_begin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) { { _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator; }; void begin(auto&) = delete; void begin(const auto&) = delete; template concept __unqualified_begin = !__member_begin<_Tp> && __can_borrow<_Tp> && __class_or_enum> && requires(_Tp && __t) { { _LIBCPP_AUTO_CAST(begin(__t)) } -> input_or_output_iterator; }; struct __fn { template - requires is_array_v> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __t) const noexcept + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[]) const noexcept + requires (sizeof(_Tp) != 0) // Disallow incomplete element types. { - return __t; + return __t + 0; + } + + template + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept + requires (sizeof(_Tp) != 0) // Disallow incomplete element types. + { + return __t + 0; } template requires __member_begin<_Tp> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin()))) { return _LIBCPP_AUTO_CAST(__t.begin()); } template requires __unqualified_begin<_Tp> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t)))) { return _LIBCPP_AUTO_CAST(begin(__t)); } void operator()(auto&&) const = delete; }; } // namespace __begin inline namespace __cpo { inline constexpr auto begin = __begin::__fn{}; } // namespace __cpo } // namespace ranges // [range.range] namespace ranges { template using iterator_t = decltype(ranges::begin(declval<_Tp&>())); } // namespace ranges // [range.access.end] namespace ranges { namespace __end { template concept __member_end = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) { typename iterator_t<_Tp>; { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for>; }; void end(auto&) = delete; void end(const auto&) = delete; template concept __unqualified_end = !__member_end<_Tp> && __can_borrow<_Tp> && __class_or_enum> && requires(_Tp && __t) { typename iterator_t<_Tp>; { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for>; }; class __fn { public: template [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept - requires (sizeof(*__t) != 0) // Disallow incomplete element types. + requires (sizeof(_Tp) != 0) // Disallow incomplete element types. { return __t + _Np; } template requires __member_end<_Tp> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end()))) { return _LIBCPP_AUTO_CAST(__t.end()); } template requires __unqualified_end<_Tp> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t)))) { return _LIBCPP_AUTO_CAST(end(__t)); } void operator()(auto&&) const = delete; }; } // namespace __end inline namespace __cpo { inline constexpr auto end = __end::__fn{}; } // namespace __cpo } // namespace ranges // [range.access.cbegin] namespace ranges { namespace __cbegin { struct __fn { template requires is_lvalue_reference_v<_Tp&&> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(ranges::begin(static_cast&>(__t)))) -> decltype( ranges::begin(static_cast&>(__t))) { return ranges::begin(static_cast&>(__t)); } template requires is_rvalue_reference_v<_Tp&&> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(ranges::begin(static_cast(__t)))) -> decltype( ranges::begin(static_cast(__t))) { return ranges::begin(static_cast(__t)); } }; } // namespace __cbegin inline namespace __cpo { inline constexpr auto cbegin = __cbegin::__fn{}; } // namespace __cpo } // namespace ranges // [range.access.cend] namespace ranges { namespace __cend { struct __fn { template requires is_lvalue_reference_v<_Tp&&> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(ranges::end(static_cast&>(__t)))) -> decltype( ranges::end(static_cast&>(__t))) { return ranges::end(static_cast&>(__t)); } template requires is_rvalue_reference_v<_Tp&&> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(ranges::end(static_cast(__t)))) -> decltype( ranges::end(static_cast(__t))) { return ranges::end(static_cast(__t)); } }; } // namespace __cend inline namespace __cpo { inline constexpr auto cend = __cend::__fn{}; } // namespace __cpo } // namespace ranges #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___RANGES_ACCESS_H diff --git a/libcxx/include/__ranges/enable_borrowed_range.h b/libcxx/include/__ranges/enable_borrowed_range.h index 5f5b3f505773..f9985dfd0061 100644 --- a/libcxx/include/__ranges/enable_borrowed_range.h +++ b/libcxx/include/__ranges/enable_borrowed_range.h @@ -1,41 +1,41 @@ // -*- 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___RANGES_ENABLE_BORROWED_RANGE_H #define _LIBCPP___RANGES_ENABLE_BORROWED_RANGE_H // These customization variables are used in and . The // separate header is used to avoid including the entire header in // and . #include <__config> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { // [range.range], ranges template inline constexpr bool enable_borrowed_range = false; } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___RANGES_ENABLE_BORROWED_RANGE_H diff --git a/libcxx/include/__ranges/non_propagating_cache.h b/libcxx/include/__ranges/non_propagating_cache.h index d0f447ce7cc5..2d3a9408713e 100644 --- a/libcxx/include/__ranges/non_propagating_cache.h +++ b/libcxx/include/__ranges/non_propagating_cache.h @@ -1,114 +1,114 @@ // -*- 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___RANGES_NON_PROPAGATING_CACHE_H #define _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H #include <__config> #include <__iterator/concepts.h> // indirectly_readable #include <__iterator/iterator_traits.h> // iter_reference_t #include <__memory/addressof.h> #include <__utility/forward.h> #include // constructible_from #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD #if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace ranges { // __non_propagating_cache is a helper type that allows storing an optional value in it, // but which does not copy the source's value when it is copy constructed/assigned to, // and which resets the source's value when it is moved-from. // // This type is used as an implementation detail of some views that need to cache the // result of `begin()` in order to provide an amortized O(1) begin() method. Typically, // we don't want to propagate the value of the cache upon copy because the cached iterator // may refer to internal details of the source view. template requires is_object_v<_Tp> class _LIBCPP_TEMPLATE_VIS __non_propagating_cache { struct __from_tag { }; struct __forward_tag { }; // This helper class is needed to perform copy and move elision when // constructing the contained type from an iterator. struct __wrapper { template constexpr explicit __wrapper(__forward_tag, _Args&& ...__args) : __t_(_VSTD::forward<_Args>(__args)...) { } template constexpr explicit __wrapper(__from_tag, _Fn const& __f) : __t_(__f()) { } _Tp __t_; }; optional<__wrapper> __value_ = nullopt; public: _LIBCPP_HIDE_FROM_ABI __non_propagating_cache() = default; _LIBCPP_HIDE_FROM_ABI constexpr __non_propagating_cache(__non_propagating_cache const&) noexcept : __value_(nullopt) { } _LIBCPP_HIDE_FROM_ABI constexpr __non_propagating_cache(__non_propagating_cache&& __other) noexcept : __value_(nullopt) { __other.__value_.reset(); } _LIBCPP_HIDE_FROM_ABI constexpr __non_propagating_cache& operator=(__non_propagating_cache const& __other) noexcept { if (this != _VSTD::addressof(__other)) { __value_.reset(); } return *this; } _LIBCPP_HIDE_FROM_ABI constexpr __non_propagating_cache& operator=(__non_propagating_cache&& __other) noexcept { __value_.reset(); __other.__value_.reset(); return *this; } _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() { return __value_->__t_; } _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& operator*() const { return __value_->__t_; } _LIBCPP_HIDE_FROM_ABI constexpr bool __has_value() const { return __value_.has_value(); } template _LIBCPP_HIDE_FROM_ABI constexpr _Tp& __emplace_from(_Fn const& __f) { return __value_.emplace(__from_tag{}, __f).__t_; } template _LIBCPP_HIDE_FROM_ABI constexpr _Tp& __emplace(_Args&& ...__args) { return __value_.emplace(__forward_tag{}, _VSTD::forward<_Args>(__args)...).__t_; } }; struct __empty_cache { }; } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H diff --git a/libcxx/include/__utility/cmp.h b/libcxx/include/__utility/cmp.h index 4fc96b054f4d..3889cc7492fa 100644 --- a/libcxx/include/__utility/cmp.h +++ b/libcxx/include/__utility/cmp.h @@ -1,110 +1,110 @@ //===----------------------------------------------------------------------===// // // 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___UTILITY_CMP_H #define _LIBCPP___UTILITY_CMP_H #include <__config> #include <__utility/forward.h> #include <__utility/move.h> #include #include #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 > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template struct _IsSameAsAny : _Or<_IsSame<_Tp, _Up>...> {}; template concept __is_safe_integral_cmp = is_integral_v<_Tp> && !_IsSameAsAny<_Tp, bool, char #ifndef _LIBCPP_HAS_NO_CHAR8_T , char8_t #endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS , char16_t, char32_t #endif #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS , wchar_t #endif >::value; template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up> _LIBCPP_INLINE_VISIBILITY constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept { if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) return __t == __u; else if constexpr (is_signed_v<_Tp>) return __t < 0 ? false : make_unsigned_t<_Tp>(__t) == __u; else return __u < 0 ? false : __t == make_unsigned_t<_Up>(__u); } template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up> _LIBCPP_INLINE_VISIBILITY constexpr bool cmp_not_equal(_Tp __t, _Up __u) noexcept { return !_VSTD::cmp_equal(__t, __u); } template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up> _LIBCPP_INLINE_VISIBILITY constexpr bool cmp_less(_Tp __t, _Up __u) noexcept { if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) return __t < __u; else if constexpr (is_signed_v<_Tp>) return __t < 0 ? true : make_unsigned_t<_Tp>(__t) < __u; else return __u < 0 ? false : __t < make_unsigned_t<_Up>(__u); } template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up> _LIBCPP_INLINE_VISIBILITY constexpr bool cmp_greater(_Tp __t, _Up __u) noexcept { return _VSTD::cmp_less(__u, __t); } template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up> _LIBCPP_INLINE_VISIBILITY constexpr bool cmp_less_equal(_Tp __t, _Up __u) noexcept { return !_VSTD::cmp_greater(__t, __u); } template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up> _LIBCPP_INLINE_VISIBILITY constexpr bool cmp_greater_equal(_Tp __t, _Up __u) noexcept { return !_VSTD::cmp_less(__t, __u); } template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up> _LIBCPP_INLINE_VISIBILITY constexpr bool in_range(_Up __u) noexcept { return _VSTD::cmp_less_equal(__u, numeric_limits<_Tp>::max()) && _VSTD::cmp_greater_equal(__u, numeric_limits<_Tp>::min()); } #endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #endif // _LIBCPP___UTILITY_CMP_H diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h index f1114696884a..82e82eabf832 100644 --- a/libcxx/include/__utility/pair.h +++ b/libcxx/include/__utility/pair.h @@ -1,609 +1,609 @@ //===----------------------------------------------------------------------===// // // 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___UTILITY_PAIR_H #define _LIBCPP___UTILITY_PAIR_H #include <__compare/common_comparison_category.h> #include <__compare/synth_three_way.h> #include <__config> #include <__functional/unwrap_ref.h> #include <__tuple> #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/piecewise_construct.h> #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) template struct __non_trivially_copyable_base { _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY __non_trivially_copyable_base() _NOEXCEPT {} _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {} }; #endif template struct _LIBCPP_TEMPLATE_VIS pair #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) : private __non_trivially_copyable_base<_T1, _T2> #endif { typedef _T1 first_type; typedef _T2 second_type; _T1 first; _T2 second; #if !defined(_LIBCPP_CXX03_LANG) pair(pair const&) = default; pair(pair&&) = default; #else // Use the implicitly declared copy constructor in C++03 #endif #ifdef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY pair() : first(), second() {} _LIBCPP_INLINE_VISIBILITY pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {} template _LIBCPP_INLINE_VISIBILITY pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} _LIBCPP_INLINE_VISIBILITY pair& operator=(pair const& __p) { first = __p.first; second = __p.second; return *this; } #else struct _CheckArgs { template static constexpr bool __enable_explicit_default() { return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value && !__enable_implicit_default<>(); } template static constexpr bool __enable_implicit_default() { return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value; } template static constexpr bool __enable_explicit() { return is_constructible::value && is_constructible::value && (!is_convertible<_U1, first_type>::value || !is_convertible<_U2, second_type>::value); } template static constexpr bool __enable_implicit() { return is_constructible::value && is_constructible::value && is_convertible<_U1, first_type>::value && is_convertible<_U2, second_type>::value; } }; template using _CheckArgsDep _LIBCPP_NODEBUG = typename conditional< _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type; struct _CheckTupleLikeConstructor { template static constexpr bool __enable_implicit() { return __tuple_convertible<_Tuple, pair>::value; } template static constexpr bool __enable_explicit() { return __tuple_constructible<_Tuple, pair>::value && !__tuple_convertible<_Tuple, pair>::value; } template static constexpr bool __enable_assign() { return __tuple_assignable<_Tuple, pair>::value; } }; template using _CheckTLC _LIBCPP_NODEBUG = typename conditional< __tuple_like_with_size<_Tuple, 2>::value && !is_same::type, pair>::value, _CheckTupleLikeConstructor, __check_tuple_constructor_fail >::type; template::__enable_explicit_default() >::type* = nullptr> explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() _NOEXCEPT_(is_nothrow_default_constructible::value && is_nothrow_default_constructible::value) : first(), second() {} template::__enable_implicit_default() >::type* = nullptr> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() _NOEXCEPT_(is_nothrow_default_constructible::value && is_nothrow_default_constructible::value) : first(), second() {} template ::template __enable_explicit<_T1 const&, _T2 const&>() >::type* = nullptr> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit pair(_T1 const& __t1, _T2 const& __t2) _NOEXCEPT_(is_nothrow_copy_constructible::value && is_nothrow_copy_constructible::value) : first(__t1), second(__t2) {} template::template __enable_implicit<_T1 const&, _T2 const&>() >::type* = nullptr> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(_T1 const& __t1, _T2 const& __t2) _NOEXCEPT_(is_nothrow_copy_constructible::value && is_nothrow_copy_constructible::value) : first(__t1), second(__t2) {} template < #if _LIBCPP_STD_VER > 20 // http://wg21.link/P1951 class _U1 = _T1, class _U2 = _T2, #else class _U1, class _U2, #endif typename enable_if<_CheckArgs::template __enable_explicit<_U1, _U2>()>::type* = nullptr > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit pair(_U1&& __u1, _U2&& __u2) _NOEXCEPT_((is_nothrow_constructible::value && is_nothrow_constructible::value)) : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} template < #if _LIBCPP_STD_VER > 20 // http://wg21.link/P1951 class _U1 = _T1, class _U2 = _T2, #else class _U1, class _U2, #endif typename enable_if<_CheckArgs::template __enable_implicit<_U1, _U2>()>::type* = nullptr > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(_U1&& __u1, _U2&& __u2) _NOEXCEPT_((is_nothrow_constructible::value && is_nothrow_constructible::value)) : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} template() >::type* = nullptr> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit pair(pair<_U1, _U2> const& __p) _NOEXCEPT_((is_nothrow_constructible::value && is_nothrow_constructible::value)) : first(__p.first), second(__p.second) {} template() >::type* = nullptr> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(pair<_U1, _U2> const& __p) _NOEXCEPT_((is_nothrow_constructible::value && is_nothrow_constructible::value)) : first(__p.first), second(__p.second) {} template() >::type* = nullptr> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit pair(pair<_U1, _U2>&&__p) _NOEXCEPT_((is_nothrow_constructible::value && is_nothrow_constructible::value)) : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} template() >::type* = nullptr> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(pair<_U1, _U2>&& __p) _NOEXCEPT_((is_nothrow_constructible::value && is_nothrow_constructible::value)) : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} template::template __enable_explicit<_Tuple>() >::type* = nullptr> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit pair(_Tuple&& __p) : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))), second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {} template::template __enable_implicit<_Tuple>() >::type* = nullptr> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(_Tuple&& __p) : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))), second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) _NOEXCEPT_((is_nothrow_constructible::value && is_nothrow_constructible::value)) : pair(__pc, __first_args, __second_args, typename __make_tuple_indices::type(), typename __make_tuple_indices::type()) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair& operator=(typename conditional< is_copy_assignable::value && is_copy_assignable::value, pair, __nat>::type const& __p) _NOEXCEPT_(is_nothrow_copy_assignable::value && is_nothrow_copy_assignable::value) { first = __p.first; second = __p.second; return *this; } _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair& operator=(typename conditional< is_move_assignable::value && is_move_assignable::value, pair, __nat>::type&& __p) _NOEXCEPT_(is_nothrow_move_assignable::value && is_nothrow_move_assignable::value) { first = _VSTD::forward(__p.first); second = _VSTD::forward(__p.second); return *this; } template ::template __enable_assign<_Tuple>() >::type* = nullptr> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair& operator=(_Tuple&& __p) { first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p)); second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p)); return *this; } #endif _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable::value && __is_nothrow_swappable::value) { using _VSTD::swap; swap(first, __p.first); swap(second, __p.second); } private: #ifndef _LIBCPP_CXX03_LANG template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair(piecewise_construct_t, tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args, __tuple_indices<_I1...>, __tuple_indices<_I2...>); #endif }; #if _LIBCPP_STD_VER >= 17 template pair(_T1, _T2) -> pair<_T1, _T2>; #endif // [pairs.spec], specialized algorithms template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { return __x.first == __y.first && __x.second == __y.second; } -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template _LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t< __synth_three_way_result<_T1>, __synth_three_way_result<_T2> > operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { if (auto __c = _VSTD::__synth_three_way(__x.first, __y.first); __c != 0) { return __c; } return _VSTD::__synth_three_way(__x.second, __y.second); } -#else // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#else // !defined(_LIBCPP_HAS_NO_CONCEPTS) template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { return !(__x == __y); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { return __y < __x; } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { return !(__x < __y); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) { return !(__y < __x); } -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __is_swappable<_T1>::value && __is_swappable<_T2>::value, void >::type swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) _NOEXCEPT_((__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value)) { __x.swap(__y); } #ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair::type, typename __unwrap_ref_decay<_T2>::type> make_pair(_T1&& __t1, _T2&& __t2) { return pair::type, typename __unwrap_ref_decay<_T2>::type> (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2)); } #else // _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY pair<_T1,_T2> make_pair(_T1 __x, _T2 __y) { return pair<_T1, _T2>(__x, __y); } #endif // _LIBCPP_CXX03_LANG template struct _LIBCPP_TEMPLATE_VIS tuple_size > : public integral_constant {}; template struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> > { static_assert(_Ip < 2, "Index out of bounds in std::tuple_element>"); }; template struct _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> > { typedef _LIBCPP_NODEBUG _T1 type; }; template struct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> > { typedef _LIBCPP_NODEBUG _T2 type; }; template struct __get_pair; template <> struct __get_pair<0> { template static _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;} template static _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _T1& get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;} #ifndef _LIBCPP_CXX03_LANG template static _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);} template static _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _T1&& get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward(__p.first);} #endif // _LIBCPP_CXX03_LANG }; template <> struct __get_pair<1> { template static _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;} template static _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _T2& get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;} #ifndef _LIBCPP_CXX03_LANG template static _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);} template static _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _T2&& get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward(__p.second);} #endif // _LIBCPP_CXX03_LANG }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(pair<_T1, _T2>& __p) _NOEXCEPT { return __get_pair<_Ip>::get(__p); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(const pair<_T1, _T2>& __p) _NOEXCEPT { return __get_pair<_Ip>::get(__p); } #ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { return __get_pair<_Ip>::get(_VSTD::move(__p)); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& get(const pair<_T1, _T2>&& __p) _NOEXCEPT { return __get_pair<_Ip>::get(_VSTD::move(__p)); } #endif // _LIBCPP_CXX03_LANG #if _LIBCPP_STD_VER > 11 template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT { return __get_pair<0>::get(__p); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT { return __get_pair<0>::get(__p); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT { return __get_pair<0>::get(_VSTD::move(__p)); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 const && get(pair<_T1, _T2> const&& __p) _NOEXCEPT { return __get_pair<0>::get(_VSTD::move(__p)); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT { return __get_pair<1>::get(__p); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT { return __get_pair<1>::get(__p); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT { return __get_pair<1>::get(_VSTD::move(__p)); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT { return __get_pair<1>::get(_VSTD::move(__p)); } #endif _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___UTILITY_PAIR_H diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap index 84abf01bf5d7..749c17f8bc08 100644 --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -1,1090 +1,1091 @@ // define the module for __config outside of the top level 'std' module // since __config may be included from C headers which may create an // include cycle. module std_config [system] [extern_c] { - header "__config" + textual header "__config" + textual header "__config_site" } module std [system] { export std_config // FIXME: The standard does not require that each of these submodules // re-exports its imported modules. We should provide an alternative form of // export that issues a warning if a name from the submodule is used, and // use that to provide a 'strict mode' for libc++. // Deprecated C-compatibility headers. These can all be included from within // an 'extern "C"' context. module depr [extern_c] { // provided by C library. module ctype_h { header "ctype.h" export * } module errno_h { header "errno.h" export * } module fenv_h { header "fenv.h" export * } // provided by compiler or C library. module inttypes_h { header "inttypes.h" export stdint_h export * } // provided by compiler. // provided by compiler or C library. module locale_h { header "locale.h" export * } module math_h { header "math.h" export * } module setjmp_h { header "setjmp.h" export * } // FIXME: is missing. // provided by C library. // provided by compiler. // provided by compiler. module stddef_h { // 's __need_* macros require textual inclusion. textual header "stddef.h" } module stdint_h { header "stdint.h" export * // FIXME: This module only exists on OS X and for some reason the // wildcard above doesn't export it. export Darwin.C.stdint } module stdio_h { // 's __need_* macros require textual inclusion. textual header "stdio.h" export * export Darwin.C.stdio } module stdlib_h { // 's __need_* macros require textual inclusion. textual header "stdlib.h" export * } module string_h { header "string.h" export * } // FIXME: is missing. // provided by C library. module wchar_h { // 's __need_* macros require textual inclusion. textual header "wchar.h" export * } module wctype_h { header "wctype.h" export * } } // and are not C headers in any real sense, do not // allow their use in extern "C" contexts. module complex_h { header "complex.h" export ccomplex export * } module tgmath_h { header "tgmath.h" export ccomplex export cmath export * } // C compatibility headers. module compat { module cassert { // 's use of NDEBUG requires textual inclusion. textual header "cassert" } module ccomplex { header "ccomplex" export complex export * } module cctype { header "cctype" export * } module cerrno { header "cerrno" export * } module cfenv { header "cfenv" export * } module cfloat { header "cfloat" export * } module cinttypes { header "cinttypes" export cstdint export * } module ciso646 { header "ciso646" export * } module climits { header "climits" export * } module clocale { header "clocale" export * } module cmath { header "cmath" export * } module csetjmp { header "csetjmp" export * } module csignal { header "csignal" export * } // FIXME: is missing. module cstdarg { header "cstdarg" export * } module cstdbool { header "cstdbool" export * } module cstddef { header "cstddef" export * } module cstdint { header "cstdint" export depr.stdint_h export * } module cstdio { header "cstdio" export * } module cstdlib { header "cstdlib" export * } module cstring { header "cstring" export * } module ctgmath { header "ctgmath" export ccomplex export cmath export * } module ctime { header "ctime" export * } // FIXME: is missing. module cwchar { header "cwchar" export depr.stdio_h export * } module cwctype { header "cwctype" export * } } module algorithm { header "algorithm" export initializer_list export * module __algorithm { module adjacent_find { private header "__algorithm/adjacent_find.h" } module all_of { private header "__algorithm/all_of.h" } module any_of { private header "__algorithm/any_of.h" } module binary_search { private header "__algorithm/binary_search.h" } module clamp { private header "__algorithm/clamp.h" } module comp { private header "__algorithm/comp.h" } module comp_ref_type { private header "__algorithm/comp_ref_type.h" } module copy { private header "__algorithm/copy.h" } module copy_backward { private header "__algorithm/copy_backward.h" } module copy_if { private header "__algorithm/copy_if.h" } module copy_n { private header "__algorithm/copy_n.h" } module count { private header "__algorithm/count.h" } module count_if { private header "__algorithm/count_if.h" } module equal { private header "__algorithm/equal.h" } module equal_range { private header "__algorithm/equal_range.h" } module fill { private header "__algorithm/fill.h" } module fill_n { private header "__algorithm/fill_n.h" } module find { private header "__algorithm/find.h" } module find_end { private header "__algorithm/find_end.h" } module find_first_of { private header "__algorithm/find_first_of.h" } module find_if { private header "__algorithm/find_if.h" } module find_if_not { private header "__algorithm/find_if_not.h" } module for_each { private header "__algorithm/for_each.h" } module for_each_n { private header "__algorithm/for_each_n.h" } module generate { private header "__algorithm/generate.h" } module generate_n { private header "__algorithm/generate_n.h" } module half_positive { private header "__algorithm/half_positive.h" } module in_in_out_result { private header "__algorithm/in_in_out_result.h" } module in_in_result { private header "__algorithm/in_in_result.h" } module in_out_result { private header "__algorithm/in_out_result.h" } module includes { private header "__algorithm/includes.h" } module inplace_merge { private header "__algorithm/inplace_merge.h" } module is_heap { private header "__algorithm/is_heap.h" } module is_heap_until { private header "__algorithm/is_heap_until.h" } module is_partitioned { private header "__algorithm/is_partitioned.h" } module is_permutation { private header "__algorithm/is_permutation.h" } module is_sorted { private header "__algorithm/is_sorted.h" } module is_sorted_until { private header "__algorithm/is_sorted_until.h" } module iter_swap { private header "__algorithm/iter_swap.h" } module lexicographical_compare { private header "__algorithm/lexicographical_compare.h" } module lower_bound { private header "__algorithm/lower_bound.h" } module make_heap { private header "__algorithm/make_heap.h" } module max { private header "__algorithm/max.h" } module max_element { private header "__algorithm/max_element.h" } module merge { private header "__algorithm/merge.h" } module min { private header "__algorithm/min.h" } module min_element { private header "__algorithm/min_element.h" } module minmax { private header "__algorithm/minmax.h" } module minmax_element { private header "__algorithm/minmax_element.h" } module mismatch { private header "__algorithm/mismatch.h" } module move { private header "__algorithm/move.h" } module move_backward { private header "__algorithm/move_backward.h" } module next_permutation { private header "__algorithm/next_permutation.h" } module none_of { private header "__algorithm/none_of.h" } module nth_element { private header "__algorithm/nth_element.h" } module partial_sort { private header "__algorithm/partial_sort.h" } module partial_sort_copy { private header "__algorithm/partial_sort_copy.h" } module partition { private header "__algorithm/partition.h" } module partition_copy { private header "__algorithm/partition_copy.h" } module partition_point { private header "__algorithm/partition_point.h" } module pop_heap { private header "__algorithm/pop_heap.h" } module prev_permutation { private header "__algorithm/prev_permutation.h" } module push_heap { private header "__algorithm/push_heap.h" } module remove { private header "__algorithm/remove.h" } module remove_copy { private header "__algorithm/remove_copy.h" } module remove_copy_if { private header "__algorithm/remove_copy_if.h" } module remove_if { private header "__algorithm/remove_if.h" } module replace { private header "__algorithm/replace.h" } module replace_copy { private header "__algorithm/replace_copy.h" } module replace_copy_if { private header "__algorithm/replace_copy_if.h" } module replace_if { private header "__algorithm/replace_if.h" } module reverse { private header "__algorithm/reverse.h" } module reverse_copy { private header "__algorithm/reverse_copy.h" } module rotate { private header "__algorithm/rotate.h" } module rotate_copy { private header "__algorithm/rotate_copy.h" } module sample { private header "__algorithm/sample.h" } module search { private header "__algorithm/search.h" } module search_n { private header "__algorithm/search_n.h" } module set_difference { private header "__algorithm/set_difference.h" } module set_intersection { private header "__algorithm/set_intersection.h" } module set_symmetric_difference { private header "__algorithm/set_symmetric_difference.h" } module set_union { private header "__algorithm/set_union.h" } module shift_left { private header "__algorithm/shift_left.h" } module shift_right { private header "__algorithm/shift_right.h" } module shuffle { private header "__algorithm/shuffle.h" } module sift_down { private header "__algorithm/sift_down.h" } module sort { private header "__algorithm/sort.h" } module sort_heap { private header "__algorithm/sort_heap.h" } module stable_partition { private header "__algorithm/stable_partition.h" } module stable_sort { private header "__algorithm/stable_sort.h" } module swap_ranges { private header "__algorithm/swap_ranges.h" } module transform { private header "__algorithm/transform.h" } module unique { private header "__algorithm/unique.h" } module unique_copy { private header "__algorithm/unique_copy.h" } module unwrap_iter { private header "__algorithm/unwrap_iter.h" } module upper_bound { private header "__algorithm/upper_bound.h" } } } module any { header "any" export * } module array { header "array" export initializer_list export * } module atomic { header "atomic" export * } module barrier { requires cplusplus14 header "barrier" export * } module bit { header "bit" export * module __bit { module bit_cast { private header "__bit/bit_cast.h" } module byteswap { private header "__bit/byteswap.h" } } } module bitset { header "bitset" export string export iosfwd export * } // No submodule for cassert. It fundamentally needs repeated, textual inclusion. module charconv { header "charconv" export * module __charconv { module chars_format { private header "__charconv/chars_format.h" } module from_chars_result { private header "__charconv/from_chars_result.h" } module to_chars_result { private header "__charconv/to_chars_result.h" } } } module chrono { header "chrono" export * module __chrono { module calendar { private header "__chrono/calendar.h" } module convert_to_timespec { private header "__chrono/convert_to_timespec.h" } module duration { private header "__chrono/duration.h" } module file_clock { private header "__chrono/file_clock.h" } module high_resolution_clock { private header "__chrono/high_resolution_clock.h" } module steady_clock { private header "__chrono/steady_clock.h" } module system_clock { private header "__chrono/system_clock.h" } module time_point { private header "__chrono/time_point.h" } } } module codecvt { header "codecvt" export * } module compare { header "compare" export * module __compare { module common_comparison_category { private header "__compare/common_comparison_category.h" } module compare_partial_order_fallback { private header "__compare/compare_partial_order_fallback.h" } module compare_strong_order_fallback { private header "__compare/compare_strong_order_fallback.h" } module compare_three_way { private header "__compare/compare_three_way.h" } module compare_three_way_result { private header "__compare/compare_three_way_result.h" } module compare_weak_order_fallback { private header "__compare/compare_weak_order_fallback.h" } module is_eq { private header "__compare/is_eq.h" } module ordering { private header "__compare/ordering.h" } module partial_order { private header "__compare/partial_order.h" } module strong_order { private header "__compare/strong_order.h" } module synth_three_way { private header "__compare/synth_three_way.h" } module three_way_comparable { private header "__compare/three_way_comparable.h" } module weak_order { private header "__compare/weak_order.h" } } } module complex { header "complex" export * } module concepts { header "concepts" export * module __concepts { module arithmetic { private header "__concepts/arithmetic.h" } module assignable { private header "__concepts/assignable.h" } module boolean_testable { private header "__concepts/boolean_testable.h" } module class_or_enum { private header "__concepts/class_or_enum.h" } module common_reference_with { private header "__concepts/common_reference_with.h" } module common_with { private header "__concepts/common_with.h" } module constructible { private header "__concepts/constructible.h" } module convertible_to { private header "__concepts/convertible_to.h" } module copyable { private header "__concepts/copyable.h" } module derived_from { private header "__concepts/derived_from.h" } module destructible { private header "__concepts/destructible.h" } module different_from { private header "__concepts/different_from.h" } module equality_comparable { private header "__concepts/equality_comparable.h" } module invocable { private header "__concepts/invocable.h" } module movable { private header "__concepts/movable.h" } module predicate { private header "__concepts/predicate.h" } module regular { private header "__concepts/regular.h" } module relation { private header "__concepts/relation.h" } module same_as { private header "__concepts/same_as.h" } module semiregular { private header "__concepts/semiregular.h" } module swappable { private header "__concepts/swappable.h" } module totally_ordered { private header "__concepts/totally_ordered.h" } } } module condition_variable { header "condition_variable" export * } module coroutine { requires coroutines header "coroutine" export compare export * module __coroutine { module coroutine_handle { private header "__coroutine/coroutine_handle.h" } module coroutine_traits { private header "__coroutine/coroutine_traits.h" } module noop_coroutine_handle { private header "__coroutine/noop_coroutine_handle.h" } module trivial_awaitables { private header "__coroutine/trivial_awaitables.h" } } } module deque { header "deque" export initializer_list export * } module exception { header "exception" export * } module execution { header "execution" export * } module filesystem { header "filesystem" export * module __filesystem { module copy_options { private header "__filesystem/copy_options.h" } module directory_entry { private header "__filesystem/directory_entry.h" } module directory_iterator { private header "__filesystem/directory_iterator.h" } module directory_options { private header "__filesystem/directory_options.h" } module file_status { private header "__filesystem/file_status.h" } module file_time_type { private header "__filesystem/file_time_type.h" } module file_type { private header "__filesystem/file_type.h" } module filesystem_error { private header "__filesystem/filesystem_error.h" } module operations { private header "__filesystem/operations.h" } module path { private header "__filesystem/path.h" } module path_iterator { private header "__filesystem/path_iterator.h" } module perm_options { private header "__filesystem/perm_options.h" } module perms { private header "__filesystem/perms.h" } module recursive_directory_iterator { private header "__filesystem/recursive_directory_iterator.h" } module space_info { private header "__filesystem/space_info.h" } module u8path { private header "__filesystem/u8path.h" } } } module format { header "format" export * module __format { module format_arg { private header "__format/format_arg.h" } module format_args { private header "__format/format_args.h" } module format_context { private header "__format/format_context.h" export optional export locale } module format_error { private header "__format/format_error.h" } module format_fwd { private header "__format/format_fwd.h" } module format_parse_context { private header "__format/format_parse_context.h" } module format_string { private header "__format/format_string.h" } module format_to_n_result { private header "__format/format_to_n_result.h" } module formatter { private header "__format/formatter.h" } module formatter_bool { private header "__format/formatter_bool.h" } module formatter_char { private header "__format/formatter_char.h" } module formatter_floating_point { private header "__format/formatter_floating_point.h" } module formatter_integer { private header "__format/formatter_integer.h" } module formatter_integral { private header "__format/formatter_integral.h" } module formatter_pointer { private header "__format/formatter_pointer.h" } module formatter_string { private header "__format/formatter_string.h" } module parser_std_format_spec { private header "__format/parser_std_format_spec.h" } } } module forward_list { header "forward_list" export initializer_list export * } module fstream { header "fstream" export * } module functional { header "functional" export * module __functional { module binary_function { private header "__functional/binary_function.h" } module binary_negate { private header "__functional/binary_negate.h" } module bind { private header "__functional/bind.h" } module bind_back { private header "__functional/bind_back.h" } module bind_front { private header "__functional/bind_front.h" } module binder1st { private header "__functional/binder1st.h" } module binder2nd { private header "__functional/binder2nd.h" } module compose { private header "__functional/compose.h" } module default_searcher { private header "__functional/default_searcher.h" } module function { private header "__functional/function.h" } module hash { private header "__functional/hash.h" } module identity { private header "__functional/identity.h" } module invoke { private header "__functional/invoke.h" } module is_transparent { private header "__functional/is_transparent.h" } module mem_fn { private header "__functional/mem_fn.h" } module mem_fun_ref { private header "__functional/mem_fun_ref.h" } module not_fn { private header "__functional/not_fn.h" } module operations { private header "__functional/operations.h" } module perfect_forward { private header "__functional/perfect_forward.h" } module pointer_to_binary_function { private header "__functional/pointer_to_binary_function.h" } module pointer_to_unary_function { private header "__functional/pointer_to_unary_function.h" } module ranges_operations { private header "__functional/ranges_operations.h" } module reference_wrapper { private header "__functional/reference_wrapper.h" } module unary_function { private header "__functional/unary_function.h" } module unary_negate { private header "__functional/unary_negate.h" } module unwrap_ref { private header "__functional/unwrap_ref.h" } module weak_result_type { private header "__functional/weak_result_type.h" } } } module future { header "future" export * } module initializer_list { header "initializer_list" export * } module iomanip { header "iomanip" export * } module ios { header "ios" export iosfwd export * } module iosfwd { header "iosfwd" export * } module iostream { header "iostream" export ios export streambuf export istream export ostream export * } module istream { header "istream" // FIXME: should re-export ios, streambuf? export * } module iterator { header "iterator" export * module __iterator { module access { private header "__iterator/access.h" } module advance { private header "__iterator/advance.h" } module back_insert_iterator { private header "__iterator/back_insert_iterator.h" } module common_iterator { private header "__iterator/common_iterator.h" } module concepts { private header "__iterator/concepts.h" } module counted_iterator { private header "__iterator/counted_iterator.h" } module data { private header "__iterator/data.h" } module default_sentinel { private header "__iterator/default_sentinel.h" } module distance { private header "__iterator/distance.h" } module empty { private header "__iterator/empty.h" } module erase_if_container { private header "__iterator/erase_if_container.h" } module front_insert_iterator { private header "__iterator/front_insert_iterator.h" } module incrementable_traits { private header "__iterator/incrementable_traits.h" } module indirectly_comparable { private header "__iterator/indirectly_comparable.h" } module insert_iterator { private header "__iterator/insert_iterator.h" } module istream_iterator { private header "__iterator/istream_iterator.h" } module istreambuf_iterator { private header "__iterator/istreambuf_iterator.h" } module iter_move { private header "__iterator/iter_move.h" } module iter_swap { private header "__iterator/iter_swap.h" } module iterator { private header "__iterator/iterator.h" } module iterator_traits { private header "__iterator/iterator_traits.h" } module move_iterator { private header "__iterator/move_iterator.h" } module next { private header "__iterator/next.h" } module ostream_iterator { private header "__iterator/ostream_iterator.h" } module ostreambuf_iterator { private header "__iterator/ostreambuf_iterator.h" } module prev { private header "__iterator/prev.h" } module projected { private header "__iterator/projected.h" } module readable_traits { private header "__iterator/readable_traits.h" } module reverse_access { private header "__iterator/reverse_access.h" } module reverse_iterator { private header "__iterator/reverse_iterator.h" } module size { private header "__iterator/size.h" } module unreachable_sentinel { private header "__iterator/unreachable_sentinel.h" } module wrap_iter { private header "__iterator/wrap_iter.h" } } } module latch { requires cplusplus14 header "latch" export * } module limits { header "limits" export * } module list { header "list" export initializer_list export * } module locale { header "locale" export * } module map { header "map" export initializer_list export * } module memory { header "memory" export * module __memory { module addressof { private header "__memory/addressof.h" } module allocation_guard { private header "__memory/allocation_guard.h" } module allocator { private header "__memory/allocator.h" } module allocator_arg_t { private header "__memory/allocator_arg_t.h" } module allocator_traits { private header "__memory/allocator_traits.h" } module auto_ptr { private header "__memory/auto_ptr.h" } module compressed_pair { private header "__memory/compressed_pair.h" } module concepts { private header "__memory/concepts.h" } module construct_at { private header "__memory/construct_at.h" } module pointer_traits { private header "__memory/pointer_traits.h" } module ranges_construct_at { private header "__memory/ranges_construct_at.h" } module ranges_uninitialized_algorithms { private header "__memory/ranges_uninitialized_algorithms.h" } module raw_storage_iterator { private header "__memory/raw_storage_iterator.h" } module shared_ptr { private header "__memory/shared_ptr.h" } module temporary_buffer { private header "__memory/temporary_buffer.h" } module uninitialized_algorithms { private header "__memory/uninitialized_algorithms.h" } module unique_ptr { private header "__memory/unique_ptr.h" } module uses_allocator { private header "__memory/uses_allocator.h" } module voidify { private header "__memory/voidify.h" } } } module mutex { header "mutex" export * } module new { header "new" export * } module numbers { header "numbers" export * } module numeric { header "numeric" export * module __numeric { module accumulate { private header "__numeric/accumulate.h" } module adjacent_difference { private header "__numeric/adjacent_difference.h" } module exclusive_scan { private header "__numeric/exclusive_scan.h" } module gcd_lcm { private header "__numeric/gcd_lcm.h" } module inclusive_scan { private header "__numeric/inclusive_scan.h" } module inner_product { private header "__numeric/inner_product.h" } module iota { private header "__numeric/iota.h" } module midpoint { private header "__numeric/midpoint.h" } module partial_sum { private header "__numeric/partial_sum.h" } module reduce { private header "__numeric/reduce.h" } module transform_exclusive_scan { private header "__numeric/transform_exclusive_scan.h" } module transform_inclusive_scan { private header "__numeric/transform_inclusive_scan.h" } module transform_reduce { private header "__numeric/transform_reduce.h" } } } module optional { header "optional" export * } module ostream { header "ostream" // FIXME: should re-export ios, streambuf? export * } module queue { header "queue" export initializer_list export * } module random { header "random" export initializer_list export * module __random { module bernoulli_distribution { private header "__random/bernoulli_distribution.h" } module binomial_distribution { private header "__random/binomial_distribution.h" } module cauchy_distribution { private header "__random/cauchy_distribution.h" } module chi_squared_distribution { private header "__random/chi_squared_distribution.h" } module clamp_to_integral { private header "__random/clamp_to_integral.h" } module default_random_engine { private header "__random/default_random_engine.h" } module discard_block_engine { private header "__random/discard_block_engine.h" } module discrete_distribution { private header "__random/discrete_distribution.h" } module exponential_distribution { private header "__random/exponential_distribution.h" } module extreme_value_distribution { private header "__random/extreme_value_distribution.h" } module fisher_f_distribution { private header "__random/fisher_f_distribution.h" } module gamma_distribution { private header "__random/gamma_distribution.h" } module generate_canonical { private header "__random/generate_canonical.h" } module geometric_distribution { private header "__random/geometric_distribution.h" } module independent_bits_engine { private header "__random/independent_bits_engine.h" } module is_seed_sequence { private header "__random/is_seed_sequence.h" } module knuth_b { private header "__random/knuth_b.h" } module linear_congruential_engine { private header "__random/linear_congruential_engine.h" } module log2 { private header "__random/log2.h" } module lognormal_distribution { private header "__random/lognormal_distribution.h" } module mersenne_twister_engine { private header "__random/mersenne_twister_engine.h" } module negative_binomial_distribution { private header "__random/negative_binomial_distribution.h" } module normal_distribution { private header "__random/normal_distribution.h" } module piecewise_constant_distribution { private header "__random/piecewise_constant_distribution.h" } module piecewise_linear_distribution { private header "__random/piecewise_linear_distribution.h" } module poisson_distribution { private header "__random/poisson_distribution.h" } module random_device { private header "__random/random_device.h" } module ranlux { private header "__random/ranlux.h" } module seed_seq { private header "__random/seed_seq.h" } module shuffle_order_engine { private header "__random/shuffle_order_engine.h" } module student_t_distribution { private header "__random/student_t_distribution.h" } module subtract_with_carry_engine { private header "__random/subtract_with_carry_engine.h" } module uniform_int_distribution { private header "__random/uniform_int_distribution.h" } module uniform_random_bit_generator { private header "__random/uniform_random_bit_generator.h" } module uniform_real_distribution { private header "__random/uniform_real_distribution.h" } module weibull_distribution { private header "__random/weibull_distribution.h" } } } module ranges { header "ranges" export compare export initializer_list export iterator export * module __ranges { module access { private header "__ranges/access.h" } module all { private header "__ranges/all.h" export functional.__functional.compose export functional.__functional.perfect_forward } module common_view { private header "__ranges/common_view.h" } module concepts { private header "__ranges/concepts.h" } module copyable_box { private header "__ranges/copyable_box.h" } module counted { private header "__ranges/counted.h" export span } module dangling { private header "__ranges/dangling.h" } module data { private header "__ranges/data.h" } module drop_view { private header "__ranges/drop_view.h" } module empty { private header "__ranges/empty.h" } module empty_view { private header "__ranges/empty_view.h" } module enable_borrowed_range { private header "__ranges/enable_borrowed_range.h" } module enable_view { private header "__ranges/enable_view.h" } module iota_view { private header "__ranges/iota_view.h" } module join_view { private header "__ranges/join_view.h" } module non_propagating_cache { private header "__ranges/non_propagating_cache.h" } module owning_view { private header "__ranges/owning_view.h" } module range_adaptor { private header "__ranges/range_adaptor.h" } module ref_view { private header "__ranges/ref_view.h" } module reverse_view { private header "__ranges/reverse_view.h" } module single_view { private header "__ranges/single_view.h" } module size { private header "__ranges/size.h" } module subrange { private header "__ranges/subrange.h" } module take_view { private header "__ranges/take_view.h" } module transform_view { private header "__ranges/transform_view.h" export functional.__functional.bind_back export functional.__functional.perfect_forward } module view_interface { private header "__ranges/view_interface.h" } } } module ratio { header "ratio" export * } module regex { header "regex" export initializer_list export * } module scoped_allocator { header "scoped_allocator" export * } module semaphore { requires cplusplus14 header "semaphore" export * } module set { header "set" export initializer_list export * } module shared_mutex { header "shared_mutex" export version } module span { header "span" export ranges.__ranges.enable_borrowed_range export version } module sstream { header "sstream" // FIXME: should re-export istream, ostream, ios, streambuf, string? export * } module stack { header "stack" export initializer_list export * } module stdexcept { header "stdexcept" export * } module streambuf { header "streambuf" export * } module string { header "string" export initializer_list export string_view export __string export * } module string_view { header "string_view" export initializer_list export __string export * } module strstream { header "strstream" export * } module system_error { header "system_error" export * } module thread { header "thread" export * module __thread { module poll_with_backoff { private header "__thread/poll_with_backoff.h" } module timed_backoff_policy { private header "__thread/timed_backoff_policy.h" } } } module tuple { header "tuple" export * } module type_traits { header "type_traits" export functional.__functional.unwrap_ref export * } module typeindex { header "typeindex" export * } module typeinfo { header "typeinfo" export * } module unordered_map { header "unordered_map" export initializer_list export * } module unordered_set { header "unordered_set" export initializer_list export * } module utility { header "utility" export initializer_list export * module __utility { module as_const { private header "__utility/as_const.h" } module auto_cast { private header "__utility/auto_cast.h" } module cmp { private header "__utility/cmp.h" } module declval { private header "__utility/declval.h" } module exchange { private header "__utility/exchange.h" } module forward { private header "__utility/forward.h" } module in_place { private header "__utility/in_place.h" } module integer_sequence { private header "__utility/integer_sequence.h" } module move { private header "__utility/move.h" } module pair { private header "__utility/pair.h" } module piecewise_construct { private header "__utility/piecewise_construct.h" } module priority_tag { private header "__utility/priority_tag.h" } module rel_ops { private header "__utility/rel_ops.h" } module swap { private header "__utility/swap.h" } module to_underlying { private header "__utility/to_underlying.h" } module transaction { private header "__utility/transaction.h" } } } module valarray { header "valarray" export initializer_list export * } module variant { header "variant" export * module __variant { module monostate { private header "__variant/monostate.h" } } } module vector { header "vector" export initializer_list export * } module version { header "version" export * } // __config not modularised due to a bug in Clang // FIXME: These should be private. module __availability { private header "__availability" export * } module __bit_reference { private header "__bit_reference" export * } module __bits { private header "__bits" export * } module __debug { header "__debug" export * } module __errc { private header "__errc" export * } module __hash_table { header "__hash_table" export * } module __locale { private header "__locale" export * } module __mbstate_t { private header "__mbstate_t.h" export * } module __mutex_base { private header "__mutex_base" export * } module __node_handle { private header "__node_handle" export * } module __nullptr { header "__nullptr" export * } module __split_buffer { private header "__split_buffer" export * } module __std_stream { private header "__std_stream" export * } module __string { private header "__string" export * } module __threading_support { header "__threading_support" export * } module __tree { header "__tree" export * } module __tuple { private header "__tuple" export * } module __undef_macros { header "__undef_macros" export * } module experimental { requires cplusplus11 module algorithm { header "experimental/algorithm" export * } module coroutine { requires coroutines header "experimental/coroutine" export * } module deque { header "experimental/deque" export * } module filesystem { header "experimental/filesystem" export * } module forward_list { header "experimental/forward_list" export * } module functional { header "experimental/functional" export * } module iterator { header "experimental/iterator" export * } module list { header "experimental/list" export * } module map { header "experimental/map" export * } module memory_resource { header "experimental/memory_resource" export * } module propagate_const { header "experimental/propagate_const" export * } module regex { header "experimental/regex" export * } module simd { header "experimental/simd" export * } module set { header "experimental/set" export * } module span { header "span" export * } module string { header "experimental/string" export * } module type_traits { header "experimental/type_traits" export * } module unordered_map { header "experimental/unordered_map" export * } module unordered_set { header "experimental/unordered_set" export * } module utility { header "experimental/utility" export * } module vector { header "experimental/vector" export * } // FIXME these should be private module __memory { header "experimental/__memory" export * } } // end experimental } diff --git a/libcxx/include/numbers b/libcxx/include/numbers index 2ac36695b888..35f5b04d9e41 100644 --- a/libcxx/include/numbers +++ b/libcxx/include/numbers @@ -1,133 +1,133 @@ // -*- 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_NUMBERS #define _LIBCPP_NUMBERS /* numbers synopsis namespace std::numbers { template inline constexpr T e_v = unspecified; template inline constexpr T log2e_v = unspecified; template inline constexpr T log10e_v = unspecified; template inline constexpr T pi_v = unspecified; template inline constexpr T inv_pi_v = unspecified; template inline constexpr T inv_sqrtpi_v = unspecified; template inline constexpr T ln2_v = unspecified; template inline constexpr T ln10_v = unspecified; template inline constexpr T sqrt2_v = unspecified; template inline constexpr T sqrt3_v = unspecified; template inline constexpr T inv_sqrt3_v = unspecified; template inline constexpr T egamma_v = unspecified; template inline constexpr T phi_v = unspecified; template inline constexpr T e_v = see below; template inline constexpr T log2e_v = see below; template inline constexpr T log10e_v = see below; template inline constexpr T pi_v = see below; template inline constexpr T inv_pi_v = see below; template inline constexpr T inv_sqrtpi_v = see below; template inline constexpr T ln2_v = see below; template inline constexpr T ln10_v = see below; template inline constexpr T sqrt2_v = see below; template inline constexpr T sqrt3_v = see below; template inline constexpr T inv_sqrt3_v = see below; template inline constexpr T egamma_v = see below; template inline constexpr T phi_v = see below; inline constexpr double e = e_v; inline constexpr double log2e = log2e_v; inline constexpr double log10e = log10e_v; inline constexpr double pi = pi_v; inline constexpr double inv_pi = inv_pi_v; inline constexpr double inv_sqrtpi = inv_sqrtpi_v; inline constexpr double ln2 = ln2_v; inline constexpr double ln10 = ln10_v; inline constexpr double sqrt2 = sqrt2_v; inline constexpr double sqrt3 = sqrt3_v; inline constexpr double inv_sqrt3 = inv_sqrt3_v; inline constexpr double egamma = egamma_v; inline constexpr double phi = phi_v; } */ #include <__config> #include #include #include -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD namespace numbers { template inline constexpr bool __false = false; template struct __illformed { static_assert(__false<_Tp>, "A program that instantiates a primary template of a mathematical constant variable template is ill-formed."); }; template inline constexpr _Tp e_v = __illformed<_Tp>{}; template inline constexpr _Tp log2e_v = __illformed<_Tp>{}; template inline constexpr _Tp log10e_v = __illformed<_Tp>{}; template inline constexpr _Tp pi_v = __illformed<_Tp>{}; template inline constexpr _Tp inv_pi_v = __illformed<_Tp>{}; template inline constexpr _Tp inv_sqrtpi_v = __illformed<_Tp>{}; template inline constexpr _Tp ln2_v = __illformed<_Tp>{}; template inline constexpr _Tp ln10_v = __illformed<_Tp>{}; template inline constexpr _Tp sqrt2_v = __illformed<_Tp>{}; template inline constexpr _Tp sqrt3_v = __illformed<_Tp>{}; template inline constexpr _Tp inv_sqrt3_v = __illformed<_Tp>{}; template inline constexpr _Tp egamma_v = __illformed<_Tp>{}; template inline constexpr _Tp phi_v = __illformed<_Tp>{}; template inline constexpr _Tp e_v<_Tp> = 2.718281828459045235360287471352662; template inline constexpr _Tp log2e_v<_Tp> = 1.442695040888963407359924681001892; template inline constexpr _Tp log10e_v<_Tp> = 0.434294481903251827651128918916605; template inline constexpr _Tp pi_v<_Tp> = 3.141592653589793238462643383279502; template inline constexpr _Tp inv_pi_v<_Tp> = 0.318309886183790671537767526745028; template inline constexpr _Tp inv_sqrtpi_v<_Tp> = 0.564189583547756286948079451560772; template inline constexpr _Tp ln2_v<_Tp> = 0.693147180559945309417232121458176; template inline constexpr _Tp ln10_v<_Tp> = 2.302585092994045684017991454684364; template inline constexpr _Tp sqrt2_v<_Tp> = 1.414213562373095048801688724209698; template inline constexpr _Tp sqrt3_v<_Tp> = 1.732050807568877293527446341505872; template inline constexpr _Tp inv_sqrt3_v<_Tp> = 0.577350269189625764509148780501957; template inline constexpr _Tp egamma_v<_Tp> = 0.577215664901532860606512090082402; template inline constexpr _Tp phi_v<_Tp> = 1.618033988749894848204586834365638; inline constexpr double e = e_v; inline constexpr double log2e = log2e_v; inline constexpr double log10e = log10e_v; inline constexpr double pi = pi_v; inline constexpr double inv_pi = inv_pi_v; inline constexpr double inv_sqrtpi = inv_sqrtpi_v; inline constexpr double ln2 = ln2_v; inline constexpr double ln10 = ln10_v; inline constexpr double sqrt2 = sqrt2_v; inline constexpr double sqrt3 = sqrt3_v; inline constexpr double inv_sqrt3 = inv_sqrt3_v; inline constexpr double egamma = egamma_v; inline constexpr double phi = phi_v; } // namespace numbers _LIBCPP_END_NAMESPACE_STD -#endif //_LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif //!defined(_LIBCPP_HAS_NO_CONCEPTS) #endif // _LIBCPP_NUMBERS diff --git a/libcxx/include/ranges b/libcxx/include/ranges index f7c543d7316c..2d79d87eef89 100644 --- a/libcxx/include/ranges +++ b/libcxx/include/ranges @@ -1,252 +1,252 @@ // -*- 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_RANGES #define _LIBCPP_RANGES /* #include // see [compare.syn] #include // see [initializer.list.syn] #include // see [iterator.synopsis] namespace std::ranges { inline namespace unspecified { // [range.access], range access inline constexpr unspecified begin = unspecified; inline constexpr unspecified end = unspecified; inline constexpr unspecified cbegin = unspecified; inline constexpr unspecified cend = unspecified; inline constexpr unspecified size = unspecified; inline constexpr unspecified ssize = unspecified; } // [range.range], ranges template concept range = see below; template inline constexpr bool enable_borrowed_range = false; template using iterator_t = decltype(ranges::begin(declval())); template using sentinel_t = decltype(ranges::end(declval())); template using range_difference_t = iter_difference_t>; template using range_size_t = decltype(ranges::size(declval())); template using range_value_t = iter_value_t>; template using range_reference_t = iter_reference_t>; template using range_rvalue_reference_t = iter_rvalue_reference_t>; // [range.sized], sized ranges template inline constexpr bool disable_sized_range = false; template concept sized_range = ...; // [range.view], views template inline constexpr bool enable_view = ...; struct view_base { }; template concept view = ...; // [range.refinements], other range refinements template concept output_range = see below; template concept input_range = see below; template concept forward_range = see below; template concept bidirectional_range = see below; template concept random_access_range = see below; template concept contiguous_range = see below; template concept common_range = see below; template concept viewable_range = see below; // [view.interface], class template view_interface template requires is_class_v && same_as> class view_interface; // [range.subrange], sub-ranges enum class subrange_kind : bool { unsized, sized }; template S = I, subrange_kind K = see below> requires (K == subrange_kind::sized || !sized_sentinel_for) class subrange; template inline constexpr bool enable_borrowed_range> = true; // [range.dangling], dangling iterator handling struct dangling; template using borrowed_iterator_t = see below; template using borrowed_subrange_t = see below; // [range.empty], empty view template requires is_object_v class empty_view; // [range.all], all view namespace views { inline constexpr unspecified all = unspecified; template using all_t = decltype(all(declval())); } template requires is_object_v class ref_view; template inline constexpr bool enable_borrowed_range> = true; template requires see below class owning_view; template inline constexpr bool enable_borrowed_range> = enable_borrowed_range; // [range.drop], drop view template class drop_view; template inline constexpr bool enable_borrowed_range> = enable_borrowed_range; // [range.transform], transform view template requires view && is_object_v && regular_invocable> && can-reference>> class transform_view; // [range.counted], counted view namespace views { inline constexpr unspecified counted = unspecified; } // [range.common], common view template requires (!common_range && copyable>) class common_view; // [range.reverse], reverse view template requires bidirectional_range class reverse_view; template inline constexpr bool enable_borrowed_range> = enable_borrowed_range; template inline constexpr bool enable_borrowed_range> = enable_borrowed_range; // [range.take], take view template class take_view; template inline constexpr bool enable_borrowed_range> = enable_borrowed_range; template requires is_object_v class single_view; template requires weakly-equality-comparable-with && copyable class iota_view; template inline constexpr bool enable_borrowed_range> = true; // [range.join], join view template requires view && input_range> class join_view; } */ // Make sure all feature-test macros are available. #include // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES. #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) #include <__config> #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/empty.h> #include <__ranges/empty_view.h> #include <__ranges/enable_borrowed_range.h> #include <__ranges/enable_view.h> #include <__ranges/iota_view.h> #include <__ranges/join_view.h> #include <__ranges/ref_view.h> #include <__ranges/reverse_view.h> #include <__ranges/single_view.h> #include <__ranges/size.h> #include <__ranges/subrange.h> #include <__ranges/take_view.h> #include <__ranges/transform_view.h> #include <__ranges/view_interface.h> #include // Required by the standard. #include // Required by the standard. #include // Required by the standard. #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) namespace views = ranges::views; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) #endif // _LIBCPP_RANGES diff --git a/libcxx/include/string b/libcxx/include/string index 3616de8a214d..01cff902e07d 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -1,4524 +1,4509 @@ // -*- 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_STRING #define _LIBCPP_STRING /* string synopsis namespace std { template class fpos { private: stateT st; public: fpos(streamoff = streamoff()); operator streamoff() const; stateT state() const; void state(stateT); fpos& operator+=(streamoff); fpos operator+ (streamoff) const; fpos& operator-=(streamoff); fpos operator- (streamoff) const; }; template streamoff operator-(const fpos& x, const fpos& y); template bool operator==(const fpos& x, const fpos& y); template bool operator!=(const fpos& x, const fpos& y); template struct char_traits { typedef charT char_type; typedef ... int_type; typedef streamoff off_type; typedef streampos pos_type; typedef mbstate_t state_type; static void assign(char_type& c1, const char_type& c2) noexcept; static constexpr bool eq(char_type c1, char_type c2) noexcept; static constexpr bool lt(char_type c1, char_type c2) noexcept; static int compare(const char_type* s1, const char_type* s2, size_t n); static size_t length(const char_type* s); static const char_type* find(const char_type* s, size_t n, const char_type& a); static char_type* move(char_type* s1, const char_type* s2, size_t n); static char_type* copy(char_type* s1, const char_type* s2, size_t n); static char_type* assign(char_type* s, size_t n, char_type a); static constexpr int_type not_eof(int_type c) noexcept; static constexpr char_type to_char_type(int_type c) noexcept; static constexpr int_type to_int_type(char_type c) noexcept; static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept; static constexpr int_type eof() noexcept; }; template <> struct char_traits; template <> struct char_traits; template <> struct char_traits; // C++20 template <> struct char_traits; template <> struct char_traits; template, class Allocator = allocator > class basic_string { public: // types: typedef traits traits_type; typedef typename traits_type::char_type value_type; typedef Allocator allocator_type; typedef typename allocator_type::size_type size_type; typedef typename allocator_type::difference_type difference_type; typedef typename allocator_type::reference reference; typedef typename allocator_type::const_reference const_reference; typedef typename allocator_type::pointer pointer; typedef typename allocator_type::const_pointer const_pointer; typedef implementation-defined iterator; typedef implementation-defined const_iterator; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; static const size_type npos = -1; basic_string() noexcept(is_nothrow_default_constructible::value); explicit basic_string(const allocator_type& a); basic_string(const basic_string& str); basic_string(basic_string&& str) noexcept(is_nothrow_move_constructible::value); basic_string(const basic_string& str, size_type pos, const allocator_type& a = allocator_type()); basic_string(const basic_string& str, size_type pos, size_type n, const Allocator& a = Allocator()); template basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17 template explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17 basic_string(const value_type* s, const allocator_type& a = allocator_type()); basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); basic_string(nullptr_t) = delete; // C++2b basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); template basic_string(InputIterator begin, InputIterator end, const allocator_type& a = allocator_type()); basic_string(initializer_list, const Allocator& = Allocator()); basic_string(const basic_string&, const Allocator&); basic_string(basic_string&&, const Allocator&); ~basic_string(); operator basic_string_view() const noexcept; basic_string& operator=(const basic_string& str); template basic_string& operator=(const T& t); // C++17 basic_string& operator=(basic_string&& str) noexcept( allocator_type::propagate_on_container_move_assignment::value || allocator_type::is_always_equal::value ); // C++17 basic_string& operator=(const value_type* s); basic_string& operator=(nullptr_t) = delete; // C++2b basic_string& operator=(value_type c); basic_string& operator=(initializer_list); iterator begin() noexcept; const_iterator begin() const noexcept; iterator end() noexcept; const_iterator end() const noexcept; reverse_iterator rbegin() noexcept; const_reverse_iterator rbegin() const noexcept; reverse_iterator rend() noexcept; const_reverse_iterator rend() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; const_reverse_iterator crbegin() const noexcept; const_reverse_iterator crend() const noexcept; size_type size() const noexcept; size_type length() const noexcept; size_type max_size() const noexcept; size_type capacity() const noexcept; void resize(size_type n, value_type c); void resize(size_type n); template constexpr void resize_and_overwrite(size_type n, Operation op); // since C++23 void reserve(size_type res_arg); void reserve(); // deprecated in C++20 void shrink_to_fit(); void clear() noexcept; bool empty() const noexcept; const_reference operator[](size_type pos) const; reference operator[](size_type pos); const_reference at(size_type n) const; reference at(size_type n); basic_string& operator+=(const basic_string& str); template basic_string& operator+=(const T& t); // C++17 basic_string& operator+=(const value_type* s); basic_string& operator+=(value_type c); basic_string& operator+=(initializer_list); basic_string& append(const basic_string& str); template basic_string& append(const T& t); // C++17 basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14 template basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17 basic_string& append(const value_type* s, size_type n); basic_string& append(const value_type* s); basic_string& append(size_type n, value_type c); template basic_string& append(InputIterator first, InputIterator last); basic_string& append(initializer_list); void push_back(value_type c); void pop_back(); reference front(); const_reference front() const; reference back(); const_reference back() const; basic_string& assign(const basic_string& str); template basic_string& assign(const T& t); // C++17 basic_string& assign(basic_string&& str); basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14 template basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17 basic_string& assign(const value_type* s, size_type n); basic_string& assign(const value_type* s); basic_string& assign(size_type n, value_type c); template basic_string& assign(InputIterator first, InputIterator last); basic_string& assign(initializer_list); basic_string& insert(size_type pos1, const basic_string& str); template basic_string& insert(size_type pos1, const T& t); basic_string& insert(size_type pos1, const basic_string& str, size_type pos2, size_type n); template basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17 basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14 basic_string& insert(size_type pos, const value_type* s); basic_string& insert(size_type pos, size_type n, value_type c); iterator insert(const_iterator p, value_type c); iterator insert(const_iterator p, size_type n, value_type c); template iterator insert(const_iterator p, InputIterator first, InputIterator last); iterator insert(const_iterator p, initializer_list); basic_string& erase(size_type pos = 0, size_type n = npos); iterator erase(const_iterator position); iterator erase(const_iterator first, const_iterator last); basic_string& replace(size_type pos1, size_type n1, const basic_string& str); template basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17 basic_string& replace(size_type pos1, size_type n1, const basic_string& str, size_type pos2, size_type n2=npos); // C++14 template basic_string& replace(size_type pos1, size_type n1, const T& t, size_type pos2, size_type n); // C++17 basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); basic_string& replace(size_type pos, size_type n1, const value_type* s); basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); template basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17 basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n); basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s); basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); template basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); basic_string& replace(const_iterator i1, const_iterator i2, initializer_list); size_type copy(value_type* s, size_type n, size_type pos = 0) const; basic_string substr(size_type pos = 0, size_type n = npos) const; void swap(basic_string& str) noexcept(allocator_traits::propagate_on_container_swap::value || allocator_traits::is_always_equal::value); // C++17 const value_type* c_str() const noexcept; const value_type* data() const noexcept; value_type* data() noexcept; // C++17 allocator_type get_allocator() const noexcept; size_type find(const basic_string& str, size_type pos = 0) const noexcept; template size_type find(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension size_type find(const value_type* s, size_type pos, size_type n) const noexcept; size_type find(const value_type* s, size_type pos = 0) const noexcept; size_type find(value_type c, size_type pos = 0) const noexcept; size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; template size_type rfind(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; size_type rfind(const value_type* s, size_type pos = npos) const noexcept; size_type rfind(value_type c, size_type pos = npos) const noexcept; size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; template size_type find_first_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept; size_type find_first_of(value_type c, size_type pos = 0) const noexcept; size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; template size_type find_last_of(const T& t, size_type pos = npos) const noexcept noexcept; // C++17, noexcept as an extension size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; size_type find_last_of(value_type c, size_type pos = npos) const noexcept; size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; template size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept; size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; template size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; int compare(const basic_string& str) const noexcept; template int compare(const T& t) const noexcept; // C++17, noexcept as an extension int compare(size_type pos1, size_type n1, const basic_string& str) const; template int compare(size_type pos1, size_type n1, const T& t) const; // C++17 int compare(size_type pos1, size_type n1, const basic_string& str, size_type pos2, size_type n2=npos) const; // C++14 template int compare(size_type pos1, size_type n1, const T& t, size_type pos2, size_type n2=npos) const; // C++17 int compare(const value_type* s) const noexcept; int compare(size_type pos1, size_type n1, const value_type* s) const; int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; bool starts_with(basic_string_view sv) const noexcept; // C++20 bool starts_with(charT c) const noexcept; // C++20 bool starts_with(const charT* s) const; // C++20 bool ends_with(basic_string_view sv) const noexcept; // C++20 bool ends_with(charT c) const noexcept; // C++20 bool ends_with(const charT* s) const; // C++20 constexpr bool contains(basic_string_view sv) const noexcept; // C++2b constexpr bool contains(charT c) const noexcept; // C++2b constexpr bool contains(const charT* s) const; // C++2b bool __invariants() const; }; template::value_type>> basic_string(InputIterator, InputIterator, Allocator = Allocator()) -> basic_string::value_type, char_traits::value_type>, Allocator>; // C++17 template basic_string operator+(const basic_string& lhs, const basic_string& rhs); template basic_string operator+(const charT* lhs , const basic_string&rhs); template basic_string operator+(charT lhs, const basic_string& rhs); template basic_string operator+(const basic_string& lhs, const charT* rhs); template basic_string operator+(const basic_string& lhs, charT rhs); template bool operator==(const basic_string& lhs, const basic_string& rhs) noexcept; template bool operator==(const charT* lhs, const basic_string& rhs) noexcept; template bool operator==(const basic_string& lhs, const charT* rhs) noexcept; template bool operator!=(const basic_string& lhs, const basic_string& rhs) noexcept; template bool operator!=(const charT* lhs, const basic_string& rhs) noexcept; template bool operator!=(const basic_string& lhs, const charT* rhs) noexcept; template bool operator< (const basic_string& lhs, const basic_string& rhs) noexcept; template bool operator< (const basic_string& lhs, const charT* rhs) noexcept; template bool operator< (const charT* lhs, const basic_string& rhs) noexcept; template bool operator> (const basic_string& lhs, const basic_string& rhs) noexcept; template bool operator> (const basic_string& lhs, const charT* rhs) noexcept; template bool operator> (const charT* lhs, const basic_string& rhs) noexcept; template bool operator<=(const basic_string& lhs, const basic_string& rhs) noexcept; template bool operator<=(const basic_string& lhs, const charT* rhs) noexcept; template bool operator<=(const charT* lhs, const basic_string& rhs) noexcept; template bool operator>=(const basic_string& lhs, const basic_string& rhs) noexcept; template bool operator>=(const basic_string& lhs, const charT* rhs) noexcept; template bool operator>=(const charT* lhs, const basic_string& rhs) noexcept; template void swap(basic_string& lhs, basic_string& rhs) noexcept(noexcept(lhs.swap(rhs))); template basic_istream& operator>>(basic_istream& is, basic_string& str); template basic_ostream& operator<<(basic_ostream& os, const basic_string& str); template basic_istream& getline(basic_istream& is, basic_string& str, charT delim); template basic_istream& getline(basic_istream& is, basic_string& str); template typename basic_string::size_type erase(basic_string& c, const U& value); // C++20 template typename basic_string::size_type erase_if(basic_string& c, Predicate pred); // C++20 typedef basic_string string; typedef basic_string wstring; typedef basic_string u8string; // C++20 typedef basic_string u16string; typedef basic_string u32string; int stoi (const string& str, size_t* idx = nullptr, int base = 10); long stol (const string& str, size_t* idx = nullptr, int base = 10); unsigned long stoul (const string& str, size_t* idx = nullptr, int base = 10); long long stoll (const string& str, size_t* idx = nullptr, int base = 10); unsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10); float stof (const string& str, size_t* idx = nullptr); double stod (const string& str, size_t* idx = nullptr); long double stold(const string& str, size_t* idx = nullptr); string to_string(int val); string to_string(unsigned val); string to_string(long val); string to_string(unsigned long val); string to_string(long long val); string to_string(unsigned long long val); string to_string(float val); string to_string(double val); string to_string(long double val); int stoi (const wstring& str, size_t* idx = nullptr, int base = 10); long stol (const wstring& str, size_t* idx = nullptr, int base = 10); unsigned long stoul (const wstring& str, size_t* idx = nullptr, int base = 10); long long stoll (const wstring& str, size_t* idx = nullptr, int base = 10); unsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10); float stof (const wstring& str, size_t* idx = nullptr); double stod (const wstring& str, size_t* idx = nullptr); long double stold(const wstring& str, size_t* idx = nullptr); wstring to_wstring(int val); wstring to_wstring(unsigned val); wstring to_wstring(long val); wstring to_wstring(unsigned long val); wstring to_wstring(long long val); wstring to_wstring(unsigned long long val); wstring to_wstring(float val); wstring to_wstring(double val); wstring to_wstring(long double val); template <> struct hash; template <> struct hash; // C++20 template <> struct hash; template <> struct hash; template <> struct hash; basic_string operator "" s( const char *str, size_t len ); // C++14 basic_string operator "" s( const wchar_t *str, size_t len ); // C++14 basic_string operator "" s( const char8_t *str, size_t len ); // C++20 basic_string operator "" s( const char16_t *str, size_t len ); // C++14 basic_string operator "" s( const char32_t *str, size_t len ); // C++14 } // std */ #include <__config> #include <__debug> #include <__functional_base> #include <__iterator/wrap_iter.h> #include #include #include // EOF #include #include #include #include #include #include #include #include #include #include #include #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS # include #endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS # include #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_PUSH_MACROS #include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD // fpos template class _LIBCPP_TEMPLATE_VIS fpos { private: _StateT __st_; streamoff __off_; public: _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {} _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;} _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;} _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;} _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;} _LIBCPP_INLINE_VISIBILITY fpos operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;} _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;} _LIBCPP_INLINE_VISIBILITY fpos operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;} }; template inline _LIBCPP_INLINE_VISIBILITY streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {return streamoff(__x) - streamoff(__y);} template inline _LIBCPP_INLINE_VISIBILITY bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {return streamoff(__x) == streamoff(__y);} template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {return streamoff(__x) != streamoff(__y);} // basic_string template basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const basic_string<_CharT, _Traits, _Allocator>& __y); template basic_string<_CharT, _Traits, _Allocator> operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y); template basic_string<_CharT, _Traits, _Allocator> operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y); template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y); template basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+, allocator >(char const*, string const&)) -#ifndef _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS -template -struct __basic_string_common; - -template <> -struct __basic_string_common { - // Both are defined in string.cpp - _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; - _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; -}; -#endif - template struct __string_is_trivial_iterator : public false_type {}; template struct __string_is_trivial_iterator<_Tp*> : public is_arithmetic<_Tp> {}; template struct __string_is_trivial_iterator<__wrap_iter<_Iter> > : public __string_is_trivial_iterator<_Iter> {}; template struct __can_be_converted_to_string_view : public _BoolConstant< is_convertible >::value && !is_convertible::value > {}; #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT template struct __padding { unsigned char __xx[sizeof(_CharT)-1]; }; template struct __padding<_CharT, 1> { }; #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT #ifndef _LIBCPP_HAS_NO_CHAR8_T typedef basic_string u8string; #endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS typedef basic_string u16string; typedef basic_string u32string; #endif template class _LIBCPP_TEMPLATE_VIS #ifndef _LIBCPP_HAS_NO_CHAR8_T _LIBCPP_PREFERRED_NAME(u8string) #endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS _LIBCPP_PREFERRED_NAME(u16string) _LIBCPP_PREFERRED_NAME(u32string) #endif basic_string -#ifndef _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS - : private __basic_string_common // This base class is historical, but it needs to remain for ABI compatibility -#endif { public: typedef basic_string __self; typedef basic_string_view<_CharT, _Traits> __self_view; typedef _Traits traits_type; typedef _CharT value_type; typedef _Allocator allocator_type; typedef allocator_traits __alloc_traits; typedef typename __alloc_traits::size_type size_type; typedef typename __alloc_traits::difference_type difference_type; typedef value_type& reference; typedef const value_type& const_reference; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; static_assert((!is_array::value), "Character type of basic_string must not be an array"); static_assert(( is_standard_layout::value), "Character type of basic_string must be standard-layout"); static_assert(( is_trivial::value), "Character type of basic_string must be trivial"); static_assert(( is_same<_CharT, typename traits_type::char_type>::value), "traits_type::char_type must be the same type as CharT"); static_assert(( is_same::value), "Allocator::value_type must be same type as value_type"); typedef __wrap_iter iterator; typedef __wrap_iter const_iterator; typedef _VSTD::reverse_iterator reverse_iterator; typedef _VSTD::reverse_iterator const_reverse_iterator; private: #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT struct __long { pointer __data_; size_type __size_; size_type __cap_; }; #ifdef _LIBCPP_BIG_ENDIAN static const size_type __short_mask = 0x01; static const size_type __long_mask = 0x1ul; #else // _LIBCPP_BIG_ENDIAN static const size_type __short_mask = 0x80; static const size_type __long_mask = ~(size_type(~0) >> 1); #endif // _LIBCPP_BIG_ENDIAN enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? (sizeof(__long) - 1)/sizeof(value_type) : 2}; struct __short { value_type __data_[__min_cap]; struct : __padding { unsigned char __size_; }; }; #else struct __long { size_type __cap_; size_type __size_; pointer __data_; }; #ifdef _LIBCPP_BIG_ENDIAN static const size_type __short_mask = 0x80; static const size_type __long_mask = ~(size_type(~0) >> 1); #else // _LIBCPP_BIG_ENDIAN static const size_type __short_mask = 0x01; static const size_type __long_mask = 0x1ul; #endif // _LIBCPP_BIG_ENDIAN enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? (sizeof(__long) - 1)/sizeof(value_type) : 2}; struct __short { union { unsigned char __size_; value_type __lx; }; value_type __data_[__min_cap]; }; #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT union __ulx{__long __lx; __short __lxx;}; enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; struct __raw { size_type __words[__n_words]; }; struct __rep { union { __long __l; __short __s; __raw __r; }; }; __compressed_pair<__rep, allocator_type> __r_; public: _LIBCPP_TEMPLATE_DATA_VIS static const size_type npos = -1; _LIBCPP_INLINE_VISIBILITY basic_string() _NOEXCEPT_(is_nothrow_default_constructible::value); _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible::value); #else _NOEXCEPT; #endif basic_string(const basic_string& __str); basic_string(const basic_string& __str, const allocator_type& __a); #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible::value); #else _NOEXCEPT; #endif _LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str, const allocator_type& __a); #endif // _LIBCPP_CXX03_LANG template ::value, nullptr_t> > _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) { _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); __init(__s, traits_type::length(__s)); _VSTD::__debug_db_insert_c(this); } template ::value, nullptr_t> > _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s, const _Allocator& __a); #if _LIBCPP_STD_VER > 20 basic_string(nullptr_t) = delete; #endif _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s, size_type __n); _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s, size_type __n, const _Allocator& __a); _LIBCPP_INLINE_VISIBILITY basic_string(size_type __n, _CharT __c); template ::value, nullptr_t> > _LIBCPP_INLINE_VISIBILITY basic_string(size_type __n, _CharT __c, const _Allocator& __a); basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator()); _LIBCPP_INLINE_VISIBILITY basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator()); template::value && !__is_same_uncvref<_Tp, basic_string>::value> > _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type()); template::value && !__is_same_uncvref<_Tp, basic_string>::value> > _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit basic_string(const _Tp& __t); template::value && !__is_same_uncvref<_Tp, basic_string>::value> > _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit basic_string(const _Tp& __t, const allocator_type& __a); template::value> > _LIBCPP_INLINE_VISIBILITY basic_string(_InputIterator __first, _InputIterator __last); template::value> > _LIBCPP_INLINE_VISIBILITY basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string(initializer_list<_CharT> __il); _LIBCPP_INLINE_VISIBILITY basic_string(initializer_list<_CharT> __il, const _Allocator& __a); #endif // _LIBCPP_CXX03_LANG inline ~basic_string(); _LIBCPP_INLINE_VISIBILITY operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); } basic_string& operator=(const basic_string& __str); template ::value && !__is_same_uncvref<_Tp, basic_string>::value> > basic_string& operator=(const _Tp& __t) {__self_view __sv = __t; return assign(__sv);} #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& operator=(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); _LIBCPP_INLINE_VISIBILITY basic_string& operator=(initializer_list __il) {return assign(__il.begin(), __il.size());} #endif _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);} #if _LIBCPP_STD_VER > 20 basic_string& operator=(nullptr_t) = delete; #endif basic_string& operator=(value_type __c); #if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return iterator(this, __get_pointer());} _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return const_iterator(this, __get_pointer());} _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return iterator(this, __get_pointer() + size());} _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return const_iterator(this, __get_pointer() + size());} #else _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return iterator(__get_pointer());} _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return const_iterator(__get_pointer());} _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return iterator(__get_pointer() + size());} _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return const_iterator(__get_pointer() + size());} #endif // _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT {return begin();} _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT {return end();} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const _NOEXCEPT {return rend();} _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT {return __is_long() ? __get_long_size() : __get_short_size();} _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();} _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT {return (__is_long() ? __get_long_cap() : static_cast(__min_cap)) - 1;} void resize(size_type __n, value_type __c); _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} void reserve(size_type __requested_capacity); #if _LIBCPP_STD_VER > 20 template _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) { __resize_default_init(__n); __erase_to_end(_VSTD::move(__op)(data(), _LIBCPP_AUTO_CAST(__n))); } #endif _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n); _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY void reserve() _NOEXCEPT {shrink_to_fit();} _LIBCPP_INLINE_VISIBILITY void shrink_to_fit() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT; _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return size() == 0;} _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __pos) _NOEXCEPT; const_reference at(size_type __n) const; reference at(size_type __n); _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);} template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string >::value, basic_string& > operator+=(const _Tp& __t) {__self_view __sv = __t; return append(__sv);} _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);} _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;} #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list __il) {return append(__il);} #endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& append(const basic_string& __str); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, basic_string& > append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); } basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, basic_string& > append(const _Tp& __t, size_type __pos, size_type __n=npos); basic_string& append(const value_type* __s, size_type __n); basic_string& append(const value_type* __s); basic_string& append(size_type __n, value_type __c); _LIBCPP_INLINE_VISIBILITY void __append_default_init(size_type __n); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __is_exactly_cpp17_input_iterator<_InputIterator>::value, basic_string& > _LIBCPP_INLINE_VISIBILITY append(_InputIterator __first, _InputIterator __last) { const basic_string __temp(__first, __last, __alloc()); append(__temp.data(), __temp.size()); return *this; } template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __is_cpp17_forward_iterator<_ForwardIterator>::value, basic_string& > _LIBCPP_INLINE_VISIBILITY append(_ForwardIterator __first, _ForwardIterator __last); #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& append(initializer_list __il) {return append(__il.begin(), __il.size());} #endif // _LIBCPP_CXX03_LANG void push_back(value_type __c); _LIBCPP_INLINE_VISIBILITY void pop_back(); _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& > assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); } _LIBCPP_INLINE_VISIBILITY basic_string& assign(const basic_string& __str) { return *this = __str; } #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& assign(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) {*this = _VSTD::move(__str); return *this;} #endif basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, basic_string& > assign(const _Tp & __t, size_type __pos, size_type __n=npos); basic_string& assign(const value_type* __s, size_type __n); basic_string& assign(const value_type* __s); basic_string& assign(size_type __n, value_type __c); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __is_exactly_cpp17_input_iterator<_InputIterator>::value, basic_string& > assign(_InputIterator __first, _InputIterator __last); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __is_cpp17_forward_iterator<_ForwardIterator>::value, basic_string& > assign(_ForwardIterator __first, _ForwardIterator __last); #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& assign(initializer_list __il) {return assign(__il.begin(), __il.size());} #endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& insert(size_type __pos1, const basic_string& __str); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& > insert(size_type __pos1, const _Tp& __t) { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); } template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, basic_string& > insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos); basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); basic_string& insert(size_type __pos, const value_type* __s, size_type __n); basic_string& insert(size_type __pos, const value_type* __s); basic_string& insert(size_type __pos, size_type __n, value_type __c); iterator insert(const_iterator __pos, value_type __c); _LIBCPP_INLINE_VISIBILITY iterator insert(const_iterator __pos, size_type __n, value_type __c); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __is_exactly_cpp17_input_iterator<_InputIterator>::value, iterator > insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __is_cpp17_forward_iterator<_ForwardIterator>::value, iterator > insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY iterator insert(const_iterator __pos, initializer_list __il) {return insert(__pos, __il.begin(), __il.end());} #endif // _LIBCPP_CXX03_LANG basic_string& erase(size_type __pos = 0, size_type __n = npos); _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __pos); _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __first, const_iterator __last); _LIBCPP_INLINE_VISIBILITY basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& > replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); } basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, basic_string& > replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos); basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& > replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); } _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n); _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s); _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __is_cpp17_input_iterator<_InputIterator>::value, basic_string& > replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list __il) {return replace(__i1, __i2, __il.begin(), __il.end());} #endif // _LIBCPP_CXX03_LANG size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; _LIBCPP_INLINE_VISIBILITY basic_string substr(size_type __pos = 0, size_type __n = npos) const; _LIBCPP_INLINE_VISIBILITY void swap(basic_string& __str) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT; #else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value); #endif _LIBCPP_INLINE_VISIBILITY const value_type* c_str() const _NOEXCEPT {return data();} _LIBCPP_INLINE_VISIBILITY const value_type* data() const _NOEXCEPT {return _VSTD::__to_address(__get_pointer());} #if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_INLINE_VISIBILITY value_type* data() _NOEXCEPT {return _VSTD::__to_address(__get_pointer());} #endif _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT {return __alloc();} _LIBCPP_INLINE_VISIBILITY size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT; size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY int compare(const basic_string& __str) const _NOEXCEPT; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int > compare(const _Tp &__t) const _NOEXCEPT; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int > compare(size_type __pos1, size_type __n1, const _Tp& __t) const; _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const basic_string& __str) const; int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const; template inline _LIBCPP_INLINE_VISIBILITY __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, int > compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const; int compare(const value_type* __s) const _NOEXCEPT; int compare(size_type __pos1, size_type __n1, const value_type* __s) const; int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; #if _LIBCPP_STD_VER > 17 constexpr _LIBCPP_INLINE_VISIBILITY bool starts_with(__self_view __sv) const noexcept { return __self_view(data(), size()).starts_with(__sv); } constexpr _LIBCPP_INLINE_VISIBILITY bool starts_with(value_type __c) const noexcept { return !empty() && _Traits::eq(front(), __c); } constexpr _LIBCPP_INLINE_VISIBILITY bool starts_with(const value_type* __s) const noexcept { return starts_with(__self_view(__s)); } constexpr _LIBCPP_INLINE_VISIBILITY bool ends_with(__self_view __sv) const noexcept { return __self_view(data(), size()).ends_with( __sv); } constexpr _LIBCPP_INLINE_VISIBILITY bool ends_with(value_type __c) const noexcept { return !empty() && _Traits::eq(back(), __c); } constexpr _LIBCPP_INLINE_VISIBILITY bool ends_with(const value_type* __s) const noexcept { return ends_with(__self_view(__s)); } #endif #if _LIBCPP_STD_VER > 20 constexpr _LIBCPP_INLINE_VISIBILITY bool contains(__self_view __sv) const noexcept { return __self_view(data(), size()).contains(__sv); } constexpr _LIBCPP_INLINE_VISIBILITY bool contains(value_type __c) const noexcept { return __self_view(data(), size()).contains(__c); } constexpr _LIBCPP_INLINE_VISIBILITY bool contains(const value_type* __s) const { return __self_view(data(), size()).contains(__s); } #endif _LIBCPP_INLINE_VISIBILITY bool __invariants() const; _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY void __shrink_or_extend(size_type __target_capacity); _LIBCPP_INLINE_VISIBILITY bool __is_long() const _NOEXCEPT {return bool(__r_.first().__s.__size_ & __short_mask);} #if _LIBCPP_DEBUG_LEVEL == 2 bool __dereferenceable(const const_iterator* __i) const; bool __decrementable(const const_iterator* __i) const; bool __addable(const const_iterator* __i, ptrdiff_t __n) const; bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; #endif // _LIBCPP_DEBUG_LEVEL == 2 private: _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly return !__libcpp_is_constant_evaluated() && (__sz < __min_cap); } _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() _NOEXCEPT {return __r_.second();} _LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const _NOEXCEPT {return __r_.second();} #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_short_size(size_type __s) _NOEXCEPT # ifdef _LIBCPP_BIG_ENDIAN {__r_.first().__s.__size_ = (unsigned char)(__s << 1);} # else {__r_.first().__s.__size_ = (unsigned char)(__s);} # endif _LIBCPP_INLINE_VISIBILITY size_type __get_short_size() const _NOEXCEPT # ifdef _LIBCPP_BIG_ENDIAN {return __r_.first().__s.__size_ >> 1;} # else {return __r_.first().__s.__size_;} # endif #else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_short_size(size_type __s) _NOEXCEPT # ifdef _LIBCPP_BIG_ENDIAN {__r_.first().__s.__size_ = (unsigned char)(__s);} # else {__r_.first().__s.__size_ = (unsigned char)(__s << 1);} # endif _LIBCPP_INLINE_VISIBILITY size_type __get_short_size() const _NOEXCEPT # ifdef _LIBCPP_BIG_ENDIAN {return __r_.first().__s.__size_;} # else {return __r_.first().__s.__size_ >> 1;} # endif #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_long_size(size_type __s) _NOEXCEPT {__r_.first().__l.__size_ = __s;} _LIBCPP_INLINE_VISIBILITY size_type __get_long_size() const _NOEXCEPT {return __r_.first().__l.__size_;} _LIBCPP_INLINE_VISIBILITY void __set_size(size_type __s) _NOEXCEPT {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);} _LIBCPP_INLINE_VISIBILITY void __set_long_cap(size_type __s) _NOEXCEPT {__r_.first().__l.__cap_ = __long_mask | __s;} _LIBCPP_INLINE_VISIBILITY size_type __get_long_cap() const _NOEXCEPT {return __r_.first().__l.__cap_ & size_type(~__long_mask);} _LIBCPP_INLINE_VISIBILITY void __set_long_pointer(pointer __p) _NOEXCEPT {__r_.first().__l.__data_ = __p;} _LIBCPP_INLINE_VISIBILITY pointer __get_long_pointer() _NOEXCEPT {return __r_.first().__l.__data_;} _LIBCPP_INLINE_VISIBILITY const_pointer __get_long_pointer() const _NOEXCEPT {return __r_.first().__l.__data_;} _LIBCPP_INLINE_VISIBILITY pointer __get_short_pointer() _NOEXCEPT {return pointer_traits::pointer_to(__r_.first().__s.__data_[0]);} _LIBCPP_INLINE_VISIBILITY const_pointer __get_short_pointer() const _NOEXCEPT {return pointer_traits::pointer_to(__r_.first().__s.__data_[0]);} _LIBCPP_INLINE_VISIBILITY pointer __get_pointer() _NOEXCEPT {return __is_long() ? __get_long_pointer() : __get_short_pointer();} _LIBCPP_INLINE_VISIBILITY const_pointer __get_pointer() const _NOEXCEPT {return __is_long() ? __get_long_pointer() : __get_short_pointer();} _LIBCPP_INLINE_VISIBILITY void __zero() _NOEXCEPT { size_type (&__a)[__n_words] = __r_.first().__r.__words; for (unsigned __i = 0; __i < __n_words; ++__i) __a[__i] = 0; } template static _LIBCPP_INLINE_VISIBILITY size_type __align_it(size_type __s) _NOEXCEPT {return (__s + (__a-1)) & ~(__a-1);} enum {__alignment = 16}; static _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __s) _NOEXCEPT { if (__s < __min_cap) return static_cast(__min_cap) - 1; size_type __guess = __align_it (__s+1) - 1; if (__guess == __min_cap) ++__guess; return __guess; } inline void __init(const value_type* __s, size_type __sz, size_type __reserve); inline void __init(const value_type* __s, size_type __sz); inline void __init(size_type __n, value_type __c); // Slow path for the (inlined) copy constructor for 'long' strings. // Always externally instantiated and not inlined. // Requires that __s is zero terminated. // The main reason for this function to exist is because for unstable, we // want to allow inlining of the copy constructor. However, we don't want // to call the __init() functions as those are marked as inline which may // result in over-aggressive inlining by the compiler, where our aim is // to only inline the fast path code directly in the ctor. void __init_copy_ctor_external(const value_type* __s, size_type __sz); template inline __enable_if_t < __is_exactly_cpp17_input_iterator<_InputIterator>::value > __init(_InputIterator __first, _InputIterator __last); template inline __enable_if_t < __is_cpp17_forward_iterator<_ForwardIterator>::value > __init(_ForwardIterator __first, _ForwardIterator __last); void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, size_type __n_copy, size_type __n_del, size_type __n_add = 0); void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz, size_type __n_copy, size_type __n_del, size_type __n_add, const value_type* __p_new_stuff); // __assign_no_alias is invoked for assignment operations where we // have proof that the input does not alias the current instance. // For example, operator=(basic_string) performs a 'self' check. template basic_string& __assign_no_alias(const value_type* __s, size_type __n); _LIBCPP_INLINE_VISIBILITY void __erase_to_end(size_type __pos); // __erase_external_with_move is invoked for erase() invocations where // `n ~= npos`, likely requiring memory moves on the string data. void __erase_external_with_move(size_type __pos, size_type __n); _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const basic_string& __str) {__copy_assign_alloc(__str, integral_constant());} _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const basic_string& __str, true_type) { if (__alloc() == __str.__alloc()) __alloc() = __str.__alloc(); else { if (!__str.__is_long()) { __clear_and_shrink(); __alloc() = __str.__alloc(); } else { allocator_type __a = __str.__alloc(); pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap()); __clear_and_shrink(); __alloc() = _VSTD::move(__a); __set_long_pointer(__p); __set_long_cap(__str.__get_long_cap()); __set_long_size(__str.size()); } } } _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {} #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY void __move_assign(basic_string& __str, false_type) _NOEXCEPT_(__alloc_traits::is_always_equal::value); _LIBCPP_INLINE_VISIBILITY void __move_assign(basic_string& __str, true_type) #if _LIBCPP_STD_VER > 14 _NOEXCEPT; #else _NOEXCEPT_(is_nothrow_move_assignable::value); #endif #endif _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(basic_string& __str) _NOEXCEPT_( !__alloc_traits::propagate_on_container_move_assignment::value || is_nothrow_move_assignable::value) {__move_assign_alloc(__str, integral_constant());} _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(basic_string& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { __alloc() = _VSTD::move(__c.__alloc()); } _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(basic_string&, false_type) _NOEXCEPT {} basic_string& __assign_external(const value_type* __s); basic_string& __assign_external(const value_type* __s, size_type __n); // Assigns the value in __s, guaranteed to be __n < __min_cap in length. inline basic_string& __assign_short(const value_type* __s, size_type __n) { pointer __p = __is_long() ? (__set_long_size(__n), __get_long_pointer()) : (__set_short_size(__n), __get_short_pointer()); traits_type::move(_VSTD::__to_address(__p), __s, __n); traits_type::assign(__p[__n], value_type()); return *this; } _LIBCPP_HIDE_FROM_ABI basic_string& __null_terminate_at(value_type* __p, size_type __newsz) { __set_size(__newsz); __invalidate_iterators_past(__newsz); traits_type::assign(__p[__newsz], value_type()); return *this; } _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); template _LIBCPP_INLINE_VISIBILITY bool __addr_in_range(_Tp&& __t) const { const volatile void *__p = _VSTD::addressof(__t); return data() <= __p && __p <= data() + size(); } _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { _VSTD::__throw_length_error("basic_string"); } _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { _VSTD::__throw_out_of_range("basic_string"); } friend basic_string operator+<>(const basic_string&, const basic_string&); friend basic_string operator+<>(const value_type*, const basic_string&); friend basic_string operator+<>(value_type, const basic_string&); friend basic_string operator+<>(const basic_string&, const value_type*); friend basic_string operator+<>(const basic_string&, value_type); }; // These declarations must appear before any functions are implicitly used // so that they have the correct visibility specifier. #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) # endif #else _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) # endif #endif #if _LIBCPP_STD_VER >= 17 template, class _Allocator = allocator<_CharT>, class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Allocator>::value> > basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; template, class = enable_if_t<__is_allocator<_Allocator>::value> > explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>; template, class = enable_if_t<__is_allocator<_Allocator>::value>, class _Sz = typename allocator_traits<_Allocator>::size_type > basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>; #endif template inline void basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() { #if _LIBCPP_DEBUG_LEVEL == 2 if (!__libcpp_is_constant_evaluated()) __get_db()->__invalidate_all(this); #endif } template inline void basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos) { #if _LIBCPP_DEBUG_LEVEL == 2 if (!__libcpp_is_constant_evaluated()) { __c_node* __c = __get_db()->__find_c_and_lock(this); if (__c) { const_pointer __new_last = __get_pointer() + __pos; for (__i_node** __p = __c->end_; __p != __c->beg_; ) { --__p; const_iterator* __i = static_cast((*__p)->__i_); if (__i->base() > __new_last) { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); } } #else (void)__pos; #endif // _LIBCPP_DEBUG_LEVEL == 2 } template inline basic_string<_CharT, _Traits, _Allocator>::basic_string() _NOEXCEPT_(is_nothrow_default_constructible::value) : __r_(__default_init_tag(), __default_init_tag()) { _VSTD::__debug_db_insert_c(this); __zero(); } template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible::value) #else _NOEXCEPT #endif : __r_(__default_init_tag(), __a) { _VSTD::__debug_db_insert_c(this); __zero(); } template void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) { if (__reserve > max_size()) __throw_length_error(); pointer __p; if (__fits_in_sso(__reserve)) { __set_short_size(__sz); __p = __get_short_pointer(); } else { size_type __cap = __recommend(__reserve); __p = __alloc_traits::allocate(__alloc(), __cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); __set_long_size(__sz); } traits_type::copy(_VSTD::__to_address(__p), __s, __sz); traits_type::assign(__p[__sz], value_type()); } template void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) { if (__sz > max_size()) __throw_length_error(); pointer __p; if (__fits_in_sso(__sz)) { __set_short_size(__sz); __p = __get_short_pointer(); } else { size_type __cap = __recommend(__sz); __p = __alloc_traits::allocate(__alloc(), __cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); __set_long_size(__sz); } traits_type::copy(_VSTD::__to_address(__p), __s, __sz); traits_type::assign(__p[__sz], value_type()); } template template basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) : __r_(__default_init_tag(), __a) { _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); __init(__s, traits_type::length(__s)); _VSTD::__debug_db_insert_c(this); } template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n) : __r_(__default_init_tag(), __default_init_tag()) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); __init(__s, __n); _VSTD::__debug_db_insert_c(this); } template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) : __r_(__default_init_tag(), __a) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); __init(__s, __n); _VSTD::__debug_db_insert_c(this); } template basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) { if (!__str.__is_long()) __r_.first().__r = __str.__r_.first().__r; else __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); _VSTD::__debug_db_insert_c(this); } template basic_string<_CharT, _Traits, _Allocator>::basic_string( const basic_string& __str, const allocator_type& __a) : __r_(__default_init_tag(), __a) { if (!__str.__is_long()) __r_.first().__r = __str.__r_.first().__r; else __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); _VSTD::__debug_db_insert_c(this); } template void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external( const value_type* __s, size_type __sz) { pointer __p; if (__fits_in_sso(__sz)) { __p = __get_short_pointer(); __set_short_size(__sz); } else { if (__sz > max_size()) __throw_length_error(); size_t __cap = __recommend(__sz); __p = __alloc_traits::allocate(__alloc(), __cap + 1); __set_long_pointer(__p); __set_long_cap(__cap + 1); __set_long_size(__sz); } traits_type::copy(_VSTD::__to_address(__p), __s, __sz + 1); } #ifndef _LIBCPP_CXX03_LANG template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) #if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible::value) #else _NOEXCEPT #endif : __r_(_VSTD::move(__str.__r_)) { __str.__zero(); _VSTD::__debug_db_insert_c(this); #if _LIBCPP_DEBUG_LEVEL == 2 if (!__libcpp_is_constant_evaluated() && __is_long()) __get_db()->swap(this, &__str); #endif } template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) : __r_(__default_init_tag(), __a) { if (__str.__is_long() && __a != __str.__alloc()) // copy, not move __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); else { __r_.first().__r = __str.__r_.first().__r; __str.__zero(); } _VSTD::__debug_db_insert_c(this); #if _LIBCPP_DEBUG_LEVEL == 2 if (!__libcpp_is_constant_evaluated() && __is_long()) __get_db()->swap(this, &__str); #endif } #endif // _LIBCPP_CXX03_LANG template void basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) { if (__n > max_size()) __throw_length_error(); pointer __p; if (__fits_in_sso(__n)) { __set_short_size(__n); __p = __get_short_pointer(); } else { size_type __cap = __recommend(__n); __p = __alloc_traits::allocate(__alloc(), __cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); __set_long_size(__n); } traits_type::assign(_VSTD::__to_address(__p), __n, __c); traits_type::assign(__p[__n], value_type()); } template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c) : __r_(__default_init_tag(), __default_init_tag()) { __init(__n, __c); _VSTD::__debug_db_insert_c(this); } template template basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a) : __r_(__default_init_tag(), __a) { __init(__n, __c); _VSTD::__debug_db_insert_c(this); } template basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a) : __r_(__default_init_tag(), __a) { size_type __str_sz = __str.size(); if (__pos > __str_sz) __throw_out_of_range(); __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos)); _VSTD::__debug_db_insert_c(this); } template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a) : __r_(__default_init_tag(), __a) { size_type __str_sz = __str.size(); if (__pos > __str_sz) __throw_out_of_range(); __init(__str.data() + __pos, __str_sz - __pos); _VSTD::__debug_db_insert_c(this); } template template basic_string<_CharT, _Traits, _Allocator>::basic_string( const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a) : __r_(__default_init_tag(), __a) { __self_view __sv0 = __t; __self_view __sv = __sv0.substr(__pos, __n); __init(__sv.data(), __sv.size()); _VSTD::__debug_db_insert_c(this); } template template basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t) : __r_(__default_init_tag(), __default_init_tag()) { __self_view __sv = __t; __init(__sv.data(), __sv.size()); _VSTD::__debug_db_insert_c(this); } template template basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a) : __r_(__default_init_tag(), __a) { __self_view __sv = __t; __init(__sv.data(), __sv.size()); _VSTD::__debug_db_insert_c(this); } template template __enable_if_t < __is_exactly_cpp17_input_iterator<_InputIterator>::value > basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) { __zero(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __first != __last; ++__first) push_back(*__first); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { if (__is_long()) __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } template template __enable_if_t < __is_cpp17_forward_iterator<_ForwardIterator>::value > basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last) { size_type __sz = static_cast(_VSTD::distance(__first, __last)); if (__sz > max_size()) __throw_length_error(); pointer __p; if (__fits_in_sso(__sz)) { __set_short_size(__sz); __p = __get_short_pointer(); } else { size_type __cap = __recommend(__sz); __p = __alloc_traits::allocate(__alloc(), __cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); __set_long_size(__sz); } #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __first != __last; ++__first, (void) ++__p) traits_type::assign(*__p, *__first); traits_type::assign(*__p, value_type()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { if (__is_long()) __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } template template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last) : __r_(__default_init_tag(), __default_init_tag()) { __init(__first, __last); _VSTD::__debug_db_insert_c(this); } template template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a) : __r_(__default_init_tag(), __a) { __init(__first, __last); _VSTD::__debug_db_insert_c(this); } #ifndef _LIBCPP_CXX03_LANG template inline basic_string<_CharT, _Traits, _Allocator>::basic_string( initializer_list<_CharT> __il) : __r_(__default_init_tag(), __default_init_tag()) { __init(__il.begin(), __il.end()); _VSTD::__debug_db_insert_c(this); } template inline basic_string<_CharT, _Traits, _Allocator>::basic_string( initializer_list<_CharT> __il, const _Allocator& __a) : __r_(__default_init_tag(), __a) { __init(__il.begin(), __il.end()); _VSTD::__debug_db_insert_c(this); } #endif // _LIBCPP_CXX03_LANG template basic_string<_CharT, _Traits, _Allocator>::~basic_string() { #if _LIBCPP_DEBUG_LEVEL == 2 if (!__libcpp_is_constant_evaluated()) __get_db()->__erase_c(this); #endif if (__is_long()) __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); } template void basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace (size_type __old_cap, size_type __delta_cap, size_type __old_sz, size_type __n_copy, size_type __n_del, size_type __n_add, const value_type* __p_new_stuff) { size_type __ms = max_size(); if (__delta_cap > __ms - __old_cap - 1) __throw_length_error(); pointer __old_p = __get_pointer(); size_type __cap = __old_cap < __ms / 2 - __alignment ? __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1; pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); __invalidate_all_iterators(); if (__n_copy != 0) traits_type::copy(_VSTD::__to_address(__p), _VSTD::__to_address(__old_p), __n_copy); if (__n_add != 0) traits_type::copy(_VSTD::__to_address(__p) + __n_copy, __p_new_stuff, __n_add); size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; if (__sec_cp_sz != 0) traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add, _VSTD::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); if (__old_cap+1 != __min_cap) __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); __old_sz = __n_copy + __n_add + __sec_cp_sz; __set_long_size(__old_sz); traits_type::assign(__p[__old_sz], value_type()); } template void basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, size_type __n_copy, size_type __n_del, size_type __n_add) { size_type __ms = max_size(); if (__delta_cap > __ms - __old_cap) __throw_length_error(); pointer __old_p = __get_pointer(); size_type __cap = __old_cap < __ms / 2 - __alignment ? __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1; pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); __invalidate_all_iterators(); if (__n_copy != 0) traits_type::copy(_VSTD::__to_address(__p), _VSTD::__to_address(__old_p), __n_copy); size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; if (__sec_cp_sz != 0) traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add, _VSTD::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); if (__old_cap+1 != __min_cap) __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); } // assign template template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias( const value_type* __s, size_type __n) { size_type __cap = __is_short ? __min_cap : __get_long_cap(); if (__n < __cap) { pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer(); __is_short ? __set_short_size(__n) : __set_long_size(__n); traits_type::copy(_VSTD::__to_address(__p), __s, __n); traits_type::assign(__p[__n], value_type()); __invalidate_iterators_past(__n); } else { size_type __sz = __is_short ? __get_short_size() : __get_long_size(); __grow_by_and_replace(__cap - 1, __n - __cap + 1, __sz, 0, __sz, __n, __s); } return *this; } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::__assign_external( const value_type* __s, size_type __n) { size_type __cap = capacity(); if (__cap >= __n) { value_type* __p = _VSTD::__to_address(__get_pointer()); traits_type::move(__p, __s, __n); return __null_terminate_at(__p, __n); } else { size_type __sz = size(); __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s); return *this; } } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); return (__builtin_constant_p(__n) && __fits_in_sso(__n)) ? __assign_short(__s, __n) : __assign_external(__s, __n); } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) { size_type __cap = capacity(); if (__cap < __n) { size_type __sz = size(); __grow_by(__cap, __n - __cap, __sz, 0, __sz); } value_type* __p = _VSTD::__to_address(__get_pointer()); traits_type::assign(__p, __n, __c); return __null_terminate_at(__p, __n); } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) { pointer __p; if (__is_long()) { __p = __get_long_pointer(); __set_long_size(1); } else { __p = __get_short_pointer(); __set_short_size(1); } traits_type::assign(*__p, __c); traits_type::assign(*++__p, value_type()); __invalidate_iterators_past(1); return *this; } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) { if (this != &__str) { __copy_assign_alloc(__str); if (!__is_long()) { if (!__str.__is_long()) { __r_.first().__r = __str.__r_.first().__r; } else { return __assign_no_alias(__str.data(), __str.size()); } } else { return __assign_no_alias(__str.data(), __str.size()); } } return *this; } #ifndef _LIBCPP_CXX03_LANG template inline void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) _NOEXCEPT_(__alloc_traits::is_always_equal::value) { if (__alloc() != __str.__alloc()) assign(__str); else __move_assign(__str, true_type()); } template inline void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) #if _LIBCPP_STD_VER > 14 _NOEXCEPT #else _NOEXCEPT_(is_nothrow_move_assignable::value) #endif { if (__is_long()) { __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); #if _LIBCPP_STD_VER <= 14 if (!is_nothrow_move_assignable::value) { __set_short_size(0); traits_type::assign(__get_short_pointer()[0], value_type()); } #endif } __move_assign_alloc(__str); __r_.first() = __str.__r_.first(); __str.__set_short_size(0); traits_type::assign(__str.__get_short_pointer()[0], value_type()); } template inline basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { __move_assign(__str, integral_constant()); return *this; } #endif template template __enable_if_t < __is_exactly_cpp17_input_iterator<_InputIterator>::value, basic_string<_CharT, _Traits, _Allocator>& > basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { const basic_string __temp(__first, __last, __alloc()); assign(__temp.data(), __temp.size()); return *this; } template template __enable_if_t < __is_cpp17_forward_iterator<_ForwardIterator>::value, basic_string<_CharT, _Traits, _Allocator>& > basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) { size_type __cap = capacity(); size_type __n = __string_is_trivial_iterator<_ForwardIterator>::value ? static_cast(_VSTD::distance(__first, __last)) : 0; if (__string_is_trivial_iterator<_ForwardIterator>::value && (__cap >= __n || !__addr_in_range(*__first))) { if (__cap < __n) { size_type __sz = size(); __grow_by(__cap, __n - __cap, __sz, 0, __sz); } pointer __p = __get_pointer(); for (; __first != __last; ++__p, (void) ++__first) traits_type::assign(*__p, *__first); traits_type::assign(*__p, value_type()); __set_size(__n); __invalidate_iterators_past(__n); } else { const basic_string __temp(__first, __last, __alloc()); assign(__temp.data(), __temp.size()); } return *this; } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) { size_type __sz = __str.size(); if (__pos > __sz) __throw_out_of_range(); return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, basic_string<_CharT, _Traits, _Allocator>& > basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n) { __self_view __sv = __t; size_type __sz = __sv.size(); if (__pos > __sz) __throw_out_of_range(); return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos)); } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) { return __assign_external(__s, traits_type::length(__s)); } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) { _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); return __builtin_constant_p(*__s) ? (__fits_in_sso(traits_type::length(__s)) ? __assign_short(__s, traits_type::length(__s)) : __assign_external(__s, traits_type::length(__s))) : __assign_external(__s); } // append template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr"); size_type __cap = capacity(); size_type __sz = size(); if (__cap - __sz >= __n) { if (__n) { value_type* __p = _VSTD::__to_address(__get_pointer()); traits_type::copy(__p + __sz, __s, __n); __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); } } else __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s); return *this; } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) { if (__n) { size_type __cap = capacity(); size_type __sz = size(); if (__cap - __sz < __n) __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); pointer __p = __get_pointer(); traits_type::assign(_VSTD::__to_address(__p) + __sz, __n, __c); __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); } return *this; } template inline void basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n) { if (__n) { size_type __cap = capacity(); size_type __sz = size(); if (__cap - __sz < __n) __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); pointer __p = __get_pointer(); __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); } } template void basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) { bool __is_short = !__is_long(); size_type __cap; size_type __sz; if (__is_short) { __cap = __min_cap - 1; __sz = __get_short_size(); } else { __cap = __get_long_cap() - 1; __sz = __get_long_size(); } if (__sz == __cap) { __grow_by(__cap, 1, __sz, __sz, 0); __is_short = false; // the string is always long after __grow_by } pointer __p; if (__is_short) { __p = __get_short_pointer() + __sz; __set_short_size(__sz+1); } else { __p = __get_long_pointer() + __sz; __set_long_size(__sz+1); } traits_type::assign(*__p, __c); traits_type::assign(*++__p, value_type()); } template template __enable_if_t < __is_cpp17_forward_iterator<_ForwardIterator>::value, basic_string<_CharT, _Traits, _Allocator>& > basic_string<_CharT, _Traits, _Allocator>::append( _ForwardIterator __first, _ForwardIterator __last) { size_type __sz = size(); size_type __cap = capacity(); size_type __n = static_cast(_VSTD::distance(__first, __last)); if (__n) { if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) { if (__cap - __sz < __n) __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); pointer __p = __get_pointer() + __sz; for (; __first != __last; ++__p, (void) ++__first) traits_type::assign(*__p, *__first); traits_type::assign(*__p, value_type()); __set_size(__sz + __n); } else { const basic_string __temp(__first, __last, __alloc()); append(__temp.data(), __temp.size()); } } return *this; } template inline basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) { return append(__str.data(), __str.size()); } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) { size_type __sz = __str.size(); if (__pos > __sz) __throw_out_of_range(); return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, basic_string<_CharT, _Traits, _Allocator>& > basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __pos, size_type __n) { __self_view __sv = __t; size_type __sz = __sv.size(); if (__pos > __sz) __throw_out_of_range(); return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos)); } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) { _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr"); return append(__s, traits_type::length(__s)); } // insert template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr"); size_type __sz = size(); if (__pos > __sz) __throw_out_of_range(); size_type __cap = capacity(); if (__cap - __sz >= __n) { if (__n) { value_type* __p = _VSTD::__to_address(__get_pointer()); size_type __n_move = __sz - __pos; if (__n_move != 0) { if (__p + __pos <= __s && __s < __p + __sz) __s += __n; traits_type::move(__p + __pos + __n, __p + __pos, __n_move); } traits_type::move(__p + __pos, __s, __n); __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); } } else __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); return *this; } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) { size_type __sz = size(); if (__pos > __sz) __throw_out_of_range(); if (__n) { size_type __cap = capacity(); value_type* __p; if (__cap - __sz >= __n) { __p = _VSTD::__to_address(__get_pointer()); size_type __n_move = __sz - __pos; if (__n_move != 0) traits_type::move(__p + __pos + __n, __p + __pos, __n_move); } else { __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); __p = _VSTD::__to_address(__get_long_pointer()); } traits_type::assign(__p + __pos, __n, __c); __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); } return *this; } template template __enable_if_t < __is_exactly_cpp17_input_iterator<_InputIterator>::value, typename basic_string<_CharT, _Traits, _Allocator>::iterator > basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) { _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, "string::insert(iterator, range) called with an iterator not" " referring to this string"); const basic_string __temp(__first, __last, __alloc()); return insert(__pos, __temp.data(), __temp.data() + __temp.size()); } template template __enable_if_t < __is_cpp17_forward_iterator<_ForwardIterator>::value, typename basic_string<_CharT, _Traits, _Allocator>::iterator > basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) { _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, "string::insert(iterator, range) called with an iterator not" " referring to this string"); size_type __ip = static_cast(__pos - begin()); size_type __n = static_cast(_VSTD::distance(__first, __last)); if (__n) { if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) { size_type __sz = size(); size_type __cap = capacity(); value_type* __p; if (__cap - __sz >= __n) { __p = _VSTD::__to_address(__get_pointer()); size_type __n_move = __sz - __ip; if (__n_move != 0) traits_type::move(__p + __ip + __n, __p + __ip, __n_move); } else { __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n); __p = _VSTD::__to_address(__get_long_pointer()); } __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); for (__p += __ip; __first != __last; ++__p, (void) ++__first) traits_type::assign(*__p, *__first); } else { const basic_string __temp(__first, __last, __alloc()); return insert(__pos, __temp.data(), __temp.data() + __temp.size()); } } return begin() + __ip; } template inline basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str) { return insert(__pos1, __str.data(), __str.size()); } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n) { size_type __str_sz = __str.size(); if (__pos2 > __str_sz) __throw_out_of_range(); return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, basic_string<_CharT, _Traits, _Allocator>& > basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n) { __self_view __sv = __t; size_type __str_sz = __sv.size(); if (__pos2 > __str_sz) __throw_out_of_range(); return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) { _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr"); return insert(__pos, __s, traits_type::length(__s)); } template typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c) { size_type __ip = static_cast(__pos - begin()); size_type __sz = size(); size_type __cap = capacity(); value_type* __p; if (__cap == __sz) { __grow_by(__cap, 1, __sz, __ip, 0, 1); __p = _VSTD::__to_address(__get_long_pointer()); } else { __p = _VSTD::__to_address(__get_pointer()); size_type __n_move = __sz - __ip; if (__n_move != 0) traits_type::move(__p + __ip + 1, __p + __ip, __n_move); } traits_type::assign(__p[__ip], __c); traits_type::assign(__p[++__sz], value_type()); __set_size(__sz); return begin() + static_cast(__ip); } template inline typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) { _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, "string::insert(iterator, n, value) called with an iterator not" " referring to this string"); difference_type __p = __pos - begin(); insert(static_cast(__p), __n, __c); return begin() + __p; } // replace template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); size_type __sz = size(); if (__pos > __sz) __throw_out_of_range(); __n1 = _VSTD::min(__n1, __sz - __pos); size_type __cap = capacity(); if (__cap - __sz + __n1 >= __n2) { value_type* __p = _VSTD::__to_address(__get_pointer()); if (__n1 != __n2) { size_type __n_move = __sz - __pos - __n1; if (__n_move != 0) { if (__n1 > __n2) { traits_type::move(__p + __pos, __s, __n2); traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); return __null_terminate_at(__p, __sz + (__n2 - __n1)); } if (__p + __pos < __s && __s < __p + __sz) { if (__p + __pos + __n1 <= __s) __s += __n2 - __n1; else // __p + __pos < __s < __p + __pos + __n1 { traits_type::move(__p + __pos, __s, __n1); __pos += __n1; __s += __n2; __n2 -= __n1; __n1 = 0; } } traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); } } traits_type::move(__p + __pos, __s, __n2); return __null_terminate_at(__p, __sz + (__n2 - __n1)); } else __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s); return *this; } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) { size_type __sz = size(); if (__pos > __sz) __throw_out_of_range(); __n1 = _VSTD::min(__n1, __sz - __pos); size_type __cap = capacity(); value_type* __p; if (__cap - __sz + __n1 >= __n2) { __p = _VSTD::__to_address(__get_pointer()); if (__n1 != __n2) { size_type __n_move = __sz - __pos - __n1; if (__n_move != 0) traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); } } else { __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2); __p = _VSTD::__to_address(__get_long_pointer()); } traits_type::assign(__p + __pos, __n2, __c); return __null_terminate_at(__p, __sz - (__n1 - __n2)); } template template __enable_if_t < __is_cpp17_input_iterator<_InputIterator>::value, basic_string<_CharT, _Traits, _Allocator>& > basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) { const basic_string __temp(__j1, __j2, __alloc()); return replace(__i1, __i2, __temp); } template inline basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str) { return replace(__pos1, __n1, __str.data(), __str.size()); } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) { size_type __str_sz = __str.size(); if (__pos2 > __str_sz) __throw_out_of_range(); return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, basic_string<_CharT, _Traits, _Allocator>& > basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) { __self_view __sv = __t; size_type __str_sz = __sv.size(); if (__pos2 > __str_sz) __throw_out_of_range(); return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) { _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr"); return replace(__pos, __n1, __s, traits_type::length(__s)); } template inline basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) { return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __str.data(), __str.size()); } template inline basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) { return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __s, __n); } template inline basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) { return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __s); } template inline basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) { return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __n, __c); } // erase // 'externally instantiated' erase() implementation, called when __n != npos. // Does not check __pos against size() template void basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move( size_type __pos, size_type __n) { if (__n) { size_type __sz = size(); value_type* __p = _VSTD::__to_address(__get_pointer()); __n = _VSTD::min(__n, __sz - __pos); size_type __n_move = __sz - __pos - __n; if (__n_move != 0) traits_type::move(__p + __pos, __p + __pos + __n, __n_move); __null_terminate_at(__p, __sz - __n); } } template basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) { if (__pos > size()) __throw_out_of_range(); if (__n == npos) { __erase_to_end(__pos); } else { __erase_external_with_move(__pos, __n); } return *this; } template inline typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) { _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, "string::erase(iterator) called with an iterator not" " referring to this string"); _LIBCPP_ASSERT(__pos != end(), "string::erase(iterator) called with a non-dereferenceable iterator"); iterator __b = begin(); size_type __r = static_cast(__pos - __b); erase(__r, 1); return __b + static_cast(__r); } template inline typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) { _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, "string::erase(iterator, iterator) called with an iterator not" " referring to this string"); _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); iterator __b = begin(); size_type __r = static_cast(__first - __b); erase(__r, static_cast(__last - __first)); return __b + static_cast(__r); } template inline void basic_string<_CharT, _Traits, _Allocator>::pop_back() { _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); __erase_to_end(size() - 1); } template inline void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT { __invalidate_all_iterators(); if (__is_long()) { traits_type::assign(*__get_long_pointer(), value_type()); __set_long_size(0); } else { traits_type::assign(*__get_short_pointer(), value_type()); __set_short_size(0); } } template inline void basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) { __null_terminate_at(_VSTD::__to_address(__get_pointer()), __pos); } template void basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) { size_type __sz = size(); if (__n > __sz) append(__n - __sz, __c); else __erase_to_end(__n); } template inline void basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) { size_type __sz = size(); if (__n > __sz) { __append_default_init(__n - __sz); } else __erase_to_end(__n); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT { size_type __m = __alloc_traits::max_size(__alloc()); #ifdef _LIBCPP_BIG_ENDIAN return (__m <= ~__long_mask ? __m : __m/2) - __alignment; #else return __m - __alignment; #endif } template void basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) { if (__requested_capacity > max_size()) __throw_length_error(); // Make sure reserve(n) never shrinks. This is technically only required in C++20 // and later (since P0966R1), however we provide consistent behavior in all Standard // modes because this function is instantiated in the shared library. if (__requested_capacity <= capacity()) return; size_type __target_capacity = _VSTD::max(__requested_capacity, size()); __target_capacity = __recommend(__target_capacity); if (__target_capacity == capacity()) return; __shrink_or_extend(__target_capacity); } template inline void basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT { size_type __target_capacity = __recommend(size()); if (__target_capacity == capacity()) return; __shrink_or_extend(__target_capacity); } template inline void basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) { size_type __cap = capacity(); size_type __sz = size(); pointer __new_data, __p; bool __was_long, __now_long; if (__target_capacity == __min_cap - 1) { __was_long = true; __now_long = false; __new_data = __get_short_pointer(); __p = __get_long_pointer(); } else { if (__target_capacity > __cap) __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1); else { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { return; } #else // _LIBCPP_NO_EXCEPTIONS if (__new_data == nullptr) return; #endif // _LIBCPP_NO_EXCEPTIONS } __now_long = true; __was_long = __is_long(); __p = __get_pointer(); } traits_type::copy(_VSTD::__to_address(__new_data), _VSTD::__to_address(__p), size()+1); if (__was_long) __alloc_traits::deallocate(__alloc(), __p, __cap+1); if (__now_long) { __set_long_cap(__target_capacity+1); __set_long_size(__sz); __set_long_pointer(__new_data); } else __set_short_size(__sz); __invalidate_all_iterators(); } template inline typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); return *(data() + __pos); } template inline typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT { _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); return *(__get_pointer() + __pos); } template typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const { if (__n >= size()) __throw_out_of_range(); return (*this)[__n]; } template typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) { if (__n >= size()) __throw_out_of_range(); return (*this)[__n]; } template inline typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT { _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); return *__get_pointer(); } template inline typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT { _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); return *data(); } template inline typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT { _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); return *(__get_pointer() + size() - 1); } template inline typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT { _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); return *(data() + size() - 1); } template typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const { size_type __sz = size(); if (__pos > __sz) __throw_out_of_range(); size_type __rlen = _VSTD::min(__n, __sz - __pos); traits_type::copy(__s, data() + __pos, __rlen); return __rlen; } template inline basic_string<_CharT, _Traits, _Allocator> basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const { return basic_string(*this, __pos, __n, __alloc()); } template inline void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT #else _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value) #endif { #if _LIBCPP_DEBUG_LEVEL == 2 if (!__libcpp_is_constant_evaluated()) { if (!__is_long()) __get_db()->__invalidate_all(this); if (!__str.__is_long()) __get_db()->__invalidate_all(&__str); __get_db()->swap(this, &__str); } #endif _LIBCPP_ASSERT( __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value || __alloc() == __str.__alloc(), "swapping non-equal allocators"); _VSTD::swap(__r_.first(), __str.__r_.first()); _VSTD::__swap_allocator(__alloc(), __str.__alloc()); } // find template struct _LIBCPP_HIDDEN __traits_eq { typedef typename _Traits::char_type char_type; _LIBCPP_INLINE_VISIBILITY bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT {return _Traits::eq(__x, __y);} }; template 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 { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr"); return __str_find (data(), size(), __s, __pos, __n); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT { return __str_find (data(), size(), __str.data(), __pos, __str.size()); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, typename basic_string<_CharT, _Traits, _Allocator>::size_type > basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t, size_type __pos) const _NOEXCEPT { __self_view __sv = __t; return __str_find (data(), size(), __sv.data(), __pos, __sv.size()); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr"); return __str_find (data(), size(), __s, __pos, traits_type::length(__s)); } template typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, size_type __pos) const _NOEXCEPT { return __str_find (data(), size(), __c, __pos); } // rfind template typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); return __str_rfind (data(), size(), __s, __pos, __n); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT { return __str_rfind (data(), size(), __str.data(), __pos, __str.size()); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, typename basic_string<_CharT, _Traits, _Allocator>::size_type > basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, size_type __pos) const _NOEXCEPT { __self_view __sv = __t; return __str_rfind (data(), size(), __sv.data(), __pos, __sv.size()); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr"); return __str_rfind (data(), size(), __s, __pos, traits_type::length(__s)); } template typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, size_type __pos) const _NOEXCEPT { return __str_rfind (data(), size(), __c, __pos); } // find_first_of template typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); return __str_find_first_of (data(), size(), __s, __pos, __n); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { return __str_find_first_of (data(), size(), __str.data(), __pos, __str.size()); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, typename basic_string<_CharT, _Traits, _Allocator>::size_type > basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { __self_view __sv = __t; return __str_find_first_of (data(), size(), __sv.data(), __pos, __sv.size()); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr"); return __str_find_first_of (data(), size(), __s, __pos, traits_type::length(__s)); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, size_type __pos) const _NOEXCEPT { return find(__c, __pos); } // find_last_of template typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); return __str_find_last_of (data(), size(), __s, __pos, __n); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { return __str_find_last_of (data(), size(), __str.data(), __pos, __str.size()); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, typename basic_string<_CharT, _Traits, _Allocator>::size_type > basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { __self_view __sv = __t; return __str_find_last_of (data(), size(), __sv.data(), __pos, __sv.size()); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr"); return __str_find_last_of (data(), size(), __s, __pos, traits_type::length(__s)); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, size_type __pos) const _NOEXCEPT { return rfind(__c, __pos); } // find_first_not_of template typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); return __str_find_first_not_of (data(), size(), __s, __pos, __n); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { return __str_find_first_not_of (data(), size(), __str.data(), __pos, __str.size()); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, typename basic_string<_CharT, _Traits, _Allocator>::size_type > basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { __self_view __sv = __t; return __str_find_first_not_of (data(), size(), __sv.data(), __pos, __sv.size()); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr"); return __str_find_first_not_of (data(), size(), __s, __pos, traits_type::length(__s)); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT { return __str_find_first_not_of (data(), size(), __c, __pos); } // find_last_not_of template typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); return __str_find_last_not_of (data(), size(), __s, __pos, __n); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { return __str_find_last_not_of (data(), size(), __str.data(), __pos, __str.size()); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, typename basic_string<_CharT, _Traits, _Allocator>::size_type > basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { __self_view __sv = __t; return __str_find_last_not_of (data(), size(), __sv.data(), __pos, __sv.size()); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr"); return __str_find_last_not_of (data(), size(), __s, __pos, traits_type::length(__s)); } template inline typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT { return __str_find_last_not_of (data(), size(), __c, __pos); } // compare template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int > basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCEPT { __self_view __sv = __t; size_t __lhs_sz = size(); size_t __rhs_sz = __sv.size(); int __result = traits_type::compare(data(), __sv.data(), _VSTD::min(__lhs_sz, __rhs_sz)); if (__result != 0) return __result; if (__lhs_sz < __rhs_sz) return -1; if (__lhs_sz > __rhs_sz) return 1; return 0; } template inline int basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT { return compare(__self_view(__str)); } template int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const { _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); size_type __sz = size(); if (__pos1 > __sz || __n2 == npos) __throw_out_of_range(); size_type __rlen = _VSTD::min(__n1, __sz - __pos1); int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2)); if (__r == 0) { if (__rlen < __n2) __r = -1; else if (__rlen > __n2) __r = 1; } return __r; } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int > basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const _Tp& __t) const { __self_view __sv = __t; return compare(__pos1, __n1, __sv.data(), __sv.size()); } template inline int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const basic_string& __str) const { return compare(__pos1, __n1, __str.data(), __str.size()); } template template __enable_if_t < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, int > basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) const { __self_view __sv = __t; return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); } template int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const { return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); } template int basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); return compare(0, npos, __s, traits_type::length(__s)); } template int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const { _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); return compare(__pos1, __n1, __s, traits_type::length(__s)); } // __invariants template inline bool basic_string<_CharT, _Traits, _Allocator>::__invariants() const { if (size() > capacity()) return false; if (capacity() < __min_cap - 1) return false; if (data() == nullptr) return false; if (data()[size()] != value_type()) return false; return true; } // __clear_and_shrink template inline void basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT { clear(); if(__is_long()) { __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1); __set_long_cap(0); __set_short_size(0); traits_type::assign(*__get_short_pointer(), value_type()); } } // operator== template inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { size_t __lhs_sz = __lhs.size(); return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), __rhs.data(), __lhs_sz) == 0; } template inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string, _Allocator>& __lhs, const basic_string, _Allocator>& __rhs) _NOEXCEPT { size_t __lhs_sz = __lhs.size(); if (__lhs_sz != __rhs.size()) return false; const char* __lp = __lhs.data(); const char* __rp = __rhs.data(); if (__lhs.__is_long()) return char_traits::compare(__lp, __rp, __lhs_sz) == 0; for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp) if (*__lp != *__rp) return false; return true; } template inline _LIBCPP_INLINE_VISIBILITY bool operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { typedef basic_string<_CharT, _Traits, _Allocator> _String; _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr"); size_t __lhs_len = _Traits::length(__lhs); if (__lhs_len != __rhs.size()) return false; return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0; } template inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { typedef basic_string<_CharT, _Traits, _Allocator> _String; _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); size_t __rhs_len = _Traits::length(__rhs); if (__rhs_len != __lhs.size()) return false; return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; } template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return !(__lhs == __rhs); } template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return !(__lhs == __rhs); } template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { return !(__lhs == __rhs); } // operator< template inline _LIBCPP_INLINE_VISIBILITY bool operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return __lhs.compare(__rhs) < 0; } template inline _LIBCPP_INLINE_VISIBILITY bool operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { return __lhs.compare(__rhs) < 0; } template inline _LIBCPP_INLINE_VISIBILITY bool operator< (const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return __rhs.compare(__lhs) > 0; } // operator> template inline _LIBCPP_INLINE_VISIBILITY bool operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return __rhs < __lhs; } template inline _LIBCPP_INLINE_VISIBILITY bool operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { return __rhs < __lhs; } template inline _LIBCPP_INLINE_VISIBILITY bool operator> (const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return __rhs < __lhs; } // operator<= template inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return !(__rhs < __lhs); } template inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { return !(__rhs < __lhs); } template inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return !(__rhs < __lhs); } // operator>= template inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return !(__lhs < __rhs); } template inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { return !(__lhs < __rhs); } template inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { return !(__lhs < __rhs); } // operator + template basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); __r.append(__rhs.data(), __rhs_sz); return __r; } template basic_string<_CharT, _Traits, _Allocator> operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) { basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs); typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz); __r.append(__rhs.data(), __rhs_sz); return __r; } template basic_string<_CharT, _Traits, _Allocator> operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs) { basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); __r.__init(&__lhs, 1, 1 + __rhs_sz); __r.append(__rhs.data(), __rhs_sz); return __r; } template inline basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) { basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs); __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); __r.append(__rhs, __rhs_sz); return __r; } template basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) { basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1); __r.push_back(__rhs); return __r; } #ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { return _VSTD::move(__lhs.append(__rhs)); } template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { return _VSTD::move(__rhs.insert(0, __lhs)); } template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { return _VSTD::move(__lhs.append(__rhs)); } template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) { return _VSTD::move(__rhs.insert(0, __lhs)); } template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) { __rhs.insert(__rhs.begin(), __lhs); return _VSTD::move(__rhs); } template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) { return _VSTD::move(__lhs.append(__rhs)); } template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { __lhs.push_back(__rhs); return _VSTD::move(__lhs); } #endif // _LIBCPP_CXX03_LANG // swap template inline _LIBCPP_INLINE_VISIBILITY void swap(basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } _LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS string to_string(int __val); _LIBCPP_FUNC_VIS string to_string(unsigned __val); _LIBCPP_FUNC_VIS string to_string(long __val); _LIBCPP_FUNC_VIS string to_string(unsigned long __val); _LIBCPP_FUNC_VIS string to_string(long long __val); _LIBCPP_FUNC_VIS string to_string(unsigned long long __val); _LIBCPP_FUNC_VIS string to_string(float __val); _LIBCPP_FUNC_VIS string to_string(double __val); _LIBCPP_FUNC_VIS string to_string(long double __val); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS wstring to_wstring(int __val); _LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val); _LIBCPP_FUNC_VIS wstring to_wstring(long __val); _LIBCPP_FUNC_VIS wstring to_wstring(unsigned long __val); _LIBCPP_FUNC_VIS wstring to_wstring(long long __val); _LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val); _LIBCPP_FUNC_VIS wstring to_wstring(float __val); _LIBCPP_FUNC_VIS wstring to_wstring(double __val); _LIBCPP_FUNC_VIS wstring to_wstring(long double __val); #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS template _LIBCPP_TEMPLATE_DATA_VIS const typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::npos; template struct _LIBCPP_TEMPLATE_VIS hash, _Allocator> > : public unary_function< basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t> { size_t operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT { return __do_string_hash(__val.data(), __val.data() + __val.size()); } }; template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Allocator>& __str); template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str); template basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str); template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str); #if _LIBCPP_STD_VER > 17 template inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { auto __old_size = __str.size(); __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end()); return __old_size - __str.size(); } template inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) { auto __old_size = __str.size(); __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred), __str.end()); return __old_size - __str.size(); } #endif #if _LIBCPP_DEBUG_LEVEL == 2 template bool basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const { return data() <= _VSTD::__to_address(__i->base()) && _VSTD::__to_address(__i->base()) < data() + size(); } template bool basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const { return data() < _VSTD::__to_address(__i->base()) && _VSTD::__to_address(__i->base()) <= data() + size(); } template bool basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const { const value_type* __p = _VSTD::__to_address(__i->base()) + __n; return data() <= __p && __p <= data() + size(); } template bool basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const { const value_type* __p = _VSTD::__to_address(__i->base()) + __n; return data() <= __p && __p < data() + size(); } #endif // _LIBCPP_DEBUG_LEVEL == 2 #if _LIBCPP_STD_VER > 11 // Literal suffixes for basic_string [basic.string.literals] inline namespace literals { inline namespace string_literals { inline _LIBCPP_INLINE_VISIBILITY basic_string operator "" s( const char *__str, size_t __len ) { return basic_string (__str, __len); } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS inline _LIBCPP_INLINE_VISIBILITY basic_string operator "" s( const wchar_t *__str, size_t __len ) { return basic_string (__str, __len); } #endif #ifndef _LIBCPP_HAS_NO_CHAR8_T inline _LIBCPP_INLINE_VISIBILITY basic_string operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT { return basic_string (__str, __len); } #endif inline _LIBCPP_INLINE_VISIBILITY basic_string operator "" s( const char16_t *__str, size_t __len ) { return basic_string (__str, __len); } inline _LIBCPP_INLINE_VISIBILITY basic_string operator "" s( const char32_t *__str, size_t __len ) { return basic_string (__str, __len); } } // namespace string_literals } // namespace literals #endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #endif // _LIBCPP_STRING diff --git a/libcxx/include/string_view b/libcxx/include/string_view index 992e88ea3c00..5d0a790dd13d 100644 --- a/libcxx/include/string_view +++ b/libcxx/include/string_view @@ -1,957 +1,957 @@ // -*- 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_STRING_VIEW #define _LIBCPP_STRING_VIEW /* string_view synopsis namespace std { // 7.2, Class template basic_string_view template> class basic_string_view; template inline constexpr bool ranges::enable_view> = true; template inline constexpr bool ranges::enable_borrowed_range> = true; // C++20 // 7.9, basic_string_view non-member comparison functions template constexpr bool operator==(basic_string_view x, basic_string_view y) noexcept; template constexpr bool operator!=(basic_string_view x, basic_string_view y) noexcept; template constexpr bool operator< (basic_string_view x, basic_string_view y) noexcept; template constexpr bool operator> (basic_string_view x, basic_string_view y) noexcept; template constexpr bool operator<=(basic_string_view x, basic_string_view y) noexcept; template constexpr bool operator>=(basic_string_view x, basic_string_view y) noexcept; // see below, sufficient additional overloads of comparison functions // 7.10, Inserters and extractors template basic_ostream& operator<<(basic_ostream& os, basic_string_view str); // basic_string_view typedef names typedef basic_string_view string_view; typedef basic_string_view u8string_view; // C++20 typedef basic_string_view u16string_view; typedef basic_string_view u32string_view; typedef basic_string_view wstring_view; template> class basic_string_view { public: // types typedef traits traits_type; typedef charT value_type; typedef charT* pointer; typedef const charT* const_pointer; typedef charT& reference; typedef const charT& const_reference; typedef implementation-defined const_iterator; typedef const_iterator iterator; typedef reverse_iterator const_reverse_iterator; typedef const_reverse_iterator reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; static constexpr size_type npos = size_type(-1); // 7.3, basic_string_view constructors and assignment operators constexpr basic_string_view() noexcept; constexpr basic_string_view(const basic_string_view&) noexcept = default; basic_string_view& operator=(const basic_string_view&) noexcept = default; template constexpr basic_string_view(const charT* str); basic_string_view(nullptr_t) = delete; // C++2b constexpr basic_string_view(const charT* str, size_type len); template constexpr basic_string_view(It begin, End end); // C++20 template constexpr basic_string_view(Range&& r); // C++23 // 7.4, basic_string_view iterator support constexpr const_iterator begin() const noexcept; constexpr const_iterator end() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; const_reverse_iterator rbegin() const noexcept; const_reverse_iterator rend() const noexcept; const_reverse_iterator crbegin() const noexcept; const_reverse_iterator crend() const noexcept; // 7.5, basic_string_view capacity constexpr size_type size() const noexcept; constexpr size_type length() const noexcept; constexpr size_type max_size() const noexcept; constexpr bool empty() const noexcept; // 7.6, basic_string_view element access constexpr const_reference operator[](size_type pos) const; constexpr const_reference at(size_type pos) const; constexpr const_reference front() const; constexpr const_reference back() const; constexpr const_pointer data() const noexcept; // 7.7, basic_string_view modifiers constexpr void remove_prefix(size_type n); constexpr void remove_suffix(size_type n); constexpr void swap(basic_string_view& s) noexcept; size_type copy(charT* s, size_type n, size_type pos = 0) const; // constexpr in C++20 constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const; constexpr int compare(basic_string_view s) const noexcept; constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const; constexpr int compare(size_type pos1, size_type n1, basic_string_view s, size_type pos2, size_type n2) const; constexpr int compare(const charT* s) const; constexpr int compare(size_type pos1, size_type n1, const charT* s) const; constexpr int compare(size_type pos1, size_type n1, const charT* s, size_type n2) const; constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept; constexpr size_type find(charT c, size_type pos = 0) const noexcept; constexpr size_type find(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension constexpr size_type find(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept; constexpr size_type rfind(charT c, size_type pos = npos) const noexcept; constexpr size_type rfind(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension constexpr size_type rfind(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept; constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept; constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension constexpr size_type find_first_of(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept; constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept; constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension constexpr size_type find_last_of(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept; constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept; constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept; constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept; constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension constexpr bool starts_with(basic_string_view s) const noexcept; // C++20 constexpr bool starts_with(charT c) const noexcept; // C++20 constexpr bool starts_with(const charT* s) const; // C++20 constexpr bool ends_with(basic_string_view s) const noexcept; // C++20 constexpr bool ends_with(charT c) const noexcept; // C++20 constexpr bool ends_with(const charT* s) const; // C++20 constexpr bool contains(basic_string_view s) const noexcept; // C++2b constexpr bool contains(charT c) const noexcept; // C++2b constexpr bool contains(const charT* s) const; // C++2b private: const_pointer data_; // exposition only size_type size_; // exposition only }; // basic_string_view deduction guides template basic_string_view(It, End) -> basic_string_view>; // C++20 template basic_string_view(Range&&) -> basic_string_view>; // C++23 // 7.11, Hash support template struct hash; template <> struct hash; template <> struct hash; // C++20 template <> struct hash; template <> struct hash; template <> struct hash; constexpr basic_string_view operator "" sv( const char *str, size_t len ) noexcept; constexpr basic_string_view operator "" sv( const wchar_t *str, size_t len ) noexcept; constexpr basic_string_view operator "" sv( const char8_t *str, size_t len ) noexcept; // C++20 constexpr basic_string_view operator "" sv( const char16_t *str, size_t len ) noexcept; constexpr basic_string_view operator "" sv( const char32_t *str, size_t len ) noexcept; } // namespace std */ #include <__config> #include <__debug> #include <__ranges/concepts.h> #include <__ranges/data.h> #include <__ranges/enable_borrowed_range.h> #include <__ranges/enable_view.h> #include <__ranges/size.h> #include <__string> #include #include #include #include #include #include #include #include #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 _LIBCPP_TEMPLATE_VIS basic_string_view; typedef basic_string_view string_view; #ifndef _LIBCPP_HAS_NO_CHAR8_T typedef basic_string_view u8string_view; #endif typedef basic_string_view u16string_view; typedef basic_string_view u32string_view; #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS typedef basic_string_view wstring_view; #endif template class _LIBCPP_PREFERRED_NAME(string_view) #ifndef _LIBCPP_HAS_NO_CHAR8_T _LIBCPP_PREFERRED_NAME(u8string_view) #endif _LIBCPP_PREFERRED_NAME(u16string_view) _LIBCPP_PREFERRED_NAME(u32string_view) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring_view)) basic_string_view { public: // types typedef _Traits traits_type; typedef _CharT value_type; typedef _CharT* pointer; typedef const _CharT* const_pointer; typedef _CharT& reference; typedef const _CharT& const_reference; typedef const_pointer const_iterator; // See [string.view.iterators] typedef const_iterator iterator; typedef _VSTD::reverse_iterator const_reverse_iterator; typedef const_reverse_iterator reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1); static_assert((!is_array::value), "Character type of basic_string_view must not be an array"); static_assert(( is_standard_layout::value), "Character type of basic_string_view must be standard-layout"); static_assert(( is_trivial::value), "Character type of basic_string_view must be trivial"); static_assert((is_same<_CharT, typename traits_type::char_type>::value), "traits_type::char_type must be the same type as CharT"); // [string.view.cons], construct/copy _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {} _LIBCPP_INLINE_VISIBILITY basic_string_view(const basic_string_view&) _NOEXCEPT = default; _LIBCPP_INLINE_VISIBILITY basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default; _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT : __data(__s), __size(__len) { #if _LIBCPP_STD_VER > 11 _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr"); #endif } -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template _End> requires (is_same_v, _CharT> && !is_convertible_v<_End, size_type>) constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end) : __data(_VSTD::to_address(__begin)), __size(__end - __begin) { _LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range"); } #endif #if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) template requires ( !is_same_v, basic_string_view> && ranges::contiguous_range<_Range> && ranges::sized_range<_Range> && is_same_v, _CharT> && !is_convertible_v<_Range, const _CharT*> && (!requires(remove_cvref_t<_Range>& d) { d.operator _VSTD::basic_string_view<_CharT, _Traits>(); }) && (!requires { typename remove_reference_t<_Range>::traits_type; } || is_same_v::traits_type, _Traits>) ) constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_Range&& __r) : __data(ranges::data(__r)), __size(ranges::size(__r)) {} #endif _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const _CharT* __s) : __data(__s), __size(_VSTD::__char_traits_length_checked<_Traits>(__s)) {} #if _LIBCPP_STD_VER > 20 basic_string_view(nullptr_t) = delete; #endif // [string.view.iterators], iterators _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT { return cbegin(); } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT { return cend(); } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT { return __data; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT { return __data + __size; } _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } // [string.view.capacity], capacity _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT { return __size; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT { return __size; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT { return numeric_limits::max() / sizeof(value_type); } _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size == 0; } // [string.view.access], element access _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT { return _LIBCPP_ASSERT(__pos < size(), "string_view[] index out of bounds"), __data[__pos]; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __pos) const { return __pos >= size() ? (__throw_out_of_range("string_view::at"), __data[0]) : __data[__pos]; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT { return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0]; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT { return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1]; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_pointer data() const _NOEXCEPT { return __data; } // [string.view.modifiers], modifiers: _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_prefix(size_type __n) _NOEXCEPT { _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()"); __data += __n; __size -= __n; } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_suffix(size_type __n) _NOEXCEPT { _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()"); __size -= __n; } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void swap(basic_string_view& __other) _NOEXCEPT { const value_type *__p = __data; __data = __other.__data; __other.__data = __p; size_type __sz = __size; __size = __other.__size; __other.__size = __sz; } _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const { if (__pos > size()) __throw_out_of_range("string_view::copy"); size_type __rlen = _VSTD::min(__n, size() - __pos); _Traits::copy(__s, data() + __pos, __rlen); return __rlen; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view substr(size_type __pos = 0, size_type __n = npos) const { return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view()) : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos)); } _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT { size_type __rlen = _VSTD::min( size(), __sv.size()); int __retval = _Traits::compare(data(), __sv.data(), __rlen); if ( __retval == 0 ) // first __rlen chars matched __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 ); return __retval; } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const { return substr(__pos1, __n1).compare(__sv); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare( size_type __pos1, size_type __n1, basic_string_view __sv, size_type __pos2, size_type __n2) const { return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(const _CharT* __s) const _NOEXCEPT { return compare(basic_string_view(__s)); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const _CharT* __s) const { return substr(__pos1, __n1).compare(basic_string_view(__s)); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const { return substr(__pos1, __n1).compare(basic_string_view(__s, __n2)); } // find _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); return __str_find (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT { return __str_find (data(), size(), __c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr"); return __str_find (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr"); return __str_find (data(), size(), __s, __pos, traits_type::length(__s)); } // rfind _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); return __str_rfind (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT { return __str_rfind (data(), size(), __c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr"); return __str_rfind (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr"); return __str_rfind (data(), size(), __s, __pos, traits_type::length(__s)); } // find_first_of _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr"); return __str_find_first_of (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT { return find(__c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr"); return __str_find_first_of (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr"); return __str_find_first_of (data(), size(), __s, __pos, traits_type::length(__s)); } // find_last_of _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr"); return __str_find_last_of (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT { return rfind(__c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr"); return __str_find_last_of (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr"); return __str_find_last_of (data(), size(), __s, __pos, traits_type::length(__s)); } // find_first_not_of _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr"); return __str_find_first_not_of (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT { return __str_find_first_not_of (data(), size(), __c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr"); return __str_find_first_not_of (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr"); return __str_find_first_not_of (data(), size(), __s, __pos, traits_type::length(__s)); } // find_last_not_of _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr"); return __str_find_last_not_of (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT { return __str_find_last_not_of (data(), size(), __c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr"); return __str_find_last_not_of (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr"); return __str_find_last_not_of (data(), size(), __s, __pos, traits_type::length(__s)); } #if _LIBCPP_STD_VER > 17 constexpr _LIBCPP_INLINE_VISIBILITY bool starts_with(basic_string_view __s) const noexcept { return size() >= __s.size() && compare(0, __s.size(), __s) == 0; } constexpr _LIBCPP_INLINE_VISIBILITY bool starts_with(value_type __c) const noexcept { return !empty() && _Traits::eq(front(), __c); } constexpr _LIBCPP_INLINE_VISIBILITY bool starts_with(const value_type* __s) const noexcept { return starts_with(basic_string_view(__s)); } constexpr _LIBCPP_INLINE_VISIBILITY bool ends_with(basic_string_view __s) const noexcept { return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; } constexpr _LIBCPP_INLINE_VISIBILITY bool ends_with(value_type __c) const noexcept { return !empty() && _Traits::eq(back(), __c); } constexpr _LIBCPP_INLINE_VISIBILITY bool ends_with(const value_type* __s) const noexcept { return ends_with(basic_string_view(__s)); } #endif #if _LIBCPP_STD_VER > 20 constexpr _LIBCPP_INLINE_VISIBILITY bool contains(basic_string_view __sv) const noexcept { return find(__sv) != npos; } constexpr _LIBCPP_INLINE_VISIBILITY bool contains(value_type __c) const noexcept { return find(__c) != npos; } constexpr _LIBCPP_INLINE_VISIBILITY bool contains(const value_type* __s) const { return find(__s) != npos; } #endif private: const value_type* __data; size_type __size; }; -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template inline constexpr bool ranges::enable_view> = true; template inline constexpr bool ranges::enable_borrowed_range > = true; -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) // [string.view.deduct] -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) template _End> basic_string_view(_It, _End) -> basic_string_view>; #endif #if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) template basic_string_view(_Range) -> basic_string_view>; #endif // [string.view.comparison] // operator == template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator==(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return false; return __lhs.compare(__rhs) == 0; } // The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details. // This applies to the other sufficient overloads below for the other comparison operators. template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator==(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return false; return __lhs.compare(__rhs) == 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator==(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return false; return __lhs.compare(__rhs) == 0; } // operator != template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return true; return __lhs.compare(__rhs) != 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator!=(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return true; return __lhs.compare(__rhs) != 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator!=(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return true; return __lhs.compare(__rhs) != 0; } // operator < template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) < 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { return __lhs.compare(__rhs) < 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) < 0; } // operator > template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) > 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { return __lhs.compare(__rhs) > 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) > 0; } // operator <= template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) <= 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<=(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { return __lhs.compare(__rhs) <= 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<=(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) <= 0; } // operator >= template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) >= 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>=(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { return __lhs.compare(__rhs) >= 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>=(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) >= 0; } template basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __str); // [string.view.hash] template struct _LIBCPP_TEMPLATE_VIS hash > > : public unary_function >, size_t> { _LIBCPP_INLINE_VISIBILITY size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT { return __do_string_hash(__val.data(), __val.data() + __val.size()); } }; #if _LIBCPP_STD_VER > 11 inline namespace literals { inline namespace string_view_literals { inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR basic_string_view operator "" sv(const char *__str, size_t __len) _NOEXCEPT { return basic_string_view (__str, __len); } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR basic_string_view operator "" sv(const wchar_t *__str, size_t __len) _NOEXCEPT { return basic_string_view (__str, __len); } #endif #ifndef _LIBCPP_HAS_NO_CHAR8_T inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR basic_string_view operator "" sv(const char8_t *__str, size_t __len) _NOEXCEPT { return basic_string_view (__str, __len); } #endif inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR basic_string_view operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT { return basic_string_view (__str, __len); } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR basic_string_view operator "" sv(const char32_t *__str, size_t __len) _NOEXCEPT { return basic_string_view (__str, __len); } } // namespace string_view_literals } // namespace literals #endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #endif // _LIBCPP_STRING_VIEW diff --git a/libcxx/include/tuple b/libcxx/include/tuple index 5cf120fec359..6f3368ca301f 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -1,1633 +1,1633 @@ // -*- 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_TUPLE #define _LIBCPP_TUPLE /* tuple synopsis namespace std { template class tuple { public: explicit(see-below) constexpr tuple(); explicit(see-below) tuple(const T&...); // constexpr in C++14 template explicit(see-below) tuple(U&&...); // constexpr in C++14 tuple(const tuple&) = default; tuple(tuple&&) = default; template explicit(see-below) tuple(const tuple&); // constexpr in C++14 template explicit(see-below) tuple(tuple&&); // constexpr in C++14 template explicit(see-below) tuple(const pair&); // iff sizeof...(T) == 2 // constexpr in C++14 template explicit(see-below) tuple(pair&&); // iff sizeof...(T) == 2 // constexpr in C++14 // allocator-extended constructors template tuple(allocator_arg_t, const Alloc& a); template explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const T&...); // constexpr in C++20 template explicit(see-below) tuple(allocator_arg_t, const Alloc& a, U&&...); // constexpr in C++20 template tuple(allocator_arg_t, const Alloc& a, const tuple&); // constexpr in C++20 template tuple(allocator_arg_t, const Alloc& a, tuple&&); // constexpr in C++20 template explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple&); // constexpr in C++20 template explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple&&); // constexpr in C++20 template explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair&); // constexpr in C++20 template explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair&&); // constexpr in C++20 tuple& operator=(const tuple&); // constexpr in C++20 tuple& operator=(tuple&&) noexcept(is_nothrow_move_assignable_v && ...); // constexpr in C++20 template tuple& operator=(const tuple&); // constexpr in C++20 template tuple& operator=(tuple&&); // constexpr in C++20 template tuple& operator=(const pair&); // iff sizeof...(T) == 2 // constexpr in C++20 template tuple& operator=(pair&&); // iff sizeof...(T) == 2 // constexpr in C++20 template tuple& operator=(array const&) // iff sizeof...(T) == N, EXTENSION template tuple& operator=(array&&) // iff sizeof...(T) == N, EXTENSION void swap(tuple&) noexcept(AND(swap(declval(), declval())...)); // constexpr in C++20 }; template class TQual, template class UQual> // since C++23 requires requires { typename tuple, UQual>...>; } struct basic_common_reference, tuple, TQual, UQual> { using type = tuple, UQual>...>; }; template // since C++23 requires requires { typename tuple...>; } struct common_type, tuple> { using type = tuple...>; }; template tuple(T...) -> tuple; // since C++17 template tuple(pair) -> tuple; // since C++17 template tuple(allocator_arg_t, Alloc, T...) -> tuple; // since C++17 template tuple(allocator_arg_t, Alloc, pair) -> tuple; // since C++17 template tuple(allocator_arg_t, Alloc, tuple) -> tuple; // since C++17 inline constexpr unspecified ignore; template tuple make_tuple(T&&...); // constexpr in C++14 template tuple forward_as_tuple(T&&...) noexcept; // constexpr in C++14 template tuple tie(T&...) noexcept; // constexpr in C++14 template tuple tuple_cat(Tuples&&... tpls); // constexpr in C++14 // [tuple.apply], calling a function with a tuple of arguments: template constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17 template constexpr T make_from_tuple(Tuple&& t); // C++17 // 20.4.1.4, tuple helper classes: template struct tuple_size; // undefined template struct tuple_size>; template inline constexpr size_t tuple_size_v = tuple_size::value; // C++17 template struct tuple_element; // undefined template struct tuple_element>; template using tuple_element_t = typename tuple_element ::type; // C++14 // 20.4.1.5, element access: template typename tuple_element>::type& get(tuple&) noexcept; // constexpr in C++14 template const typename tuple_element>::type& get(const tuple&) noexcept; // constexpr in C++14 template typename tuple_element>::type&& get(tuple&&) noexcept; // constexpr in C++14 template const typename tuple_element>::type&& get(const tuple&&) noexcept; // constexpr in C++14 template constexpr T1& get(tuple&) noexcept; // C++14 template constexpr const T1& get(const tuple&) noexcept; // C++14 template constexpr T1&& get(tuple&&) noexcept; // C++14 template constexpr const T1&& get(const tuple&&) noexcept; // C++14 // 20.4.1.6, relational operators: template bool operator==(const tuple&, const tuple&); // constexpr in C++14 template bool operator<(const tuple&, const tuple&); // constexpr in C++14, removed in C++20 template bool operator!=(const tuple&, const tuple&); // constexpr in C++14, removed in C++20 template bool operator>(const tuple&, const tuple&); // constexpr in C++14, removed in C++20 template bool operator<=(const tuple&, const tuple&); // constexpr in C++14, removed in C++20 template bool operator>=(const tuple&, const tuple&); // constexpr in C++14, removed in C++20 template constexpr common_comparison_category_t...> operator<=>(const tuple&, const tuple&); // since C++20 template struct uses_allocator, Alloc>; template void swap(tuple& x, tuple& y) noexcept(noexcept(x.swap(y))); } // std */ #include <__compare/common_comparison_category.h> #include <__compare/synth_three_way.h> #include <__config> #include <__functional/unwrap_ref.h> #include <__functional_base> #include <__memory/allocator_arg_t.h> #include <__memory/uses_allocator.h> #include <__tuple> #include <__utility/forward.h> #include <__utility/integer_sequence.h> #include <__utility/move.h> #include #include #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_CXX03_LANG // __tuple_leaf template ::value && !__libcpp_is_final<_Hp>::value > class __tuple_leaf; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y) _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value) { swap(__x.get(), __y.get()); } template class __tuple_leaf { _Hp __value_; template static constexpr bool __can_bind_reference() { #if __has_keyword(__reference_binds_to_temporary) return !__reference_binds_to_temporary(_Hp, _Tp); #else return true; #endif } _LIBCPP_CONSTEXPR_AFTER_CXX11 __tuple_leaf& operator=(const __tuple_leaf&); public: _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf() _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_() {static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");} template _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf(integral_constant, const _Alloc&) : __value_() {static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");} template _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf(integral_constant, const _Alloc& __a) : __value_(allocator_arg_t(), __a) {static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");} template _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf(integral_constant, const _Alloc& __a) : __value_(__a) {static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");} template , __tuple_leaf>, is_constructible<_Hp, _Tp> >::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) : __value_(_VSTD::forward<_Tp>(__t)) {static_assert(__can_bind_reference<_Tp&&>(), "Attempted construction of reference element binds to a temporary whose lifetime has ended");} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(integral_constant, const _Alloc&, _Tp&& __t) : __value_(_VSTD::forward<_Tp>(__t)) {static_assert(__can_bind_reference<_Tp&&>(), "Attempted construction of reference element binds to a temporary whose lifetime has ended");} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(integral_constant, const _Alloc& __a, _Tp&& __t) : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple");} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(integral_constant, const _Alloc& __a, _Tp&& __t) : __value_(_VSTD::forward<_Tp>(__t), __a) {static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple");} __tuple_leaf(const __tuple_leaf& __t) = default; __tuple_leaf(__tuple_leaf&& __t) = default; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) { _VSTD::swap(*this, __t); return 0; } _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;} }; template class __tuple_leaf<_Ip, _Hp, true> : private _Hp { _LIBCPP_CONSTEXPR_AFTER_CXX11 __tuple_leaf& operator=(const __tuple_leaf&); public: _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf() _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {} template _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf(integral_constant, const _Alloc&) {} template _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf(integral_constant, const _Alloc& __a) : _Hp(allocator_arg_t(), __a) {} template _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf(integral_constant, const _Alloc& __a) : _Hp(__a) {} template , __tuple_leaf>, is_constructible<_Hp, _Tp> >::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) : _Hp(_VSTD::forward<_Tp>(__t)) {} template _LIBCPP_INLINE_VISIBILITY constexpr explicit __tuple_leaf(integral_constant, const _Alloc&, _Tp&& __t) : _Hp(_VSTD::forward<_Tp>(__t)) {} template _LIBCPP_INLINE_VISIBILITY constexpr explicit __tuple_leaf(integral_constant, const _Alloc& __a, _Tp&& __t) : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {} template _LIBCPP_INLINE_VISIBILITY constexpr explicit __tuple_leaf(integral_constant, const _Alloc& __a, _Tp&& __t) : _Hp(_VSTD::forward<_Tp>(__t), __a) {} __tuple_leaf(__tuple_leaf const &) = default; __tuple_leaf(__tuple_leaf &&) = default; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) { _VSTD::swap(*this, __t); return 0; } _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast(*this);} }; template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swallow(_Tp&&...) _NOEXCEPT {} template struct __all_default_constructible; template struct __all_default_constructible<__tuple_types<_Tp...>> : __all::value...> { }; // __tuple_impl template struct __tuple_impl; template struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...> : public __tuple_leaf<_Indx, _Tp>... { _LIBCPP_INLINE_VISIBILITY constexpr __tuple_impl() _NOEXCEPT_(__all::value...>::value) {} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>, __tuple_indices<_Ul...>, __tuple_types<_Tl...>, _Up&&... __u) _NOEXCEPT_((__all::value...>::value && __all::value...>::value)) : __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))..., __tuple_leaf<_Ul, _Tl>()... {} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_impl(allocator_arg_t, const _Alloc& __a, __tuple_indices<_Uf...>, __tuple_types<_Tf...>, __tuple_indices<_Ul...>, __tuple_types<_Tl...>, _Up&&... __u) : __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a, _VSTD::forward<_Up>(__u))..., __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)... {} template >::value >::type > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all::type>::type>::value...>::value)) : __tuple_leaf<_Indx, _Tp>(_VSTD::forward::type>::type>(_VSTD::get<_Indx>(__t)))... {} template >::value >::type > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>(), __a, _VSTD::forward::type>::type>(_VSTD::get<_Indx>(__t)))... {} __tuple_impl(const __tuple_impl&) = default; __tuple_impl(__tuple_impl&&) = default; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void swap(__tuple_impl& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) { _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...); } }; template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) { _VSTD::__swallow(((_VSTD::get<_Np>(__dest) = _VSTD::get<_Np>(__source)), void(), 0)...); } template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) { _VSTD::__swallow((( _VSTD::get<_Np>(__dest) = _VSTD::forward<_Up>(_VSTD::get<_Np>(__source)) ), void(), 0)...); } template class _LIBCPP_TEMPLATE_VIS tuple { typedef __tuple_impl::type, _Tp...> _BaseT; _BaseT __base_; template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT; template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT; template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT; template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT; public: // [tuple.cnstr] // tuple() constructors (including allocator_arg_t variants) template class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t< _And< _IsImpDefault<_Tp>... // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR tuple() _NOEXCEPT_(_And...>::value) { } template class _IsImpDefault = __is_implicitly_default_constructible, template class _IsDefault = is_default_constructible, __enable_if_t< _And< _IsDefault<_Tp>..., _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit tuple() _NOEXCEPT_(_And...>::value) { } template class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t< _And< _IsImpDefault<_Tp>... // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(allocator_arg_t, _Alloc const& __a) : __base_(allocator_arg_t(), __a, __tuple_indices<>(), __tuple_types<>(), typename __make_tuple_indices::type(), __tuple_types<_Tp...>()) {} template class _IsImpDefault = __is_implicitly_default_constructible, template class _IsDefault = is_default_constructible, __enable_if_t< _And< _IsDefault<_Tp>..., _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit tuple(allocator_arg_t, _Alloc const& __a) : __base_(allocator_arg_t(), __a, __tuple_indices<>(), __tuple_types<>(), typename __make_tuple_indices::type(), __tuple_types<_Tp...>()) {} // tuple(const T&...) constructors (including allocator_arg_t variants) template class _And = _And, __enable_if_t< _And< _BoolConstant= 1>, is_copy_constructible<_Tp>..., is_convertible... // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(const _Tp& ... __t) _NOEXCEPT_(_And...>::value) : __base_(typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices<0>::type(), typename __make_tuple_types::type(), __t... ) {} template class _And = _And, __enable_if_t< _And< _BoolConstant= 1>, is_copy_constructible<_Tp>..., _Not<_Lazy<_And, is_convertible...> > // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit tuple(const _Tp& ... __t) _NOEXCEPT_(_And...>::value) : __base_(typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices<0>::type(), typename __make_tuple_types::type(), __t... ) {} template class _And = _And, __enable_if_t< _And< _BoolConstant= 1>, is_copy_constructible<_Tp>..., is_convertible... // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t) : __base_(allocator_arg_t(), __a, typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices<0>::type(), typename __make_tuple_types::type(), __t... ) {} template class _And = _And, __enable_if_t< _And< _BoolConstant= 1>, is_copy_constructible<_Tp>..., _Not<_Lazy<_And, is_convertible...> > // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t) : __base_(allocator_arg_t(), __a, typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices<0>::type(), typename __make_tuple_types::type(), __t... ) {} // tuple(U&& ...) constructors (including allocator_arg_t variants) template struct _IsThisTuple : false_type { }; template struct _IsThisTuple<_Up> : is_same<__uncvref_t<_Up>, tuple> { }; template struct _EnableUTypesCtor : _And< _BoolConstant= 1>, _Not<_IsThisTuple<_Up...> >, // extension to allow mis-behaved user constructors is_constructible<_Tp, _Up>... > { }; template , _EnableUTypesCtor<_Up...>, is_convertible<_Up, _Tp>... // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(_Up&&... __u) _NOEXCEPT_((_And...>::value)) : __base_(typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices::type(), typename __make_tuple_types::type(), _VSTD::forward<_Up>(__u)...) {} template , _EnableUTypesCtor<_Up...>, _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit tuple(_Up&&... __u) _NOEXCEPT_((_And...>::value)) : __base_(typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices::type(), typename __make_tuple_types::type(), _VSTD::forward<_Up>(__u)...) {} template , _EnableUTypesCtor<_Up...>, is_convertible<_Up, _Tp>... // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) : __base_(allocator_arg_t(), __a, typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices::type(), typename __make_tuple_types::type(), _VSTD::forward<_Up>(__u)...) {} template , _EnableUTypesCtor<_Up...>, _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) : __base_(allocator_arg_t(), __a, typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices::type(), typename __make_tuple_types::type(), _VSTD::forward<_Up>(__u)...) {} // Copy and move constructors (including the allocator_arg_t variants) tuple(const tuple&) = default; tuple(tuple&&) = default; template class _And = _And, __enable_if_t< _And...>::value , int> = 0> tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t) : __base_(allocator_arg_t(), __alloc, __t) { } template class _And = _And, __enable_if_t< _And...>::value , int> = 0> tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t) : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t)) { } // tuple(const tuple&) constructors (including allocator_arg_t variants) template struct _EnableCopyFromOtherTuple : _And< _Not, tuple<_Up...> > >, _Lazy<_Or, _BoolConstant, // _Tp and _Up are 1-element packs - the pack expansions look // weird to avoid tripping up the type traits in degenerate cases _Lazy<_And, _Not&, _Tp> >..., _Not&> >... > >, is_constructible<_Tp, const _Up&>... > { }; template , _EnableCopyFromOtherTuple<_Up...>, is_convertible... // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(const tuple<_Up...>& __t) _NOEXCEPT_((_And...>::value)) : __base_(__t) { } template , _EnableCopyFromOtherTuple<_Up...>, _Not<_Lazy<_And, is_convertible...> > // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit tuple(const tuple<_Up...>& __t) _NOEXCEPT_((_And...>::value)) : __base_(__t) { } template , _EnableCopyFromOtherTuple<_Up...>, is_convertible... // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) : __base_(allocator_arg_t(), __a, __t) { } template , _EnableCopyFromOtherTuple<_Up...>, _Not<_Lazy<_And, is_convertible...> > // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) : __base_(allocator_arg_t(), __a, __t) { } // tuple(tuple&&) constructors (including allocator_arg_t variants) template struct _EnableMoveFromOtherTuple : _And< _Not, tuple<_Up...> > >, _Lazy<_Or, _BoolConstant, // _Tp and _Up are 1-element packs - the pack expansions look // weird to avoid tripping up the type traits in degenerate cases _Lazy<_And, _Not, _Tp> >..., _Not > >... > >, is_constructible<_Tp, _Up>... > { }; template , _EnableMoveFromOtherTuple<_Up...>, is_convertible<_Up, _Tp>... // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(tuple<_Up...>&& __t) _NOEXCEPT_((_And...>::value)) : __base_(_VSTD::move(__t)) { } template , _EnableMoveFromOtherTuple<_Up...>, _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit tuple(tuple<_Up...>&& __t) _NOEXCEPT_((_And...>::value)) : __base_(_VSTD::move(__t)) { } template , _EnableMoveFromOtherTuple<_Up...>, is_convertible<_Up, _Tp>... // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t) : __base_(allocator_arg_t(), __a, _VSTD::move(__t)) { } template , _EnableMoveFromOtherTuple<_Up...>, _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t) : __base_(allocator_arg_t(), __a, _VSTD::move(__t)) { } // tuple(const pair&) constructors (including allocator_arg_t variants) template struct _EnableImplicitCopyFromPair : _And< is_constructible<_FirstType<_DependentTp...>, const _Up1&>, is_constructible<_SecondType<_DependentTp...>, const _Up2&>, is_convertible >, // explicit check is_convertible > > { }; template struct _EnableExplicitCopyFromPair : _And< is_constructible<_FirstType<_DependentTp...>, const _Up1&>, is_constructible<_SecondType<_DependentTp...>, const _Up2&>, _Not > >, // explicit check _Not > > > { }; template class _And = _And, __enable_if_t< _And< _BoolConstant, _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(const pair<_Up1, _Up2>& __p) _NOEXCEPT_((_And< is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>, is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&> >::value)) : __base_(__p) { } template class _And = _And, __enable_if_t< _And< _BoolConstant, _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit tuple(const pair<_Up1, _Up2>& __p) _NOEXCEPT_((_And< is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>, is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&> >::value)) : __base_(__p) { } template class _And = _And, __enable_if_t< _And< _BoolConstant, _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) : __base_(allocator_arg_t(), __a, __p) { } template class _And = _And, __enable_if_t< _And< _BoolConstant, _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) : __base_(allocator_arg_t(), __a, __p) { } // tuple(pair&&) constructors (including allocator_arg_t variants) template struct _EnableImplicitMoveFromPair : _And< is_constructible<_FirstType<_DependentTp...>, _Up1>, is_constructible<_SecondType<_DependentTp...>, _Up2>, is_convertible<_Up1, _FirstType<_DependentTp...> >, // explicit check is_convertible<_Up2, _SecondType<_DependentTp...> > > { }; template struct _EnableExplicitMoveFromPair : _And< is_constructible<_FirstType<_DependentTp...>, _Up1>, is_constructible<_SecondType<_DependentTp...>, _Up2>, _Not > >, // explicit check _Not > > > { }; template class _And = _And, __enable_if_t< _And< _BoolConstant, _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(pair<_Up1, _Up2>&& __p) _NOEXCEPT_((_And< is_nothrow_constructible<_FirstType<_Tp...>, _Up1>, is_nothrow_constructible<_SecondType<_Tp...>, _Up2> >::value)) : __base_(_VSTD::move(__p)) { } template class _And = _And, __enable_if_t< _And< _BoolConstant, _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit tuple(pair<_Up1, _Up2>&& __p) _NOEXCEPT_((_And< is_nothrow_constructible<_FirstType<_Tp...>, _Up1>, is_nothrow_constructible<_SecondType<_Tp...>, _Up2> >::value)) : __base_(_VSTD::move(__p)) { } template class _And = _And, __enable_if_t< _And< _BoolConstant, _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) : __base_(allocator_arg_t(), __a, _VSTD::move(__p)) { } template class _And = _And, __enable_if_t< _And< _BoolConstant, _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) : __base_(allocator_arg_t(), __a, _VSTD::move(__p)) { } // [tuple.assign] _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple& operator=(_If<_And...>::value, tuple, __nat> const& __tuple) _NOEXCEPT_((_And...>::value)) { _VSTD::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices::type()); return *this; } _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple& operator=(_If<_And...>::value, tuple, __nat>&& __tuple) _NOEXCEPT_((_And...>::value)) { _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices::type()); return *this; } template, is_assignable<_Tp&, _Up const&>... >::value ,int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple& operator=(tuple<_Up...> const& __tuple) _NOEXCEPT_((_And...>::value)) { _VSTD::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices::type()); return *this; } template, is_assignable<_Tp&, _Up>... >::value ,int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple& operator=(tuple<_Up...>&& __tuple) _NOEXCEPT_((_And...>::value)) { _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices::type()); return *this; } template, is_assignable<_FirstType<_Tp..., _Dep>&, _Up1 const&>, is_assignable<_SecondType<_Tp..., _Dep>&, _Up2 const&> >::value ,int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple& operator=(pair<_Up1, _Up2> const& __pair) _NOEXCEPT_((_And< is_nothrow_assignable<_FirstType<_Tp...>&, _Up1 const&>, is_nothrow_assignable<_SecondType<_Tp...>&, _Up2 const&> >::value)) { _VSTD::get<0>(*this) = __pair.first; _VSTD::get<1>(*this) = __pair.second; return *this; } template, is_assignable<_FirstType<_Tp..., _Dep>&, _Up1>, is_assignable<_SecondType<_Tp..., _Dep>&, _Up2> >::value ,int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple& operator=(pair<_Up1, _Up2>&& __pair) _NOEXCEPT_((_And< is_nothrow_assignable<_FirstType<_Tp...>&, _Up1>, is_nothrow_assignable<_SecondType<_Tp...>&, _Up2> >::value)) { _VSTD::get<0>(*this) = _VSTD::forward<_Up1>(__pair.first); _VSTD::get<1>(*this) = _VSTD::forward<_Up2>(__pair.second); return *this; } // EXTENSION template, is_assignable<_Tp&, _Up const&>... >::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple& operator=(array<_Up, _Np> const& __array) _NOEXCEPT_((_And...>::value)) { _VSTD::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices::type()); return *this; } // EXTENSION template, is_assignable<_Tp&, _Up>... >::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple& operator=(array<_Up, _Np>&& __array) _NOEXCEPT_((_And...>::value)) { _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__array), __tuple_types<_If...>(), typename __make_tuple_indices::type()); return *this; } // [tuple.swap] _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) {__base_.swap(__t.__base_);} }; template <> class _LIBCPP_TEMPLATE_VIS tuple<> { public: _LIBCPP_INLINE_VISIBILITY constexpr tuple() _NOEXCEPT = default; template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(array<_Up, 0>) _NOEXCEPT {} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(tuple&) _NOEXCEPT {} }; #if _LIBCPP_STD_VER > 20 template class _TQual, template class _UQual> requires requires { typename tuple, _UQual<_UTypes>>...>; } struct basic_common_reference, tuple<_UTypes...>, _TQual, _UQual> { using type = tuple, _UQual<_UTypes>>...>; }; template requires requires { typename tuple...>; } struct common_type, tuple<_UTypes...>> { using type = tuple...>; }; #endif #if _LIBCPP_STD_VER > 14 template tuple(_Tp...) -> tuple<_Tp...>; template tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>; template tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>; template tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>; template tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>; #endif template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if < __all<__is_swappable<_Tp>::value...>::value, void >::type swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) {__t.swap(__u);} // get template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, tuple<_Tp...> >::type& get(tuple<_Tp...>& __t) _NOEXCEPT { typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get(); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, tuple<_Tp...> >::type& get(const tuple<_Tp...>& __t) _NOEXCEPT { typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; return static_cast&>(__t.__base_).get(); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, tuple<_Tp...> >::type&& get(tuple<_Tp...>&& __t) _NOEXCEPT { typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; return static_cast( static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get()); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, tuple<_Tp...> >::type&& get(const tuple<_Tp...>&& __t) _NOEXCEPT { typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; return static_cast( static_cast&&>(__t.__base_).get()); } #if _LIBCPP_STD_VER > 11 namespace __find_detail { static constexpr size_t __not_found = static_cast(-1); static constexpr size_t __ambiguous = __not_found - 1; inline _LIBCPP_INLINE_VISIBILITY constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) { return !__matches ? __res : (__res == __not_found ? __curr_i : __ambiguous); } template inline _LIBCPP_INLINE_VISIBILITY constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) { return __i == _Nx ? __not_found : __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]); } template struct __find_exactly_one_checked { static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...}; static constexpr size_t value = __find_detail::__find_idx(0, __matches); static_assert(value != __not_found, "type not found in type list" ); static_assert(value != __ambiguous, "type occurs more than once in type list"); }; template struct __find_exactly_one_checked<_T1> { static_assert(!is_same<_T1, _T1>::value, "type not in empty type list"); }; } // namespace __find_detail template struct __find_exactly_one_t : public __find_detail::__find_exactly_one_checked<_T1, _Args...> { }; template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1& get(tuple<_Args...>& __tup) noexcept { return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept { return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept { return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup)); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept { return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup)); } #endif // tie template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple<_Tp&...> tie(_Tp&... __t) _NOEXCEPT { return tuple<_Tp&...>(__t...); } template struct __ignore_t { template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const __ignore_t& operator=(_Tp&&) const {return *this;} }; namespace { constexpr __ignore_t ignore = __ignore_t(); } // namespace template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple::type...> make_tuple(_Tp&&... __t) { return tuple::type...>(_VSTD::forward<_Tp>(__t)...); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple<_Tp&&...> forward_as_tuple(_Tp&&... __t) _NOEXCEPT { return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...); } template struct __tuple_equal { template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _Tp& __x, const _Up& __y) { return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y); } }; template <> struct __tuple_equal<0> { template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _Tp&, const _Up&) { return true; } }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes"); return __tuple_equal()(__x, __y); } -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) // operator<=> template _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_compare_three_way(const tuple<_Tp...>& __x, const tuple<_Up...>& __y, index_sequence<_Is...>) { common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> __result = strong_ordering::equal; static_cast(((__result = _VSTD::__synth_three_way(_VSTD::get<_Is>(__x), _VSTD::get<_Is>(__y)), __result != 0) || ...)); return __result; } template requires (sizeof...(_Tp) == sizeof...(_Up)) _LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { return _VSTD::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{}); } -#else // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#else // !defined(_LIBCPP_HAS_NO_CONCEPTS) template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { return !(__x == __y); } template struct __tuple_less { template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _Tp& __x, const _Up& __y) { const size_t __idx = tuple_size<_Tp>::value - _Ip; if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y)) return true; if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x)) return false; return __tuple_less<_Ip-1>()(__x, __y); } }; template <> struct __tuple_less<0> { template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _Tp&, const _Up&) { return false; } }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes"); return __tuple_less()(__x, __y); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { return __y < __x; } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { return !(__x < __y); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { return !(__y < __x); } -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) // tuple_cat template struct __tuple_cat_type; template struct __tuple_cat_type, __tuple_types<_Utypes...> > { typedef _LIBCPP_NODEBUG tuple<_Ttypes..., _Utypes...> type; }; template struct __tuple_cat_return_1 { }; template struct __tuple_cat_return_1, true, _Tuple0> { typedef _LIBCPP_NODEBUG typename __tuple_cat_type, typename __make_tuple_types::type>::type>::type type; }; template struct __tuple_cat_return_1, true, _Tuple0, _Tuple1, _Tuples...> : public __tuple_cat_return_1< typename __tuple_cat_type< tuple<_Types...>, typename __make_tuple_types::type>::type >::type, __tuple_like::type>::value, _Tuple1, _Tuples...> { }; template struct __tuple_cat_return; template struct __tuple_cat_return<_Tuple0, _Tuples...> : public __tuple_cat_return_1, __tuple_like::type>::value, _Tuple0, _Tuples...> { }; template <> struct __tuple_cat_return<> { typedef _LIBCPP_NODEBUG tuple<> type; }; inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple<> tuple_cat() { return tuple<>(); } template struct __tuple_cat_return_ref_imp; template struct __tuple_cat_return_ref_imp, __tuple_indices<_I0...>, _Tuple0> { typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0; typedef tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_I0, _T0>::type>::type&&...> type; }; template struct __tuple_cat_return_ref_imp, __tuple_indices<_I0...>, _Tuple0, _Tuple1, _Tuples...> : public __tuple_cat_return_ref_imp< tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_I0, typename remove_reference<_Tuple0>::type>::type>::type&&...>, typename __make_tuple_indices::type>::value>::type, _Tuple1, _Tuples...> { }; template struct __tuple_cat_return_ref : public __tuple_cat_return_ref_imp, typename __make_tuple_indices< tuple_size::type>::value >::type, _Tuple0, _Tuples...> { }; template struct __tuple_cat; template struct __tuple_cat, __tuple_indices<_I0...>, __tuple_indices<_J0...> > { template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename __tuple_cat_return_ref&&, _Tuple0&&>::type operator()(tuple<_Types...> __t, _Tuple0&& __t0) { return _VSTD::forward_as_tuple( _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))..., _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...); } template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename __tuple_cat_return_ref&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls) { typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0; typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1; return __tuple_cat< tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element< _J0, _T0>::type>::type&&...>, typename __make_tuple_indices::value>::type, typename __make_tuple_indices::value>::type>()( _VSTD::forward_as_tuple( _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))..., _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...), _VSTD::forward<_Tuple1>(__t1), _VSTD::forward<_Tuples>(__tpls)...); } }; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename __tuple_cat_return<_Tuple0, _Tuples...>::type tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) { typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0; return __tuple_cat, __tuple_indices<>, typename __make_tuple_indices::value>::type>() (tuple<>(), _VSTD::forward<_Tuple0>(__t0), _VSTD::forward<_Tuples>(__tpls)...); } template struct _LIBCPP_TEMPLATE_VIS uses_allocator, _Alloc> : true_type {}; template template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_T1, _T2>::pair(piecewise_construct_t, tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args, __tuple_indices<_I1...>, __tuple_indices<_I2...>) : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...), second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) { } #if _LIBCPP_STD_VER > 14 template inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; #define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; } template inline _LIBCPP_INLINE_VISIBILITY constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t, __tuple_indices<_Id...>) _LIBCPP_NOEXCEPT_RETURN( _VSTD::__invoke_constexpr( _VSTD::forward<_Fn>(__f), _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...) ) template inline _LIBCPP_INLINE_VISIBILITY constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t) _LIBCPP_NOEXCEPT_RETURN( _VSTD::__apply_tuple_impl( _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t), typename __make_tuple_indices>>::type{}) ) template inline _LIBCPP_INLINE_VISIBILITY constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>) _LIBCPP_NOEXCEPT_RETURN( _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...) ) template inline _LIBCPP_INLINE_VISIBILITY constexpr _Tp make_from_tuple(_Tuple&& __t) _LIBCPP_NOEXCEPT_RETURN( _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t), typename __make_tuple_indices>>::type{}) ) #undef _LIBCPP_NOEXCEPT_RETURN #endif // _LIBCPP_STD_VER > 14 #endif // !defined(_LIBCPP_CXX03_LANG) _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_TUPLE diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index b4010851f133..3391999675a0 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1,4155 +1,4155 @@ // -*- 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_TYPE_TRAITS #define _LIBCPP_TYPE_TRAITS /* type_traits synopsis namespace std { // helper class: template struct integral_constant; typedef integral_constant true_type; // C++11 typedef integral_constant false_type; // C++11 template // C++14 using bool_constant = integral_constant; // C++14 typedef bool_constant true_type; // C++14 typedef bool_constant false_type; // C++14 // helper traits template struct enable_if; template struct conditional; // Primary classification traits: template struct is_void; template struct is_null_pointer; // C++14 template struct is_integral; template struct is_floating_point; template struct is_array; template struct is_pointer; template struct is_lvalue_reference; template struct is_rvalue_reference; template struct is_member_object_pointer; template struct is_member_function_pointer; template struct is_enum; template struct is_union; template struct is_class; template struct is_function; // Secondary classification traits: template struct is_reference; template struct is_arithmetic; template struct is_fundamental; template struct is_member_pointer; template struct is_scoped_enum; // C++2b template struct is_scalar; template struct is_object; template struct is_compound; // Const-volatile properties and transformations: template struct is_const; template struct is_volatile; template struct remove_const; template struct remove_volatile; template struct remove_cv; template struct add_const; template struct add_volatile; template struct add_cv; // Reference transformations: template struct remove_reference; template struct add_lvalue_reference; template struct add_rvalue_reference; // Pointer transformations: template struct remove_pointer; template struct add_pointer; template struct type_identity; // C++20 template using type_identity_t = typename type_identity::type; // C++20 // Integral properties: template struct is_signed; template struct is_unsigned; template struct make_signed; template struct make_unsigned; // Array properties and transformations: template struct rank; template struct extent; template struct remove_extent; template struct remove_all_extents; template struct is_bounded_array; // C++20 template struct is_unbounded_array; // C++20 // Member introspection: template struct is_pod; template struct is_trivial; template struct is_trivially_copyable; template struct is_standard_layout; template struct is_literal_type; // Deprecated in C++17; removed in C++20 template struct is_empty; template struct is_polymorphic; template struct is_abstract; template struct is_final; // C++14 template struct is_aggregate; // C++17 template struct is_constructible; template struct is_default_constructible; template struct is_copy_constructible; template struct is_move_constructible; template struct is_assignable; template struct is_copy_assignable; template struct is_move_assignable; template struct is_swappable_with; // C++17 template struct is_swappable; // C++17 template struct is_destructible; template struct is_trivially_constructible; template struct is_trivially_default_constructible; template struct is_trivially_copy_constructible; template struct is_trivially_move_constructible; template struct is_trivially_assignable; template struct is_trivially_copy_assignable; template struct is_trivially_move_assignable; template struct is_trivially_destructible; template struct is_nothrow_constructible; template struct is_nothrow_default_constructible; template struct is_nothrow_copy_constructible; template struct is_nothrow_move_constructible; template struct is_nothrow_assignable; template struct is_nothrow_copy_assignable; template struct is_nothrow_move_assignable; template struct is_nothrow_swappable_with; // C++17 template struct is_nothrow_swappable; // C++17 template struct is_nothrow_destructible; template struct has_virtual_destructor; template struct has_unique_object_representations; // C++17 // Relationships between types: template struct is_same; template struct is_base_of; template struct is_convertible; template struct is_nothrow_convertible; // C++20 template inline constexpr bool is_nothrow_convertible_v; // C++20 template struct is_invocable; template struct is_invocable_r; template struct is_nothrow_invocable; template struct is_nothrow_invocable_r; // Alignment properties and transformations: template struct alignment_of; template struct aligned_storage; template struct aligned_union; template struct remove_cvref; // C++20 template struct decay; template struct common_type; template struct underlying_type; template class result_of; // undefined; deprecated in C++17; removed in C++20 template class result_of; // deprecated in C++17; removed in C++20 template struct invoke_result; // C++17 // const-volatile modifications: template using remove_const_t = typename remove_const::type; // C++14 template using remove_volatile_t = typename remove_volatile::type; // C++14 template using remove_cv_t = typename remove_cv::type; // C++14 template using add_const_t = typename add_const::type; // C++14 template using add_volatile_t = typename add_volatile::type; // C++14 template using add_cv_t = typename add_cv::type; // C++14 // reference modifications: template using remove_reference_t = typename remove_reference::type; // C++14 template using add_lvalue_reference_t = typename add_lvalue_reference::type; // C++14 template using add_rvalue_reference_t = typename add_rvalue_reference::type; // C++14 // sign modifications: template using make_signed_t = typename make_signed::type; // C++14 template using make_unsigned_t = typename make_unsigned::type; // C++14 // array modifications: template using remove_extent_t = typename remove_extent::type; // C++14 template using remove_all_extents_t = typename remove_all_extents::type; // C++14 template inline constexpr bool is_bounded_array_v = is_bounded_array::value; // C++20 inline constexpr bool is_unbounded_array_v = is_unbounded_array::value; // C++20 // pointer modifications: template using remove_pointer_t = typename remove_pointer::type; // C++14 template using add_pointer_t = typename add_pointer::type; // C++14 // other transformations: template using aligned_storage_t = typename aligned_storage::type; // C++14 template using aligned_union_t = typename aligned_union::type; // C++14 template using remove_cvref_t = typename remove_cvref::type; // C++20 template using decay_t = typename decay::type; // C++14 template using enable_if_t = typename enable_if::type; // C++14 template using conditional_t = typename conditional::type; // C++14 template using common_type_t = typename common_type::type; // C++14 template using underlying_type_t = typename underlying_type::type; // C++14 template using result_of_t = typename result_of::type; // C++14; deprecated in C++17; removed in C++20 template using invoke_result_t = typename invoke_result::type; // C++17 template using void_t = void; // C++17 // See C++14 20.10.4.1, primary type categories template inline constexpr bool is_void_v = is_void::value; // C++17 template inline constexpr bool is_null_pointer_v = is_null_pointer::value; // C++17 template inline constexpr bool is_integral_v = is_integral::value; // C++17 template inline constexpr bool is_floating_point_v = is_floating_point::value; // C++17 template inline constexpr bool is_array_v = is_array::value; // C++17 template inline constexpr bool is_pointer_v = is_pointer::value; // C++17 template inline constexpr bool is_lvalue_reference_v = is_lvalue_reference::value; // C++17 template inline constexpr bool is_rvalue_reference_v = is_rvalue_reference::value; // C++17 template inline constexpr bool is_member_object_pointer_v = is_member_object_pointer::value; // C++17 template inline constexpr bool is_member_function_pointer_v = is_member_function_pointer::value; // C++17 template inline constexpr bool is_enum_v = is_enum::value; // C++17 template inline constexpr bool is_union_v = is_union::value; // C++17 template inline constexpr bool is_class_v = is_class::value; // C++17 template inline constexpr bool is_function_v = is_function::value; // C++17 // See C++14 20.10.4.2, composite type categories template inline constexpr bool is_reference_v = is_reference::value; // C++17 template inline constexpr bool is_arithmetic_v = is_arithmetic::value; // C++17 template inline constexpr bool is_fundamental_v = is_fundamental::value; // C++17 template inline constexpr bool is_object_v = is_object::value; // C++17 template inline constexpr bool is_scalar_v = is_scalar::value; // C++17 template inline constexpr bool is_compound_v = is_compound::value; // C++17 template inline constexpr bool is_member_pointer_v = is_member_pointer::value; // C++17 template inline constexpr bool is_scoped_enum_v = is_scoped_enum::value; // C++2b // See C++14 20.10.4.3, type properties template inline constexpr bool is_const_v = is_const::value; // C++17 template inline constexpr bool is_volatile_v = is_volatile::value; // C++17 template inline constexpr bool is_trivial_v = is_trivial::value; // C++17 template inline constexpr bool is_trivially_copyable_v = is_trivially_copyable::value; // C++17 template inline constexpr bool is_standard_layout_v = is_standard_layout::value; // C++17 template inline constexpr bool is_pod_v = is_pod::value; // C++17 template inline constexpr bool is_literal_type_v = is_literal_type::value; // C++17; deprecated in C++17; removed in C++20 template inline constexpr bool is_empty_v = is_empty::value; // C++17 template inline constexpr bool is_polymorphic_v = is_polymorphic::value; // C++17 template inline constexpr bool is_abstract_v = is_abstract::value; // C++17 template inline constexpr bool is_final_v = is_final::value; // C++17 template inline constexpr bool is_aggregate_v = is_aggregate::value; // C++17 template inline constexpr bool is_signed_v = is_signed::value; // C++17 template inline constexpr bool is_unsigned_v = is_unsigned::value; // C++17 template inline constexpr bool is_constructible_v = is_constructible::value; // C++17 template inline constexpr bool is_default_constructible_v = is_default_constructible::value; // C++17 template inline constexpr bool is_copy_constructible_v = is_copy_constructible::value; // C++17 template inline constexpr bool is_move_constructible_v = is_move_constructible::value; // C++17 template inline constexpr bool is_assignable_v = is_assignable::value; // C++17 template inline constexpr bool is_copy_assignable_v = is_copy_assignable::value; // C++17 template inline constexpr bool is_move_assignable_v = is_move_assignable::value; // C++17 template inline constexpr bool is_swappable_with_v = is_swappable_with::value; // C++17 template inline constexpr bool is_swappable_v = is_swappable::value; // C++17 template inline constexpr bool is_destructible_v = is_destructible::value; // C++17 template inline constexpr bool is_trivially_constructible_v = is_trivially_constructible::value; // C++17 template inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible::value; // C++17 template inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible::value; // C++17 template inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible::value; // C++17 template inline constexpr bool is_trivially_assignable_v = is_trivially_assignable::value; // C++17 template inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable::value; // C++17 template inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable::value; // C++17 template inline constexpr bool is_trivially_destructible_v = is_trivially_destructible::value; // C++17 template inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible::value; // C++17 template inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible::value; // C++17 template inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible::value; // C++17 template inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible::value; // C++17 template inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable::value; // C++17 template inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable::value; // C++17 template inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable::value; // C++17 template inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with::value; // C++17 template inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable::value; // C++17 template inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible::value; // C++17 template inline constexpr bool has_virtual_destructor_v = has_virtual_destructor::value; // C++17 template inline constexpr bool has_unique_object_representations_v // C++17 = has_unique_object_representations::value; // See C++14 20.10.5, type property queries template inline constexpr size_t alignment_of_v = alignment_of::value; // C++17 template inline constexpr size_t rank_v = rank::value; // C++17 template inline constexpr size_t extent_v = extent::value; // C++17 // See C++14 20.10.6, type relations template inline constexpr bool is_same_v = is_same::value; // C++17 template inline constexpr bool is_base_of_v = is_base_of::value; // C++17 template inline constexpr bool is_convertible_v = is_convertible::value; // C++17 template inline constexpr bool is_invocable_v = is_invocable::value; // C++17 template inline constexpr bool is_invocable_r_v = is_invocable_r::value; // C++17 template inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable::value; // C++17 template inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r::value; // C++17 // [meta.logical], logical operator traits: template struct conjunction; // C++17 template inline constexpr bool conjunction_v = conjunction::value; // C++17 template struct disjunction; // C++17 template inline constexpr bool disjunction_v = disjunction::value; // C++17 template struct negation; // C++17 template inline constexpr bool negation_v = negation::value; // C++17 } */ #include <__config> #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TEMPLATE_VIS pair; template class _LIBCPP_TEMPLATE_VIS reference_wrapper; template struct _LIBCPP_TEMPLATE_VIS hash; template struct _LIBCPP_TEMPLATE_VIS integral_constant { static _LIBCPP_CONSTEXPR const _Tp value = __v; typedef _Tp value_type; typedef integral_constant type; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;} #if _LIBCPP_STD_VER > 11 _LIBCPP_INLINE_VISIBILITY constexpr value_type operator ()() const _NOEXCEPT {return value;} #endif }; template _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; #if _LIBCPP_STD_VER > 14 template using bool_constant = integral_constant; #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> #else #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant #endif template struct _LIBCPP_TEMPLATE_VIS enable_if {}; template struct _LIBCPP_TEMPLATE_VIS enable_if {typedef _Tp type;}; template using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type; #if _LIBCPP_STD_VER > 11 template using enable_if_t = typename enable_if<_Bp, _Tp>::type; #endif typedef _LIBCPP_BOOL_CONSTANT(true) true_type; typedef _LIBCPP_BOOL_CONSTANT(false) false_type; template using _BoolConstant _LIBCPP_NODEBUG = integral_constant; template struct _MetaBase; template <> struct _MetaBase { template using _SelectImpl _LIBCPP_NODEBUG = _Tp; template