mirror of
https://github.com/boostorg/integer.git
synced 2025-06-25 12:01:34 +02:00
Compare commits
9 Commits
boost-1.27
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
fcd3688fcd | |||
344fe9f30a | |||
8ad3bbafbc | |||
cc1183d347 | |||
a9703fa803 | |||
5e26f47535 | |||
57e7ccd494 | |||
c56e4674f8 | |||
41620a14f9 |
@ -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 = -1;
|
||||
T2 t2 = -1;
|
||||
T1 t1 = static_cast<T1>(-1); // cast suppresses warnings
|
||||
T2 t2 = static_cast<T2>(-1); // ditto
|
||||
#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,11 +107,12 @@ 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>.</p>
|
||||
href="../../../people/daryle_walker.html">Daryle Walker</a>. Giovanni Bajo
|
||||
added support for compilers without partial template specialization.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<p>Revised October 1, 2001</p>
|
||||
<p>Revised May 14, 2002</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>
|
||||
|
||||
|
@ -228,9 +228,9 @@ namespace boost
|
||||
# else
|
||||
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
||||
# endif
|
||||
# elif (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
||||
# elif defined(BOOST_HAS_MS_INT64)
|
||||
//
|
||||
// we have Borland/Microsoft __int64:
|
||||
// we have Borland/Intel/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_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
||||
# if defined(BOOST_HAS_MS_INT64)
|
||||
//
|
||||
// Borland/Microsoft compilers have width specific suffixes:
|
||||
// Borland/Intel/Microsoft compilers have width specific suffixes:
|
||||
//
|
||||
# define INT8_C(value) value##i8
|
||||
# define INT16_C(value) value##i16
|
||||
|
@ -12,9 +12,13 @@
|
||||
|
||||
#include <boost/integer_fwd.hpp> // self include
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
|
||||
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
|
||||
#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
|
||||
{
|
||||
@ -30,9 +34,22 @@ 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
|
||||
@ -50,7 +67,11 @@ 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 );
|
||||
@ -58,6 +79,8 @@ 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 >
|
||||
{
|
||||
@ -66,6 +89,33 @@ 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
|
||||
|
||||
|
||||
|
@ -35,10 +35,20 @@
|
||||
* 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)
|
||||
@ -73,7 +83,7 @@ int test_main(int, char*[])
|
||||
runtest("long", long());
|
||||
typedef unsigned long unsigned_long;
|
||||
runtest("unsigned long", unsigned_long());
|
||||
#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_MSVC) && !defined(__BORLANDC__) && !defined(__BEOS__)
|
||||
#if !defined(BOOST_NO_INT64_T) && (!defined(BOOST_MSVC) || BOOST_MSVC > 1300) && !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.
|
||||
|
Reference in New Issue
Block a user