//===- STLForwardCompat.h - Library features from future STLs ------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 // //===----------------------------------------------------------------------===// /// /// \file /// This file contains library features backported from future STL versions. /// /// These should be replaced with their STL counterparts as the C++ version LLVM /// is compiled with is updated. /// //===----------------------------------------------------------------------===// #ifndef LLVM_ADT_STLFORWARDCOMPAT_H #define LLVM_ADT_STLFORWARDCOMPAT_H #include #include #include namespace llvm { //===----------------------------------------------------------------------===// // Features from C++20 //===----------------------------------------------------------------------===// namespace numbers { // clang-format off template >> inline constexpr T e_v = T(0x1.5bf0a8b145769P+1); // (2.7182818284590452354) https://oeis.org/A001113 template >> inline constexpr T egamma_v = T(0x1.2788cfc6fb619P-1); // (.57721566490153286061) https://oeis.org/A001620 template >> inline constexpr T ln2_v = T(0x1.62e42fefa39efP-1); // (.69314718055994530942) https://oeis.org/A002162 template >> inline constexpr T ln10_v = T(0x1.26bb1bbb55516P+1); // (2.3025850929940456840) https://oeis.org/A002392 template >> inline constexpr T log2e_v = T(0x1.71547652b82feP+0); // (1.4426950408889634074) template >> inline constexpr T log10e_v = T(0x1.bcb7b1526e50eP-2); // (.43429448190325182765) template >> inline constexpr T pi_v = T(0x1.921fb54442d18P+1); // (3.1415926535897932385) https://oeis.org/A000796 template >> inline constexpr T inv_pi_v = T(0x1.45f306dc9c883P-2); // (.31830988618379067154) https://oeis.org/A049541 template >> inline constexpr T inv_sqrtpi_v = T(0x1.20dd750429b6dP-1); // (.56418958354775628695) https://oeis.org/A087197 template >> inline constexpr T sqrt2_v = T(0x1.6a09e667f3bcdP+0); // (1.4142135623730950488) https://oeis.org/A00219 template >> inline constexpr T inv_sqrt2_v = T(0x1.6a09e667f3bcdP-1); // (.70710678118654752440) template >> inline constexpr T sqrt3_v = T(0x1.bb67ae8584caaP+0); // (1.7320508075688772935) https://oeis.org/A002194 template >> inline constexpr T inv_sqrt3_v = T(0x1.279a74590331cP-1); // (.57735026918962576451) template >> inline constexpr T phi_v = T(0x1.9e3779b97f4a8P+0); // (1.6180339887498948482) https://oeis.org/A001622 inline constexpr double e = e_v; inline constexpr double egamma = egamma_v; inline constexpr double ln2 = ln2_v; inline constexpr double ln10 = ln10_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 sqrt2 = sqrt2_v; inline constexpr double inv_sqrt2 = inv_sqrt2_v; inline constexpr double sqrt3 = sqrt3_v; inline constexpr double inv_sqrt3 = inv_sqrt3_v; inline constexpr double phi = phi_v; // clang-format on } // namespace numbers template struct remove_cvref // NOLINT(readability-identifier-naming) { using type = std::remove_cv_t>; }; template using remove_cvref_t // NOLINT(readability-identifier-naming) = typename llvm::remove_cvref::type; // TODO: Remove this in favor of std::type_identity once we switch to C++20. template struct type_identity // NOLINT(readability-identifier-naming) { using type = T; }; // TODO: Remove this in favor of std::type_identity_t once we switch to // C++20. template using type_identity_t // NOLINT(readability-identifier-naming) = typename llvm::type_identity::type; namespace detail { template class Op, class... Args> struct detector { using value_t = std::false_type; }; template