xref: /freebsd/contrib/llvm-project/libcxx/include/numbers (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
15ffd83dbSDimitry Andric// -*- C++ -*-
2349cc55cSDimitry Andric//===----------------------------------------------------------------------===//
35ffd83dbSDimitry Andric//
45ffd83dbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
55ffd83dbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
65ffd83dbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
75ffd83dbSDimitry Andric//
85ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
95ffd83dbSDimitry Andric
105ffd83dbSDimitry Andric#ifndef _LIBCPP_NUMBERS
115ffd83dbSDimitry Andric#define _LIBCPP_NUMBERS
125ffd83dbSDimitry Andric
135ffd83dbSDimitry Andric/*
145ffd83dbSDimitry Andric    numbers synopsis
155ffd83dbSDimitry Andric
165ffd83dbSDimitry Andricnamespace std::numbers {
175ffd83dbSDimitry Andric  template<class T> inline constexpr T e_v          = unspecified;
185ffd83dbSDimitry Andric  template<class T> inline constexpr T log2e_v      = unspecified;
195ffd83dbSDimitry Andric  template<class T> inline constexpr T log10e_v     = unspecified;
205ffd83dbSDimitry Andric  template<class T> inline constexpr T pi_v         = unspecified;
215ffd83dbSDimitry Andric  template<class T> inline constexpr T inv_pi_v     = unspecified;
225ffd83dbSDimitry Andric  template<class T> inline constexpr T inv_sqrtpi_v = unspecified;
235ffd83dbSDimitry Andric  template<class T> inline constexpr T ln2_v        = unspecified;
245ffd83dbSDimitry Andric  template<class T> inline constexpr T ln10_v       = unspecified;
255ffd83dbSDimitry Andric  template<class T> inline constexpr T sqrt2_v      = unspecified;
265ffd83dbSDimitry Andric  template<class T> inline constexpr T sqrt3_v      = unspecified;
275ffd83dbSDimitry Andric  template<class T> inline constexpr T inv_sqrt3_v  = unspecified;
285ffd83dbSDimitry Andric  template<class T> inline constexpr T egamma_v     = unspecified;
295ffd83dbSDimitry Andric  template<class T> inline constexpr T phi_v        = unspecified;
305ffd83dbSDimitry Andric
315ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T e_v<T>          = see below;
325ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T log2e_v<T>      = see below;
335ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T log10e_v<T>     = see below;
345ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T pi_v<T>         = see below;
355ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T inv_pi_v<T>     = see below;
365ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T inv_sqrtpi_v<T> = see below;
375ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T ln2_v<T>        = see below;
385ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T ln10_v<T>       = see below;
395ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T sqrt2_v<T>      = see below;
405ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T sqrt3_v<T>      = see below;
415ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T inv_sqrt3_v<T>  = see below;
425ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T egamma_v<T>     = see below;
435ffd83dbSDimitry Andric  template<floating_point T> inline constexpr T phi_v<T>        = see below;
445ffd83dbSDimitry Andric
455ffd83dbSDimitry Andric  inline constexpr double e          = e_v<double>;
465ffd83dbSDimitry Andric  inline constexpr double log2e      = log2e_v<double>;
475ffd83dbSDimitry Andric  inline constexpr double log10e     = log10e_v<double>;
485ffd83dbSDimitry Andric  inline constexpr double pi         = pi_v<double>;
495ffd83dbSDimitry Andric  inline constexpr double inv_pi     = inv_pi_v<double>;
505ffd83dbSDimitry Andric  inline constexpr double inv_sqrtpi = inv_sqrtpi_v<double>;
515ffd83dbSDimitry Andric  inline constexpr double ln2        = ln2_v<double>;
525ffd83dbSDimitry Andric  inline constexpr double ln10       = ln10_v<double>;
535ffd83dbSDimitry Andric  inline constexpr double sqrt2      = sqrt2_v<double>;
545ffd83dbSDimitry Andric  inline constexpr double sqrt3      = sqrt3_v<double>;
555ffd83dbSDimitry Andric  inline constexpr double inv_sqrt3  = inv_sqrt3_v<double>;
565ffd83dbSDimitry Andric  inline constexpr double egamma     = egamma_v<double>;
575ffd83dbSDimitry Andric  inline constexpr double phi        = phi_v<double>;
585ffd83dbSDimitry Andric}
595ffd83dbSDimitry Andric*/
605ffd83dbSDimitry Andric
61bdd1243dSDimitry Andric#include <__concepts/arithmetic.h>
625ffd83dbSDimitry Andric#include <__config>
635ffd83dbSDimitry Andric#include <version>
645ffd83dbSDimitry Andric
6506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
66fe6060f1SDimitry Andric
675ffd83dbSDimitry Andric#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
685ffd83dbSDimitry Andric#    pragma GCC system_header
695ffd83dbSDimitry Andric#  endif
705ffd83dbSDimitry Andric
715ffd83dbSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
725ffd83dbSDimitry Andric
735ffd83dbSDimitry Andricnamespace numbers {
745ffd83dbSDimitry Andric
7504eeddc0SDimitry Andrictemplate <class _Tp>
765ffd83dbSDimitry Andricinline constexpr bool __false = false;
775ffd83dbSDimitry Andric
7804eeddc0SDimitry Andrictemplate <class _Tp>
79*cb14a3feSDimitry Andricstruct __illformed {
80*cb14a3feSDimitry Andric  static_assert(
81*cb14a3feSDimitry Andric      __false<_Tp>,
82*cb14a3feSDimitry Andric      "A program that instantiates a primary template of a mathematical constant variable template is ill-formed.");
835ffd83dbSDimitry Andric};
845ffd83dbSDimitry Andric
85*cb14a3feSDimitry Andrictemplate <class _Tp>
86*cb14a3feSDimitry Andricinline constexpr _Tp e_v = __illformed<_Tp>{};
87*cb14a3feSDimitry Andrictemplate <class _Tp>
88*cb14a3feSDimitry Andricinline constexpr _Tp log2e_v = __illformed<_Tp>{};
89*cb14a3feSDimitry Andrictemplate <class _Tp>
90*cb14a3feSDimitry Andricinline constexpr _Tp log10e_v = __illformed<_Tp>{};
91*cb14a3feSDimitry Andrictemplate <class _Tp>
92*cb14a3feSDimitry Andricinline constexpr _Tp pi_v = __illformed<_Tp>{};
93*cb14a3feSDimitry Andrictemplate <class _Tp>
94*cb14a3feSDimitry Andricinline constexpr _Tp inv_pi_v = __illformed<_Tp>{};
95*cb14a3feSDimitry Andrictemplate <class _Tp>
96*cb14a3feSDimitry Andricinline constexpr _Tp inv_sqrtpi_v = __illformed<_Tp>{};
97*cb14a3feSDimitry Andrictemplate <class _Tp>
98*cb14a3feSDimitry Andricinline constexpr _Tp ln2_v = __illformed<_Tp>{};
99*cb14a3feSDimitry Andrictemplate <class _Tp>
100*cb14a3feSDimitry Andricinline constexpr _Tp ln10_v = __illformed<_Tp>{};
101*cb14a3feSDimitry Andrictemplate <class _Tp>
102*cb14a3feSDimitry Andricinline constexpr _Tp sqrt2_v = __illformed<_Tp>{};
103*cb14a3feSDimitry Andrictemplate <class _Tp>
104*cb14a3feSDimitry Andricinline constexpr _Tp sqrt3_v = __illformed<_Tp>{};
105*cb14a3feSDimitry Andrictemplate <class _Tp>
106*cb14a3feSDimitry Andricinline constexpr _Tp inv_sqrt3_v = __illformed<_Tp>{};
107*cb14a3feSDimitry Andrictemplate <class _Tp>
108*cb14a3feSDimitry Andricinline constexpr _Tp egamma_v = __illformed<_Tp>{};
109*cb14a3feSDimitry Andrictemplate <class _Tp>
110*cb14a3feSDimitry Andricinline constexpr _Tp phi_v = __illformed<_Tp>{};
1115ffd83dbSDimitry Andric
112*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
113*cb14a3feSDimitry Andricinline constexpr _Tp e_v<_Tp> = 2.718281828459045235360287471352662;
114*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
115*cb14a3feSDimitry Andricinline constexpr _Tp log2e_v<_Tp> = 1.442695040888963407359924681001892;
116*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
117*cb14a3feSDimitry Andricinline constexpr _Tp log10e_v<_Tp> = 0.434294481903251827651128918916605;
118*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
119*cb14a3feSDimitry Andricinline constexpr _Tp pi_v<_Tp> = 3.141592653589793238462643383279502;
120*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
121*cb14a3feSDimitry Andricinline constexpr _Tp inv_pi_v<_Tp> = 0.318309886183790671537767526745028;
122*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
123*cb14a3feSDimitry Andricinline constexpr _Tp inv_sqrtpi_v<_Tp> = 0.564189583547756286948079451560772;
124*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
125*cb14a3feSDimitry Andricinline constexpr _Tp ln2_v<_Tp> = 0.693147180559945309417232121458176;
126*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
127*cb14a3feSDimitry Andricinline constexpr _Tp ln10_v<_Tp> = 2.302585092994045684017991454684364;
128*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
129*cb14a3feSDimitry Andricinline constexpr _Tp sqrt2_v<_Tp> = 1.414213562373095048801688724209698;
130*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
131*cb14a3feSDimitry Andricinline constexpr _Tp sqrt3_v<_Tp> = 1.732050807568877293527446341505872;
132*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
133*cb14a3feSDimitry Andricinline constexpr _Tp inv_sqrt3_v<_Tp> = 0.577350269189625764509148780501957;
134*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
135*cb14a3feSDimitry Andricinline constexpr _Tp egamma_v<_Tp> = 0.577215664901532860606512090082402;
136*cb14a3feSDimitry Andrictemplate <floating_point _Tp>
137*cb14a3feSDimitry Andricinline constexpr _Tp phi_v<_Tp> = 1.618033988749894848204586834365638;
1385ffd83dbSDimitry Andric
1395ffd83dbSDimitry Andricinline constexpr double e          = e_v<double>;
1405ffd83dbSDimitry Andricinline constexpr double log2e      = log2e_v<double>;
1415ffd83dbSDimitry Andricinline constexpr double log10e     = log10e_v<double>;
1425ffd83dbSDimitry Andricinline constexpr double pi         = pi_v<double>;
1435ffd83dbSDimitry Andricinline constexpr double inv_pi     = inv_pi_v<double>;
1445ffd83dbSDimitry Andricinline constexpr double inv_sqrtpi = inv_sqrtpi_v<double>;
1455ffd83dbSDimitry Andricinline constexpr double ln2        = ln2_v<double>;
1465ffd83dbSDimitry Andricinline constexpr double ln10       = ln10_v<double>;
1475ffd83dbSDimitry Andricinline constexpr double sqrt2      = sqrt2_v<double>;
1485ffd83dbSDimitry Andricinline constexpr double sqrt3      = sqrt3_v<double>;
1495ffd83dbSDimitry Andricinline constexpr double inv_sqrt3  = inv_sqrt3_v<double>;
1505ffd83dbSDimitry Andricinline constexpr double egamma     = egamma_v<double>;
1515ffd83dbSDimitry Andricinline constexpr double phi        = phi_v<double>;
1525ffd83dbSDimitry Andric
1535ffd83dbSDimitry Andric} // namespace numbers
1545ffd83dbSDimitry Andric
1555ffd83dbSDimitry Andric_LIBCPP_END_NAMESPACE_STD
1565ffd83dbSDimitry Andric
15706c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
1585ffd83dbSDimitry Andric
159bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
160bdd1243dSDimitry Andric#  include <concepts>
161bdd1243dSDimitry Andric#  include <type_traits>
162bdd1243dSDimitry Andric#endif
163bdd1243dSDimitry Andric
1645ffd83dbSDimitry Andric#endif // _LIBCPP_NUMBERS
165