Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <type_traits> 7 : 8 : namespace tt { 9 : /// @{ 10 : /*! 11 : * \ingroup TypeTraitsGroup 12 : * \brief Check if `I` is an integer type (non-bool, non-character), unlike 13 : * std::is_integral 14 : * 15 : * \details 16 : * Inherits from `std::true_type` if `I` is a `short`, `unsigned short`, 17 : * `int`, `unsigned int`, `long`, `unsigned long`, `long long`, or 18 : * `unsigned long long`, otherwise inherits from `std::false_type`. 19 : * 20 : * \usage 21 : * For any type `I`, 22 : * \code 23 : * using result = tt::is_integer<I>; 24 : * \endcode 25 : * \metareturns 26 : * std::bool_constant 27 : * 28 : * \example 29 : * \snippet Test_IsInteger.cpp is_integer_example 30 : * \see std::is_integral std::is_arithmetic std::is_floating_point 31 : */ 32 : template <typename I> 33 1 : struct is_integer : std::false_type {}; 34 : 35 : /// \cond HIDDEN_SYMBOLS 36 : template <> 37 : struct is_integer<short> : std::true_type {}; 38 : 39 : template <> 40 : struct is_integer<unsigned short> : std::true_type {}; 41 : 42 : template <> 43 : struct is_integer<int> : std::true_type {}; 44 : 45 : template <> 46 : struct is_integer<unsigned int> : std::true_type {}; 47 : 48 : template <> 49 : struct is_integer<long> : std::true_type {}; 50 : 51 : template <> 52 : struct is_integer<unsigned long> : std::true_type {}; 53 : 54 : template <> 55 : struct is_integer<long long> : std::true_type {}; 56 : 57 : template <> 58 : struct is_integer<unsigned long long> : std::true_type {}; 59 : /// \endcond 60 : 61 : /// \see is_integer 62 : template <typename T> 63 1 : constexpr bool is_integer_v = is_integer<T>::value; 64 : /// @} 65 : } // namespace tt