Change long long to boost::long_long_type etc.

[SVN r58029]
This commit is contained in:
John Maddock
2009-11-29 13:59:18 +00:00
parent 05c1f88324
commit 1797528e35
3 changed files with 51 additions and 37 deletions

View File

@ -41,7 +41,11 @@ namespace boost
// fast integers from least integers // fast integers from least integers
// int_fast_t<> works correctly for unsigned too, in spite of the name. // int_fast_t<> works correctly for unsigned too, in spite of the name.
template< typename LeastInt > template< typename LeastInt >
struct int_fast_t { typedef LeastInt fast; }; // imps may specialize struct int_fast_t
{
typedef LeastInt fast;
typedef fast type;
}; // imps may specialize
namespace detail{ namespace detail{
@ -115,7 +119,7 @@ namespace boost
(Bits-1 <= ::std::numeric_limits<short>::digits) + (Bits-1 <= ::std::numeric_limits<short>::digits) +
(Bits-1 <= ::std::numeric_limits<signed char>::digits) (Bits-1 <= ::std::numeric_limits<signed char>::digits)
>::least least; >::least least;
typedef typename int_fast_t<least>::fast fast; typedef typename int_fast_t<least>::type fast;
}; };
// unsigned // unsigned
@ -135,7 +139,7 @@ namespace boost
(Bits <= ::std::numeric_limits<unsigned short>::digits) + (Bits <= ::std::numeric_limits<unsigned short>::digits) +
(Bits <= ::std::numeric_limits<unsigned char>::digits) (Bits <= ::std::numeric_limits<unsigned char>::digits)
>::least least; >::least least;
typedef typename int_fast_t<least>::fast fast; typedef typename int_fast_t<least>::type fast;
// int_fast_t<> works correctly for unsigned too, in spite of the name. // int_fast_t<> works correctly for unsigned too, in spite of the name.
}; };
@ -161,7 +165,7 @@ namespace boost
(MaxValue <= ::boost::integer_traits<short>::const_max) + (MaxValue <= ::boost::integer_traits<short>::const_max) +
(MaxValue <= ::boost::integer_traits<signed char>::const_max) (MaxValue <= ::boost::integer_traits<signed char>::const_max)
>::least least; >::least least;
typedef typename int_fast_t<least>::fast fast; typedef typename int_fast_t<least>::type fast;
}; };
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) #if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG)
@ -183,7 +187,7 @@ namespace boost
(MinValue >= ::boost::integer_traits<short>::const_min) + (MinValue >= ::boost::integer_traits<short>::const_min) +
(MinValue >= ::boost::integer_traits<signed char>::const_min) (MinValue >= ::boost::integer_traits<signed char>::const_min)
>::least least; >::least least;
typedef typename int_fast_t<least>::fast fast; typedef typename int_fast_t<least>::type fast;
}; };
// unsigned // unsigned
@ -207,7 +211,7 @@ namespace boost
(MaxValue <= ::boost::integer_traits<unsigned short>::const_max) + (MaxValue <= ::boost::integer_traits<unsigned short>::const_max) +
(MaxValue <= ::boost::integer_traits<unsigned char>::const_max) (MaxValue <= ::boost::integer_traits<unsigned char>::const_max)
>::least least; >::least least;
typedef typename int_fast_t<least>::fast fast; typedef typename int_fast_t<least>::type fast;
}; };

View File

@ -7,9 +7,9 @@ import testing ;
project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ; project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ;
test-suite integer test-suite integer
: [ run cstdint_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long <toolset>gcc:<cxxflags>-Wno-type-limits ] : [ run cstdint_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long <toolset>darwin:<cxxflags>-Wno-long-long ]
[ run integer_traits_test.cpp ] [ run integer_traits_test.cpp ]
[ run integer_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long ] [ run integer_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long <toolset>darwin:<cxxflags>-Wno-long-long ]
[ run integer_mask_test.cpp ] [ run integer_mask_test.cpp ]
[ run static_log2_test.cpp ] [ run static_log2_test.cpp ]
[ run static_min_max_test.cpp ] [ run static_min_max_test.cpp ]

View File

