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