16 #ifndef OPENKALMAN_LANGUAGE_FEATURES_HPP 17 #define OPENKALMAN_LANGUAGE_FEATURES_HPP 20 # define OPENKALMAN_CPP_FEATURE_CONCEPTS true 21 # define OPENKALMAN_CPP_FEATURE_CONCEPTS_2 (__clang_major__ >= 15) // optimal value may be as low as > 10 (ver. 10.0.0) 22 #elif defined(__GNUC__) 23 # define OPENKALMAN_CPP_FEATURE_CONCEPTS (__GNUC__ >= 20) // optimal value may be as low as > 10 (ver. 10.1.0) 24 # define OPENKALMAN_CPP_FEATURE_CONCEPTS_2 (__GNUC__ >= 12) // optimal value may be as low as > 10 (ver. 10.1.0) 26 # define OPENKALMAN_CPP_FEATURE_CONCEPTS true 27 # define OPENKALMAN_CPP_FEATURE_CONCEPTS_2 true 32 #include <type_traits> 36 #ifdef __cpp_lib_math_constants 40 #ifdef __cpp_lib_concepts 49 constexpr std::size_t
operator ""_uz(
unsigned long long x) {
return x; };
56 #ifdef __cpp_lib_math_constants 57 using namespace std::numbers;
59 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T e_v = 2.718281828459045235360287471352662498L;
60 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T log2e_v = 1.442695040888963407359924681001892137L;
61 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T log10e_v = 0.434294481903251827651128918916605082L;
62 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T pi_v = 3.141592653589793238462643383279502884L;
63 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T inv_pi_v = 0.318309886183790671537767526745028724L;
64 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T inv_sqrtpi_v = 0.564189583547756286948079451560772586L;
65 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T ln2_v = 0.693147180559945309417232121458176568L;
66 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T ln10_v = 2.302585092994045684017991454684364208L;
67 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T sqrt2_v = 1.414213562373095048801688724209698079L;
68 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T sqrt3_v = 1.732050807568877293527446341505872367L;
69 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T inv_sqrt3_v = 0.577350269189625764509148780501957456L;
70 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T egamma_v = 0.577215664901532860606512090082402431L;
71 template<
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>,
int> = 0>
inline constexpr T phi_v = 1.618033988749894848204586834365638118L;
73 inline constexpr
double e = e_v<double>;
74 inline constexpr
double log2e = log2e_v<double>;
75 inline constexpr
double log10e = log10e_v<double>;
76 inline constexpr
double pi = pi_v<double>;
77 inline constexpr
double inv_pi = inv_pi_v<double>;
78 inline constexpr
double inv_sqrtpi = inv_sqrtpi_v<double>;
79 inline constexpr
double ln2 = ln2_v<double>;
80 inline constexpr
double ln10 = ln10_v<double>;
81 inline constexpr
double sqrt2 = sqrt2_v<double>;
82 inline constexpr
double sqrt3 = sqrt3_v<double>;
83 inline constexpr
double inv_sqrt3 = inv_sqrt3_v<double>;
84 inline constexpr
double egamma = egamma_v<double>;
85 inline constexpr
double phi = phi_v<double>;
90 #ifdef __cpp_lib_remove_cvref 91 using std::remove_cvref;
92 using std::remove_cvref_t;
95 struct remove_cvref {
using type = std::remove_cv_t<std::remove_reference_t<T>>; };
98 using remove_cvref_t =
typename remove_cvref<T>::type;
102 #ifdef __cpp_lib_bounded_array_traits 103 using std::is_bounded_array;
104 using std::is_bounded_array_v;
109 template<
typename T, std::
size_t N>
117 #if __cplusplus >= 202002L 118 using std::reference_wrapper;
128 template<
typename T> constexpr T& reference_wrapper_FUN(T& t) noexcept {
return t; }
129 template<
typename T>
void reference_wrapper_FUN(T&&) =
delete;
138 template<
typename U,
typename = std::
void_t<decltype(detail::reference_wrapper_FUN<T>(std::declval<U>()))>,
139 std::enable_if_t<not std::is_same_v<reference_wrapper, stdex::remove_cvref_t<U>>,
int> = 0>
140 constexpr
reference_wrapper(U&& u) noexcept(noexcept(detail::reference_wrapper_FUN<T>(std::forward<U>(u))))
141 : ptr(std::addressof(detail::reference_wrapper_FUN<T>(std::forward<U>(u)))) {}
150 constexpr
operator T& ()
const noexcept {
return *ptr; }
151 constexpr T&
get()
const noexcept {
return *ptr; }
154 template<
typename... ArgTypes>
155 constexpr std::invoke_result_t<T&, ArgTypes...>
156 operator() (ArgTypes&&... args )
const noexcept(std::is_nothrow_invocable_v<T&, ArgTypes...>)
158 return get()(std::forward<ArgTypes>(args)...);
173 constexpr std::reference_wrapper<T>
174 ref(T& t) noexcept {
return {t}; };
177 constexpr std::reference_wrapper<T>
178 ref(std::reference_wrapper<T> t) noexcept {
return std::move(t); };
181 void ref(
const T&&) =
delete;
184 constexpr std::reference_wrapper<const T>
185 cref(
const T& t) noexcept {
return {t}; };
188 constexpr std::reference_wrapper<const T>
189 cref(std::reference_wrapper<T> t) noexcept {
return std::move(t); };
192 void cref(
const T&&) =
delete;
196 #ifdef __cpp_lib_unwrap_ref 197 using std::unwrap_reference;
198 using std::unwrap_reference_t;
199 using std::unwrap_ref_decay;
200 using std::unwrap_ref_decay_t;
208 #if __cplusplus < 202002L 214 using unwrap_reference_t =
typename unwrap_reference<T>::type;
221 using unwrap_ref_decay_t =
typename unwrap_ref_decay<T>::type;
225 #if __cplusplus >= 202002L 231 [[nodiscard]] constexpr T&& operator()(T&& t)
const noexcept {
return std::forward<T>(t); }
233 struct is_transparent;
238 #ifdef __cpp_lib_type_identity 239 using std::type_identity;
240 using std::type_identity_t;
246 using type_identity_t =
typename type_identity<T>::type;
Definition: language-features.hpp:218
Definition: language-features.hpp:95
Definition: language-features.hpp:228
Definition: language-features.hpp:107
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition: language-features.hpp:134
Definition: language-features.hpp:203
Definition: language-features.hpp:243