@ -50,8 +50,8 @@ const char* get_name_of_type(unsigned int){ return "unsigned int"; }
const char* get_name_of_type(long){ return "long"; } const char* get_name_of_type(long){ return "long"; }
const char* get_name_of_type(unsigned long){ return "unsigned long"; } const char* get_name_of_type(unsigned long){ return "unsigned long"; }
#ifdef BOOST_HAS_LONG_LONG #ifdef BOOST_HAS_LONG_LONG
const char* get_name_of_type(long long){ return "long long"; } const char* get_name_of_type(boost::long_long_type){ return "boost::long_long_type"; }
const char* get_name_of_type(unsigned long long){ return "unsigned long long"; } const char* get_name_of_type(boost::ulong_long_type){ return "boost::ulong_long_type"; }
#endif #endif
template <int Bits> template <int Bits>
@ -89,7 +89,7 @@ void do_test_bits()
|| (sizeof(unsigned int) * CHAR_BIT == Bits) || (sizeof(unsigned int) * CHAR_BIT == Bits)
|| (sizeof(unsigned long) * CHAR_BIT == Bits) || (sizeof(unsigned long) * CHAR_BIT == Bits)
#ifdef BOOST_HAS_LONG_LONG #ifdef BOOST_HAS_LONG_LONG
|| (sizeof(unsigned long long) * CHAR_BIT == Bits) || (sizeof(boost::ulong_long_type) * CHAR_BIT == Bits)
#endif #endif
>()); >());
// //
@ -165,8 +165,8 @@ void do_test_bits<-1>()
// Nothing to do here!! // Nothing to do here!!
} }
template <class Traits, class Expected> template <class Traits, class Expected, class Value>
void test_min_max_type(Expected val) void test_min_max_type(Value val)
{ {
typedef typename Traits::least least_type; typedef typename Traits::least least_type;
typedef typename Traits::fast fast_type; typedef typename Traits::fast fast_type;
@ -174,6 +174,16 @@ void test_min_max_type(Expected val)
BOOST_TEST(sizeof(fast_type) >= sizeof(least_type)); BOOST_TEST(sizeof(fast_type) >= sizeof(least_type));
BOOST_TEST((std::numeric_limits<least_type>::min)() <= val); BOOST_TEST((std::numeric_limits<least_type>::min)() <= val);
BOOST_TEST((std::numeric_limits<least_type>::max)() >= val); BOOST_TEST((std::numeric_limits<least_type>::max)() >= val);
if(boost::detail::test_errors() != last_error_count)
{
last_error_count = boost::detail::test_errors();
std::cout << "Traits type is: " << typeid(Traits).name() << std::endl;
std::cout << "Least type is: " << get_name_of_type(least_type(0)) << std::endl;
std::cout << "Fast type is: " << get_name_of_type(fast_type(0)) << std::endl;
std::cout << "Expected type is: " << get_name_of_type(Expected(0)) << std::endl;
std::cout << "Required value is: " << val << std::endl;
}
} }
// Test program // Test program
@ -216,36 +226,36 @@ int main(int, char*[])
test_min_max_type<boost::uint_value_t<ULONG_MAX>, unsigned long>(ULONG_MAX); test_min_max_type<boost::uint_value_t<ULONG_MAX>, unsigned long>(ULONG_MAX);
#endif #endif
#if defined(BOOST_HAS_LONG_LONG) && (defined(ULLONG_MAX) && (ULLONG_MAX != ULONG_MAX)) #if defined(BOOST_HAS_LONG_LONG) && (defined(ULLONG_MAX) && (ULLONG_MAX != ULONG_MAX))
test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, long long>(LONG_MAX+1LL); test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, long long>(LONG_MIN-1LL); test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, unsigned long long>(ULONG_MAX+1uLL); test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
test_min_max_type<boost::int_max_value_t<LLONG_MAX>, long long>(LLONG_MAX); test_min_max_type<boost::int_max_value_t<LLONG_MAX>, boost::long_long_type>(LLONG_MAX);
test_min_max_type<boost::int_min_value_t<LLONG_MIN>, long long>(LLONG_MIN); test_min_max_type<boost::int_min_value_t<LLONG_MIN>, boost::long_long_type>(LLONG_MIN);
test_min_max_type<boost::uint_value_t<ULLONG_MAX>, unsigned long long>(ULLONG_MAX); test_min_max_type<boost::uint_value_t<ULLONG_MAX>, boost::ulong_long_type>(ULLONG_MAX);
#endif #endif
#if defined(BOOST_HAS_LONG_LONG) && (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX != ULONG_MAX)) #if defined(BOOST_HAS_LONG_LONG) && (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX != ULONG_MAX))
test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, long long>(LONG_MAX+1LL); test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, long long>(LONG_MIN-1LL); test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, unsigned long long>(ULONG_MAX+1uLL); test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
test_min_max_type<boost::int_max_value_t<LONG_LONG_MAX>, long long>(LONG_LONG_MAX); test_min_max_type<boost::int_max_value_t<LONG_LONG_MAX>, boost::long_long_type>(LONG_LONG_MAX);
test_min_max_type<boost::int_min_value_t<LONG_LONG_MIN>, long long>(LONG_LONG_MIN); test_min_max_type<boost::int_min_value_t<LONG_LONG_MIN>, boost::long_long_type>(LONG_LONG_MIN);
test_min_max_type<boost::uint_value_t<ULONG_LONG_MAX>, unsigned long long>(ULONG_LONG_MAX); test_min_max_type<boost::uint_value_t<ULONG_LONG_MAX>, boost::ulong_long_type>(ULONG_LONG_MAX);
#endif #endif
#if defined(BOOST_HAS_LONG_LONG) && (defined(ULONGLONG_MAX) && (ULONGLONG_MAX != ULONG_MAX)) #if defined(BOOST_HAS_LONG_LONG) && (defined(ULONGLONG_MAX) && (ULONGLONG_MAX != ULONG_MAX))
test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, long long>(LONG_MAX+1LL); test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, long long>(LONG_MIN-1LL); test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, unsigned long long>(ULONG_MAX+1uLL); test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
test_min_max_type<boost::int_max_value_t<LONGLONG_MAX>, long long>(LONGLONG_MAX); test_min_max_type<boost::int_max_value_t<LONGLONG_MAX>, boost::long_long_type>(LONGLONG_MAX);
test_min_max_type<boost::int_min_value_t<LONGLONG_MIN>, long long>(LONGLONG_MAX); test_min_max_type<boost::int_min_value_t<LONGLONG_MIN>, boost::long_long_type>(LONGLONG_MAX);
test_min_max_type<boost::uint_value_t<ULONGLONG_MAX>, unsigned long long>(ULONGLONG_MAX); test_min_max_type<boost::uint_value_t<ULONGLONG_MAX>, boost::ulong_long_type>(ULONGLONG_MAX);
#endif #endif
#if defined(BOOST_HAS_LONG_LONG) && (defined(_ULLONG_MAX) && defined(_LLONG_MIN) && (_ULLONG_MAX != ULONG_MAX)) #if defined(BOOST_HAS_LONG_LONG) && (defined(_ULLONG_MAX) && defined(_LLONG_MIN) && (_ULLONG_MAX != ULONG_MAX))
test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, long long>(LONG_MAX+1LL); test_min_max_type<boost::int_max_value_t<LONG_MAX+1LL>, boost::long_long_type>(LONG_MAX+1LL);
test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, long long>(LONG_MIN-1LL); test_min_max_type<boost::int_min_value_t<LONG_MIN-1LL>, boost::long_long_type>(LONG_MIN-1LL);
test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, unsigned long long>(ULONG_MAX+1uLL); test_min_max_type<boost::uint_value_t<ULONG_MAX+1uLL>, boost::ulong_long_type>(ULONG_MAX+1uLL);
test_min_max_type<boost::int_max_value_t<_LLONG_MAX>, long long>(_LLONG_MAX); test_min_max_type<boost::int_max_value_t<_LLONG_MAX>, boost::long_long_type>(_LLONG_MAX);
test_min_max_type<boost::int_min_value_t<_LLONG_MIN>, long long>(_LLONG_MIN); test_min_max_type<boost::int_min_value_t<_LLONG_MIN>, boost::long_long_type>(_LLONG_MIN);
test_min_max_type<boost::uint_value_t<_ULLONG_MAX>, unsigned long long>(_ULLONG_MAX); test_min_max_type<boost::uint_value_t<_ULLONG_MAX>, boost::ulong_long_type>(_ULLONG_MAX);
#endif #endif
return boost::report_errors(); return boost::report_errors();
} }