forked from boostorg/type_traits
Pick up missing smart_ptr, utility, and type_traits files from full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41386]
This commit is contained in:
1 parent
2d9de2e57e
commit
0265a9354b
87 files changed
+4940
No files matched your search
@@ -0,0 +1,45 @@
|
||||
|
||||
// (C) Copyright John Maddock 2007.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "test.hpp"
|
||||
#include "check_integral_constant.hpp"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/is_complex.hpp>
|
||||
#endif
|
||||
#include <iostream>
|
||||
|
||||
struct bad_struct
|
||||
{
|
||||
operator std::complex<double> ()const;
|
||||
};
|
||||
|
||||
struct derived_complex : public std::complex<double>
|
||||
{
|
||||
};
|
||||
|
||||
TT_TEST_BEGIN(is_complex)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_complex<int>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_complex<double>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_complex<float>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_complex<bad_struct>::value, false);
|
||||
//BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_complex<derived_complex>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_complex<std::complex<long double> >::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_complex<std::complex<double> >::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_complex<std::complex<float> >::value, true);
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
|
||||
// (C) Copyright John Maddock 2007.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.tt.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "test.hpp"
|
||||
#include "check_type.hpp"
|
||||
#include "check_integral_constant.hpp"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/make_signed.hpp>
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(make_signed)
|
||||
// signed types:
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<signed char>::type, signed char);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<short>::type, short);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<int>::type, int);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<long>::type, long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<long long>::type, long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<__int64>::type, __int64);
|
||||
#endif
|
||||
// const signed types:
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const signed char>::type, const signed char);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const short>::type, const short);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const int>::type, const int);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const long>::type, const long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const long long>::type, const long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const __int64>::type, const __int64);
|
||||
#endif
|
||||
// volatile signed types:
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile signed char>::type, volatile signed char);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile short>::type, volatile short);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile int>::type, volatile int);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile long>::type, volatile long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile long long>::type, volatile long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile __int64>::type, volatile __int64);
|
||||
#endif
|
||||
// const volatile signed types:
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile signed char>::type, const volatile signed char);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile short>::type, const volatile short);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile int>::type, const volatile int);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile long>::type, const volatile long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile long long>::type, const volatile long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile __int64>::type, const volatile __int64);
|
||||
#endif
|
||||
|
||||
// unsigned types:
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<unsigned char>::type, signed char);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<unsigned short>::type, short);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<unsigned int>::type, int);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<unsigned long>::type, long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<unsigned long long>::type, long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<unsigned __int64>::type, __int64);
|
||||
#endif
|
||||
// const unsigned types:
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const unsigned char>::type, const signed char);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const unsigned short>::type, const short);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const unsigned int>::type, const int);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const unsigned long>::type, const long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const unsigned long long>::type, const long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const unsigned __int64>::type, const __int64);
|
||||
#endif
|
||||
// volatile unsigned types:
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned char>::type, volatile signed char);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned short>::type, volatile short);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned int>::type, volatile int);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned long>::type, volatile long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned long long>::type, volatile long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned __int64>::type, volatile __int64);
|
||||
#endif
|
||||
// const volatile unsigned types:
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned char>::type, const volatile signed char);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned short>::type, const volatile short);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned int>::type, const volatile int);
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned long>::type, const volatile long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned long long>::type, const volatile long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned __int64>::type, const volatile __int64);
|
||||
#endif
|
||||
|
||||
// character types:
|
||||
BOOST_CHECK_TYPE(::tt::make_signed<char>::type, signed char);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_integral< ::tt::make_signed<wchar_t>::type>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_signed< ::tt::make_signed<wchar_t>::type>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_integral< ::tt::make_signed<enum_UDT>::type>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_signed< ::tt::make_signed<enum_UDT>::type>::value, true);
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
|
||||
// (C) Copyright John Maddock 2007.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.tt.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "test.hpp"
|
||||
#include "check_type.hpp"
|
||||
#include "check_integral_constant.hpp"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/make_unsigned.hpp>
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(make_unsigned)
|
||||
// signed types:
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<signed char>::type, unsigned char);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<short>::type, unsigned short);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<int>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<long>::type, unsigned long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<long long>::type, unsigned long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<__int64>::type, unsigned __int64);
|
||||
#endif
|
||||
// const signed types:
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const signed char>::type, const unsigned char);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const short>::type, const unsigned short);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const int>::type, const unsigned int);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const long>::type, const unsigned long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const long long>::type, const unsigned long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const __int64>::type, const unsigned __int64);
|
||||
#endif
|
||||
// volatile signed types:
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile signed char>::type, volatile unsigned char);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile short>::type, volatile unsigned short);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile int>::type, volatile unsigned int);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile long>::type, volatile unsigned long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile long long>::type, volatile unsigned long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile __int64>::type, volatile unsigned __int64);
|
||||
#endif
|
||||
// const volatile signed types:
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile signed char>::type, const volatile unsigned char);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile short>::type, const volatile unsigned short);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile int>::type, const volatile unsigned int);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile long>::type, const volatile unsigned long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile long long>::type, const volatile unsigned long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile __int64>::type, const volatile unsigned __int64);
|
||||
#endif
|
||||
|
||||
// unsigned types:
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<unsigned char>::type, unsigned char);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<unsigned short>::type, unsigned short);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<unsigned int>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<unsigned long>::type, unsigned long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<unsigned long long>::type, unsigned long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<unsigned __int64>::type, unsigned __int64);
|
||||
#endif
|
||||
// const unsigned types:
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const unsigned char>::type, const unsigned char);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const unsigned short>::type, const unsigned short);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const unsigned int>::type, const unsigned int);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const unsigned long>::type, const unsigned long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const unsigned long long>::type, const unsigned long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const unsigned __int64>::type, const unsigned __int64);
|
||||
#endif
|
||||
// volatile unsigned types:
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile unsigned char>::type, volatile unsigned char);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile unsigned short>::type, volatile unsigned short);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile unsigned int>::type, volatile unsigned int);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile unsigned long>::type, volatile unsigned long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile unsigned long long>::type, volatile unsigned long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<volatile unsigned __int64>::type, volatile unsigned __int64);
|
||||
#endif
|
||||
// const volatile unsigned types:
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile unsigned char>::type, const volatile unsigned char);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile unsigned short>::type, const volatile unsigned short);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile unsigned int>::type, const volatile unsigned int);
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile unsigned long>::type, const volatile unsigned long);
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile unsigned long long>::type, const volatile unsigned long long);
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<const volatile unsigned __int64>::type, const volatile unsigned __int64);
|
||||
#endif
|
||||
|
||||
// character types:
|
||||
BOOST_CHECK_TYPE(::tt::make_unsigned<char>::type, unsigned char);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_integral< ::tt::make_unsigned<wchar_t>::type>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unsigned< ::tt::make_unsigned<wchar_t>::type>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_integral< ::tt::make_unsigned<enum_UDT>::type>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unsigned< ::tt::make_unsigned<enum_UDT>::type>::value, true);
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
Executable
+153
@@ -0,0 +1,153 @@
|
||||
// Copyright 2005 Alexander Nasonov.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <climits>
|
||||
|
||||
#if !defined(BOOST_NO_CWCHAR)
|
||||
#include <cwchar>
|
||||
#endif
|
||||
|
||||
#include "promote_util.hpp"
|
||||
|
||||
struct Struct {};
|
||||
|
||||
int main()
|
||||
{
|
||||
// char types
|
||||
|
||||
#if CHAR_MAX <= INT_MAX
|
||||
test_cv< char, int >();
|
||||
#else
|
||||
// TODO: dead branch?
|
||||
test_cv< char, unsigned int >();
|
||||
#endif
|
||||
|
||||
test_cv< signed char, int >();
|
||||
|
||||
#if UCHAR_MAX <= INT_MAX
|
||||
test_cv< unsigned char, int >();
|
||||
#else
|
||||
test_cv< unsigned char, unsigned int >();
|
||||
#endif
|
||||
|
||||
|
||||
// short types
|
||||
|
||||
test_cv< short int, int >();
|
||||
|
||||
#if USHRT_MAX <= INT_MAX
|
||||
test_cv< unsigned short, int >();
|
||||
#else
|
||||
test_cv< unsigned short, unsigned int >();
|
||||
#endif
|
||||
|
||||
|
||||
// int and long
|
||||
|
||||
test_cv< int, int >();
|
||||
test_cv< unsigned int, unsigned int >();
|
||||
test_cv< long, long >();
|
||||
test_cv< unsigned long, unsigned long >();
|
||||
|
||||
// wchar_t
|
||||
|
||||
#if !defined(BOOST_NO_CWCHAR) && defined(WCHAR_MAX) && defined(WCHAR_MIN)
|
||||
|
||||
// Version prior to VC8 didn't allow WCHAR_MAX in #if expressions
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC < 1400
|
||||
# define BOOST_TT_AUX_WCHAR_MAX USHORT_MAX // force test_cv< wchar_t, int >
|
||||
#elif defined(WCHAR_MAX) && !defined(__APPLE__)
|
||||
# define BOOST_TT_AUX_WCHAR_MAX WCHAR_MAX
|
||||
#elif defined(__BORLANDC__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__))
|
||||
// No WCHAR_MIN and WCHAR_MAX, whar_t is short and unsigned:
|
||||
# define BOOST_TT_AUX_WCHAR_MAX USHORT_MAX // force test_cv< wchar_t, int >
|
||||
#elif (defined(__sgi) && (!defined(__SGI_STL_PORT) || __SGI_STL_PORT < 0x400))\
|
||||
|| (defined __APPLE__)\
|
||||
|| (defined(__OpenBSD__) && defined(__GNUC__))\
|
||||
|| (defined(__NetBSD__) && defined(__GNUC__))\
|
||||
|| (defined(__FreeBSD__) && defined(__GNUC__))\
|
||||
|| (defined(__DragonFly__) && defined(__GNUC__))\
|
||||
|| (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
|
||||
// No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as int.
|
||||
// - SGI MIPSpro with native library
|
||||
// - gcc 3.x on HP-UX
|
||||
// - Mac OS X with native library
|
||||
// - gcc on FreeBSD, OpenBSD and NetBSD
|
||||
# define BOOST_TT_AUX_WCHAR_MAX INT_MAX // force test_cv< wchar_t, int >
|
||||
#elif defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 2) && !defined(__SGI_STL_PORT)
|
||||
// No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as unsigned int.
|
||||
// - gcc 2.95.x on HP-UX
|
||||
// (also, std::numeric_limits<wchar_t> appears to return the wrong values).
|
||||
# define BOOST_TT_AUX_WCHAR_MAX UINT_MAX // force test_cv< wchar_t, int >
|
||||
#endif
|
||||
|
||||
// For this PP-logic to work we need a valid WCHAR_MAX etc:
|
||||
#if defined(BOOST_TT_AUX_WCHAR_MAX) \
|
||||
&& !defined(__DECCXX) \
|
||||
&& !defined(__hpux) \
|
||||
&& !defined(_WIN32_WCE)
|
||||
|
||||
#if BOOST_TT_AUX_WCHAR_MAX <= INT_MAX
|
||||
test_cv< wchar_t, int >();
|
||||
#elif WCHAR_MIN == 0 && BOOST_TT_AUX_WCHAR_MAX <= UINT_MAX
|
||||
test_cv< wchar_t, unsigned int >();
|
||||
#elif BOOST_TT_AUX_WCHAR_MAX <= LONG_MAX
|
||||
test_cv< wchar_t, long >();
|
||||
#else
|
||||
test_cv< wchar_t, unsigned long >();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#undef BOOST_TT_AUX_WCHAR_MAX
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// floating point promotion
|
||||
|
||||
test_cv< float , double >();
|
||||
test_cv< double, double >();
|
||||
|
||||
|
||||
// Other types
|
||||
|
||||
test_cv< Struct, Struct >();
|
||||
test_cv< void , void >();
|
||||
test_cv< void* , void* >();
|
||||
|
||||
// Array types
|
||||
|
||||
typedef int arr[3];
|
||||
typedef int (&arr_ref)[3];
|
||||
typedef int (*arr_ptr)[3];
|
||||
|
||||
test_cv< arr , arr >();
|
||||
test_cv< arr_ptr, arr_ptr >();
|
||||
|
||||
test_no_cv<arr_ref,arr_ref>();
|
||||
|
||||
|
||||
// Function types
|
||||
|
||||
typedef int (fun)();
|
||||
typedef int (&fun_ref)();
|
||||
typedef int (*fun_ptr)();
|
||||
|
||||
test_no_cv< fun , fun >();
|
||||
test_no_cv< fun_ref, fun_ref >();
|
||||
test_no_cv< fun_ptr, fun_ptr >();
|
||||
|
||||
// Member pointer types
|
||||
|
||||
typedef int (Struct::*mem_fun_ptr)();
|
||||
typedef int Struct::*mem_ptr;
|
||||
|
||||
test_no_cv< mem_ptr, mem_ptr >();
|
||||
test_no_cv< mem_fun_ptr, mem_fun_ptr >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Executable
+152
@@ -0,0 +1,152 @@
|
||||
// Copyright 2005-2006 Alexander Nasonov.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Status of some compilers:
|
||||
//
|
||||
// Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
|
||||
// /Za (disable extentions) is totally broken.
|
||||
// /Ze (enable extentions) promotes UIntEnum incorrectly to int.
|
||||
// See http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=22b0a6b7-120f-4ca0-9136-fa1b25b26efe
|
||||
//
|
||||
// Intel 9.0.028 for Windows has a similar problem:
|
||||
// https://premier.intel.com/IssueDetail.aspx?IssueID=365073
|
||||
//
|
||||
// gcc 3.4.4 with -fshort-enums option on x86
|
||||
// Dummy value is required, otherwise gcc promotes Enum1
|
||||
// to unsigned int although USHRT_MAX <= INT_MAX.
|
||||
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24063
|
||||
//
|
||||
// CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-20 2004/03/19
|
||||
// on SPARC V9 64-bit processor (-xarch=v9 flag)
|
||||
// Dummy values are required for LongEnum3 and LongEnum4.
|
||||
//
|
||||
// CC: Sun C++ 5.7 Patch 117830-03 2005/07/21
|
||||
// ICE in boost/type_traits/is_enum.hpp at line 67.
|
||||
|
||||
|
||||
#include <climits>
|
||||
|
||||
#include "promote_util.hpp"
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
enum IntEnum1 { IntEnum1_min = -5 , IntEnum1_max = 5 };
|
||||
enum IntEnum2 { IntEnum2_min = SHRT_MIN, IntEnum2_max = SHRT_MAX };
|
||||
enum IntEnum3 { IntEnum3_min = INT_MIN , IntEnum3_max = INT_MAX };
|
||||
enum IntEnum4 { IntEnum4_value = INT_MAX };
|
||||
enum IntEnum5 { IntEnum5_value = INT_MIN };
|
||||
|
||||
void test_promote_to_int()
|
||||
{
|
||||
test_cv<IntEnum1,int>();
|
||||
test_cv<IntEnum2,int>();
|
||||
test_cv<IntEnum3,int>();
|
||||
test_cv<IntEnum4,int>();
|
||||
test_cv<IntEnum5,int>();
|
||||
}
|
||||
|
||||
|
||||
#if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ == 4 && USHRT_MAX <= INT_MAX)
|
||||
|
||||
enum Enum1 { Enum1_value = USHRT_MAX };
|
||||
|
||||
#else
|
||||
|
||||
// workaround for bug #24063 in gcc 3.4
|
||||
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24063
|
||||
namespace gcc_short_enums_workaround {
|
||||
|
||||
enum short_enum { value = 1 };
|
||||
|
||||
template<bool ShortEnumsIsOn>
|
||||
struct select
|
||||
{
|
||||
// Adding negative dummy value doesn't change
|
||||
// promoted type because USHRT_MAX <= INT_MAX.
|
||||
enum type { dummy = -1, value = USHRT_MAX };
|
||||
};
|
||||
|
||||
template<>
|
||||
struct select<false>
|
||||
{
|
||||
// No dummy value
|
||||
enum type { value = USHRT_MAX };
|
||||
};
|
||||
|
||||
} // namespace gcc_short_enums_workaround
|
||||
|
||||
typedef gcc_short_enums_workaround::select<
|
||||
sizeof(gcc_short_enums_workaround::short_enum) != sizeof(int)
|
||||
>::type Enum1;
|
||||
|
||||
#endif
|
||||
|
||||
void test_promote_to_int_or_uint()
|
||||
{
|
||||
#if USHRT_MAX <= INT_MAX
|
||||
test_cv<Enum1, int>();
|
||||
#else
|
||||
test_cv<Enum1, unsigned int>();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) ) || \
|
||||
BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(1000))
|
||||
// Don't test UIntEnum on VC++ 8.0 and Intel for Windows 9.0,
|
||||
// they are broken. More info is on top of this file.
|
||||
#else
|
||||
|
||||
enum UIntEnum { UIntEnum_max = UINT_MAX };
|
||||
|
||||
void test_promote_to_uint()
|
||||
{
|
||||
test_cv< UIntEnum, unsigned int >();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Enums can't be promoted to [unsigned] long if sizeof(int) == sizeof(long).
|
||||
#if INT_MAX < LONG_MAX
|
||||
|
||||
enum LongEnum1 { LongEnum1_min = -1 , LongEnum1_max = UINT_MAX };
|
||||
enum LongEnum2 { LongEnum2_min = LONG_MIN, LongEnum2_max = LONG_MAX };
|
||||
|
||||
enum LongEnum3
|
||||
{
|
||||
LongEnum3_value = LONG_MAX
|
||||
#if defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x530
|
||||
, LongEnum3_dummy = -1
|
||||
#endif
|
||||
};
|
||||
|
||||
enum LongEnum4
|
||||
{
|
||||
LongEnum4_value = LONG_MIN
|
||||
#if defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x530
|
||||
, LongEnum4_dummy = 1
|
||||
#endif
|
||||
};
|
||||
|
||||
void test_promote_to_long()
|
||||
{
|
||||
test_cv< LongEnum1, long >();
|
||||
test_cv< LongEnum2, long >();
|
||||
test_cv< LongEnum3, long >();
|
||||
test_cv< LongEnum4, long >();
|
||||
}
|
||||
|
||||
enum ULongEnum { ULongEnum_value = ULONG_MAX };
|
||||
|
||||
void test_promote_to_ulong()
|
||||
{
|
||||
test_cv< ULongEnum, unsigned long >();
|
||||
}
|
||||
|
||||
#endif // #if INT_MAX < LONG_MAX
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
// Copyright 2005 Alexander Nasonov.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/lambda.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/mpl/transform.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/promote.hpp>
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace mpl::placeholders;
|
||||
|
||||
typedef mpl::vector< char
|
||||
, signed char // 1
|
||||
, unsigned char
|
||||
, short int const // 3
|
||||
, unsigned short int
|
||||
, int volatile // 5
|
||||
, unsigned int // 6
|
||||
, long // 7
|
||||
, unsigned long // 8
|
||||
, float const // 9
|
||||
> types;
|
||||
|
||||
typedef mpl::transform< types
|
||||
, mpl::lambda< boost::promote<_> >::type
|
||||
>::type promoted;
|
||||
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,1>::type, int >::value ));
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,3>::type, int const >::value ));
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,5>::type, int volatile >::value ));
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,6>::type, unsigned int >::value ));
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,7>::type, long >::value ));
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,8>::type, unsigned long >::value ));
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< mpl::at_c<promoted,9>::type, double const >::value ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
// Copyright 2005 Alexander Nasonov.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef FILE_boost_libs_type_traits_test_promote_util_hpp_INCLUDED
|
||||
#define FILE_boost_libs_type_traits_test_promote_util_hpp_INCLUDED
|
||||
|
||||
#include <boost/type_traits/promote.hpp>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
template<class T, class Promoted>
|
||||
inline void test_no_cv()
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::promote<T>::type promoted;
|
||||
BOOST_STATIC_ASSERT(( boost::is_same<promoted,Promoted>::value ));
|
||||
}
|
||||
|
||||
template<class T, class Promoted>
|
||||
inline void test_cv()
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::promote<T >::type promoted;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::promote<T const >::type promoted_c;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::promote<T volatile>::type promoted_v;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::promote<T const volatile>::type promoted_cv;
|
||||
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< promoted , Promoted >::value ));
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< promoted_c , Promoted const >::value ));
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< promoted_v , Promoted volatile >::value ));
|
||||
BOOST_STATIC_ASSERT(( ::boost::is_same< promoted_cv, Promoted const volatile >::value ));
|
||||
}
|
||||
|
||||
#endif // #ifndef FILE_boost_libs_type_traits_test_promote_util_hpp_INCLUDED
|
||||
|
||||
Reference in new issue
Block a user