epoc32/include/stdapis/boost/integer_traits.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/integer_traits.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,236 @@
     1.4 +/* boost integer_traits.hpp header file
     1.5 + *
     1.6 + * Copyright Jens Maurer 2000
     1.7 + * Distributed under the Boost Software License, Version 1.0. (See
     1.8 + * accompanying file LICENSE_1_0.txt or copy at
     1.9 + * http://www.boost.org/LICENSE_1_0.txt)
    1.10 + *
    1.11 + * $Id: integer_traits.hpp,v 1.30 2006/02/05 10:19:42 johnmaddock Exp $
    1.12 + *
    1.13 + * Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers
    1.14 + */
    1.15 +
    1.16 +//  See http://www.boost.org/libs/integer for documentation.
    1.17 +
    1.18 +
    1.19 +#ifndef BOOST_INTEGER_TRAITS_HPP
    1.20 +#define BOOST_INTEGER_TRAITS_HPP
    1.21 +
    1.22 +#include <boost/config.hpp>
    1.23 +#include <boost/limits.hpp>
    1.24 +
    1.25 +// These are an implementation detail and not part of the interface
    1.26 +#include <limits.h>
    1.27 +// we need wchar.h for WCHAR_MAX/MIN but not all platforms provide it,
    1.28 +// and some may have <wchar.h> but not <cwchar> ...
    1.29 +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && (!defined(BOOST_NO_CWCHAR) || defined(sun) || defined(__sun) || defined(__QNX__))
    1.30 +#include <wchar.h>
    1.31 +#endif
    1.32 +
    1.33 +
    1.34 +namespace boost {
    1.35 +template<class T>
    1.36 +class integer_traits : public std::numeric_limits<T>
    1.37 +{
    1.38 +public:
    1.39 +  BOOST_STATIC_CONSTANT(bool, is_integral = false);
    1.40 +};
    1.41 +
    1.42 +namespace detail {
    1.43 +template<class T, T min_val, T max_val>
    1.44 +class integer_traits_base
    1.45 +{
    1.46 +public:
    1.47 +  BOOST_STATIC_CONSTANT(bool, is_integral = true);
    1.48 +  BOOST_STATIC_CONSTANT(T, const_min = min_val);
    1.49 +  BOOST_STATIC_CONSTANT(T, const_max = max_val);
    1.50 +};
    1.51 +
    1.52 +#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
    1.53 +//  A definition is required even for integral static constants
    1.54 +template<class T, T min_val, T max_val>
    1.55 +const bool integer_traits_base<T, min_val, max_val>::is_integral;
    1.56 +
    1.57 +template<class T, T min_val, T max_val>
    1.58 +const T integer_traits_base<T, min_val, max_val>::const_min;
    1.59 +
    1.60 +template<class T, T min_val, T max_val>
    1.61 +const T integer_traits_base<T, min_val, max_val>::const_max;
    1.62 +#endif
    1.63 +
    1.64 +} // namespace detail
    1.65 +
    1.66 +template<>
    1.67 +class integer_traits<bool>
    1.68 +  : public std::numeric_limits<bool>,
    1.69 +    public detail::integer_traits_base<bool, false, true>
    1.70 +{ };
    1.71 +
    1.72 +template<>
    1.73 +class integer_traits<char>
    1.74 +  : public std::numeric_limits<char>,
    1.75 +    public detail::integer_traits_base<char, CHAR_MIN, CHAR_MAX>
    1.76 +{ };
    1.77 +
    1.78 +template<>
    1.79 +class integer_traits<signed char>
    1.80 +  : public std::numeric_limits<signed char>,
    1.81 +    public detail::integer_traits_base<signed char, SCHAR_MIN, SCHAR_MAX>
    1.82 +{ };
    1.83 +
    1.84 +template<>
    1.85 +class integer_traits<unsigned char>
    1.86 +  : public std::numeric_limits<unsigned char>,
    1.87 +    public detail::integer_traits_base<unsigned char, 0, UCHAR_MAX>
    1.88 +{ };
    1.89 +
    1.90 +#ifndef BOOST_NO_INTRINSIC_WCHAR_T
    1.91 +template<>
    1.92 +class integer_traits<wchar_t>
    1.93 +  : public std::numeric_limits<wchar_t>,
    1.94 +    // Don't trust WCHAR_MIN and WCHAR_MAX with Mac OS X's native
    1.95 +    // library: they are wrong!
    1.96 +#if defined(WCHAR_MIN) && defined(WCHAR_MAX) && !defined(__APPLE__)
    1.97 +    public detail::integer_traits_base<wchar_t, WCHAR_MIN, WCHAR_MAX>
    1.98 +#elif defined(__BORLANDC__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__))
    1.99 +    // No WCHAR_MIN and WCHAR_MAX, whar_t is short and unsigned:
   1.100 +    public detail::integer_traits_base<wchar_t, 0, 0xffff>
   1.101 +#elif (defined(__sgi) && (!defined(__SGI_STL_PORT) || __SGI_STL_PORT < 0x400))\
   1.102 +    || (defined __APPLE__)\
   1.103 +    || (defined(__OpenBSD__) && defined(__GNUC__))\
   1.104 +    || (defined(__NetBSD__) && defined(__GNUC__))\
   1.105 +    || (defined(__FreeBSD__) && defined(__GNUC__))\
   1.106 +    || (defined(__DragonFly__) && defined(__GNUC__))\
   1.107 +    || (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
   1.108 +    // No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as int.
   1.109 +    //  - SGI MIPSpro with native library
   1.110 +    //  - gcc 3.x on HP-UX
   1.111 +    //  - Mac OS X with native library
   1.112 +    //  - gcc on FreeBSD, OpenBSD and NetBSD
   1.113 +    public detail::integer_traits_base<wchar_t, INT_MIN, INT_MAX>
   1.114 +#elif defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 2) && !defined(__SGI_STL_PORT)
   1.115 +    // No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as unsigned int.
   1.116 +    //  - gcc 2.95.x on HP-UX
   1.117 +    // (also, std::numeric_limits<wchar_t> appears to return the wrong values).
   1.118 +    public detail::integer_traits_base<wchar_t, 0, UINT_MAX>
   1.119 +#else
   1.120 +#error No WCHAR_MIN and WCHAR_MAX present, please adjust integer_traits<> for your compiler.
   1.121 +#endif
   1.122 +{ };
   1.123 +#endif // BOOST_NO_INTRINSIC_WCHAR_T
   1.124 +
   1.125 +template<>
   1.126 +class integer_traits<short>
   1.127 +  : public std::numeric_limits<short>,
   1.128 +    public detail::integer_traits_base<short, SHRT_MIN, SHRT_MAX>
   1.129 +{ };
   1.130 +
   1.131 +template<>
   1.132 +class integer_traits<unsigned short>
   1.133 +  : public std::numeric_limits<unsigned short>,
   1.134 +    public detail::integer_traits_base<unsigned short, 0, USHRT_MAX>
   1.135 +{ };
   1.136 +
   1.137 +template<>
   1.138 +class integer_traits<int>
   1.139 +  : public std::numeric_limits<int>,
   1.140 +    public detail::integer_traits_base<int, INT_MIN, INT_MAX>
   1.141 +{ };
   1.142 +
   1.143 +template<>
   1.144 +class integer_traits<unsigned int>
   1.145 +  : public std::numeric_limits<unsigned int>,
   1.146 +    public detail::integer_traits_base<unsigned int, 0, UINT_MAX>
   1.147 +{ };
   1.148 +
   1.149 +template<>
   1.150 +class integer_traits<long>
   1.151 +  : public std::numeric_limits<long>,
   1.152 +    public detail::integer_traits_base<long, LONG_MIN, LONG_MAX>
   1.153 +{ };
   1.154 +
   1.155 +template<>
   1.156 +class integer_traits<unsigned long>
   1.157 +  : public std::numeric_limits<unsigned long>,
   1.158 +    public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
   1.159 +{ };
   1.160 +
   1.161 +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T)
   1.162 +#if defined(ULLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
   1.163 +
   1.164 +template<>
   1.165 +class integer_traits< ::boost::long_long_type>
   1.166 +  : public std::numeric_limits< ::boost::long_long_type>,
   1.167 +    public detail::integer_traits_base< ::boost::long_long_type, LLONG_MIN, LLONG_MAX>
   1.168 +{ };
   1.169 +
   1.170 +template<>
   1.171 +class integer_traits< ::boost::ulong_long_type>
   1.172 +  : public std::numeric_limits< ::boost::ulong_long_type>,
   1.173 +    public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULLONG_MAX>
   1.174 +{ };
   1.175 +
   1.176 +#elif defined(ULONG_LONG_MAX) && defined(BOOST_HAS_LONG_LONG)
   1.177 +
   1.178 +template<>
   1.179 +class integer_traits< ::boost::long_long_type>  : public std::numeric_limits< ::boost::long_long_type>,    public detail::integer_traits_base< ::boost::long_long_type, LONG_LONG_MIN, LONG_LONG_MAX>{ };
   1.180 +template<>
   1.181 +class integer_traits< ::boost::ulong_long_type>
   1.182 +  : public std::numeric_limits< ::boost::ulong_long_type>,
   1.183 +    public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULONG_LONG_MAX>
   1.184 +{ };
   1.185 +
   1.186 +#elif defined(ULONGLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
   1.187 +
   1.188 +template<>
   1.189 +class integer_traits< ::boost::long_long_type>
   1.190 +  : public std::numeric_limits< ::boost::long_long_type>,
   1.191 +    public detail::integer_traits_base< ::boost::long_long_type, LONGLONG_MIN, LONGLONG_MAX>
   1.192 +{ };
   1.193 +
   1.194 +template<>
   1.195 +class integer_traits< ::boost::ulong_long_type>
   1.196 +  : public std::numeric_limits< ::boost::ulong_long_type>,
   1.197 +    public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULONGLONG_MAX>
   1.198 +{ };
   1.199 +
   1.200 +#elif defined(_LLONG_MAX) && defined(_C2) && defined(BOOST_HAS_LONG_LONG)
   1.201 +
   1.202 +template<>
   1.203 +class integer_traits< ::boost::long_long_type>
   1.204 +  : public std::numeric_limits< ::boost::long_long_type>,
   1.205 +    public detail::integer_traits_base< ::boost::long_long_type, -_LLONG_MAX - _C2, _LLONG_MAX>
   1.206 +{ };
   1.207 +
   1.208 +template<>
   1.209 +class integer_traits< ::boost::ulong_long_type>
   1.210 +  : public std::numeric_limits< ::boost::ulong_long_type>,
   1.211 +    public detail::integer_traits_base< ::boost::ulong_long_type, 0, _ULLONG_MAX>
   1.212 +{ };
   1.213 +
   1.214 +#elif defined(BOOST_HAS_LONG_LONG)
   1.215 +//
   1.216 +// we have long long but no constants, this happens for example with gcc in -ansi mode,
   1.217 +// we'll just have to work out the values for ourselves (assumes 2's compliment representation):
   1.218 +//
   1.219 +template<>
   1.220 +class integer_traits< ::boost::long_long_type>
   1.221 +  : public std::numeric_limits< ::boost::long_long_type>,
   1.222 +    public detail::integer_traits_base< ::boost::long_long_type, (1LL << (sizeof(::boost::long_long_type) - 1)), ~(1LL << (sizeof(::boost::long_long_type) - 1))>
   1.223 +{ };
   1.224 +
   1.225 +template<>
   1.226 +class integer_traits< ::boost::ulong_long_type>
   1.227 +  : public std::numeric_limits< ::boost::ulong_long_type>,
   1.228 +    public detail::integer_traits_base< ::boost::ulong_long_type, 0, ~0uLL>
   1.229 +{ };
   1.230 +
   1.231 +#endif
   1.232 +#endif
   1.233 +
   1.234 +} // namespace boost
   1.235 +
   1.236 +#endif /* BOOST_INTEGER_TRAITS_HPP */
   1.237 +
   1.238 +
   1.239 +