Compare commits

..

18 Commits

Author SHA1 Message Date
b3b5b039f7 Changed BOOST_SYSTEM_HAS_STDINT_H to BOOST_HAS_STDINT_H
[SVN r10888]
2001-08-18 10:25:02 +00:00
0462a811f6 This commit was manufactured by cvs2svn to create branch 'split-config'.
[SVN r10742]
2001-08-04 14:31:38 +00:00
c6f3dce91a Fixed VC6+STLport-4.1b6 (changed preprocessor logic)
[SVN r10360]
2001-06-20 11:42:44 +00:00
3e2b929118 free -> fee
[SVN r10248]
2001-05-31 17:22:20 +00:00
645f809379 fix the "gcc 3.0 and long long" fix to check for the appropriate symbol
[SVN r10107]
2001-05-13 18:17:15 +00:00
28ec7fa76c Don't use "long long" with gcc 3.0's shipped library, because it does
not define operator<<(ostream&, long long) overloads.


[SVN r10095]
2001-05-11 17:04:56 +00:00
07505c76f8 Preprocessor fix for VC6 + STLPort 4.1b6
[SVN r10087]
2001-05-11 10:47:57 +00:00
fda46f9780 HP-UX needs special attention because ULONG_LONG_MAX is not fully usable
[SVN r10080]
2001-05-09 21:07:20 +00:00
125bf3351f gcc on HP-UX doesn't have WCHAR_MIN and WCHAR_MAX
[SVN r10068]
2001-05-08 18:15:32 +00:00
e3702f3abc int64_t may not be defined on HP-UX when using gcc
[SVN r10067]
2001-05-08 18:14:14 +00:00
c54da75efb Fixed more wchar_t problems
[SVN r10058]
2001-05-08 11:11:30 +00:00
2dd1bee693 add HP-UX workaround
[SVN r10051]
2001-05-07 21:21:13 +00:00
949134726f fix the fix for SGI MIPSpro with STLport
[SVN r10008]
2001-05-03 11:57:57 +00:00
b3f587b9f7 IRIX doesn't have WCHAR_MIN and WCHAR_MAX, either
[SVN r10005]
2001-05-02 16:18:08 +00:00
215b4d8ee7 compactify John Maddock's fix for Borland C++ / WCHAR_MIN, WCHAR_MAX
[SVN r10004]
2001-05-02 15:44:02 +00:00
976c5e6572 Fix for Borland C++ and wchar_t
[SVN r10001]
2001-05-02 10:58:30 +00:00
0424bb266e use Boost.Test
test wchar_t
output a message when int64_t is not available


[SVN r9998]
2001-04-30 13:38:23 +00:00
33abcf7250 use BOOST_STATIC_CONSTANT
define static member constants
add wchar_t specialization


[SVN r9997]
2001-04-30 13:36:05 +00:00
4 changed files with 76 additions and 41 deletions

View File

