1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/integer/integer_mask.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,93 @@
1.4 +// Boost integer/integer_mask.hpp header file ------------------------------//
1.5 +
1.6 +// (C) Copyright Daryle Walker 2001.
1.7 +// Distributed under the Boost Software License, Version 1.0. (See
1.8 +// accompanying file LICENSE_1_0.txt or copy at
1.9 +// http://www.boost.org/LICENSE_1_0.txt)
1.10 +
1.11 +// See http://www.boost.org for updates, documentation, and revision history.
1.12 +
1.13 +#ifndef BOOST_INTEGER_INTEGER_MASK_HPP
1.14 +#define BOOST_INTEGER_INTEGER_MASK_HPP
1.15 +
1.16 +#include <boost/integer_fwd.hpp> // self include
1.17 +
1.18 +#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
1.19 +#include <boost/integer.hpp> // for boost::uint_t
1.20 +
1.21 +#include <climits> // for UCHAR_MAX, etc.
1.22 +#include <cstddef> // for std::size_t
1.23 +
1.24 +#include <boost/limits.hpp> // for std::numeric_limits
1.25 +
1.26 +
1.27 +namespace boost
1.28 +{
1.29 +
1.30 +
1.31 +// Specified single-bit mask class declaration -----------------------------//
1.32 +// (Lowest bit starts counting at 0.)
1.33 +
1.34 +template < std::size_t Bit >
1.35 +struct high_bit_mask_t
1.36 +{
1.37 + typedef typename uint_t<(Bit + 1)>::least least;
1.38 + typedef typename uint_t<(Bit + 1)>::fast fast;
1.39 +
1.40 + BOOST_STATIC_CONSTANT( least, high_bit = (least( 1u ) << Bit) );
1.41 + BOOST_STATIC_CONSTANT( fast, high_bit_fast = (fast( 1u ) << Bit) );
1.42 +
1.43 + BOOST_STATIC_CONSTANT( std::size_t, bit_position = Bit );
1.44 +
1.45 +}; // boost::high_bit_mask_t
1.46 +
1.47 +
1.48 +// Specified bit-block mask class declaration ------------------------------//
1.49 +// Makes masks for the lowest N bits
1.50 +// (Specializations are needed when N fills up a type.)
1.51 +
1.52 +template < std::size_t Bits >
1.53 +struct low_bits_mask_t
1.54 +{
1.55 + typedef typename uint_t<Bits>::least least;
1.56 + typedef typename uint_t<Bits>::fast fast;
1.57 +
1.58 + BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(least( 0u )) << Bits )) );
1.59 + BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
1.60 +
1.61 + BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
1.62 +
1.63 +}; // boost::low_bits_mask_t
1.64 +
1.65 +
1.66 +#define BOOST_LOW_BITS_MASK_SPECIALIZE( Type ) \
1.67 + template < > struct low_bits_mask_t< std::numeric_limits<Type>::digits > { \
1.68 + typedef std::numeric_limits<Type> limits_type; \
1.69 + typedef uint_t<limits_type::digits>::least least; \
1.70 + typedef uint_t<limits_type::digits>::fast fast; \
1.71 + BOOST_STATIC_CONSTANT( least, sig_bits = (~( least(0u) )) ); \
1.72 + BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) ); \
1.73 + BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \
1.74 + }
1.75 +
1.76 +BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
1.77 +
1.78 +#if USHRT_MAX > UCHAR_MAX
1.79 +BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned short );
1.80 +#endif
1.81 +
1.82 +#if UINT_MAX > USHRT_MAX
1.83 +BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
1.84 +#endif
1.85 +
1.86 +#if ULONG_MAX > UINT_MAX
1.87 +BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
1.88 +#endif
1.89 +
1.90 +#undef BOOST_LOW_BITS_MASK_SPECIALIZE
1.91 +
1.92 +
1.93 +} // namespace boost
1.94 +
1.95 +
1.96 +#endif // BOOST_INTEGER_INTEGER_MASK_HPP