annotate DEPENDENCIES/generic/include/boost/integer/integer_mask.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Boost integer/integer_mask.hpp header file ------------------------------//
Chris@16 2
Chris@16 3 // (C) Copyright Daryle Walker 2001.
Chris@16 4 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 5 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 6 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7
Chris@16 8 // See http://www.boost.org for updates, documentation, and revision history.
Chris@16 9
Chris@16 10 #ifndef BOOST_INTEGER_INTEGER_MASK_HPP
Chris@16 11 #define BOOST_INTEGER_INTEGER_MASK_HPP
Chris@16 12
Chris@16 13 #include <boost/integer_fwd.hpp> // self include
Chris@16 14
Chris@16 15 #include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
Chris@16 16 #include <boost/integer.hpp> // for boost::uint_t
Chris@16 17
Chris@16 18 #include <climits> // for UCHAR_MAX, etc.
Chris@16 19 #include <cstddef> // for std::size_t
Chris@16 20
Chris@16 21 #include <boost/limits.hpp> // for std::numeric_limits
Chris@16 22
Chris@16 23 //
Chris@16 24 // We simply cannot include this header on gcc without getting copious warnings of the kind:
Chris@16 25 //
Chris@16 26 // boost/integer/integer_mask.hpp:93:35: warning: use of C99 long long integer constant
Chris@16 27 //
Chris@16 28 // And yet there is no other reasonable implementation, so we declare this a system header
Chris@16 29 // to suppress these warnings.
Chris@16 30 //
Chris@16 31 #if defined(__GNUC__) && (__GNUC__ >= 4)
Chris@16 32 #pragma GCC system_header
Chris@16 33 #endif
Chris@16 34
Chris@16 35 namespace boost
Chris@16 36 {
Chris@16 37
Chris@16 38
Chris@16 39 // Specified single-bit mask class declaration -----------------------------//
Chris@16 40 // (Lowest bit starts counting at 0.)
Chris@16 41
Chris@16 42 template < std::size_t Bit >
Chris@16 43 struct high_bit_mask_t
Chris@16 44 {
Chris@16 45 typedef typename uint_t<(Bit + 1)>::least least;
Chris@16 46 typedef typename uint_t<(Bit + 1)>::fast fast;
Chris@16 47
Chris@16 48 BOOST_STATIC_CONSTANT( least, high_bit = (least( 1u ) << Bit) );
Chris@16 49 BOOST_STATIC_CONSTANT( fast, high_bit_fast = (fast( 1u ) << Bit) );
Chris@16 50
Chris@16 51 BOOST_STATIC_CONSTANT( std::size_t, bit_position = Bit );
Chris@16 52
Chris@16 53 }; // boost::high_bit_mask_t
Chris@16 54
Chris@16 55
Chris@16 56 // Specified bit-block mask class declaration ------------------------------//
Chris@16 57 // Makes masks for the lowest N bits
Chris@16 58 // (Specializations are needed when N fills up a type.)
Chris@16 59
Chris@16 60 template < std::size_t Bits >
Chris@16 61 struct low_bits_mask_t
Chris@16 62 {
Chris@16 63 typedef typename uint_t<Bits>::least least;
Chris@16 64 typedef typename uint_t<Bits>::fast fast;
Chris@16 65
Chris@16 66 BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(least( 0u )) << Bits )) );
Chris@16 67 BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
Chris@16 68
Chris@16 69 BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
Chris@16 70
Chris@16 71 }; // boost::low_bits_mask_t
Chris@16 72
Chris@16 73
Chris@16 74 #define BOOST_LOW_BITS_MASK_SPECIALIZE( Type ) \
Chris@16 75 template < > struct low_bits_mask_t< std::numeric_limits<Type>::digits > { \
Chris@16 76 typedef std::numeric_limits<Type> limits_type; \
Chris@16 77 typedef uint_t<limits_type::digits>::least least; \
Chris@16 78 typedef uint_t<limits_type::digits>::fast fast; \
Chris@16 79 BOOST_STATIC_CONSTANT( least, sig_bits = (~( least(0u) )) ); \
Chris@16 80 BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) ); \
Chris@16 81 BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \
Chris@16 82 }
Chris@16 83
Chris@16 84 #ifdef BOOST_MSVC
Chris@16 85 #pragma warning(push)
Chris@16 86 #pragma warning(disable:4245) // 'initializing' : conversion from 'int' to 'const boost::low_bits_mask_t<8>::least', signed/unsigned mismatch
Chris@16 87 #endif
Chris@16 88
Chris@16 89 BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
Chris@16 90
Chris@16 91 #if USHRT_MAX > UCHAR_MAX
Chris@16 92 BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned short );
Chris@16 93 #endif
Chris@16 94
Chris@16 95 #if UINT_MAX > USHRT_MAX
Chris@16 96 BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
Chris@16 97 #endif
Chris@16 98
Chris@16 99 #if ULONG_MAX > UINT_MAX
Chris@16 100 BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
Chris@16 101 #endif
Chris@16 102
Chris@16 103 #if defined(BOOST_HAS_LONG_LONG)
Chris@16 104 #if ((defined(ULLONG_MAX) && (ULLONG_MAX > ULONG_MAX)) ||\
Chris@16 105 (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX > ULONG_MAX)) ||\
Chris@16 106 (defined(ULONGLONG_MAX) && (ULONGLONG_MAX > ULONG_MAX)) ||\
Chris@16 107 (defined(_ULLONG_MAX) && (_ULLONG_MAX > ULONG_MAX)))
Chris@16 108 BOOST_LOW_BITS_MASK_SPECIALIZE( boost::ulong_long_type );
Chris@16 109 #endif
Chris@16 110 #elif defined(BOOST_HAS_MS_INT64)
Chris@16 111 #if 18446744073709551615ui64 > ULONG_MAX
Chris@16 112 BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned __int64 );
Chris@16 113 #endif
Chris@16 114 #endif
Chris@16 115
Chris@16 116 #ifdef BOOST_MSVC
Chris@16 117 #pragma warning(pop)
Chris@16 118 #endif
Chris@16 119
Chris@16 120 #undef BOOST_LOW_BITS_MASK_SPECIALIZE
Chris@16 121
Chris@16 122
Chris@16 123 } // namespace boost
Chris@16 124
Chris@16 125
Chris@16 126 #endif // BOOST_INTEGER_INTEGER_MASK_HPP