17 #include <type_traits>
35 constexpr
bool hasFeature<LanguageFeature::exceptions>() noexcept {
41 constexpr
bool hasFeature<LanguageFeature::rtti>() noexcept {
47 constexpr
bool hasFeature<LanguageFeature::threads>() noexcept {
53 constexpr
bool hasFeature<LanguageFeature::atomic_operations>() noexcept {
59 constexpr
bool hasFeature<LanguageFeature::inline_assembly>() noexcept {
65 constexpr
bool hasFeature<LanguageFeature::vector_intrinsics>() noexcept {
71 constexpr
bool hasFeature<LanguageFeature::stack_protection>() noexcept {
77 constexpr
bool hasFeature<LanguageFeature::address_sanitizer>() noexcept {
83 constexpr
bool hasFeature<LanguageFeature::thread_sanitizer>() noexcept {
89 constexpr
bool hasFeature<LanguageFeature::memory_sanitizer>() noexcept {
102 template <RuntimeFeature TFeature>
109 inline bool hasRuntimeFeature<RuntimeFeature::sse>() noexcept {
114 inline bool hasRuntimeFeature<RuntimeFeature::sse2>() noexcept {
119 inline bool hasRuntimeFeature<RuntimeFeature::sse3>() noexcept {
124 inline bool hasRuntimeFeature<RuntimeFeature::sse4_1>() noexcept {
129 inline bool hasRuntimeFeature<RuntimeFeature::sse4_2>() noexcept {
134 inline bool hasRuntimeFeature<RuntimeFeature::avx>() noexcept {
139 inline bool hasRuntimeFeature<RuntimeFeature::avx2>() noexcept {
144 inline bool hasRuntimeFeature<RuntimeFeature::avx512f>() noexcept {
149 inline bool hasRuntimeFeature<RuntimeFeature::neon>() noexcept {
159 #if __cplusplus >= 201703L
161 template <
bool B,
class T =
void>
168 template <
bool B,
class T =
void>
169 using enable_if_t =
typename std::enable_if<B, T>::type;
183 template <LanguageFeature TFeature>
190 template <LanguageFeature TFeature>
218 return (hasFeature<Features>() && ...);
228 return (hasFeature<Features>() || ...);
238 return (
static_cast<std::size_t
>(hasFeature<Features>()) + ...);
249 template <LanguageFeature TFeature>
256 template <LanguageFeature TFeature>
295 template <RuntimeFeature TFeature>
297 static bool value() noexcept {
return hasRuntimeFeature<TFeature>(); }
309 template <LanguageFeature TFeature>
311 return hasFeature<TFeature>();
318 template <LanguageFeature TFeature>
333 #define TRLC_HAS_LANGUAGE_FEATURE(feature) \
334 (trlc::platform::hasFeature<trlc::platform::LanguageFeature::feature>())
340 #define TRLC_HAS_RUNTIME_FEATURE(feature) \
341 (trlc::platform::hasRuntimeFeature<trlc::platform::RuntimeFeature::feature>())
347 #define TRLC_IF_LANGUAGE_FEATURE(feature) \
348 if constexpr (trlc::platform::hasFeature<trlc::platform::LanguageFeature::feature>())
354 #define TRLC_IF_NO_LANGUAGE_FEATURE(feature) \
355 if constexpr (!trlc::platform::hasFeature<trlc::platform::LanguageFeature::feature>())
361 #define TRLC_REQUIRE_FEATURE(feature) \
362 template <typename = trlc::platform::traits::enable_if_feature_t< \
363 trlc::platform::LanguageFeature::feature>>
369 #define TRLC_REQUIRE_NO_FEATURE(feature) \
370 template <typename = trlc::platform::traits::enable_if_no_feature_t< \
371 trlc::platform::LanguageFeature::feature>>
377 #define TRLC_HAS_ALL_FEATURES(...) (trlc::platform::traits::hasAllFeatures<__VA_ARGS__>())
383 #define TRLC_HAS_ANY_FEATURES(...) (trlc::platform::traits::hasAnyFeature<__VA_ARGS__>())
Language and runtime feature detection utilities.