@ -24,9 +24,19 @@
#include <boost/config.hpp>
#ifdef BOOST_SYSTEM_HAS_STDINT_H
#ifdef BOOST_HAS_STDINT_H
# include <stdint.h> // implementation artifact; not part of interface
// The following #include is an implementation artifact; not part of interface.
# ifdef __hpux
// HP-UX has a nice <stdint.h> in a non-standard location
# include <sys/_inttypes.h>
# ifdef __STDC_32_MODE__
// this is triggered with GCC, because it defines __cplusplus < 199707L
# define BOOST_NO_INT64_T
# endif
# else
# include <stdint.h>
# endif
namespace boost
{
@ -69,7 +79,7 @@ namespace boost
} // namespace boost
#else // BOOST_SYSTEM_HAS_STDINT_H
#else // BOOST_HAS_STDINT_H
# include <limits.h> // implementation artifact; not part of interface
@ -134,7 +144,9 @@ namespace boost
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
# if defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX)
# if !defined(BOOST_MSVC) && !defined(__BORLANDC__) && \
(!defined(__GLIBCPP__) || defined(_GLIBCPP_USE_LONG_LONG)) && \
(defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
# if (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U) || (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
// 2**64 - 1
typedef long long intmax_t;
@ -183,7 +195,7 @@ namespace boost
} // namespace boost
#endif // BOOST_SYSTEM_HAS_STDINT_H
#endif // BOOST_HAS_STDINT_H
#endif // BOOST_CSTDINT_HPP
@ -254,8 +266,10 @@ Added 23rd September (John Maddock).
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
# if defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX)
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
# if (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || \
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U) || (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
(defined(ULONG_LONG_MAX) && (defined(__hpux) || ULONG_LONG_MAX == 18446744073709551615U)) || \
(defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
# define INT64_C(value) value##LL
# define UINT64_C(value) value##uLL
# else
@ -299,3 +313,4 @@ Added 23rd September (John Maddock).
#endif // __STDC_CONSTANT_MACROS_DEFINED etc.

View File

@ -21,8 +21,11 @@
#include <boost/config.hpp>
#include <boost/limits.hpp>
// This is an implementation detail and not part of the interface
// These are an implementation detail and not part of the interface
#include <limits.h>
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
#include <wchar.h>
#endif
namespace boost {
@ -30,11 +33,7 @@ template<class T>
class integer_traits : public std::numeric_limits<T>
{
public:
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
static const bool is_integral = false;
#else
enum { is_integral = false };
#endif
BOOST_STATIC_CONSTANT(bool, is_integral = false);
};
namespace detail {
@ -42,18 +41,20 @@ template<class T, T min_val, T max_val>
class integer_traits_base
{
public:
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
static const bool is_integral = true;
static const T const_min = min_val;
static const T const_max = max_val;
#else
enum {
is_integral = true,
const_min = min_val,
const_max = max_val
};
#endif
BOOST_STATIC_CONSTANT(bool, is_integral = true);
BOOST_STATIC_CONSTANT(T, const_min = min_val);
BOOST_STATIC_CONSTANT(T, const_max = max_val);
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// The definition is required even for integral static constants
template<class T, T min_val, T max_val>
const T integer_traits_base<T, min_val, max_val>::const_min;
template<class T, T min_val, T max_val>
const T integer_traits_base<T, min_val, max_val>::const_max;
#endif
} // namespace detail
template<>
@ -80,7 +81,25 @@ class integer_traits<unsigned char>
public detail::integer_traits_base<unsigned char, 0, UCHAR_MAX>
{ };
// What about wchar_t ?
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<>
class integer_traits<wchar_t>
: public std::numeric_limits<wchar_t>,
#if defined(__BORLANDC__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__))
// No WCHAR_MIN and WCHAR_MAX, whar_t is short and unsigned:
public detail::integer_traits_base<wchar_t, 0, 0xffff>
#elif defined(__sgi) && (!defined(__SGI_STL_PORT) || __SGI_STL_PORT < 0x400)
// SGI MIPSpro with native library doesn't have them, either
public detail::integer_traits_base<wchar_t, INT_MIN, INT_MAX>
#elif defined(__hpux) && defined(__GNUC__) && !defined(__SGI_STL_PORT)
// GCC 2.95.2 doesn't have them on HP-UX, either
// (also, std::numeric_limits<wchar_t> appears to return the wrong values)
public detail::integer_traits_base<wchar_t, 0, UINT_MAX>
#else
public detail::integer_traits_base<wchar_t, WCHAR_MIN, WCHAR_MAX>
#endif
{ };
#endif // BOOST_NO_INTRINSIC_WCHAR_T
template<>
class integer_traits<short>
@ -140,7 +159,7 @@ class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, ULONG_LONG_MAX>
{ };
#elif defined(ULONGLONG_MAX)
#elif defined(ULONGLONG_MAX) && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
@ -156,3 +175,4 @@ class integer_traits<unsigned long long>
} // namespace boost
#endif /* BOOST_INTEGER_TRAITS_HPP */

View File

@ -14,11 +14,11 @@
// NOTE OF OBSOLESCENCE: In general, this header file cannot detect
// whether the current translation unit somewhere includes ISO C99
// <stdint.h> or not. For example, in case BOOST_SYSTEM_HAS_STDINT_H
// <stdint.h> or not. For example, in case BOOST_HAS_STDINT_H
// is not defined and ISO C99 <stdint.h> has been included before,
// this file will re-define ISO C99 reserved file-scope identifiers
// such as int8_t (see ISO C99 7.1.3 and 7.18). Defining the macro
// BOOST_SYSTEM_HAS_STDINT_H is not sufficient in general, in
// BOOST_HAS_STDINT_H is not sufficient in general, in
// particular if a partly conformant <stdint.h> header is available
// on the platform, e.g. Comeau C++ with GNU glibc 2.1.2.
//
@ -40,7 +40,7 @@
#include <boost/config.hpp>
#ifdef BOOST_SYSTEM_HAS_STDINT_H
#ifdef BOOST_HAS_STDINT_H
#include <stdint.h>
#else
@ -150,7 +150,7 @@
typedef uint32_t uintmax_t;
# endif
#endif // BOOST_SYSTEM_HAS_STDINT_H not defined
#endif // BOOST_HAS_STDINT_H not defined
#endif // BOOST_STDINT_H
/****************************************************

View File

@ -2,7 +2,7 @@
*
* Copyright Jens Maurer 2000
* Permission to use, copy, modify, sell, and distribute this software
* is hereby granted without free provided that the above copyright notice
* is hereby granted without fee provided that the above copyright notice
* appears in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation,
*
@ -18,15 +18,12 @@
*/
#include <iostream>
#include <cassert>
#include <boost/integer_traits.hpp>
// use int64_t instead of long long for better portability
#include <boost/cstdint.hpp>
#ifdef NDEBUG
#error This test relies on assert() and thus makes no sense with NDEBUG defined
#endif
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
/*
* General portability note:
@ -46,14 +43,14 @@ void runtest(const char * type, T)
<< "; min is " << traits::min()
<< ", max is " << traits::max()
<< std::endl;
assert(traits::is_specialized);
assert(traits::is_integer);
assert(traits::is_integral);
assert(traits::const_min == traits::min());
assert(traits::const_max == traits::max());
BOOST_TEST(traits::is_specialized);
BOOST_TEST(traits::is_integer);
BOOST_TEST(traits::is_integral);
BOOST_TEST(traits::const_min == traits::min());
BOOST_TEST(traits::const_max == traits::max());
}
int main()
int test_main(int, char*[])
{
runtest("bool", bool());
runtest("char", char());
@ -61,6 +58,7 @@ int main()
runtest("signed char", signed_char());
typedef unsigned char unsigned_char;
runtest("unsigned char", unsigned_char());
runtest("wchar_t", wchar_t());
runtest("short", short());
typedef unsigned short unsigned_short;
runtest("unsigned short", unsigned_short());
@ -76,6 +74,8 @@ int main()
// BeOS doesn't have specialisations for long long in SGI's <limits> header.
runtest("int64_t (possibly long long)", boost::int64_t());
runtest("uint64_t (possibly unsigned long long)", boost::uint64_t());
#else
std::cout << "Skipped int64_t and uint64_t" << std::endl;
#endif
// Some compilers don't pay attention to std:3.6.1/5 and issue a
// warning here if "return 0;" is omitted.