File indexing completed on 2024-11-15 09:14:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_INTEGER_INTEGER_MASK_HPP
0011 #define BOOST_INTEGER_INTEGER_MASK_HPP
0012
0013 #include <boost/integer_fwd.hpp> // self include
0014
0015 #include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
0016 #include <boost/integer.hpp> // for boost::uint_t
0017
0018 #include <climits> // for UCHAR_MAX, etc.
0019 #include <cstddef> // for std::size_t
0020
0021 #include <boost/limits.hpp> // for std::numeric_limits
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #if defined(__GNUC__) && (__GNUC__ >= 4)
0032 #pragma GCC system_header
0033 #endif
0034
0035 namespace boost
0036 {
0037
0038
0039
0040
0041
0042 template < std::size_t Bit >
0043 struct high_bit_mask_t
0044 {
0045 typedef typename uint_t<(Bit + 1)>::least least;
0046 typedef typename uint_t<(Bit + 1)>::fast fast;
0047
0048 BOOST_STATIC_CONSTANT( least, high_bit = (least( 1u ) << Bit) );
0049 BOOST_STATIC_CONSTANT( fast, high_bit_fast = (fast( 1u ) << Bit) );
0050
0051 BOOST_STATIC_CONSTANT( std::size_t, bit_position = Bit );
0052
0053 };
0054
0055
0056
0057
0058
0059
0060 #ifdef BOOST_MSVC
0061 #pragma warning(push)
0062 #pragma warning(disable:4310)
0063 #endif
0064
0065 template < std::size_t Bits >
0066 struct low_bits_mask_t
0067 {
0068 typedef typename uint_t<Bits>::least least;
0069 typedef typename uint_t<Bits>::fast fast;
0070
0071 BOOST_STATIC_CONSTANT( least, sig_bits = least(~(least(~(least( 0u ))) << Bits )) );
0072 BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
0073
0074 BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
0075
0076 };
0077
0078 #ifdef BOOST_MSVC
0079 #pragma warning(pop)
0080 #endif
0081
0082 #define BOOST_LOW_BITS_MASK_SPECIALIZE( Type ) \
0083 template < > struct low_bits_mask_t< std::numeric_limits<Type>::digits > { \
0084 typedef std::numeric_limits<Type> limits_type; \
0085 typedef uint_t<limits_type::digits>::least least; \
0086 typedef uint_t<limits_type::digits>::fast fast; \
0087 BOOST_STATIC_CONSTANT( least, sig_bits = (~( least(0u) )) ); \
0088 BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) ); \
0089 BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \
0090 }
0091
0092 #ifdef BOOST_MSVC
0093 #pragma warning(push)
0094 #pragma warning(disable:4245)
0095 #endif
0096
0097 BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
0098
0099 #if USHRT_MAX > UCHAR_MAX
0100 BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned short );
0101 #endif
0102
0103 #if UINT_MAX > USHRT_MAX
0104 BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
0105 #endif
0106
0107 #if ULONG_MAX > UINT_MAX
0108 BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
0109 #endif
0110
0111 #if defined(BOOST_HAS_LONG_LONG)
0112 #if ((defined(ULLONG_MAX) && (ULLONG_MAX > ULONG_MAX)) ||\
0113 (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX > ULONG_MAX)) ||\
0114 (defined(ULONGLONG_MAX) && (ULONGLONG_MAX > ULONG_MAX)) ||\
0115 (defined(_ULLONG_MAX) && (_ULLONG_MAX > ULONG_MAX)))
0116 BOOST_LOW_BITS_MASK_SPECIALIZE( boost::ulong_long_type );
0117 #endif
0118 #elif defined(BOOST_HAS_MS_INT64)
0119 #if 18446744073709551615ui64 > ULONG_MAX
0120 BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned __int64 );
0121 #endif
0122 #endif
0123
0124 #ifdef BOOST_MSVC
0125 #pragma warning(pop)
0126 #endif
0127
0128 #undef BOOST_LOW_BITS_MASK_SPECIALIZE
0129
0130
0131 }
0132
0133
0134 #endif