forked from boostorg/type_traits
Big type_traits update:
Added make_signed, make_unsigned and is_complex. Added docs for some previously undocumented traits: is_signed, is_unsigned and decay.html Added synonyms for some traits that have changed name in the latest C++ std draft. Re-organised docs, moved docs out of the main doc build for now (it takes too long). This also fixes issues: http://svn.boost.org/trac/boost/ticket/492 and http://svn.boost.org/trac/boost/ticket/1008. [SVN r39175]
This commit is contained in:
1 parent
6378e00d86
commit
4d0bcdc9f5
182 files changed
+15452
-2938
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
|
||||
|
||||
|
||||
Reference in new issue
Block a user