]> git.tdb.fi Git - ext/openal.git/blob - common/alnumbers.h
Import OpenAL Soft 1.23.1 sources
[ext/openal.git] / common / alnumbers.h
1 #ifndef COMMON_ALNUMBERS_H
2 #define COMMON_ALNUMBERS_H
3
4 #include <utility>
5
6 namespace al {
7
8 namespace numbers {
9
10 namespace detail_ {
11     template<typename T>
12     using as_fp = std::enable_if_t<std::is_floating_point<T>::value, T>;
13 } // detail_
14
15 template<typename T>
16 static constexpr auto pi_v = detail_::as_fp<T>(3.141592653589793238462643383279502884L);
17
18 template<typename T>
19 static constexpr auto inv_pi_v = detail_::as_fp<T>(0.318309886183790671537767526745028724L);
20
21 template<typename T>
22 static constexpr auto sqrt2_v = detail_::as_fp<T>(1.414213562373095048801688724209698079L);
23
24 template<typename T>
25 static constexpr auto sqrt3_v = detail_::as_fp<T>(1.732050807568877293527446341505872367L);
26
27 static constexpr auto pi = pi_v<double>;
28 static constexpr auto inv_pi = inv_pi_v<double>;
29 static constexpr auto sqrt2 = sqrt2_v<double>;
30 static constexpr auto sqrt3 = sqrt3_v<double>;
31
32 } // namespace numbers
33
34 } // namespace al
35
36 #endif /* COMMON_ALNUMBERS_H */