mirror of
https://github.com/boostorg/type_traits.git
synced 2025-07-31 21:14:37 +02:00
Add the remaining traits - only common_type still has dependencies to something other than Boost.Config.
This commit is contained in:
18
include/boost/aligned_storage.hpp
Normal file
18
include/boost/aligned_storage.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost aligned_storage.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003
|
||||
// Eric Friedman, Itay Maman
|
||||
//
|
||||
// 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 BOOST_ALIGNED_STORAGE_HPP
|
||||
#define BOOST_ALIGNED_STORAGE_HPP
|
||||
|
||||
#include <boost/type_traits/aligned_storage.hpp>
|
||||
|
||||
#endif // BOOST_ALIGNED_STORAGE_HPP
|
100
include/boost/type_traits.hpp
Normal file
100
include/boost/type_traits.hpp
Normal file
@@ -0,0 +1,100 @@
|
||||
// (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).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
// See boost/type_traits/*.hpp for full copyright notices.
|
||||
|
||||
#ifndef BOOST_TYPE_TRAITS_HPP
|
||||
#define BOOST_TYPE_TRAITS_HPP
|
||||
|
||||
#include "boost/type_traits/add_const.hpp"
|
||||
#include "boost/type_traits/add_cv.hpp"
|
||||
#include "boost/type_traits/add_lvalue_reference.hpp"
|
||||
#include "boost/type_traits/add_pointer.hpp"
|
||||
#include "boost/type_traits/add_reference.hpp"
|
||||
#include "boost/type_traits/add_rvalue_reference.hpp"
|
||||
#include "boost/type_traits/add_volatile.hpp"
|
||||
#include "boost/type_traits/aligned_storage.hpp"
|
||||
#include "boost/type_traits/alignment_of.hpp"
|
||||
#include "boost/type_traits/common_type.hpp"
|
||||
#include "boost/type_traits/conditional.hpp"
|
||||
#include "boost/type_traits/decay.hpp"
|
||||
#include "boost/type_traits/extent.hpp"
|
||||
#include "boost/type_traits/floating_point_promotion.hpp"
|
||||
#include "boost/type_traits/function_traits.hpp"
|
||||
#if !defined(__BORLANDC__) && !defined(__CUDACC__)
|
||||
#include "boost/type_traits/has_new_operator.hpp"
|
||||
#endif
|
||||
#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/has_nothrow_destructor.hpp"
|
||||
#include <boost/type_traits/has_operator.hpp>
|
||||
#include "boost/type_traits/has_trivial_assign.hpp"
|
||||
#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/has_trivial_move_assign.hpp"
|
||||
#include "boost/type_traits/has_trivial_move_constructor.hpp"
|
||||
#include "boost/type_traits/has_virtual_destructor.hpp"
|
||||
#include "boost/type_traits/is_abstract.hpp"
|
||||
#include "boost/type_traits/is_arithmetic.hpp"
|
||||
#include "boost/type_traits/is_array.hpp"
|
||||
#include "boost/type_traits/is_base_and_derived.hpp"
|
||||
#include "boost/type_traits/is_base_of.hpp"
|
||||
#include "boost/type_traits/is_class.hpp"
|
||||
#include <boost/type_traits/is_complex.hpp>
|
||||
#include "boost/type_traits/is_compound.hpp"
|
||||
#include "boost/type_traits/is_const.hpp"
|
||||
#include "boost/type_traits/is_convertible.hpp"
|
||||
#include "boost/type_traits/is_copy_constructible.hpp"
|
||||
#include "boost/type_traits/is_copy_assignable.hpp"
|
||||
#include "boost/type_traits/is_empty.hpp"
|
||||
#include "boost/type_traits/is_enum.hpp"
|
||||
#include "boost/type_traits/is_float.hpp"
|
||||
#include "boost/type_traits/is_floating_point.hpp"
|
||||
#include "boost/type_traits/is_function.hpp"
|
||||
#include "boost/type_traits/is_fundamental.hpp"
|
||||
#include "boost/type_traits/is_integral.hpp"
|
||||
#include "boost/type_traits/is_lvalue_reference.hpp"
|
||||
#include "boost/type_traits/is_member_function_pointer.hpp"
|
||||
#include "boost/type_traits/is_member_object_pointer.hpp"
|
||||
#include "boost/type_traits/is_member_pointer.hpp"
|
||||
#include "boost/type_traits/is_nothrow_move_assignable.hpp"
|
||||
#include "boost/type_traits/is_nothrow_move_constructible.hpp"
|
||||
#include "boost/type_traits/is_object.hpp"
|
||||
#include "boost/type_traits/is_pod.hpp"
|
||||
#include "boost/type_traits/is_polymorphic.hpp"
|
||||
#include "boost/type_traits/is_pointer.hpp"
|
||||
#include "boost/type_traits/is_reference.hpp"
|
||||
#include "boost/type_traits/is_rvalue_reference.hpp"
|
||||
#include "boost/type_traits/is_signed.hpp"
|
||||
#include "boost/type_traits/is_same.hpp"
|
||||
#include "boost/type_traits/is_scalar.hpp"
|
||||
#include "boost/type_traits/is_stateless.hpp"
|
||||
#include "boost/type_traits/is_union.hpp"
|
||||
#include "boost/type_traits/is_unsigned.hpp"
|
||||
#include "boost/type_traits/is_void.hpp"
|
||||
#include "boost/type_traits/is_virtual_base_of.hpp"
|
||||
#include "boost/type_traits/is_volatile.hpp"
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <boost/type_traits/make_signed.hpp>
|
||||
#include "boost/type_traits/rank.hpp"
|
||||
#include "boost/type_traits/remove_bounds.hpp"
|
||||
#include "boost/type_traits/remove_extent.hpp"
|
||||
#include "boost/type_traits/remove_all_extents.hpp"
|
||||
#include "boost/type_traits/remove_const.hpp"
|
||||
#include "boost/type_traits/remove_cv.hpp"
|
||||
#include "boost/type_traits/remove_pointer.hpp"
|
||||
#include "boost/type_traits/remove_reference.hpp"
|
||||
#include "boost/type_traits/remove_volatile.hpp"
|
||||
#include "boost/type_traits/type_with_alignment.hpp"
|
||||
#if !(defined(__sgi) && defined(__EDG_VERSION__) && (__EDG_VERSION__ == 238))
|
||||
#include "boost/type_traits/integral_promotion.hpp"
|
||||
#include "boost/type_traits/promote.hpp"
|
||||
#endif
|
||||
|
||||
#endif // BOOST_TYPE_TRAITS_HPP
|
15
include/boost/type_traits/alignment_traits.hpp
Normal file
15
include/boost/type_traits/alignment_traits.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
// (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).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
#ifndef BOOST_TT_ALIGNMENT_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_TT_ALIGNMENT_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/type_traits/type_with_alignment.hpp>
|
||||
|
||||
#endif // BOOST_TT_ALIGNMENT_TRAITS_HPP_INCLUDED
|
20
include/boost/type_traits/arithmetic_traits.hpp
Normal file
20
include/boost/type_traits/arithmetic_traits.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// (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.
|
||||
//
|
||||
// defines traits classes for arithmetic types:
|
||||
// is_void, is_integral, is_float, is_arithmetic, is_fundamental.
|
||||
|
||||
#ifndef BOOST_TT_ARITHMETIC_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_TT_ARITHMETIC_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/type_traits/is_float.hpp>
|
||||
#include <boost/type_traits/is_fundamental.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_void.hpp>
|
||||
|
||||
#endif // BOOST_TT_ARITHMETIC_TRAITS_HPP_INCLUDED
|
15
include/boost/type_traits/array_traits.hpp
Normal file
15
include/boost/type_traits/array_traits.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
// (C) Copyright Dave Abrahams, 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_ARRAY_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_TT_ARRAY_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
|
||||
#endif // BOOST_TT_ARRAY_TRAITS_HPP_INCLUDED
|
157
include/boost/type_traits/common_type.hpp
Normal file
157
include/boost/type_traits/common_type.hpp
Normal file
@@ -0,0 +1,157 @@
|
||||
// common_type.hpp ---------------------------------------------------------//
|
||||
|
||||
// Copyright 2008 Howard Hinnant
|
||||
// Copyright 2008 Beman Dawes
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_TYPE_TRAITS_COMMON_TYPE_HPP
|
||||
#define BOOST_TYPE_TRAITS_COMMON_TYPE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(__SUNPRO_CC) && !defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
# define BOOST_COMMON_TYPE_DONT_USE_TYPEOF
|
||||
#endif
|
||||
#if defined(__IBMCPP__) && !defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
# define BOOST_COMMON_TYPE_DONT_USE_TYPEOF
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_COMMON_TYPE_ARITY)
|
||||
#define BOOST_COMMON_TYPE_ARITY 3
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
#if defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
#include <boost/typeof/typeof.hpp> // boost wonders never cease!
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
#ifndef BOOST_NO_CXX11_STATIC_ASSERT
|
||||
#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) static_assert(CND,MSG)
|
||||
#elif defined(BOOST_COMMON_TYPE_USES_MPL_ASSERT)
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) \
|
||||
BOOST_MPL_ASSERT_MSG(boost::mpl::bool_< (CND) >::type::value, MSG, TYPES)
|
||||
#else
|
||||
#include <boost/static_assert.hpp>
|
||||
#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) BOOST_STATIC_ASSERT(CND)
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) || !defined(BOOST_COMMON_TYPE_USES_MPL_ASSERT)
|
||||
#define BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE "must be complete type"
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DECLTYPE) && defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
#include <boost/type_traits/detail/common_type_imp.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#endif
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/utility/declval.hpp>
|
||||
#include <boost/type_traits/add_rvalue_reference.hpp>
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
// //
|
||||
// C++03 implementation of //
|
||||
// 20.9.7.6 Other transformations [meta.trans.other] //
|
||||
// Written by Howard Hinnant //
|
||||
// Adapted for Boost by Beman Dawes, Vicente Botet and Jeffrey Hellrung //
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
namespace boost {
|
||||
|
||||
// prototype
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<typename... T>
|
||||
struct common_type;
|
||||
#else // or no specialization
|
||||
template <class T, class U = void, class V = void>
|
||||
struct common_type
|
||||
{
|
||||
public:
|
||||
typedef typename common_type<typename common_type<T, U>::type, V>::type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
// 1 arg
|
||||
template<typename T>
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
struct common_type<T>
|
||||
#else
|
||||
struct common_type<T, void, void>
|
||||
|
||||
#endif
|
||||
{
|
||||
BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(T) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (T));
|
||||
public:
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
// 2 args
|
||||
namespace type_traits_detail {
|
||||
|
||||
template <class T, class U>
|
||||
struct common_type_2
|
||||
{
|
||||
private:
|
||||
BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(T) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (T));
|
||||
BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(U) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (U));
|
||||
static bool declval_bool(); // workaround gcc bug; not required by std
|
||||
static typename add_rvalue_reference<T>::type declval_T(); // workaround gcc bug; not required by std
|
||||
static typename add_rvalue_reference<U>::type declval_U(); // workaround gcc bug; not required by std
|
||||
static typename add_rvalue_reference<bool>::type declval_b();
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
public:
|
||||
typedef decltype(declval<bool>() ? declval<T>() : declval<U>()) type;
|
||||
#elif defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
public:
|
||||
typedef typename detail_type_traits_common_type::common_type_impl<
|
||||
typename remove_cv<T>::type,
|
||||
typename remove_cv<U>::type
|
||||
>::type type;
|
||||
#else
|
||||
public:
|
||||
typedef BOOST_TYPEOF_TPL(declval_b() ? declval_T() : declval_U()) type;
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ == 3
|
||||
public:
|
||||
void public_dummy_function_just_to_silence_warning();
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct common_type_2<T, T>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class T, class U>
|
||||
struct common_type<T, U>
|
||||
#else
|
||||
template <class T, class U>
|
||||
struct common_type<T, U, void>
|
||||
#endif
|
||||
: public type_traits_detail::common_type_2<T,U>
|
||||
{ };
|
||||
|
||||
|
||||
// 3 or more args
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<typename T, typename U, typename... V>
|
||||
struct common_type<T, U, V...> {
|
||||
public:
|
||||
typedef typename common_type<typename common_type<T, U>::type, V...>::type type;
|
||||
};
|
||||
#endif
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TYPE_TRAITS_COMMON_TYPE_HPP
|
17
include/boost/type_traits/conversion_traits.hpp
Normal file
17
include/boost/type_traits/conversion_traits.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
// Copyright 2000 John Maddock (john@johnmaddock.co.uk)
|
||||
// Copyright 2000 Jeremy Siek (jsiek@lsc.nd.edu)
|
||||
// Copyright 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
|
||||
//
|
||||
// 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_CONVERSION_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_TT_CONVERSION_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
#endif // BOOST_TT_CONVERSION_TRAITS_HPP_INCLUDED
|
24
include/boost/type_traits/cv_traits.hpp
Normal file
24
include/boost/type_traits/cv_traits.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
// (C) Copyright Dave Abrahams, 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.
|
||||
//
|
||||
// defines traits classes for cv-qualified types:
|
||||
// is_const, is_volatile, remove_const, remove_volatile, remove_cv.
|
||||
|
||||
#ifndef BOOST_TT_CV_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_TT_CV_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/add_volatile.hpp>
|
||||
#include <boost/type_traits/add_cv.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/is_volatile.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/remove_volatile.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
|
||||
#endif // BOOST_TT_CV_TRAITS_HPP_INCLUDED
|
333
include/boost/type_traits/detail/common_type_imp.hpp
Normal file
333
include/boost/type_traits/detail/common_type_imp.hpp
Normal file
@@ -0,0 +1,333 @@
|
||||
/*******************************************************************************
|
||||
* boost/type_traits/detail/common_type_imp.hpp
|
||||
*
|
||||
* Copyright 2010, Jeffrey Hellrung.
|
||||
* 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)
|
||||
*
|
||||
* struct boost::common_type<T,U>
|
||||
*
|
||||
* common_type<T,U>::type is the type of the expression
|
||||
* b() ? x() : y()
|
||||
* where b() returns a bool, x() has return type T, and y() has return type U.
|
||||
* See
|
||||
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm#common_type
|
||||
*
|
||||
* Note that this evaluates to void if one or both of T and U is void.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMP_HPP
|
||||
#define BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMP_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/contains.hpp>
|
||||
#include <boost/mpl/copy.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/inserter.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/mpl/push_back.hpp>
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/mpl/vector/vector0.hpp>
|
||||
#include <boost/mpl/vector/vector10.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/make_signed.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/utility/declval.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail_type_traits_common_type
|
||||
{
|
||||
|
||||
/*******************************************************************************
|
||||
* struct propagate_cv< From, To >
|
||||
*
|
||||
* This metafunction propagates cv-qualifiers on type From to type To.
|
||||
******************************************************************************/
|
||||
|
||||
template< class From, class To >
|
||||
struct propagate_cv
|
||||
{ typedef To type; };
|
||||
template< class From, class To >
|
||||
struct propagate_cv< const From, To >
|
||||
{ typedef To const type; };
|
||||
template< class From, class To >
|
||||
struct propagate_cv< volatile From, To >
|
||||
{ typedef To volatile type; };
|
||||
template< class From, class To >
|
||||
struct propagate_cv< const volatile From, To >
|
||||
{ typedef To const volatile type; };
|
||||
|
||||
/*******************************************************************************
|
||||
* struct is_integral_or_enum<T>
|
||||
*
|
||||
* This metafunction determines if T is an integral type which can be made
|
||||
* signed or unsigned.
|
||||
******************************************************************************/
|
||||
|
||||
template< class T >
|
||||
struct is_integral_or_enum
|
||||
: public mpl::or_< is_integral<T>, is_enum<T> >
|
||||
{ };
|
||||
template<>
|
||||
struct is_integral_or_enum< bool >
|
||||
: public false_type
|
||||
{ };
|
||||
|
||||
/*******************************************************************************
|
||||
* struct make_unsigned_soft<T>
|
||||
* struct make_signed_soft<T>
|
||||
*
|
||||
* These metafunction are identical to make_unsigned and make_signed,
|
||||
* respectively, except for special-casing bool.
|
||||
******************************************************************************/
|
||||
|
||||
template< class T >
|
||||
struct make_unsigned_soft
|
||||
: public make_unsigned<T>
|
||||
{ };
|
||||
template<>
|
||||
struct make_unsigned_soft< bool >
|
||||
{ typedef bool type; };
|
||||
|
||||
template< class T >
|
||||
struct make_signed_soft
|
||||
: public make_signed<T>
|
||||
{ };
|
||||
template<>
|
||||
struct make_signed_soft< bool >
|
||||
{ typedef bool type; };
|
||||
|
||||
/*******************************************************************************
|
||||
* struct sizeof_t<N>
|
||||
* typedef ... yes_type
|
||||
* typedef ... no_type
|
||||
*
|
||||
* These types are integral players in the use of the "sizeof trick", i.e., we
|
||||
* can distinguish overload selection by inspecting the size of the return type
|
||||
* of the overload.
|
||||
******************************************************************************/
|
||||
|
||||
template< std::size_t N > struct sizeof_t { char _dummy[N]; };
|
||||
typedef sizeof_t<1> yes_type;
|
||||
typedef sizeof_t<2> no_type;
|
||||
BOOST_MPL_ASSERT_RELATION( sizeof( yes_type ), ==, 1 );
|
||||
BOOST_MPL_ASSERT_RELATION( sizeof( no_type ), ==, 2 );
|
||||
|
||||
/*******************************************************************************
|
||||
* rvalue_test(T&) -> no_type
|
||||
* rvalue_test(...) -> yes_type
|
||||
*
|
||||
* These overloads are used to determine the rvalue-ness of an expression.
|
||||
******************************************************************************/
|
||||
|
||||
template< class T > no_type rvalue_test(T&);
|
||||
yes_type rvalue_test(...);
|
||||
|
||||
/*******************************************************************************
|
||||
* struct conversion_test_overloads< Sequence >
|
||||
*
|
||||
* This struct has multiple overloads of the static member function apply, each
|
||||
* one taking a single parameter of a type within the Boost.MPL sequence
|
||||
* Sequence. Each such apply overload has a return type with sizeof equal to
|
||||
* one plus the index of the parameter type within Sequence. Thus, we can
|
||||
* deduce the type T of an expression as long as we can generate a finite set of
|
||||
* candidate types containing T via these apply overloads and the "sizeof
|
||||
* trick".
|
||||
******************************************************************************/
|
||||
|
||||
template< class First, class Last, std::size_t Index >
|
||||
struct conversion_test_overloads_iterate
|
||||
: public conversion_test_overloads_iterate<
|
||||
typename mpl::next< First >::type, Last, Index + 1
|
||||
>
|
||||
{
|
||||
using conversion_test_overloads_iterate<
|
||||
typename mpl::next< First >::type, Last, Index + 1
|
||||
>::apply;
|
||||
static sizeof_t< Index + 1 >
|
||||
apply(typename mpl::deref< First >::type);
|
||||
};
|
||||
|
||||
template< class Last, std::size_t Index >
|
||||
struct conversion_test_overloads_iterate< Last, Last, Index >
|
||||
{ static sizeof_t< Index + 1 > apply(...); };
|
||||
|
||||
template< class Sequence >
|
||||
struct conversion_test_overloads
|
||||
: public conversion_test_overloads_iterate<
|
||||
typename mpl::begin< Sequence >::type,
|
||||
typename mpl::end< Sequence >::type,
|
||||
0
|
||||
>
|
||||
{ };
|
||||
|
||||
/*******************************************************************************
|
||||
* struct select< Sequence, Index >
|
||||
*
|
||||
* select is synonymous with mpl::at_c unless Index equals the size of the
|
||||
* Boost.MPL Sequence, in which case this evaluates to void.
|
||||
******************************************************************************/
|
||||
|
||||
template<
|
||||
class Sequence, int Index,
|
||||
int N = mpl::size< Sequence >::value
|
||||
>
|
||||
struct select
|
||||
: public mpl::at_c< Sequence, Index >
|
||||
{ };
|
||||
template< class Sequence, int N >
|
||||
struct select< Sequence, N, N >
|
||||
{ typedef void type; };
|
||||
|
||||
/*******************************************************************************
|
||||
* class deduce_common_type< T, U, NominalCandidates >
|
||||
* struct nominal_candidates<T,U>
|
||||
* struct common_type_dispatch_on_rvalueness<T,U>
|
||||
* struct common_type_impl<T,U>
|
||||
*
|
||||
* These classes and structs implement the logic behind common_type, which goes
|
||||
* roughly as follows. Let C be the type of the conditional expression
|
||||
* declval< bool >() ? declval<T>() : declval<U>()
|
||||
* if C is an rvalue, then:
|
||||
* let T' and U' be T and U stripped of reference- and cv-qualifiers
|
||||
* if T' and U' are pointer types, say, T' = V* and U' = W*, then:
|
||||
* define the set of NominalCandidates to be
|
||||
* { V*, W*, V'*, W'* }
|
||||
* where V' is V with whatever cv-qualifiers are on W, and W' is W
|
||||
* with whatever cv-qualifiers are on V
|
||||
* else if T' and U' are both integral or enum types, then:
|
||||
* define the set of NominalCandidates to be
|
||||
* {
|
||||
* unsigned_soft(T'),
|
||||
* unsigned_soft(U'),
|
||||
* signed_soft(T'),
|
||||
* signed_soft(U'),
|
||||
* T',
|
||||
* U',
|
||||
* unsigned int,
|
||||
* int
|
||||
* }
|
||||
* where unsigned_soft(X) is make_unsigned_soft<X>::type and
|
||||
* signed_soft(X) is make_signed_soft<X>::type (these are all
|
||||
* generally necessary to cover the various integral promotion cases)
|
||||
* else
|
||||
* define the set of NominalCandidates to be
|
||||
* { T', U' }
|
||||
* else
|
||||
* let V and W be T and U stripped of reference-qualifiers
|
||||
* define the set of NominalCandidates to be
|
||||
* { V&, W&, V'&, W'& }
|
||||
* where V' is V with whatever cv-qualifiers are on W, and W' is W with
|
||||
* whatever cv-qualifiers are on V
|
||||
* define the set of Candidates to be equal to the set of NominalCandidates with
|
||||
* duplicates removed, and use this set of Candidates to determine C using the
|
||||
* conversion_test_overloads struct
|
||||
******************************************************************************/
|
||||
|
||||
template< class T, class U, class NominalCandidates >
|
||||
class deduce_common_type
|
||||
{
|
||||
typedef typename mpl::copy<
|
||||
NominalCandidates,
|
||||
mpl::inserter<
|
||||
mpl::vector0<>,
|
||||
mpl::if_<
|
||||
mpl::contains< mpl::_1, mpl::_2 >,
|
||||
mpl::_1,
|
||||
mpl::push_back< mpl::_1, mpl::_2 >
|
||||
>
|
||||
>
|
||||
>::type candidate_types;
|
||||
static const int best_candidate_index =
|
||||
sizeof( conversion_test_overloads< candidate_types >::apply(
|
||||
declval< bool >() ? declval<T>() : declval<U>()
|
||||
) ) - 1;
|
||||
public:
|
||||
typedef typename select< candidate_types, best_candidate_index >::type type;
|
||||
};
|
||||
|
||||
template<
|
||||
class T, class U,
|
||||
class V = typename remove_cv< typename remove_reference<T>::type >::type,
|
||||
class W = typename remove_cv< typename remove_reference<U>::type >::type,
|
||||
bool = is_integral_or_enum<V>::value && is_integral_or_enum<W>::value
|
||||
>
|
||||
struct nominal_candidates
|
||||
{ typedef mpl::vector2<V,W> type; };
|
||||
|
||||
template< class T, class U, class V, class W >
|
||||
struct nominal_candidates< T, U, V, W, true >
|
||||
{
|
||||
typedef boost::mpl::vector8<
|
||||
typename make_unsigned_soft<V>::type,
|
||||
typename make_unsigned_soft<W>::type,
|
||||
typename make_signed_soft<V>::type,
|
||||
typename make_signed_soft<W>::type,
|
||||
V, W, unsigned int, int
|
||||
> type;
|
||||
};
|
||||
|
||||
template< class T, class U, class V, class W >
|
||||
struct nominal_candidates< T, U, V*, W*, false >
|
||||
{
|
||||
typedef mpl::vector4<
|
||||
V*, W*,
|
||||
typename propagate_cv<W,V>::type *,
|
||||
typename propagate_cv<V,W>::type *
|
||||
> type;
|
||||
};
|
||||
|
||||
template<class T, class U, bool b>
|
||||
struct common_type_dispatch_on_rvalueness
|
||||
: public deduce_common_type< T, U, typename nominal_candidates<T,U>::type >
|
||||
{ };
|
||||
|
||||
template< class T, class U >
|
||||
struct common_type_dispatch_on_rvalueness< T, U, false >
|
||||
{
|
||||
private:
|
||||
typedef typename remove_reference<T>::type unrefed_T_type;
|
||||
typedef typename remove_reference<U>::type unrefed_U_type;
|
||||
public:
|
||||
typedef typename deduce_common_type<
|
||||
T, U,
|
||||
mpl::vector4<
|
||||
unrefed_T_type &,
|
||||
unrefed_U_type &,
|
||||
typename propagate_cv< unrefed_U_type, unrefed_T_type >::type &,
|
||||
typename propagate_cv< unrefed_T_type, unrefed_U_type >::type &
|
||||
>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
struct common_type_impl
|
||||
: public common_type_dispatch_on_rvalueness<T,U, sizeof( ::boost::detail_type_traits_common_type::rvalue_test(
|
||||
declval< bool >() ? declval<T>() : declval<U>() ) ) == sizeof( yes_type ) >
|
||||
{ };
|
||||
|
||||
template< class T > struct common_type_impl< T, void > { typedef void type; };
|
||||
template< class T > struct common_type_impl< void, T > { typedef void type; };
|
||||
template<> struct common_type_impl< void, void > { typedef void type; };
|
||||
|
||||
} // namespace detail_type_traits_common_type
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_HPP
|
||||
|
20
include/boost/type_traits/has_nothrow_destructor.hpp
Normal file
20
include/boost/type_traits/has_nothrow_destructor.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
// (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_HAS_NOTHROW_DESTRUCTOR_HPP_INCLUDED
|
||||
#define BOOST_TT_HAS_NOTHROW_DESTRUCTOR_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <class T> struct has_nothrow_destructor : public ::boost::has_trivial_destructor<T> {};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_HAS_NOTHROW_DESTRUCTOR_HPP_INCLUDED
|
15
include/boost/type_traits/reference_traits.hpp
Normal file
15
include/boost/type_traits/reference_traits.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
// (C) Copyright David Abrahams Steve Cleary, Beman Dawes, Howard
|
||||
// Hinnant & John Maddock 2000-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).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
|
||||
#ifndef BOOST_TT_REFERENCE_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_TT_REFERENCE_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
|
||||
#endif // BOOST_TT_REFERENCE_TRAITS_HPP_INCLUDED
|
15
include/boost/type_traits/same_traits.hpp
Normal file
15
include/boost/type_traits/same_traits.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
// (C) Copyright Steve Cleary, Beman Dawes, Aleksey Gurtovoy, 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.
|
||||
//
|
||||
// defines is_same:
|
||||
|
||||
#ifndef BOOST_TT_SAME_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_TT_SAME_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#endif // BOOST_TT_SAME_TRAITS_HPP_INCLUDED
|
21
include/boost/type_traits/transform_traits.hpp
Normal file
21
include/boost/type_traits/transform_traits.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
// (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.
|
||||
//
|
||||
// defines traits classes for transforming one type to another:
|
||||
// remove_reference, add_reference, remove_bounds, remove_pointer.
|
||||
//
|
||||
|
||||
#ifndef BOOST_TT_TRANSFORM_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_TT_TRANSFORM_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/add_pointer.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/remove_bounds.hpp>
|
||||
#include <boost/type_traits/remove_pointer.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
#endif // BOOST_TT_TRANSFORM_TRAITS_HPP_INCLUDED
|
222
test/common_type_2_test.cpp
Normal file
222
test/common_type_2_test.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
// common_type_test.cpp ----------------------------------------------------//
|
||||
|
||||
// Copyright 2010 Beman Dawes
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#define BOOST_COMMON_TYPE_DONT_USE_TYPEOF 1
|
||||
|
||||
#include "test.hpp"
|
||||
#include "check_type.hpp"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/common_type.hpp>
|
||||
#endif
|
||||
#include <iostream>
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
#pragma warning(disable: 304 383)
|
||||
#endif
|
||||
|
||||
struct C1 {};
|
||||
|
||||
struct C2 {};
|
||||
|
||||
|
||||
struct C3 : C2 {};
|
||||
struct C1C2 {
|
||||
C1C2() {}
|
||||
C1C2(C1 const&) {}
|
||||
C1C2(C2 const&) {}
|
||||
C1C2& operator=(C1C2 const&) {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename C, typename A>
|
||||
void proc2(typename boost::common_type<A, C>::type const& ) {}
|
||||
|
||||
template <typename C, typename A, typename B>
|
||||
void proc3(typename boost::common_type<C, A, B>::type const& ) {}
|
||||
|
||||
template <typename C, typename A>
|
||||
void assignation_2() {
|
||||
typedef typename boost::common_type<A, C>::type AC;
|
||||
A a;
|
||||
C c;
|
||||
AC ac;
|
||||
ac=a;
|
||||
ac=c;
|
||||
|
||||
proc2<C, A>(a);
|
||||
proc2<C, A>(c);
|
||||
|
||||
}
|
||||
|
||||
template <typename C, typename A, typename B>
|
||||
void assignation_3() {
|
||||
typedef typename boost::common_type<C, A, B>::type ABC;
|
||||
A a;
|
||||
B b;
|
||||
C c;
|
||||
ABC abc;
|
||||
|
||||
abc=a;
|
||||
abc=b;
|
||||
abc=c;
|
||||
|
||||
proc3<C, A, B>(a);
|
||||
proc3<C, A, B>(b);
|
||||
proc3<C, A, B>(c);
|
||||
}
|
||||
|
||||
C1C2 c1c2;
|
||||
C1 c1;
|
||||
|
||||
int f(C1C2 ) { return 1;}
|
||||
int f(C1 ) { return 2;}
|
||||
template <typename OSTREAM>
|
||||
OSTREAM& operator<<(OSTREAM& os, C1 const&) {return os;}
|
||||
|
||||
C1C2& declval_C1C2() {return c1c2;}
|
||||
C1& declval_C1(){return c1;}
|
||||
bool declval_bool(){return true;}
|
||||
|
||||
|
||||
TT_TEST_BEGIN(common_type)
|
||||
{
|
||||
#ifndef __SUNPRO_CC
|
||||
assignation_2<C1C2, C1>();
|
||||
typedef tt::common_type<C1C2&, C1&>::type T1;
|
||||
BOOST_CHECK_TYPE(T1, C1C2);
|
||||
typedef tt::common_type<C3*, C2*>::type T2;
|
||||
BOOST_CHECK_TYPE(T2, C2*);
|
||||
typedef tt::common_type<int*, int const*>::type T3;
|
||||
BOOST_CHECK_TYPE(T3, int const*);
|
||||
#if defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
// fails if BOOST_COMMON_TYPE_DONT_USE_TYPEOF:
|
||||
typedef tt::common_type<int volatile*, int const*>::type T4;
|
||||
BOOST_CHECK_TYPE(T4, int const volatile*);
|
||||
#endif
|
||||
typedef tt::common_type<int*, int volatile*>::type T5;
|
||||
BOOST_CHECK_TYPE(T5, int volatile*);
|
||||
|
||||
assignation_2<C1, C1C2>();
|
||||
assignation_2<C1C2, C2>();
|
||||
assignation_2<C2, C1C2>();
|
||||
assignation_3<C1, C1C2, C2>();
|
||||
assignation_3<C1C2, C1, C2>();
|
||||
assignation_3<C2, C1C2, C1>();
|
||||
assignation_3<C1C2, C2, C1>();
|
||||
//assignation_3<C1, C2, C1C2>(); // fails because the common type is the third
|
||||
#endif
|
||||
|
||||
typedef tt::common_type<C1C2, C1>::type t1;
|
||||
BOOST_CHECK_TYPE(t1, C1C2);
|
||||
|
||||
BOOST_CHECK_TYPE(tt::common_type<int>::type, int);
|
||||
BOOST_CHECK_TYPE(tt::common_type<char>::type, char);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, char>::type, char);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, unsigned char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, unsigned short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, int>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, unsigned char>::type, unsigned char);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, unsigned short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, int>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, unsigned char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, short>::type, short);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, unsigned short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, int>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, unsigned char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, unsigned short>::type, unsigned short);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, int>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, unsigned char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, unsigned short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, int>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, char>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, unsigned char>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, short>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, unsigned short>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, int>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, double>::type, double);
|
||||
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, char>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, unsigned char>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, short>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, unsigned short>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, int>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, unsigned int>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, double>::type, double);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, char>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, unsigned char>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, short>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, unsigned short>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, int>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, unsigned int>::type, double);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, boost::long_long_type>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, boost::ulong_long_type>::type, double);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE4(tt::common_type<double, char, int>::type, double);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE4(tt::common_type<unsigned, char, boost::long_long_type>::type, boost::long_long_type);
|
||||
#endif
|
||||
}
|
||||
TT_TEST_END
|
27
test/common_type_fail.cpp
Normal file
27
test/common_type_fail.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// common_type_test.cpp ----------------------------------------------------//
|
||||
|
||||
// Copyright 2010 Beman Dawes
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS // disable VC++ foolishness
|
||||
|
||||
#include "test.hpp"
|
||||
#ifndef TEST_STD
|
||||
#include <boost/type_traits/common_type.hpp>
|
||||
#else
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
struct C1 {
|
||||
//~ private:
|
||||
//~ C1();
|
||||
};
|
||||
|
||||
struct C2 {};
|
||||
|
||||
|
||||
|
||||
typedef tt::common_type<C1, C2>::type AC;
|
||||
|
215
test/common_type_test.cpp
Normal file
215
test/common_type_test.cpp
Normal file
@@ -0,0 +1,215 @@
|
||||
// common_type_test.cpp ----------------------------------------------------//
|
||||
|
||||
// Copyright 2010 Beman Dawes
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "test.hpp"
|
||||
#include "check_type.hpp"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/common_type.hpp>
|
||||
#endif
|
||||
#include <iostream>
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
#pragma warning(disable: 304 383)
|
||||
#endif
|
||||
|
||||
struct C1 {};
|
||||
|
||||
struct C2 {};
|
||||
|
||||
|
||||
struct C3 : C2 {};
|
||||
struct C1C2 {
|
||||
C1C2() {}
|
||||
C1C2(C1 const&) {}
|
||||
C1C2(C2 const&) {}
|
||||
C1C2& operator=(C1C2 const&) {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename C, typename A>
|
||||
void proc2(typename boost::common_type<A, C>::type const& ) {}
|
||||
|
||||
template <typename C, typename A, typename B>
|
||||
void proc3(typename boost::common_type<C, A, B>::type const& ) {}
|
||||
|
||||
template <typename C, typename A>
|
||||
void assignation_2() {
|
||||
typedef typename boost::common_type<A, C>::type AC;
|
||||
A a;
|
||||
C c;
|
||||
AC ac;
|
||||
ac=a;
|
||||
ac=c;
|
||||
|
||||
proc2<C, A>(a);
|
||||
proc2<C, A>(c);
|
||||
|
||||
}
|
||||
|
||||
template <typename C, typename A, typename B>
|
||||
void assignation_3() {
|
||||
typedef typename boost::common_type<C, A, B>::type ABC;
|
||||
A a;
|
||||
B b;
|
||||
C c;
|
||||
ABC abc;
|
||||
|
||||
abc=a;
|
||||
abc=b;
|
||||
abc=c;
|
||||
|
||||
proc3<C, A, B>(a);
|
||||
proc3<C, A, B>(b);
|
||||
proc3<C, A, B>(c);
|
||||
}
|
||||
|
||||
C1C2 c1c2;
|
||||
C1 c1;
|
||||
|
||||
int f(C1C2 ) { return 1;}
|
||||
int f(C1 ) { return 2;}
|
||||
template <typename OSTREAM>
|
||||
OSTREAM& operator<<(OSTREAM& os, C1 const&) {return os;}
|
||||
|
||||
C1C2& declval_C1C2() {return c1c2;}
|
||||
C1& declval_C1(){return c1;}
|
||||
bool declval_bool(){return true;}
|
||||
|
||||
|
||||
TT_TEST_BEGIN(common_type)
|
||||
{
|
||||
assignation_2<C1C2, C1>();
|
||||
typedef tt::common_type<C1C2&, C1&>::type T1;
|
||||
BOOST_CHECK_TYPE(T1, C1C2);
|
||||
typedef tt::common_type<C3*, C2*>::type T2;
|
||||
BOOST_CHECK_TYPE(T2, C2*);
|
||||
typedef tt::common_type<int*, int const*>::type T3;
|
||||
BOOST_CHECK_TYPE(T3, int const*);
|
||||
#if defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
// fails if BOOST_COMMON_TYPE_DONT_USE_TYPEOF:
|
||||
typedef tt::common_type<int volatile*, int const*>::type T4;
|
||||
BOOST_CHECK_TYPE(T4, int const volatile*);
|
||||
#endif
|
||||
typedef tt::common_type<int*, int volatile*>::type T5;
|
||||
BOOST_CHECK_TYPE(T5, int volatile*);
|
||||
|
||||
assignation_2<C1, C1C2>();
|
||||
assignation_2<C1C2, C2>();
|
||||
assignation_2<C2, C1C2>();
|
||||
assignation_3<C1, C1C2, C2>();
|
||||
assignation_3<C1C2, C1, C2>();
|
||||
assignation_3<C2, C1C2, C1>();
|
||||
assignation_3<C1C2, C2, C1>();
|
||||
//assignation_3<C1, C2, C1C2>(); // fails because the common type is the third
|
||||
|
||||
BOOST_CHECK_TYPE(tt::common_type<int>::type, int);
|
||||
BOOST_CHECK_TYPE(tt::common_type<char>::type, char);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, char>::type, char);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, unsigned char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, unsigned short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, int>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<char, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, unsigned char>::type, unsigned char);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, unsigned short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, int>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned char, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, unsigned char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, short>::type, short);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, unsigned short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, int>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<short, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, unsigned char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, unsigned short>::type, unsigned short);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, int>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned short, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, unsigned char>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, unsigned short>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, int>::type, int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<int, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, char>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, unsigned char>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, short>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, unsigned short>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, int>::type, unsigned int);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, unsigned int>::type, unsigned int);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<unsigned int, double>::type, double);
|
||||
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, char>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, unsigned char>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, short>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, unsigned short>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, int>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, unsigned int>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, boost::long_long_type>::type, boost::long_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, boost::ulong_long_type>::type, boost::ulong_long_type);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<boost::long_long_type, double>::type, double);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, char>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, unsigned char>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, short>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, unsigned short>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, int>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, unsigned int>::type, double);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, boost::long_long_type>::type, double);
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, boost::ulong_long_type>::type, double);
|
||||
#endif
|
||||
BOOST_CHECK_TYPE3(tt::common_type<double, double>::type, double);
|
||||
|
||||
BOOST_CHECK_TYPE4(tt::common_type<double, char, int>::type, double);
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
BOOST_CHECK_TYPE4(tt::common_type<unsigned, char, boost::long_long_type>::type, boost::long_long_type);
|
||||
#endif
|
||||
}
|
||||
TT_TEST_END
|
37
test/tricky_incomplete_type_test.cpp
Normal file
37
test/tricky_incomplete_type_test.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
// (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.hpp>
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(tricky_incomplete_type_test)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<incomplete_type>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_compound<incomplete_type>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_enum<incomplete_type>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_scalar<incomplete_type>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_array<int[]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_array<int[][3]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_array<const int[]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_array<const int[][3]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_array<volatile int[]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_array<volatile int[][3]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_array<const volatile int[]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_array<const volatile int[][3]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<incomplete_type>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_function<incomplete_type>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer<incomplete_type>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer<incomplete_type>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer<incomplete_type>::value, false);
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
103
test/type_traits_test.cpp
Normal file
103
test/type_traits_test.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
// (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 <boost/type_traits.hpp>
|
||||
|
||||
//
|
||||
// Just check that each trait actually exists, not
|
||||
// that it gives the correct answer, we do that elsewhere:
|
||||
//
|
||||
|
||||
typedef boost::add_const<int>::type t1;
|
||||
typedef boost::add_cv<int>::type t2;
|
||||
typedef boost::add_lvalue_reference<int>::type t3;
|
||||
typedef boost::add_pointer<int>::type t4;
|
||||
typedef boost::add_reference<int>::type t5;
|
||||
typedef boost::add_rvalue_reference<int>::type t6;
|
||||
typedef boost::add_volatile<int>::type t7;
|
||||
|
||||
typedef boost::aligned_storage<2>::type t8;
|
||||
typedef boost::alignment_of<int>::type t9;
|
||||
typedef boost::conditional<true, int, long>::type t10;
|
||||
typedef boost::common_type<int, long>::type t11;
|
||||
typedef boost::decay<int[2] >::type t12;
|
||||
typedef boost::extent<int[3] >::type t13;
|
||||
typedef boost::floating_point_promotion<int>::type t14;
|
||||
typedef boost::function_traits<int (int) > t15;
|
||||
|
||||
typedef boost::has_new_operator<int> t16;
|
||||
typedef boost::has_nothrow_assign<int> t17;
|
||||
typedef boost::has_nothrow_constructor<int> t18;
|
||||
typedef boost::has_nothrow_copy<int> t19;
|
||||
typedef boost::has_nothrow_copy_constructor<int> t20;
|
||||
typedef boost::has_nothrow_default_constructor<int> t21;
|
||||
typedef boost::has_trivial_assign<int> t22;
|
||||
typedef boost::has_trivial_constructor<int> t23;
|
||||
typedef boost::has_trivial_copy<int> t24;
|
||||
typedef boost::has_trivial_copy_constructor<int> t25;
|
||||
typedef boost::has_trivial_default_constructor<int> t26;
|
||||
typedef boost::has_trivial_destructor<int> t27;
|
||||
typedef boost::has_virtual_destructor<int> t28;
|
||||
|
||||
typedef boost::integral_constant<int, 2> t29;
|
||||
typedef boost::integral_promotion<short>::type t30;
|
||||
|
||||
typedef boost::is_abstract<int>::type t31;
|
||||
typedef boost::is_arithmetic<int>::type t32;
|
||||
typedef boost::is_array<int>::type t33;
|
||||
typedef boost::is_base_of<int, long>::type t34;
|
||||
typedef boost::is_class<int>::type t35;
|
||||
typedef boost::is_complex<int>::type t36;
|
||||
typedef boost::is_compound<int>::type t37;
|
||||
typedef boost::is_const<int>::type t38;
|
||||
typedef boost::is_convertible<int, long>::type t39;
|
||||
typedef boost::is_empty<int>::type t40;
|
||||
typedef boost::is_enum<int>::type t41;
|
||||
typedef boost::is_floating_point<int>::type t42;
|
||||
typedef boost::is_function<int>::type t43;
|
||||
typedef boost::is_fundamental<int>::type t44;
|
||||
typedef boost::is_integral<int>::type t45;
|
||||
typedef boost::is_lvalue_reference<int>::type t46;
|
||||
typedef boost::is_member_function_pointer<int>::type t47;
|
||||
typedef boost::is_member_object_pointer<int>::type t48;
|
||||
typedef boost::is_member_pointer<int>::type t49;
|
||||
typedef boost::is_object<int>::type t50;
|
||||
typedef boost::is_pod<int>::type t51;
|
||||
typedef boost::is_pointer<int>::type t52;
|
||||
typedef boost::is_polymorphic<int>::type t53;
|
||||
typedef boost::is_reference<int>::type t54;
|
||||
typedef boost::is_rvalue_reference<int>::type t55;
|
||||
typedef boost::is_same<int, int>::type t56;
|
||||
typedef boost::is_scalar<int>::type t57;
|
||||
typedef boost::is_signed<int>::type t58;
|
||||
typedef boost::is_stateless<int>::type t59;
|
||||
typedef boost::is_union<int>::type t60;
|
||||
typedef boost::is_unsigned<int>::type t61;
|
||||
typedef boost::is_virtual_base_of<int, int>::type t62;
|
||||
typedef boost::is_void<int>::type t63;
|
||||
typedef boost::is_volatile<int>::type t64;
|
||||
typedef boost::make_signed<int>::type t65;
|
||||
typedef boost::make_unsigned<int>::type t66;
|
||||
typedef boost::promote<int>::type t67;
|
||||
typedef boost::rank<int>::type t68;
|
||||
|
||||
typedef boost::remove_all_extents<int>::type t69;
|
||||
typedef boost::remove_const<int>::type t70;
|
||||
typedef boost::remove_cv<int>::type t71;
|
||||
typedef boost::remove_extent<int>::type t72;
|
||||
typedef boost::remove_pointer<int>::type t73;
|
||||
typedef boost::remove_reference<int>::type t74;
|
||||
typedef boost::remove_volatile<int>::type t75;
|
||||
typedef boost::type_with_alignment<4>::type t76;
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user