Compare commits

..

1 Commits

Author SHA1 Message Date
nobody c622558246 This commit was manufactured by cvs2svn to create tag
'Version_1_20_1'.

[SVN r8548]
2001-01-10 18:29:12 +00:00
4 changed files with 33 additions and 40 deletions
+4 -4
View File
@@ -9,13 +9,13 @@
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 20 Jan 01 removed use of <limits> for portability to raw GCC (David Abrahams)
// 28 Jun 00 implicit_cast removed (Beman Dawes)
// 30 Aug 99 value_cast replaced by numeric_cast
// 3 Aug 99 Initial Version
#include <iostream>
#include <climits>
#include <limits>
#include <boost/cast.hpp>
# if SCHAR_MAX == LONG_MAX
@@ -95,8 +95,8 @@ int main( int argc, char * argv[] )
// tests which should succeed
long small_value = 1;
long small_negative_value = -1;
long large_value = LONG_MAX;
long large_negative_value = LONG_MIN;
long large_value = std::numeric_limits<long>::max();
long large_negative_value = std::numeric_limits<long>::min();
signed char c = 0;
c = large_value; // see if compiler generates warning
@@ -142,7 +142,7 @@ int main( int argc, char * argv[] )
if ( !caught_exception ) ++err_count;
caught_exception = false;
try { numeric_cast<int>( DBL_MAX ); }
try { numeric_cast<int>( std::numeric_limits<double>::max() ); }
catch (bad_numeric_cast)
{ cout<<"caught bad_numeric_cast #5\n"; caught_exception = true; }
if ( !caught_exception ) ++err_count;
+25 -22
View File
@@ -9,13 +9,6 @@
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never
// worked with stock GCC; trying to get it to do that broke
// vc-stlport.
// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp.
// Removed unused BOOST_EXPLICIT_TARGET macro. Moved
// boost::detail::type to boost/type.hpp. Made it compile with
// stock gcc again (Dave Abrahams)
// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal
// Review (Beman Dawes)
// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams)
@@ -41,11 +34,8 @@
# include <boost/config.hpp>
# include <cassert>
# include <typeinfo>
# include <boost/type.hpp>
# ifndef BOOST_NO_LIMITS
# include <limits>
# endif
# include <typeinfo>
# include <limits>
// It has been demonstrated numerous times that MSVC 6.0 fails silently at link
// time if you use a template function which has template parameters that don't
@@ -53,13 +43,20 @@
//
// TODO: Add this to config.hpp?
# if defined(BOOST_MSVC) && BOOST_MSVC <= 1200 // 1200 = VC6
# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type<Target>* = 0
# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::detail::type_wrapper<Target>* = 0
# define BOOST_EXPLICIT_TARGET ,::boost::detail::type_wrapper<Target>*
# else
# define BOOST_EXPLICIT_DEFAULT_TARGET
# define BOOST_EXPLICIT_TARGET
# endif
namespace boost
{
namespace detail
{
template <class T> struct type_wrapper {};
}
// See the documentation for descriptions of how to choose between
// static_cast<>, dynamic_cast<>, polymorphic_cast<> and polymorphic_downcast<>
@@ -119,6 +116,17 @@ namespace boost
// numeric_cast ------------------------------------------------------------//
// Move to config.hpp?
#if defined(_RWSTD_VER) || (defined(__SGI_STL_PORT) && __SGI_STL_PORT <= 0x400 && __STL_STATIC_CONST_INIT_BUG)
// STLPort 4.0 doesn't define the static constants in numeric_limits<> so that they
// can be used at compile time if the compiler bug indicated by
// __STL_STATIC_CONST_INIT_BUG is present.
// Rogue wave STL (C++ Builder) also has broken numeric_limits
// with default template defining members out of line.
# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
#endif
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
namespace detail
@@ -263,10 +271,8 @@ namespace boost
# pragma warning(disable : 4018)
# pragma warning(disable : 4146)
#elif defined(__BORLANDC__)
# pragma option push -w-8041
#pragma option push -w-8041
# endif
# ifndef BOOST_NO_LIMITS
// Move to namespace boost in utility.hpp?
template <class T>
struct fixed_numeric_limits : public std::numeric_limits<T>
@@ -277,12 +283,10 @@ namespace boost
? T(-std::numeric_limits<T>::max()) : std::numeric_limits<T>::min();
}
};
# endif // BOOST_NO_LIMITS
# if BOOST_MSVC
# pragma warning(pop)
#elif defined(__BORLANDC__)
# pragma option pop
#pragma option pop
# endif
} // namespace detail
@@ -291,12 +295,10 @@ namespace boost
template<typename Target, typename Source>
inline Target numeric_cast(Source arg BOOST_EXPLICIT_DEFAULT_TARGET)
{
#ifndef BOOST_NO_LIMITS
// typedefs abbreviating respective trait classes
typedef std::numeric_limits<Source> arg_traits;
typedef detail::fixed_numeric_limits<Target> result_traits;
#endif
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
// typedefs that act as compile time assertions
// (to be replaced by boost compile time assertions
@@ -336,6 +338,7 @@ namespace boost
} // numeric_cast
# undef BOOST_EXPLICIT_DEFAULT_TARGET
# undef BOOST_EXPLICIT_TARGET
} // namespace boost
+1 -1
View File
@@ -127,7 +127,7 @@ void log_errno(int yoko)
<hr>
<h2><a name="synopsis">Synopsis</a></h2>
Library features defined in <a href="../../boost/lexical_cast.hpp"><code>&quot;boost/lexical_cast.hpp&quot;</code></a>:
Library features defined in <a href="lexical_cast.hpp"><code>&quot;boost/lexical_cast.hpp&quot;</code></a>:
<blockquote>
<pre>
+3 -13
View File
@@ -2,9 +2,6 @@
// who: developed by Kevlin Henney
// when: November 2000
// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.91
//
// ChangeLog:
// 20 Jan 2001 - Fixed a warning for MSVC (Dave Abrahams)
#ifndef TEST_INCLUDED
#define TEST_INCLUDED
@@ -43,13 +40,6 @@ namespace test // failure exception used to indicate checked test failures
{
}
// std::~string has no exception-specification (could throw anything),
// but we need to be compatible with std::~exception's empty one
// see std::15.4p13 and std::15.4p3
~failure() throw()
{
}
public: // usage
virtual const char * what() const throw()
@@ -114,14 +104,14 @@ namespace test // test utilities
check(lhs != rhs, "expected unequal values: " + description);
}
inline void check_null(const void* ptr, const std::string & description)
inline void check_null(const void * ptr, const std::string & description)
{
check(!ptr, "expected null pointer: " + description);
}
inline void check_non_null(const void* ptr, const std::string & description)
inline void check_non_null(const void * ptr, const std::string & description)
{
check(ptr != 0, "expected non-null pointer: " + description);
check(ptr, "expected non-null pointer: " + description);
}
}