forked from boostorg/type_traits
Add more traits back - nearly complete now.
This commit is contained in:
181
include/boost/type_traits/integral_promotion.hpp
Normal file
181
include/boost/type_traits/integral_promotion.hpp
Normal file
@ -0,0 +1,181 @@
|
||||
// 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_type_traits_integral_promotion_hpp_INCLUDED
|
||||
#define FILE_boost_type_traits_integral_promotion_hpp_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_volatile.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace type_traits { namespace detail {
|
||||
|
||||
// 4.5/2
|
||||
template <class T> struct need_promotion : public boost::is_enum<T> {};
|
||||
|
||||
// 4.5/1
|
||||
template<> struct need_promotion<char > : public true_type {};
|
||||
template<> struct need_promotion<signed char > : public true_type {};
|
||||
template<> struct need_promotion<unsigned char > : public true_type {};
|
||||
template<> struct need_promotion<signed short int > : public true_type {};
|
||||
template<> struct need_promotion<unsigned short int> : public true_type {};
|
||||
|
||||
|
||||
// Specializations for non-standard types.
|
||||
// Type is promoted if it's smaller then int.
|
||||
|
||||
#define BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(T) \
|
||||
template<> struct need_promotion<T> \
|
||||
: public integral_constant<bool, (sizeof(T) < sizeof(int))> {};
|
||||
|
||||
// Same set of integral types as in boost/type_traits/is_integral.hpp.
|
||||
// Please, keep in sync.
|
||||
#if (defined(BOOST_INTEL_CXX_VERSION) && defined(_MSC_VER) && (BOOST_INTEL_CXX_VERSION <= 600)) \
|
||||
|| (defined(__BORLANDC__) && (__BORLANDC__ == 0x600) && (_MSC_VER < 1300))
|
||||
// TODO: common macro for this #if. Or better yet, PP SEQ of non-standard types.
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(__int8 )
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(unsigned __int8 )
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(__int16 )
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(unsigned __int16)
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(__int32 )
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(unsigned __int32)
|
||||
#ifdef __BORLANDC__
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(unsigned __int64)
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE( __int64)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(boost::ulong_long_type)
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(boost::long_long_type )
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE(unsigned __int64)
|
||||
BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE( __int64)
|
||||
#endif
|
||||
|
||||
#undef BOOST_TT_AUX_PROMOTE_NONSTANDARD_TYPE
|
||||
|
||||
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
// 4.5/2
|
||||
template<> struct need_promotion<wchar_t> : public true_type {};
|
||||
#endif
|
||||
|
||||
// 4.5/3 (integral bit-field) is not supported.
|
||||
|
||||
// 4.5/4
|
||||
template<> struct need_promotion<bool> : public true_type {};
|
||||
|
||||
|
||||
// Get promoted type by index and cv qualifiers.
|
||||
|
||||
template<int Index, int IsConst, int IsVolatile> struct promote_from_index;
|
||||
|
||||
#define BOOST_TT_AUX_PROMOTE_FROM_INDEX(N,T) \
|
||||
template<> struct promote_from_index<N,0,0> { typedef T type; }; \
|
||||
template<> struct promote_from_index<N,0,1> { typedef T volatile type; }; \
|
||||
template<> struct promote_from_index<N,1,0> { typedef T const type; }; \
|
||||
template<> struct promote_from_index<N,1,1> { typedef T const volatile type; };
|
||||
|
||||
|
||||
BOOST_TT_AUX_PROMOTE_FROM_INDEX(1, int )
|
||||
BOOST_TT_AUX_PROMOTE_FROM_INDEX(2, unsigned int )
|
||||
BOOST_TT_AUX_PROMOTE_FROM_INDEX(3, long )
|
||||
BOOST_TT_AUX_PROMOTE_FROM_INDEX(4, unsigned long)
|
||||
|
||||
|
||||
// WARNING: integral promotions to non-standard types
|
||||
// long long and __int64 are not defined by the standard.
|
||||
// Additional specialisations and overloads shouldn't
|
||||
// introduce ambiguity, though.
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
BOOST_TT_AUX_PROMOTE_FROM_INDEX(5, boost::long_long_type )
|
||||
BOOST_TT_AUX_PROMOTE_FROM_INDEX(6, boost::ulong_long_type)
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_TT_AUX_PROMOTE_FROM_INDEX(7, __int64 )
|
||||
BOOST_TT_AUX_PROMOTE_FROM_INDEX(8, unsigned __int64)
|
||||
#endif
|
||||
|
||||
#undef BOOST_TT_AUX_PROMOTE_FROM_INDEX
|
||||
|
||||
|
||||
// Define BOOST_TT_AUX_PROMOTED_INDEX_TESTER:
|
||||
#if !defined(BOOST_MSVC)
|
||||
|
||||
template<int N>
|
||||
struct sized_type_for_promotion
|
||||
{
|
||||
typedef char (&type)[N];
|
||||
};
|
||||
|
||||
#define BOOST_TT_AUX_PROMOTED_INDEX_TESTER(I,T) \
|
||||
sized_type_for_promotion<I>::type promoted_index_tester(T);
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_TT_AUX_PROMOTED_INDEX_TESTER(I,T) \
|
||||
char (&promoted_index_tester(T))[I];
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_TT_AUX_PROMOTED_INDEX_TESTER(1, int )
|
||||
BOOST_TT_AUX_PROMOTED_INDEX_TESTER(2, unsigned int )
|
||||
BOOST_TT_AUX_PROMOTED_INDEX_TESTER(3, long )
|
||||
BOOST_TT_AUX_PROMOTED_INDEX_TESTER(4, unsigned long)
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
BOOST_TT_AUX_PROMOTED_INDEX_TESTER(5, boost::long_long_type )
|
||||
BOOST_TT_AUX_PROMOTED_INDEX_TESTER(6, boost::ulong_long_type)
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
BOOST_TT_AUX_PROMOTED_INDEX_TESTER(7, __int64 )
|
||||
BOOST_TT_AUX_PROMOTED_INDEX_TESTER(8, unsigned __int64)
|
||||
#endif
|
||||
|
||||
#undef BOOST_TT_AUX_PROMOTED_INDEX_TESTER
|
||||
|
||||
|
||||
// Get an index of promoted type for type T.
|
||||
// Precondition: need_promotion<T>
|
||||
template<class T>
|
||||
struct promoted_index
|
||||
{
|
||||
static T testee; // undefined
|
||||
BOOST_STATIC_CONSTANT(int, value = sizeof(promoted_index_tester(+testee)) );
|
||||
// Unary plus promotes testee LOOK HERE ---> ^
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct integral_promotion_impl
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME promote_from_index<
|
||||
(boost::type_traits::detail::promoted_index<T>::value)
|
||||
, (boost::is_const<T>::value)
|
||||
, (boost::is_volatile<T>::value)
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<class T, bool b> struct integral_promotion { typedef T type; };
|
||||
template<class T> struct integral_promotion<T, true> : public integral_promotion_impl<T>{};
|
||||
|
||||
} }
|
||||
|
||||
template <class T> struct integral_promotion
|
||||
{
|
||||
private:
|
||||
typedef boost::type_traits::detail::need_promotion<typename remove_cv<T>::type> tag_type;
|
||||
public:
|
||||
typedef typename boost::type_traits::detail::integral_promotion<T, tag_type::value>::type type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // #ifndef FILE_boost_type_traits_integral_promotion_hpp_INCLUDED
|
||||
|
33
include/boost/type_traits/is_stateless.hpp
Normal file
33
include/boost/type_traits/is_stateless.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
||||
// 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).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
#ifndef BOOST_TT_IS_STATELESS_HPP_INCLUDED
|
||||
#define BOOST_TT_IS_STATELESS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/has_trivial_constructor.hpp>
|
||||
#include <boost/type_traits/has_trivial_copy.hpp>
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_empty.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename T>
|
||||
struct is_stateless
|
||||
: public integral_constant<bool,
|
||||
(::boost::has_trivial_constructor<T>::value
|
||||
&& ::boost::has_trivial_copy<T>::value
|
||||
&& ::boost::has_trivial_destructor<T>::value
|
||||
&& ::boost::is_class<T>::value
|
||||
&& ::boost::is_empty<T>::value)>
|
||||
{};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_IS_STATELESS_HPP_INCLUDED
|
20
include/boost/type_traits/promote.hpp
Normal file
20
include/boost/type_traits/promote.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
// 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_type_traits_promote_hpp_INCLUDED
|
||||
#define FILE_boost_type_traits_promote_hpp_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/integral_promotion.hpp>
|
||||
#include <boost/type_traits/floating_point_promotion.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class T> struct promote : public integral_promotion<typename floating_point_promotion<T>::type>{};
|
||||
|
||||
}
|
||||
|
||||
#endif // #ifndef FILE_boost_type_traits_promote_hpp_INCLUDED
|
||||
|
86
include/boost/type_traits/rank.hpp
Normal file
86
include/boost/type_traits/rank.hpp
Normal file
@ -0,0 +1,86 @@
|
||||
|
||||
// (C) Copyright John Maddock 2005.
|
||||
// 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).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
|
||||
#ifndef BOOST_TT_RANK_HPP_INCLUDED
|
||||
#define BOOST_TT_RANK_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if !defined( __CODEGEARC__ )
|
||||
|
||||
namespace detail{
|
||||
|
||||
template <class T, std::size_t N>
|
||||
struct rank_imp
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = N);
|
||||
};
|
||||
#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
|
||||
template <class T, std::size_t R, std::size_t N>
|
||||
struct rank_imp<T[R], N>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp<T, N+1>::value));
|
||||
};
|
||||
|
||||
template <class T, std::size_t R, std::size_t N>
|
||||
struct rank_imp<T const[R], N>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp<T, N+1>::value));
|
||||
};
|
||||
|
||||
template <class T, std::size_t R, std::size_t N>
|
||||
struct rank_imp<T volatile[R], N>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp<T, N+1>::value));
|
||||
};
|
||||
|
||||
template <class T, std::size_t R, std::size_t N>
|
||||
struct rank_imp<T const volatile[R], N>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp<T, N+1>::value));
|
||||
};
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840))
|
||||
template <class T, std::size_t N>
|
||||
struct rank_imp<T[], N>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp<T, N+1>::value));
|
||||
};
|
||||
template <class T, std::size_t N>
|
||||
struct rank_imp<T const[], N>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp<T, N+1>::value));
|
||||
};
|
||||
template <class T, std::size_t N>
|
||||
struct rank_imp<T volatile[], N>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp<T, N+1>::value));
|
||||
};
|
||||
template <class T, std::size_t N>
|
||||
struct rank_imp<T const volatile[], N>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp<T, N+1>::value));
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // !defined( __CODEGEARC__ )
|
||||
|
||||
#if defined( __CODEGEARC__ )
|
||||
template <class T> struct rank : public integral_constant<std::size_t, __array_rank(T)>{};
|
||||
#else
|
||||
template <class T> struct rank : public integral_constant<std::size_t, (::boost::detail::rank_imp<T, 0>::value)>{};
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED
|
168
test/is_stateless_test.cpp
Normal file
168
test/is_stateless_test.cpp
Normal file
@ -0,0 +1,168 @@
|
||||
|
||||
// (C) Copyright John Maddock 2000.
|
||||
// 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_stateless.hpp>
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(is_stateless)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<bool>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<bool const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<bool volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<bool const volatile>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<signed char>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<signed char const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<signed char volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<signed char const volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned char>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<char>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned char const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<char const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned char volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<char volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned char const volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<char const volatile>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned short>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<short>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned short const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<short const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned short volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<short volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned short const volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<short const volatile>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned int>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned int const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned int volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned int const volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int const volatile>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned long>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<long>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned long const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<long const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned long volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<long volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned long const volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<long const volatile>::value, false);
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless< ::boost::ulong_long_type>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless< ::boost::long_long_type>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless< ::boost::ulong_long_type const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless< ::boost::long_long_type const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless< ::boost::ulong_long_type volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless< ::boost::long_long_type volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless< ::boost::ulong_long_type const volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless< ::boost::long_long_type const volatile>::value, false);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_HAS_MS_INT64
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int8>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int8>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int8 const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int8 const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int8 volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int8 volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int8 const volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int8 const volatile>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int16>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int16>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int16 const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int16 const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int16 volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int16 volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int16 const volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int16 const volatile>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int32>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int32>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int32 const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int32 const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int32 volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int32 volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int32 const volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int32 const volatile>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int64>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int64>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int64 const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int64 const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int64 volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int64 volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<unsigned __int64 const volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<__int64 const volatile>::value, false);
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<float>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<float const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<float volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<float const volatile>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<double>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<double const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<double volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<double const volatile>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<long double>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<long double const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<long double volatile>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<long double const volatile>::value, false);
|
||||
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<void*>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int*const>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<f1>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<f2>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<f3>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<mf1>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<mf2>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<mf3>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<mp>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<cmf>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<enum_UDT>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int&>::value, false);
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int&&>::value, false);
|
||||
#endif
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<const int&>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int[2]>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int[3][2]>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<int[2][4][5][6][3]>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<UDT>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<empty_UDT>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<void>::value, false);
|
||||
|
||||
// cases we would like to succeed but can't implement in the language:
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_stateless<empty_POD_UDT>::value, true, false);
|
||||
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
153
test/promote_basic_test.cpp
Normal file
153
test/promote_basic_test.cpp
Normal file
@ -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;
|
||||
}
|
||||
|
44
test/promote_enum_msvc_bug_test.cpp
Normal file
44
test/promote_enum_msvc_bug_test.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright 2009 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)
|
||||
|
||||
// Test bug 99776 'enum UIntEnum { value = UINT_MAX } is promoted to int'
|
||||
// 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
|
||||
|
||||
#include <boost/type_traits/promote.hpp>
|
||||
|
||||
#include <climits>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include "promote_util.hpp"
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
// remark #1418: external function definition with no prior declaration
|
||||
#pragma warning(disable:1418)
|
||||
#endif
|
||||
|
||||
|
||||
enum UIntEnum { UIntEnum_max = UINT_MAX };
|
||||
|
||||
template<class T>
|
||||
void assert_is_uint(T)
|
||||
{
|
||||
BOOST_STATIC_ASSERT((boost::is_same<T, unsigned int>::value));
|
||||
}
|
||||
|
||||
void test_promote_to_uint()
|
||||
{
|
||||
assert_is_uint(+UIntEnum_max);
|
||||
test_cv< UIntEnum, unsigned int >();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
157
test/promote_enum_test.cpp
Normal file
157
test/promote_enum_test.cpp
Normal file
@ -0,0 +1,157 @@
|
||||
// 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>
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
// remark #1418: external function definition with no prior declaration
|
||||
#pragma warning(disable:1418)
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
||||
|
47
test/promote_mpl_test.cpp
Normal file
47
test/promote_mpl_test.cpp
Normal file
@ -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;
|
||||
}
|
||||
|
37
test/promote_util.hpp
Normal file
37
test/promote_util.hpp
Normal file
@ -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
|
||||
|
36
test/rank_test.cpp
Normal file
36
test/rank_test.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
// (C) Copyright John Maddock 2005.
|
||||
// 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/rank.hpp>
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(rank)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::rank<int>::value, 0);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::rank<int[]>::value, 1);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::rank<int[][10]>::value, 2);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::rank<int[5][10]>::value, 2);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::rank<int[5][10][40]>::value, 3);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::rank<int (&)[5][10]>::value, 0);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::rank<int (*)[5][10]>::value, 0);
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::rank<int (&&)[5][10]>::value, 0);
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
31
test/tricky_abstract_type_test.cpp
Normal file
31
test/tricky_abstract_type_test.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
// (C) Copyright John Maddock 2000.
|
||||
// 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_empty.hpp>
|
||||
# include <boost/type_traits/is_stateless.hpp>
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(tricky_abstract_type_test)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_empty<test_abc1>::value, false);
|
||||
#ifndef TEST_STD
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_stateless<test_abc1>::value, false);
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
51
test/tricky_add_pointer_test.cpp
Normal file
51
test/tricky_add_pointer_test.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
|
||||
// (C) Copyright John Maddock 2002.
|
||||
// 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"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/add_pointer.hpp>
|
||||
#endif
|
||||
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_5, ::tt::add_pointer, const &, const*)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_6, ::tt::add_pointer, &, *)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_8, ::tt::add_pointer, const [2], const (*)[2])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_9, ::tt::add_pointer, const &, const*)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_12, ::tt::add_pointer, const[2][3], const (*)[2][3])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_13, ::tt::add_pointer, (&)[2], (*)[2])
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_5a, ::tt::add_pointer, const &&, const*)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_6a, ::tt::add_pointer, &&, *)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_9a, ::tt::add_pointer, const &&, const*)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_13a, ::tt::add_pointer, (&&)[2], (*)[2])
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(tricky_add_pointer_test)
|
||||
|
||||
add_pointer_test_5();
|
||||
add_pointer_test_6();
|
||||
add_pointer_test_8();
|
||||
add_pointer_test_9();
|
||||
add_pointer_test_12();
|
||||
add_pointer_test_13();
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
add_pointer_test_5a();
|
||||
add_pointer_test_6a();
|
||||
add_pointer_test_9a();
|
||||
add_pointer_test_13a();
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
115
test/tricky_function_type_test.cpp
Normal file
115
test/tricky_function_type_test.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
|
||||
// (C) Copyright John Maddock 2002.
|
||||
// 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_function.hpp>
|
||||
# include <boost/type_traits/is_float.hpp>
|
||||
# include <boost/type_traits/is_enum.hpp>
|
||||
# include <boost/type_traits/is_class.hpp>
|
||||
# include <boost/type_traits/is_scalar.hpp>
|
||||
# include <boost/type_traits/is_pod.hpp>
|
||||
# include <boost/type_traits/has_trivial_constructor.hpp>
|
||||
# include <boost/type_traits/has_trivial_copy.hpp>
|
||||
# include <boost/type_traits/has_trivial_assign.hpp>
|
||||
# include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
# include <boost/type_traits/is_compound.hpp>
|
||||
# include <boost/type_traits/is_base_of.hpp>
|
||||
# include <boost/type_traits/is_convertible.hpp>
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(tricky_function_type_test)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_function<const int&>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_function<int (&)(int)>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_enum<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_scalar<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_compound<foo0_t>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_constructor<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_assign<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<foo0_t>::value, false);
|
||||
#if defined(TEST_STD) && (TEST_STD < 2006)
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<foo0_t, foo0_t>::value), true); // TR1 required behaviour (new to 1.34)
|
||||
#else
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<foo0_t, foo0_t>::value), false); // C++0x required behaviour (new to 1.40)
|
||||
#endif
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<foo0_t, int>::value), false);
|
||||
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<foo1_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_enum<foo1_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_scalar<foo1_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_compound<foo1_t>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<foo1_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_constructor<foo1_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy<foo1_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_assign<foo1_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<foo1_t>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<foo2_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_enum<foo2_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_scalar<foo2_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_compound<foo2_t>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<foo2_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_constructor<foo2_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy<foo2_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_assign<foo2_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<foo2_t>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<foo3_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_enum<foo3_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_scalar<foo3_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_compound<foo3_t>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<foo3_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_constructor<foo3_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy<foo3_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_assign<foo3_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<foo3_t>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<foo4_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_enum<foo4_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_scalar<foo4_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_compound<foo4_t>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<foo4_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_constructor<foo4_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy<foo4_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_assign<foo4_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<foo4_t>::value, false);
|
||||
|
||||
typedef void foo5_t(int, bool, int*, int[], int, int, int, int, int ...);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_function<foo5_t>::value, true);
|
||||
|
||||
typedef void (test_abc1::*vproc1)(...);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<vproc1>::value, true);
|
||||
typedef void (test_abc1::*vproc2)(int, char, long, ...);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<vproc2>::value, true);
|
||||
typedef void (test_abc1::*vproc3)(int, char, long, long, ...)const;
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<vproc3>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(), int()>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(), int(*)()>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(), int(* const)()>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(), int(* volatile)()>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(), int(* const volatile)()>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(), int(&)()>::value), true);
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
27
test/tricky_is_enum_test.cpp
Normal file
27
test/tricky_is_enum_test.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
// (C) Copyright Dave Abrahams 2003. Use, modification and distribution is
|
||||
// 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_enum.hpp>
|
||||
#endif
|
||||
|
||||
struct convertible_to_anything
|
||||
{
|
||||
template<typename T> operator T() { return 0; }
|
||||
};
|
||||
|
||||
|
||||
TT_TEST_BEGIN(is_enum)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_enum<convertible_to_anything>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_enum<int[] >::value, false);
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
128
test/tricky_partial_spec_test.cpp
Normal file
128
test/tricky_partial_spec_test.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
|
||||
// (C) Copyright John Maddock 2000.
|
||||
// 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/alignment_of.hpp>
|
||||
#include <boost/type_traits/has_nothrow_assign.hpp>
|
||||
#include <boost/type_traits/has_nothrow_constructor.hpp>
|
||||
#include <boost/type_traits/has_nothrow_copy.hpp>
|
||||
#include <boost/type_traits/is_base_and_derived.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_polymorphic.hpp>
|
||||
#include <boost/type_traits/is_member_pointer.hpp>
|
||||
#include <boost/type_traits/is_member_object_pointer.hpp>
|
||||
#include <boost/type_traits/is_member_function_pointer.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#endif
|
||||
#include <stdexcept>
|
||||
#include <new>
|
||||
#include <exception>
|
||||
|
||||
//
|
||||
// VC++ emits an awful lot of warnings unless we define these:
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable:4244)
|
||||
#endif
|
||||
|
||||
|
||||
template <class T>
|
||||
struct align_calc
|
||||
{
|
||||
char padding;
|
||||
T instance;
|
||||
static std::ptrdiff_t get()
|
||||
{
|
||||
static align_calc<T> a;
|
||||
return reinterpret_cast<const char*>(&(a.instance)) - reinterpret_cast<const char*>(&(a.padding));
|
||||
}
|
||||
};
|
||||
|
||||
#define ALIGNOF(x) align_calc<x>::get()
|
||||
|
||||
|
||||
TT_TEST_BEGIN(tricky_partial_specialization_test)
|
||||
//
|
||||
// corner cases which don't compile without partial specialization
|
||||
// support:
|
||||
//
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<char&>::value, ALIGNOF(void*));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<char (&)(int)>::value, ALIGNOF(void*));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<char(&)[4]>::value, ALIGNOF(void*));
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<Base&,Derived>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<Base&,Derived&>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<Base,Derived&>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<Base,void>::value), false);
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<Base&&,Derived>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<Base&&,Derived&&>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of<Base,Derived&&>::value), false);
|
||||
#endif
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<void, int>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<void, void>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<void, const void>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<test_abc1, test_abc1>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<test_abc1, const test_abc1>::value), false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<void,float>::value), false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const UDT>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<volatile empty_UDT>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const VB>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const volatile VD>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const test_abc1>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<volatile test_abc2>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const std::exception>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const std::bad_alloc>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const std::runtime_error>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const std::out_of_range>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const std::range_error>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<const f1>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<volatile f1>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<const volatile f1>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer<const f1>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer<const mp>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer<volatile mp>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer<const volatile mp>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer<const mf3>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer<volatile mf3>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer<const volatile mf3>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer<const f1>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer<const mp>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer<volatile mp>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer<const volatile mp>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer<const mf3>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer<volatile mf3>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer<const volatile mf3>::value, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const f1>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const mp>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<volatile mp>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const volatile mp>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const mf3>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<volatile mf3>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const volatile mf3>::value, true);
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
37
test/tricky_rvalue_test.cpp
Normal file
37
test/tricky_rvalue_test.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
// (C) Copyright John Maddock 2010.
|
||||
// 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_convertible.hpp>
|
||||
# include <boost/type_traits/is_lvalue_reference.hpp>
|
||||
# include <boost/type_traits/is_rvalue_reference.hpp>
|
||||
# include <boost/type_traits/is_reference.hpp>
|
||||
# include <boost/type_traits/is_function.hpp>
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(rvalue_reference_test)
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_reference<int (&&)(int)>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_rvalue_reference<int (&)(int)>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_rvalue_reference<int (&&)(int)>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int&&, int&>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<int(), int(&&)()>::value), true);
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
48
test/udt_specialisations.cpp
Normal file
48
test/udt_specialisations.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
// (C) Copyright John Maddock 2004.
|
||||
// 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_pod.hpp>
|
||||
# include <boost/type_traits/is_class.hpp>
|
||||
# include <boost/type_traits/is_union.hpp>
|
||||
#endif
|
||||
|
||||
struct my_pod{};
|
||||
struct my_union
|
||||
{
|
||||
char c;
|
||||
int i;
|
||||
};
|
||||
|
||||
namespace tt
|
||||
{
|
||||
template<>
|
||||
struct is_pod<my_pod>
|
||||
: public mpl::true_{};
|
||||
template<>
|
||||
struct is_pod<my_union>
|
||||
: public mpl::true_{};
|
||||
template<>
|
||||
struct is_union<my_union>
|
||||
: public mpl::true_{};
|
||||
template<>
|
||||
struct is_class<my_union>
|
||||
: public mpl::false_{};
|
||||
}
|
||||
|
||||
TT_TEST_BEGIN(is_pod)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<my_pod>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pod<my_union>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_union<my_union>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<my_union>::value, false);
|
||||
|
||||
TT_TEST_END
|
||||
|
Reference in New Issue
Block a user