Created
October 10, 2022 05:02
-
-
Save sthalik/563989f7ca892570d9fb62082e2207b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _MSC_VER | |
#define CORRADE_CXX_STANDARD _MSVC_LANG | |
#else | |
#define CORRADE_CXX_STANDARD __cplusplus | |
#endif | |
#if defined(__clang__) && __clang_major__ >= 9 || defined(__GNUG__) && __GNUG__ >= 9 || defined(_MSC_VER) && _MSC_VER >= 1931 | |
#define CORRADE_CONSTEVAL (__builtin_is_constant_evaluated()) | |
#elif CORRADE_CXX_STANDARD >= 202002L | |
#define CORRADE_CONSTEVAL (std::is_constant_evaluated()) /*include type_traits*/ | |
#elif __cpp_if_constexpr >= 201606 | |
#define CORRADE_CONSTEVAL constexpr(false) | |
#else | |
#define CORRADE_CONSTEVAL (false) | |
#define CORRADE_NO_CONSTEVAL | |
#endif | |
#define STRINGIFY2(x) #x | |
#define STRINGIFY(x) STRINGIFY2(x) | |
#define _USE_MATH_DEFINES | |
#include <cmath> | |
#include <cstdio> | |
constexpr float maybe_get_pi() | |
{ | |
if CORRADE_CONSTEVAL | |
return 3.14; | |
else | |
return std::atan(1.f)*4; | |
} | |
template<typename T> constexpr float my_abs(T x) { return x < 0 ? -x : x; } | |
#ifdef _MSC_VER | |
#define VERSION msvc _MSVC_LANG | |
#elif defined __clang__ | |
#define VERSION clang __clang__ __clang_minor__ | |
#elif defined __GNUG__ | |
#define VERSION gcc __GNUC__ __GNUC_MINOR__ | |
#else | |
#define VERSION dunno | |
#endif | |
extern const volatile char* str; | |
const volatile char* str = STRINGIFY(VERSION); | |
static_assert(my_abs(maybe_get_pi() - M_PI) > 1e-3, ""); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment