mirror of
https://github.com/boostorg/integer.git
synced 2025-07-30 04:37:13 +02:00
Removed part of the Boost files from the SPIRIT_MINIBOOST branch.
[SVN r26352]
This commit is contained in:
@ -1,93 +0,0 @@
|
|||||||
// Boost integer/integer_mask.hpp header file ------------------------------//
|
|
||||||
|
|
||||||
// (C) Copyright Daryle Walker 2001.
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
// See http://www.boost.org for updates, documentation, and revision history.
|
|
||||||
|
|
||||||
#ifndef BOOST_INTEGER_INTEGER_MASK_HPP
|
|
||||||
#define BOOST_INTEGER_INTEGER_MASK_HPP
|
|
||||||
|
|
||||||
#include <boost/integer_fwd.hpp> // self include
|
|
||||||
|
|
||||||
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
|
|
||||||
#include <boost/integer.hpp> // for boost::uint_t
|
|
||||||
|
|
||||||
#include <climits> // for UCHAR_MAX, etc.
|
|
||||||
#include <cstddef> // for std::size_t
|
|
||||||
|
|
||||||
#include <boost/limits.hpp> // for std::numeric_limits
|
|
||||||
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
// Specified single-bit mask class declaration -----------------------------//
|
|
||||||
// (Lowest bit starts counting at 0.)
|
|
||||||
|
|
||||||
template < std::size_t Bit >
|
|
||||||
struct high_bit_mask_t
|
|
||||||
{
|
|
||||||
typedef typename uint_t<(Bit + 1)>::least least;
|
|
||||||
typedef typename uint_t<(Bit + 1)>::fast fast;
|
|
||||||
|
|
||||||
BOOST_STATIC_CONSTANT( least, high_bit = (least( 1u ) << Bit) );
|
|
||||||
BOOST_STATIC_CONSTANT( fast, high_bit_fast = (fast( 1u ) << Bit) );
|
|
||||||
|
|
||||||
BOOST_STATIC_CONSTANT( std::size_t, bit_position = Bit );
|
|
||||||
|
|
||||||
}; // boost::high_bit_mask_t
|
|
||||||
|
|
||||||
|
|
||||||
// Specified bit-block mask class declaration ------------------------------//
|
|
||||||
// Makes masks for the lowest N bits
|
|
||||||
// (Specializations are needed when N fills up a type.)
|
|
||||||
|
|
||||||
template < std::size_t Bits >
|
|
||||||
struct low_bits_mask_t
|
|
||||||
{
|
|
||||||
typedef typename uint_t<Bits>::least least;
|
|
||||||
typedef typename uint_t<Bits>::fast fast;
|
|
||||||
|
|
||||||
BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(least( 0u )) << Bits )) );
|
|
||||||
BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
|
|
||||||
|
|
||||||
BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
|
|
||||||
|
|
||||||
}; // boost::low_bits_mask_t
|
|
||||||
|
|
||||||
|
|
||||||
#define BOOST_LOW_BITS_MASK_SPECIALIZE( Type ) \
|
|
||||||
template < > struct low_bits_mask_t< std::numeric_limits<Type>::digits > { \
|
|
||||||
typedef std::numeric_limits<Type> limits_type; \
|
|
||||||
typedef uint_t<limits_type::digits>::least least; \
|
|
||||||
typedef uint_t<limits_type::digits>::fast fast; \
|
|
||||||
BOOST_STATIC_CONSTANT( least, sig_bits = (~( least(0u) )) ); \
|
|
||||||
BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) ); \
|
|
||||||
BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
|
|
||||||
|
|
||||||
#if USHRT_MAX > UCHAR_MAX
|
|
||||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned short );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UINT_MAX > USHRT_MAX
|
|
||||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ULONG_MAX > UINT_MAX
|
|
||||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef BOOST_LOW_BITS_MASK_SPECIALIZE
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BOOST_INTEGER_INTEGER_MASK_HPP
|
|
@ -1,132 +0,0 @@
|
|||||||
// -------------- Boost static_log2.hpp header file ----------------------- //
|
|
||||||
//
|
|
||||||
// Copyright (C) 2001 Daryle Walker.
|
|
||||||
// Copyright (C) 2003 Vesa Karvonen.
|
|
||||||
// Copyright (C) 2003 Gennaro Prota.
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// ---------------------------------------------------
|
|
||||||
// See http://www.boost.org/libs/integer for documentation.
|
|
||||||
// ------------------------------------------------------------------------- //
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BOOST_INTEGER_STATIC_LOG2_HPP
|
|
||||||
#define BOOST_INTEGER_STATIC_LOG2_HPP
|
|
||||||
|
|
||||||
#include "boost/config.hpp" // for BOOST_STATIC_CONSTANT
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
namespace static_log2_impl {
|
|
||||||
|
|
||||||
// choose_initial_n<>
|
|
||||||
//
|
|
||||||
// Recursively doubles its integer argument, until it
|
|
||||||
// becomes >= of the "width" (C99, 6.2.6.2p4) of
|
|
||||||
// static_log2_argument_type.
|
|
||||||
//
|
|
||||||
// Used to get the maximum power of two less then the width.
|
|
||||||
//
|
|
||||||
// Example: if on your platform argument_type has 48 value
|
|
||||||
// bits it yields n=32.
|
|
||||||
//
|
|
||||||
// It's easy to prove that, starting from such a value
|
|
||||||
// of n, the core algorithm works correctly for any width
|
|
||||||
// of static_log2_argument_type and that recursion always
|
|
||||||
// terminates with x = 1 and n = 0 (see the algorithm's
|
|
||||||
// invariant).
|
|
||||||
|
|
||||||
typedef unsigned long argument_type;
|
|
||||||
typedef int result_type;
|
|
||||||
|
|
||||||
|
|
||||||
template <result_type n>
|
|
||||||
struct choose_initial_n {
|
|
||||||
|
|
||||||
enum { c = (argument_type(1) << n << n) != 0 };
|
|
||||||
BOOST_STATIC_CONSTANT(
|
|
||||||
result_type,
|
|
||||||
value = !c*n + choose_initial_n<2*c*n>::value
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct choose_initial_n<0> {
|
|
||||||
BOOST_STATIC_CONSTANT(result_type, value = 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// start computing from n_zero - must be a power of two
|
|
||||||
const result_type n_zero = 16;
|
|
||||||
const result_type initial_n = choose_initial_n<n_zero>::value;
|
|
||||||
|
|
||||||
// static_log2_impl<>
|
|
||||||
//
|
|
||||||
// * Invariant:
|
|
||||||
// 2n
|
|
||||||
// 1 <= x && x < 2 at the start of each recursion
|
|
||||||
// (see also choose_initial_n<>)
|
|
||||||
//
|
|
||||||
// * Type requirements:
|
|
||||||
//
|
|
||||||
// argument_type maybe any unsigned type with at least n_zero + 1
|
|
||||||
// value bits. (Note: If larger types will be standardized -e.g.
|
|
||||||
// unsigned long long- then the argument_type typedef can be
|
|
||||||
// changed without affecting the rest of the code.)
|
|
||||||
//
|
|
||||||
|
|
||||||
template <argument_type x, result_type n = initial_n>
|
|
||||||
struct static_log2_impl {
|
|
||||||
|
|
||||||
enum { c = (x >> n) > 0 }; // x >= 2**n ?
|
|
||||||
BOOST_STATIC_CONSTANT(
|
|
||||||
result_type,
|
|
||||||
value = c*n + (static_log2_impl< (x>>c*n), n/2 >::value)
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct static_log2_impl<1, 0> {
|
|
||||||
BOOST_STATIC_CONSTANT(result_type, value = 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
} // detail
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------
|
|
||||||
// static_log2<x>
|
|
||||||
// ----------------------------------------
|
|
||||||
|
|
||||||
typedef detail::static_log2_impl::argument_type static_log2_argument_type;
|
|
||||||
typedef detail::static_log2_impl::result_type static_log2_result_type;
|
|
||||||
|
|
||||||
|
|
||||||
template <static_log2_argument_type x>
|
|
||||||
struct static_log2 {
|
|
||||||
|
|
||||||
BOOST_STATIC_CONSTANT(
|
|
||||||
static_log2_result_type,
|
|
||||||
value = detail::static_log2_impl::static_log2_impl<x>::value
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct static_log2<0> { };
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // include guard
|
|
@ -1,55 +0,0 @@
|
|||||||
// Boost integer/static_min_max.hpp header file ----------------------------//
|
|
||||||
|
|
||||||
// (C) Copyright Daryle Walker 2001.
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
// See http://www.boost.org for updates, documentation, and revision history.
|
|
||||||
|
|
||||||
#ifndef BOOST_INTEGER_STATIC_MIN_MAX_HPP
|
|
||||||
#define BOOST_INTEGER_STATIC_MIN_MAX_HPP
|
|
||||||
|
|
||||||
#include <boost/integer_fwd.hpp> // self include
|
|
||||||
|
|
||||||
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
|
|
||||||
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
// Compile-time extrema class declarations ---------------------------------//
|
|
||||||
// Get the minimum or maximum of two values, signed or unsigned.
|
|
||||||
|
|
||||||
template < long Value1, long Value2 >
|
|
||||||
struct static_signed_min
|
|
||||||
{
|
|
||||||
BOOST_STATIC_CONSTANT( long, value = (Value1 > Value2) ? Value2 : Value1 );
|
|
||||||
};
|
|
||||||
|
|
||||||
template < long Value1, long Value2 >
|
|
||||||
struct static_signed_max
|
|
||||||
{
|
|
||||||
BOOST_STATIC_CONSTANT( long, value = (Value1 < Value2) ? Value2 : Value1 );
|
|
||||||
};
|
|
||||||
|
|
||||||
template < unsigned long Value1, unsigned long Value2 >
|
|
||||||
struct static_unsigned_min
|
|
||||||
{
|
|
||||||
BOOST_STATIC_CONSTANT( unsigned long, value
|
|
||||||
= (Value1 > Value2) ? Value2 : Value1 );
|
|
||||||
};
|
|
||||||
|
|
||||||
template < unsigned long Value1, unsigned long Value2 >
|
|
||||||
struct static_unsigned_max
|
|
||||||
{
|
|
||||||
BOOST_STATIC_CONSTANT( unsigned long, value
|
|
||||||
= (Value1 < Value2) ? Value2 : Value1 );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BOOST_INTEGER_STATIC_MIN_MAX_HPP
|
|
Reference in New Issue
Block a user