mirror of
https://github.com/boostorg/functional.git
synced 2025-08-01 21:44:28 +02:00
Formatting changes, mostly to fit within 80 characters.
Also, some C casts converted to static_cast. [SVN r58692]
This commit is contained in:
@@ -16,5 +16,6 @@
|
||||
#if defined(_WIN32_WCE)
|
||||
// The standard windows mobile headers trigger this warning so I disable it
|
||||
// before doing anything else.
|
||||
#pragma warning(disable:4201) // nonstandard extension used : nameless struct/union
|
||||
#pragma warning(disable:4201) // nonstandard extension used :
|
||||
// nameless struct/union
|
||||
#endif
|
||||
|
@@ -7,14 +7,17 @@
|
||||
|
||||
#include <boost/functional/detail/container_fwd.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||
#if BOOST_WORKAROUND(__GNUC__, < 3) && \
|
||||
!defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||
template <class charT, class Allocator>
|
||||
static void test(std::basic_string<charT, std::string_char_traits<charT>, Allocator> const&)
|
||||
static void test(
|
||||
std::basic_string<charT, std::string_char_traits<charT>, Allocator> const&)
|
||||
{
|
||||
}
|
||||
#else
|
||||
template <class charT, class Allocator>
|
||||
static void test(std::basic_string<charT, std::char_traits<charT>, Allocator> const&)
|
||||
static void test(
|
||||
std::basic_string<charT, std::char_traits<charT>, Allocator> const&)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
@@ -20,13 +20,18 @@ int main() {}
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable:4244) // conversion from 'unsigned long' to 'unsigned short', possible loss of data
|
||||
#pragma warning(disable:4245) // conversion from 'int' to 'const unsigned short', signed/unsigned mismatch
|
||||
#pragma warning(disable:4305) // truncation from 'double' to 'const std::complex<float>::_Ty'
|
||||
#pragma warning(disable:4309) // truncation of constant value
|
||||
#pragma warning(disable:4512) // assignment operator could not be generated
|
||||
#pragma warning(disable:4244) // conversion from 'unsigned long' to
|
||||
// 'unsigned short', possible loss of data
|
||||
#pragma warning(disable:4245) // conversion from 'int' to
|
||||
// 'const unsigned short',
|
||||
// signed/unsigned mismatch
|
||||
#pragma warning(disable:4305) // truncation from 'double' to
|
||||
// 'const std::complex<float>::_Ty'
|
||||
#pragma warning(disable:4309) // truncation of constant value
|
||||
#pragma warning(disable:4512) // assignment operator could not be generated
|
||||
#if BOOST_MSVC < 1400
|
||||
#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int', possible loss of data
|
||||
#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int',
|
||||
// possible loss of data
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@@ -84,8 +84,8 @@ void custom_tests()
|
||||
HASH_NAMESPACE::hash_combine(seed2, 250u);
|
||||
HASH_NAMESPACE::hash_combine(seed2, 350u);
|
||||
|
||||
BOOST_TEST(seed ==
|
||||
HASH_NAMESPACE::hash_range(custom_vector.begin(), custom_vector.end()));
|
||||
BOOST_TEST(seed == HASH_NAMESPACE::hash_range(
|
||||
custom_vector.begin(), custom_vector.end()));
|
||||
BOOST_TEST(seed == seed2);
|
||||
}
|
||||
|
||||
|
@@ -22,10 +22,11 @@
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127) // conditional expression is constant
|
||||
#pragma warning(disable:4723) // conditional expression is constant
|
||||
#pragma warning(disable:4127) // conditional expression is constant
|
||||
#pragma warning(disable:4723) // conditional expression is constant
|
||||
#if BOOST_MSVC < 1400
|
||||
#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int', possible loss of data
|
||||
#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int',
|
||||
// possible loss of data
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -36,23 +37,33 @@ char const* float_type(long double*) { return "long double"; }
|
||||
template <class T>
|
||||
void float_tests(char const* name, T* = 0)
|
||||
{
|
||||
std::cerr<<"\n"
|
||||
<<"Testing " BOOST_STRINGIZE(HASH_NAMESPACE) "::hash<"<<name<<">\n"
|
||||
<<"\n"
|
||||
<<"boost::hash_detail::limits<T>::digits = "
|
||||
<<boost::hash_detail::limits<T>::digits<<"\n"
|
||||
<<"boost::hash_detail::limits<int>::digits = "
|
||||
<<boost::hash_detail::limits<int>::digits<<"\n"
|
||||
<<"boost::hash_detail::limits<std::size_t>::digits = "
|
||||
<<boost::hash_detail::limits<std::size_t>::digits<<"\n"
|
||||
<<"\n"
|
||||
<<"boost::hash_detail::call_ldexp<T>::float_type = "
|
||||
<<float_type((BOOST_DEDUCED_TYPENAME boost::hash_detail::call_ldexp<T>::float_type*)0)<<"\n"
|
||||
<<"boost::hash_detail::call_frexp<T>::float_type = "
|
||||
<<float_type((BOOST_DEDUCED_TYPENAME boost::hash_detail::call_frexp<T>::float_type*)0)<<"\n"
|
||||
<<"boost::hash_detail::select_hash_type<T>::type = "
|
||||
<<float_type((BOOST_DEDUCED_TYPENAME boost::hash_detail::select_hash_type<T>::type*)0)<<"\n"
|
||||
<<"\n"
|
||||
std::cerr
|
||||
<< "\n"
|
||||
<< "Testing " BOOST_STRINGIZE(HASH_NAMESPACE) "::hash<"
|
||||
<< name
|
||||
<< ">\n"
|
||||
<< "\n"
|
||||
<< "boost::hash_detail::limits<T>::digits = "
|
||||
<< boost::hash_detail::limits<T>::digits<< "\n"
|
||||
<< "boost::hash_detail::limits<int>::digits = "
|
||||
<< boost::hash_detail::limits<int>::digits<< "\n"
|
||||
<< "boost::hash_detail::limits<std::size_t>::digits = "
|
||||
<< boost::hash_detail::limits<std::size_t>::digits
|
||||
<< "\n"
|
||||
<< "\n"
|
||||
<< "boost::hash_detail::call_ldexp<T>::float_type = "
|
||||
<< float_type(static_cast<BOOST_DEDUCED_TYPENAME
|
||||
boost::hash_detail::call_ldexp<T>::float_type*>(0))
|
||||
<< "\n"
|
||||
<< "boost::hash_detail::call_frexp<T>::float_type = "
|
||||
<< float_type(static_cast<BOOST_DEDUCED_TYPENAME
|
||||
boost::hash_detail::call_frexp<T>::float_type*>(0))
|
||||
<< "\n"
|
||||
<< "boost::hash_detail::select_hash_type<T>::type = "
|
||||
<< float_type(static_cast<BOOST_DEDUCED_TYPENAME
|
||||
boost::hash_detail::select_hash_type<T>::type*>(0))
|
||||
<< "\n"
|
||||
<< "\n"
|
||||
;
|
||||
|
||||
HASH_NAMESPACE::hash<T> x1;
|
||||
@@ -72,7 +83,9 @@ void float_tests(char const* name, T* = 0)
|
||||
|
||||
// Doing anything with infinity causes borland to crash.
|
||||
#if defined(__BORLANDC__)
|
||||
std::cerr<<"Not running infinity checks on Borland, as it causes it to crash.\n";
|
||||
std::cerr
|
||||
<< "Not running infinity checks on Borland, as it causes it to crash."
|
||||
"\n";
|
||||
#else
|
||||
if(boost::hash_detail::limits<T>::has_infinity) {
|
||||
T infinity = -log(zero);
|
||||
@@ -111,19 +124,40 @@ void float_tests(char const* name, T* = 0)
|
||||
// This should really be 'has_denorm == denorm_present' but some
|
||||
// compilers don't have 'denorm_present'. See also a later use.
|
||||
if(boost::hash_detail::limits<T>::has_denorm) {
|
||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) == x1(infinity)) {
|
||||
std::cerr<<"x1(denorm_min) == x1(infinity) == "<<x1(infinity)<<"\n";
|
||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) == x1(infinity))
|
||||
{
|
||||
std::cerr
|
||||
<< "x1(denorm_min) == x1(infinity) == "
|
||||
<< x1(infinity)
|
||||
<< "\n";
|
||||
}
|
||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) == x1(minus_infinity)) {
|
||||
std::cerr<<"x1(denorm_min) == x1(-infinity) == "<<x1(minus_infinity)<<"\n";
|
||||
|
||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) ==
|
||||
x1(minus_infinity))
|
||||
{
|
||||
std::cerr
|
||||
<< "x1(denorm_min) == x1(-infinity) == "
|
||||
<< x1(minus_infinity)
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(boost::hash_detail::limits<T>::has_quiet_NaN) {
|
||||
if(x1(boost::hash_detail::limits<T>::quiet_NaN()) == x1(infinity)) {
|
||||
std::cerr<<"x1(quiet_NaN) == x1(infinity) == "<<x1(infinity)<<"\n";
|
||||
if(x1(boost::hash_detail::limits<T>::quiet_NaN()) == x1(infinity))
|
||||
{
|
||||
std::cerr
|
||||
<< "x1(quiet_NaN) == x1(infinity) == "
|
||||
<< x1(infinity)
|
||||
<< "\n";
|
||||
}
|
||||
if(x1(boost::hash_detail::limits<T>::quiet_NaN()) == x1(minus_infinity)) {
|
||||
std::cerr<<"x1(quiet_NaN) == x1(-infinity) == "<<x1(minus_infinity)<<"\n";
|
||||
|
||||
if(x1(boost::hash_detail::limits<T>::quiet_NaN()) ==
|
||||
x1(minus_infinity))
|
||||
{
|
||||
std::cerr
|
||||
<< "x1(quiet_NaN) == x1(-infinity) == "
|
||||
<< x1(minus_infinity)
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,10 +180,12 @@ void float_tests(char const* name, T* = 0)
|
||||
BOOST_TEST(x1(max) == HASH_NAMESPACE::hash_value(max));
|
||||
BOOST_TEST(x1(half_max) == HASH_NAMESPACE::hash_value(half_max));
|
||||
BOOST_TEST(x1(quarter_max) == HASH_NAMESPACE::hash_value(quarter_max));
|
||||
BOOST_TEST(x1(three_quarter_max) == HASH_NAMESPACE::hash_value(three_quarter_max));
|
||||
BOOST_TEST(x1(three_quarter_max) ==
|
||||
HASH_NAMESPACE::hash_value(three_quarter_max));
|
||||
#endif
|
||||
|
||||
// The '!=' tests could legitimately fail, but with my hash it indicates a bug.
|
||||
// The '!=' tests could legitimately fail, but with my hash it indicates a
|
||||
// bug.
|
||||
BOOST_TEST(x1(max) == x1(max));
|
||||
BOOST_TEST(x1(max) != x1(quarter_max));
|
||||
BOOST_TEST(x1(max) != x1(half_max));
|
||||
@@ -179,7 +215,8 @@ void float_tests(char const* name, T* = 0)
|
||||
|
||||
#if defined(TEST_EXTENSIONS)
|
||||
BOOST_TEST(x1(boost::hash_detail::limits<T>::epsilon()) ==
|
||||
HASH_NAMESPACE::hash_value(boost::hash_detail::limits<T>::epsilon()));
|
||||
HASH_NAMESPACE::hash_value(
|
||||
boost::hash_detail::limits<T>::epsilon()));
|
||||
#endif
|
||||
|
||||
BOOST_TEST(boost::hash_detail::limits<T>::epsilon() != (T) 0);
|
||||
@@ -216,14 +253,19 @@ void float_tests(char const* name, T* = 0)
|
||||
// specialization of boost::hash_detail::limits::denorm_min() for long
|
||||
// doubles which causes this test to fail.
|
||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) !=
|
||||
HASH_NAMESPACE::hash_value(boost::hash_detail::limits<T>::denorm_min()))
|
||||
HASH_NAMESPACE::hash_value(
|
||||
boost::hash_detail::limits<T>::denorm_min()))
|
||||
{
|
||||
std::cerr<<"x1(boost::hash_detail::limits<T>::denorm_min()) = "
|
||||
<< x1(boost::hash_detail::limits<T>::denorm_min())
|
||||
<< "\nhash_value(boost::hash_detail::limits<T>::denorm_min()) = "
|
||||
<< HASH_NAMESPACE::hash_value(
|
||||
std::cerr
|
||||
<< "x1(boost::hash_detail::limits<T>::denorm_min()) = "
|
||||
<< x1(boost::hash_detail::limits<T>::denorm_min())
|
||||
<< "\nhash_value(boost::hash_detail::limits<T>::denorm_min())"
|
||||
" = "
|
||||
<< HASH_NAMESPACE::hash_value(
|
||||
boost::hash_detail::limits<T>::denorm_min())
|
||||
<< "\nx1(0) = "<<x1(0)<<"\n";
|
||||
<< "\nx1(0) = "
|
||||
<< x1(0)
|
||||
<< "\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -235,7 +277,8 @@ void float_tests(char const* name, T* = 0)
|
||||
std::cerr<<"x1(quiet_NaN) == x1(1.0) == "<<x1(1.0)<<"\n";
|
||||
}
|
||||
BOOST_TEST(x1(boost::hash_detail::limits<T>::quiet_NaN()) ==
|
||||
HASH_NAMESPACE::hash_value(boost::hash_detail::limits<T>::quiet_NaN()));
|
||||
HASH_NAMESPACE::hash_value(
|
||||
boost::hash_detail::limits<T>::quiet_NaN()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -87,8 +87,8 @@ void custom_tests()
|
||||
HASH_NAMESPACE::hash_combine(seed2, 250u);
|
||||
HASH_NAMESPACE::hash_combine(seed2, 350u);
|
||||
|
||||
BOOST_TEST(seed ==
|
||||
HASH_NAMESPACE::hash_range(custom_vector.begin(), custom_vector.end()));
|
||||
BOOST_TEST(seed == HASH_NAMESPACE::hash_range(
|
||||
custom_vector.begin(), custom_vector.end()));
|
||||
BOOST_TEST(seed == seed2);
|
||||
}
|
||||
|
||||
|
@@ -60,7 +60,8 @@ namespace test {
|
||||
template <class T>
|
||||
std::size_t hash_value(test_type3<T> const& x)
|
||||
{
|
||||
std::size_t seed = HASH_NAMESPACE::hash_range(x.values.begin(), x.values.end());
|
||||
std::size_t seed =
|
||||
HASH_NAMESPACE::hash_range(x.values.begin(), x.values.end());
|
||||
HASH_NAMESPACE::hash_range(seed, x.values.begin(), x.values.end());
|
||||
return seed;
|
||||
}
|
||||
@@ -91,7 +92,8 @@ namespace boost
|
||||
template <class T>
|
||||
std::size_t hash_value(test::test_type3<T> const& x)
|
||||
{
|
||||
std::size_t seed = HASH_NAMESPACE::hash_range(x.values.begin(), x.values.end());
|
||||
std::size_t seed =
|
||||
HASH_NAMESPACE::hash_range(x.values.begin(), x.values.end());
|
||||
HASH_NAMESPACE::hash_range(seed, x.values.begin(), x.values.end());
|
||||
return seed;
|
||||
}
|
||||
|
@@ -68,10 +68,12 @@ void fwd_test3()
|
||||
test::test_type3<int> x(values1.begin(), values1.end());
|
||||
test::test_type3<std::string> y(values2.begin(), values2.end());
|
||||
|
||||
std::size_t seed1 = HASH_NAMESPACE::hash_range(values1.begin(), values1.end());
|
||||
std::size_t seed1 =
|
||||
HASH_NAMESPACE::hash_range(values1.begin(), values1.end());
|
||||
HASH_NAMESPACE::hash_range(seed1, values1.begin(), values1.end());
|
||||
|
||||
std::size_t seed2 = HASH_NAMESPACE::hash_range(values2.begin(), values2.end());
|
||||
std::size_t seed2 =
|
||||
HASH_NAMESPACE::hash_range(values2.begin(), values2.end());
|
||||
HASH_NAMESPACE::hash_range(seed2, values2.begin(), values2.end());
|
||||
|
||||
HASH_NAMESPACE::hash<test::test_type3<int> > hasher_test_int;
|
||||
@@ -92,4 +94,3 @@ int main()
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@@ -85,8 +85,8 @@ void custom_tests()
|
||||
HASH_NAMESPACE::hash_combine(seed2, 250u);
|
||||
HASH_NAMESPACE::hash_combine(seed2, 350u);
|
||||
|
||||
BOOST_TEST(seed ==
|
||||
HASH_NAMESPACE::hash_range(custom_vector.begin(), custom_vector.end()));
|
||||
BOOST_TEST(seed == HASH_NAMESPACE::hash_range(
|
||||
custom_vector.begin(), custom_vector.end()));
|
||||
BOOST_TEST(seed == seed2);
|
||||
}
|
||||
|
||||
|
@@ -55,8 +55,11 @@ void numeric_test(T*)
|
||||
|
||||
if (limits::is_integer)
|
||||
{
|
||||
if(limits::is_signed || limits::digits <= boost::hash_detail::limits<std::size_t>::digits)
|
||||
if(limits::is_signed ||
|
||||
limits::digits <= boost::hash_detail::limits<std::size_t>::digits)
|
||||
{
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(T(-5)) == (std::size_t)T(-5));
|
||||
}
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(T(0)) == (std::size_t)T(0u));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(T(10)) == (std::size_t)T(10u));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(T(25)) == (std::size_t)T(25u));
|
||||
|
@@ -70,10 +70,12 @@ void hash_range_tests()
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_range(values3.begin(), values3.end())
|
||||
== HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
|
||||
std::size_t seed = HASH_NAMESPACE::hash_range(values3.begin(), values3.end());
|
||||
std::size_t seed =
|
||||
HASH_NAMESPACE::hash_range(values3.begin(), values3.end());
|
||||
HASH_NAMESPACE::hash_range(seed, values4.begin(), values4.end());
|
||||
HASH_NAMESPACE::hash_range(seed, x.begin(), x.end());
|
||||
BOOST_TEST(seed == HASH_NAMESPACE::hash_range(values5.begin(), values5.end()));
|
||||
BOOST_TEST(seed ==
|
||||
HASH_NAMESPACE::hash_range(values5.begin(), values5.end()));
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -20,7 +20,8 @@
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||
#if BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
&& !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||
#define BOOST_HASH_CHAR_TRAITS string_char_traits
|
||||
#else
|
||||
#define BOOST_HASH_CHAR_TRAITS char_traits
|
||||
@@ -67,7 +68,8 @@ namespace boost
|
||||
std::size_t hash_value(long double v);
|
||||
|
||||
template <class Ch, class A>
|
||||
std::size_t hash_value(std::basic_string<Ch, std::BOOST_HASH_CHAR_TRAITS<Ch>, A> const&);
|
||||
std::size_t hash_value(
|
||||
std::basic_string<Ch, std::BOOST_HASH_CHAR_TRAITS<Ch>, A> const&);
|
||||
|
||||
// Implementation
|
||||
|
||||
@@ -200,9 +202,10 @@ namespace boost
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
#if BOOST_MSVC <= 1400
|
||||
#pragma warning(disable:4267) // 'argument' : conversion from 'size_t' to 'unsigned int',
|
||||
// possible loss of data
|
||||
// A misguided attempt to detect 64-bit incompatability.
|
||||
#pragma warning(disable:4267) // 'argument' : conversion from 'size_t' to
|
||||
// 'unsigned int', possible loss of data
|
||||
// A misguided attempt to detect 64-bit
|
||||
// incompatability.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -285,7 +288,8 @@ namespace boost
|
||||
#endif
|
||||
|
||||
template <class Ch, class A>
|
||||
inline std::size_t hash_value(std::basic_string<Ch, std::BOOST_HASH_CHAR_TRAITS<Ch>, A> const& v)
|
||||
inline std::size_t hash_value(
|
||||
std::basic_string<Ch, std::BOOST_HASH_CHAR_TRAITS<Ch>, A> const& v)
|
||||
{
|
||||
return hash_range(v.begin(), v.end());
|
||||
}
|
||||
@@ -310,8 +314,8 @@ namespace boost
|
||||
//
|
||||
|
||||
// Define the specializations required by the standard. The general purpose
|
||||
// boost::hash is defined later in extensions.hpp if BOOST_HASH_NO_EXTENSIONS
|
||||
// is not defined.
|
||||
// boost::hash is defined later in extensions.hpp if
|
||||
// BOOST_HASH_NO_EXTENSIONS is not defined.
|
||||
|
||||
// BOOST_HASH_SPECIALIZE - define a specialization for a type which is
|
||||
// passed by copy.
|
||||
|
Reference in New Issue
Block a user