integral_by_size.hpp 966 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef BOOST_ENDIAN_DETAIL_INTEGRAL_BY_SIZE_HPP_INCLUDED
  2. #define BOOST_ENDIAN_DETAIL_INTEGRAL_BY_SIZE_HPP_INCLUDED
  3. // Copyright 2019 Peter Dimov
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. #include <boost/cstdint.hpp>
  8. #include <boost/config.hpp>
  9. #include <cstddef>
  10. namespace boost
  11. {
  12. namespace endian
  13. {
  14. namespace detail
  15. {
  16. template<std::size_t N> struct integral_by_size
  17. {
  18. };
  19. template<> struct integral_by_size<1>
  20. {
  21. typedef uint8_t type;
  22. };
  23. template<> struct integral_by_size<2>
  24. {
  25. typedef uint16_t type;
  26. };
  27. template<> struct integral_by_size<4>
  28. {
  29. typedef uint32_t type;
  30. };
  31. template<> struct integral_by_size<8>
  32. {
  33. typedef uint64_t type;
  34. };
  35. #if defined(BOOST_HAS_INT128)
  36. template<> struct integral_by_size<16>
  37. {
  38. typedef uint128_type type;
  39. };
  40. #endif
  41. } // namespace detail
  42. } // namespace endian
  43. } // namespace boost
  44. #endif // BOOST_ENDIAN_DETAIL_INTEGRAL_BY_SIZE_HPP_INCLUDED