forked from boostorg/integer
Compare commits
1 Commits
boost-1.29
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
c8341e4757 |
@ -99,8 +99,8 @@ void integral_constant_type_check(T1, T2)
|
||||
// numeric_limits implementations currently
|
||||
// vary too much, or are incomplete or missing.
|
||||
//
|
||||
T1 t1 = static_cast<T1>(-1); // cast suppresses warnings
|
||||
T2 t2 = static_cast<T2>(-1); // ditto
|
||||
T1 t1 = -1;
|
||||
T2 t2 = -1;
|
||||
#if defined(BOOST_HAS_STDINT_H)
|
||||
// if we have a native stdint.h
|
||||
// then the INTXX_C macros may define
|
||||
@ -110,10 +110,10 @@ void integral_constant_type_check(T1, T2)
|
||||
assert(sizeof(T1) == sizeof(T2));
|
||||
assert(t1 == t2);
|
||||
#endif
|
||||
if(t1 > 0)
|
||||
assert(t2 > 0);
|
||||
if(t1 >= 0)
|
||||
assert(t2 >= 0);
|
||||
else
|
||||
assert(!(t2 > 0));
|
||||
assert(t2 < 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,12 +107,11 @@ at compile-time) available.</p>
|
||||
<h2><a name="credits">Credits</a></h2>
|
||||
|
||||
<p>The author of the Boost binary logarithm class template is <a
|
||||
href="../../../people/daryle_walker.html">Daryle Walker</a>. Giovanni Bajo
|
||||
added support for compilers without partial template specialization.</p>
|
||||
href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<p>Revised May 14, 2002</p>
|
||||
<p>Revised October 1, 2001</p>
|
||||
|
||||
<p>© Copyright Daryle Walker 2001. Permission to copy, use,
|
||||
modify, sell and distribute this document is granted provided this
|
||||
|
@ -106,7 +106,7 @@ class template.</p>
|
||||
<h2><a name="credits">Credits</a></h2>
|
||||
|
||||
<p>The author of the Boost compile-time extrema class templates is <a
|
||||
href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
|
||||
href="../../../../people/daryle_walker.html">Daryle Walker</a>.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
// this is triggered with GCC, because it defines __cplusplus < 199707L
|
||||
# define BOOST_NO_INT64_T
|
||||
# endif
|
||||
# elif defined(__FreeBSD__) || defined(__IBMCPP__)
|
||||
# elif defined(__FreeBSD__)
|
||||
# include <inttypes.h>
|
||||
# else
|
||||
# include <stdint.h>
|
||||
@ -228,9 +228,9 @@ namespace boost
|
||||
# else
|
||||
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
||||
# endif
|
||||
# elif defined(BOOST_HAS_MS_INT64)
|
||||
# elif (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
||||
//
|
||||
// we have Borland/Intel/Microsoft __int64:
|
||||
// we have Borland/Microsoft __int64:
|
||||
//
|
||||
typedef __int64 intmax_t;
|
||||
typedef unsigned __int64 uintmax_t;
|
||||
@ -272,9 +272,9 @@ BOOST_HAS_STDINT_H is defined (John Maddock).
|
||||
|
||||
#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(BOOST_HAS_STDINT_H)
|
||||
# define BOOST__STDC_CONSTANT_MACROS_DEFINED
|
||||
# if defined(BOOST_HAS_MS_INT64)
|
||||
# if (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
||||
//
|
||||
// Borland/Intel/Microsoft compilers have width specific suffixes:
|
||||
// Borland/Microsoft compilers have width specific suffixes:
|
||||
//
|
||||
# define INT8_C(value) value##i8
|
||||
# define INT16_C(value) value##i16
|
||||
|
@ -12,13 +12,9 @@
|
||||
|
||||
#include <boost/integer_fwd.hpp> // self include
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
|
||||
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
|
||||
#include <boost/limits.hpp> // for std::numeric_limits
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#include <boost/pending/ct_if.hpp> // for boost::ct_if<>
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -34,22 +30,9 @@ template < unsigned long Val, int Place = 0, int Index
|
||||
= std::numeric_limits<unsigned long>::digits >
|
||||
struct static_log2_helper_t;
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template < unsigned long Val, int Place >
|
||||
struct static_log2_helper_t< Val, Place, 1 >;
|
||||
|
||||
#else
|
||||
|
||||
template < int Place >
|
||||
struct static_log2_helper_final_step;
|
||||
|
||||
template < unsigned long Val, int Place = 0, int Index
|
||||
= std::numeric_limits<unsigned long>::digits >
|
||||
struct static_log2_helper_nopts_t;
|
||||
|
||||
#endif
|
||||
|
||||
// Recursively build the logarithm by examining the upper bits
|
||||
template < unsigned long Val, int Place, int Index >
|
||||
struct static_log2_helper_t
|
||||
@ -67,11 +50,7 @@ private:
|
||||
: Place );
|
||||
BOOST_STATIC_CONSTANT( int, new_index = Index - half_place );
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
typedef static_log2_helper_t<new_val, new_place, new_index> next_step_type;
|
||||
#else
|
||||
typedef static_log2_helper_nopts_t<new_val, new_place, new_index> next_step_type;
|
||||
#endif
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT( int, value = next_step_type::value );
|
||||
@ -79,8 +58,6 @@ public:
|
||||
}; // boost::detail::static_log2_helper_t
|
||||
|
||||
// Non-recursive case
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template < unsigned long Val, int Place >
|
||||
struct static_log2_helper_t< Val, Place, 1 >
|
||||
{
|
||||
@ -89,33 +66,6 @@ public:
|
||||
|
||||
}; // boost::detail::static_log2_helper_t
|
||||
|
||||
#else
|
||||
|
||||
template < int Place >
|
||||
struct static_log2_helper_final_step
|
||||
{
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT( int, value = Place );
|
||||
|
||||
}; // boost::detail::static_log2_helper_final_step
|
||||
|
||||
template < unsigned long Val, int Place, int Index >
|
||||
struct static_log2_helper_nopts_t
|
||||
{
|
||||
private:
|
||||
typedef static_log2_helper_t<Val, Place, Index> recursive_step_type;
|
||||
typedef static_log2_helper_final_step<Place> final_step_type;
|
||||
|
||||
typedef typename ct_if<( Index != 1 ), recursive_step_type,
|
||||
final_step_type>::type next_step_type;
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT( int, value = next_step_type::value );
|
||||
|
||||
}; // boost::detail::static_log2_helper_nopts_t
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
|
@ -147,64 +147,42 @@ class integer_traits<unsigned long>
|
||||
public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
|
||||
{ };
|
||||
|
||||
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T)
|
||||
#if defined(ULLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
|
||||
|
||||
#if defined(ULLONG_MAX) && !defined(__SUNPRO_CC)
|
||||
template<>
|
||||
class integer_traits<long long>
|
||||
: public std::numeric_limits<long long>,
|
||||
public detail::integer_traits_base<long long, LLONG_MIN, LLONG_MAX>
|
||||
{ };
|
||||
|
||||
template<>
|
||||
class integer_traits<unsigned long long>
|
||||
: public std::numeric_limits<unsigned long long>,
|
||||
public detail::integer_traits_base<unsigned long long, 0, ULLONG_MAX>
|
||||
{ };
|
||||
|
||||
#elif defined(ULONG_LONG_MAX) && defined(BOOST_HAS_LONG_LONG)
|
||||
|
||||
#elif defined(ULONG_LONG_MAX)
|
||||
template<>
|
||||
class integer_traits<long long> : public std::numeric_limits<long long>, public detail::integer_traits_base<long long, LONG_LONG_MIN, LONG_LONG_MAX>{ };
|
||||
class integer_traits<long long>
|
||||
: public std::numeric_limits<long long>,
|
||||
public detail::integer_traits_base<long long, LONG_LONG_MIN, LONG_LONG_MAX>
|
||||
{ };
|
||||
template<>
|
||||
class integer_traits<unsigned long long>
|
||||
: public std::numeric_limits<unsigned long long>,
|
||||
public detail::integer_traits_base<unsigned long long, 0, ULONG_LONG_MAX>
|
||||
{ };
|
||||
|
||||
#elif defined(ULONGLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
|
||||
|
||||
#elif defined(ULONGLONG_MAX) && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
|
||||
template<>
|
||||
class integer_traits<long long>
|
||||
: public std::numeric_limits<long long>,
|
||||
public detail::integer_traits_base<long long, LONGLONG_MIN, LONGLONG_MAX>
|
||||
{ };
|
||||
|
||||
template<>
|
||||
class integer_traits<unsigned long long>
|
||||
: public std::numeric_limits<unsigned long long>,
|
||||
public detail::integer_traits_base<unsigned long long, 0, ULONGLONG_MAX>
|
||||
{ };
|
||||
|
||||
#elif defined(_LLONG_MAX) && defined(_C2) && defined(BOOST_HAS_LONG_LONG)
|
||||
|
||||
template<>
|
||||
class integer_traits<long long>
|
||||
: public std::numeric_limits<long long>,
|
||||
public detail::integer_traits_base<long long, -_LLONG_MAX - _C2, _LLONG_MAX>
|
||||
{ };
|
||||
|
||||
template<>
|
||||
class integer_traits<unsigned long long>
|
||||
: public std::numeric_limits<unsigned long long>,
|
||||
public detail::integer_traits_base<unsigned long long, 0, _ULLONG_MAX>
|
||||
{ };
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif /* BOOST_INTEGER_TRAITS_HPP */
|
||||
|
||||
|
||||
|
@ -13,7 +13,8 @@
|
||||
// 10 Mar 01 Boost Test Library now used for tests (Beman Dawes)
|
||||
// 31 Aug 99 Initial version
|
||||
|
||||
#include <boost/test/minimal.hpp> // for main, BOOST_TEST
|
||||
#define BOOST_INCLUDE_MAIN
|
||||
#include <boost/test/test_tools.hpp> // for main, BOOST_TEST
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_NO_USING_TEMPLATE
|
||||
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||
|
@ -35,20 +35,10 @@
|
||||
* Therefore, avoid explicit function template instantiations.
|
||||
*/
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
|
||||
template<typename T> inline T make_char_numeric_for_streaming(T x) { return x; }
|
||||
namespace fix{
|
||||
inline int make_char_numeric_for_streaming(char c) { return c; }
|
||||
inline int make_char_numeric_for_streaming(signed char c) { return c; }
|
||||
inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
|
||||
}
|
||||
using namespace fix;
|
||||
#else
|
||||
template<typename T> inline T make_char_numeric_for_streaming(T x) { return x; }
|
||||
inline int make_char_numeric_for_streaming(char c) { return c; }
|
||||
inline int make_char_numeric_for_streaming(signed char c) { return c; }
|
||||
inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
void runtest(const char * type, T)
|
||||
@ -83,11 +73,10 @@ int test_main(int, char*[])
|
||||
runtest("long", long());
|
||||
typedef unsigned long unsigned_long;
|
||||
runtest("unsigned long", unsigned_long());
|
||||
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T)
|
||||
//
|
||||
// Only test for compilers that have 64-bit int's that
|
||||
// can be used in integral constant expressions:
|
||||
#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_MSVC) && !defined(__BORLANDC__) && !defined(__BEOS__)
|
||||
//
|
||||
// MS/Borland compilers can't support 64-bit member constants
|
||||
// BeOS doesn't have specialisations for long long in SGI's <limits> header.
|
||||
runtest("int64_t (possibly long long)", boost::int64_t());
|
||||
runtest("uint64_t (possibly unsigned long long)", boost::uint64_t());
|
||||
#else
|
||||
|
Reference in New Issue
Block a user