numeric.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2021 Duowan Inc. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing,
  11. * software distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef __X_PACK_NUMERIC_H
  17. #define __X_PACK_NUMERIC_H
  18. namespace xpack {
  19. template <class T>
  20. struct numeric{static bool const value = false; static bool const is_integer = false;static bool const is_float = false;};
  21. template<>
  22. struct numeric<char>{static bool const value = true; static bool const is_integer = true;};
  23. template<>
  24. struct numeric<signed char>{static bool const value = true; static bool const is_integer = true;};
  25. template<>
  26. struct numeric<unsigned char>{static bool const value = true; static bool const is_integer = true;};
  27. template<>
  28. struct numeric<short>{static bool const value = true; static bool const is_integer = true;};
  29. template<>
  30. struct numeric<unsigned short>{static bool const value = true; static bool const is_integer = true;};
  31. template<>
  32. struct numeric<int>{static bool const value = true; static bool const is_integer = true;};
  33. template<>
  34. struct numeric<unsigned int>{static bool const value = true; static bool const is_integer = true;};
  35. template<>
  36. struct numeric<long>{static bool const value = true; static bool const is_integer = true;};
  37. template<>
  38. struct numeric<unsigned long>{static bool const value = true; static bool const is_integer = true;};
  39. template<>
  40. struct numeric<long long>{static bool const value = true; static bool const is_integer = true;};
  41. template<>
  42. struct numeric<unsigned long long>{static bool const value = true; static bool const is_integer = true;};
  43. template<>
  44. struct numeric<float>{static bool const value = true;static bool const is_float = true;};
  45. template<>
  46. struct numeric<double>{static bool const value = true;static bool const is_float = true;};
  47. template<>
  48. struct numeric<long double>{static bool const value = true;static bool const is_float = true;};
  49. }
  50. #endif