Compile time math utilities
[sol.git] / sol / math / sign.hpp
blob7a05e3d49977a30753a05229ec6ed3a29f2e71c3
1 #if !defined(sol_math_sign_hpp_included)
2 #define sol_math_sign_hpp_included
3 /// \addtogroup sol_math
4 /// \{
7 /**
8 * \file sol/math/sign.hpp
9 * \brief Compile-time sign taking
10 * \author Sven Suursoho
14 #include <sol/cstdint.hpp>
17 namespace sol { namespace math {
20 /// Take sign of V during compile-time
21 template <intmax_t V>
22 struct sign
24 /// Has -1 if V is less than zero and 1 otherwise
25 static int const value = (V < 0) ? -1 : 1;
29 }} // namespace sol::math
32 /// \}
33 #endif // sol_math_sign_hpp_included