Specialize std::numeric_limits<> for wxLongLong and wxULongLong.
numeric_limits<> should be specialized for number-like types to allow using them in a similar way to the built-in types. Closes #13162. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1075,6 +1075,31 @@ WXDLLIMPEXP_BASE class wxTextInputStream &operator>>(class wxTextInputStream &st
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Specialize numeric_limits<> for our long long wrapper classes.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_LONGLONG_NATIVE
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template<> class numeric_limits<wxLongLong>
|
||||||
|
: public numeric_limits<wxLongLong_t>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> class numeric_limits<wxULongLong>
|
||||||
|
: public numeric_limits<wxULongLong_t>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
#endif // wxUSE_LONGLONG_NATIVE
|
||||||
|
|
||||||
#endif // wxUSE_LONGLONG
|
#endif // wxUSE_LONGLONG
|
||||||
|
|
||||||
#endif // _WX_LONGLONG_H
|
#endif // _WX_LONGLONG_H
|
||||||
|
@@ -69,6 +69,7 @@ private:
|
|||||||
CPPUNIT_TEST( BitOperations );
|
CPPUNIT_TEST( BitOperations );
|
||||||
CPPUNIT_TEST( ToString );
|
CPPUNIT_TEST( ToString );
|
||||||
CPPUNIT_TEST( LoHi );
|
CPPUNIT_TEST( LoHi );
|
||||||
|
CPPUNIT_TEST( Limits );
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
void Conversion();
|
void Conversion();
|
||||||
@@ -79,6 +80,7 @@ private:
|
|||||||
void BitOperations();
|
void BitOperations();
|
||||||
void ToString();
|
void ToString();
|
||||||
void LoHi();
|
void LoHi();
|
||||||
|
void Limits();
|
||||||
|
|
||||||
DECLARE_NO_COPY_CLASS(LongLongTestCase)
|
DECLARE_NO_COPY_CLASS(LongLongTestCase)
|
||||||
};
|
};
|
||||||
@@ -337,4 +339,15 @@ void LongLongTestCase::LoHi()
|
|||||||
CPPUNIT_ASSERT_EQUAL( 987u, ull.GetHi() );
|
CPPUNIT_ASSERT_EQUAL( 987u, ull.GetHi() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LongLongTestCase::Limits()
|
||||||
|
{
|
||||||
|
#if wxUSE_LONGLONG_NATIVE
|
||||||
|
CPPUNIT_ASSERT( std::numeric_limits<wxLongLong>::is_specialized );
|
||||||
|
CPPUNIT_ASSERT( std::numeric_limits<wxULongLong>::is_specialized );
|
||||||
|
|
||||||
|
wxULongLong maxval = std::numeric_limits<wxULongLong>::max();
|
||||||
|
CPPUNIT_ASSERT( maxval.ToDouble() > 0 );
|
||||||
|
#endif // wxUSE_LONGLONG_NATIVE
|
||||||
|
}
|
||||||
|
|
||||||
#endif // wxUSE_LONGLONG
|
#endif // wxUSE_LONGLONG
|
||||||
|
Reference in New Issue
Block a user