mirror of
https://github.com/boostorg/integer.git
synced 2025-06-28 05:20:57 +02:00
Compare commits
2 Commits
svn-branch
...
boost-1.27
Author | SHA1 | Date | |
---|---|---|---|
7d500a2723 | |||
73b925e479 |
@ -99,8 +99,8 @@ void integral_constant_type_check(T1, T2)
|
|||||||
// numeric_limits implementations currently
|
// numeric_limits implementations currently
|
||||||
// vary too much, or are incomplete or missing.
|
// vary too much, or are incomplete or missing.
|
||||||
//
|
//
|
||||||
T1 t1 = static_cast<T1>(-1); // cast suppresses warnings
|
T1 t1 = -1;
|
||||||
T2 t2 = static_cast<T2>(-1); // ditto
|
T2 t2 = -1;
|
||||||
#if defined(BOOST_HAS_STDINT_H)
|
#if defined(BOOST_HAS_STDINT_H)
|
||||||
// if we have a native stdint.h
|
// if we have a native stdint.h
|
||||||
// then the INTXX_C macros may define
|
// then the INTXX_C macros may define
|
||||||
@ -110,10 +110,10 @@ void integral_constant_type_check(T1, T2)
|
|||||||
assert(sizeof(T1) == sizeof(T2));
|
assert(sizeof(T1) == sizeof(T2));
|
||||||
assert(t1 == t2);
|
assert(t1 == t2);
|
||||||
#endif
|
#endif
|
||||||
if(t1 > 0)
|
if(t1 >= 0)
|
||||||
assert(t2 > 0);
|
assert(t2 >= 0);
|
||||||
else
|
else
|
||||||
assert(!(t2 > 0));
|
assert(t2 < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,12 +107,11 @@ at compile-time) available.</p>
|
|||||||
<h2><a name="credits">Credits</a></h2>
|
<h2><a name="credits">Credits</a></h2>
|
||||||
|
|
||||||
<p>The author of the Boost binary logarithm class template is <a
|
<p>The author of the Boost binary logarithm class template is <a
|
||||||
href="../../../people/daryle_walker.html">Daryle Walker</a>. Giovanni Bajo
|
href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
|
||||||
added support for compilers without partial template specialization.</p>
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<p>Revised May 14, 2002</p>
|
<p>Revised October 1, 2001</p>
|
||||||
|
|
||||||
<p>© Copyright Daryle Walker 2001. Permission to copy, use,
|
<p>© Copyright Daryle Walker 2001. Permission to copy, use,
|
||||||
modify, sell and distribute this document is granted provided this
|
modify, sell and distribute this document is granted provided this
|
||||||
|
@ -106,7 +106,7 @@ class template.</p>
|
|||||||
<h2><a name="credits">Credits</a></h2>
|
<h2><a name="credits">Credits</a></h2>
|
||||||
|
|
||||||
<p>The author of the Boost compile-time extrema class templates is <a
|
<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>
|
<hr>
|
||||||
|
|
||||||
|
@ -228,9 +228,9 @@ namespace boost
|
|||||||
# else
|
# else
|
||||||
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
||||||
# endif
|
# 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 __int64 intmax_t;
|
||||||
typedef unsigned __int64 uintmax_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)
|
#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(BOOST_HAS_STDINT_H)
|
||||||
# define BOOST__STDC_CONSTANT_MACROS_DEFINED
|
# 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 INT8_C(value) value##i8
|
||||||
# define INT16_C(value) value##i16
|
# define INT16_C(value) value##i16
|
||||||
|
@ -12,13 +12,9 @@
|
|||||||
|
|
||||||
#include <boost/integer_fwd.hpp> // self include
|
#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
|
#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
|
namespace boost
|
||||||
{
|
{
|
||||||
@ -34,22 +30,9 @@ template < unsigned long Val, int Place = 0, int Index
|
|||||||
= std::numeric_limits<unsigned long>::digits >
|
= std::numeric_limits<unsigned long>::digits >
|
||||||
struct static_log2_helper_t;
|
struct static_log2_helper_t;
|
||||||
|
|
||||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
|
|
||||||
template < unsigned long Val, int Place >
|
template < unsigned long Val, int Place >
|
||||||
struct static_log2_helper_t< Val, Place, 1 >;
|
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
|
// Recursively build the logarithm by examining the upper bits
|
||||||
template < unsigned long Val, int Place, int Index >
|
template < unsigned long Val, int Place, int Index >
|
||||||
struct static_log2_helper_t
|
struct static_log2_helper_t
|
||||||
@ -67,11 +50,7 @@ private:
|
|||||||
: Place );
|
: Place );
|
||||||
BOOST_STATIC_CONSTANT( int, new_index = Index - half_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;
|
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:
|
public:
|
||||||
BOOST_STATIC_CONSTANT( int, value = next_step_type::value );
|
BOOST_STATIC_CONSTANT( int, value = next_step_type::value );
|
||||||
@ -79,8 +58,6 @@ public:
|
|||||||
}; // boost::detail::static_log2_helper_t
|
}; // boost::detail::static_log2_helper_t
|
||||||
|
|
||||||
// Non-recursive case
|
// Non-recursive case
|
||||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
|
|
||||||
template < unsigned long Val, int Place >
|
template < unsigned long Val, int Place >
|
||||||
struct static_log2_helper_t< Val, Place, 1 >
|
struct static_log2_helper_t< Val, Place, 1 >
|
||||||
{
|
{
|
||||||
@ -89,33 +66,6 @@ public:
|
|||||||
|
|
||||||
}; // boost::detail::static_log2_helper_t
|
}; // 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
|
} // namespace detail
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,20 +35,10 @@
|
|||||||
* Therefore, avoid explicit function template instantiations.
|
* 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; }
|
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(char c) { return c; }
|
||||||
inline int make_char_numeric_for_streaming(signed 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; }
|
inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void runtest(const char * type, T)
|
void runtest(const char * type, T)
|
||||||
@ -83,7 +73,7 @@ int test_main(int, char*[])
|
|||||||
runtest("long", long());
|
runtest("long", long());
|
||||||
typedef unsigned long unsigned_long;
|
typedef unsigned long unsigned_long;
|
||||||
runtest("unsigned long", unsigned_long());
|
runtest("unsigned long", unsigned_long());
|
||||||
#if !defined(BOOST_NO_INT64_T) && (!defined(BOOST_MSVC) || BOOST_MSVC > 1300) && !defined(__BORLANDC__) && !defined(__BEOS__)
|
#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_MSVC) && !defined(__BORLANDC__) && !defined(__BEOS__)
|
||||||
//
|
//
|
||||||
// MS/Borland compilers can't support 64-bit member constants
|
// MS/Borland compilers can't support 64-bit member constants
|
||||||
// BeOS doesn't have specialisations for long long in SGI's <limits> header.
|
// BeOS doesn't have specialisations for long long in SGI's <limits> header.
|
||||||
|
Reference in New Issue
Block a user