forked from boostorg/type_traits
Convert some more traits.
This commit is contained in:
41
include/boost/type_traits/add_cv.hpp
Normal file
41
include/boost/type_traits/add_cv.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
// (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_ADD_CV_HPP_INCLUDED
|
||||
#define BOOST_TT_ADD_CV_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// * convert a type T to a const volatile type - add_cv<T>
|
||||
// this is not required since the result is always
|
||||
// the same as "T const volatile", but it does suppress warnings
|
||||
// from some compilers:
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
// This bogus warning will appear when add_volatile is applied to a
|
||||
// const volatile reference because we can't detect const volatile
|
||||
// references with MSVC6.
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4181) // warning C4181: qualifier applied to reference type ignored
|
||||
#endif
|
||||
|
||||
template <class T> struct add_cv{ typedef T const volatile type; };
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
template <class T> struct add_cv<T&>{ typedef T& type; };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_ADD_CV_HPP_INCLUDED
|
61
include/boost/type_traits/add_pointer.hpp
Normal file
61
include/boost/type_traits/add_pointer.hpp
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
// (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_ADD_POINTER_HPP_INCLUDED
|
||||
#define BOOST_TT_ADD_POINTER_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x5A0)
|
||||
//
|
||||
// For some reason this implementation stops Borlands compiler
|
||||
// from dropping cv-qualifiers, it still fails with references
|
||||
// to arrays for some reason though (shrug...) (JM 20021104)
|
||||
//
|
||||
template <typename T>
|
||||
struct add_pointer
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
template <typename T>
|
||||
struct add_pointer<T&>
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
template <typename T>
|
||||
struct add_pointer<T&const>
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
template <typename T>
|
||||
struct add_pointer<T&volatile>
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
template <typename T>
|
||||
struct add_pointer<T&const volatile>
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template <typename T>
|
||||
struct add_pointer
|
||||
{
|
||||
typedef typename remove_reference<T>::type no_ref_type;
|
||||
typedef no_ref_type* type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_ADD_POINTER_HPP_INCLUDED
|
40
include/boost/type_traits/add_volatile.hpp
Normal file
40
include/boost/type_traits/add_volatile.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
// (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_ADD_VOLATILE_HPP_INCLUDED
|
||||
#define BOOST_TT_ADD_VOLATILE_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// * convert a type T to volatile type - add_volatile<T>
|
||||
// this is not required since the result is always
|
||||
// the same as "T volatile", but it does suppress warnings
|
||||
// from some compilers:
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
// This bogus warning will appear when add_volatile is applied to a
|
||||
// const volatile reference because we can't detect const volatile
|
||||
// references with MSVC6.
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4181) // warning C4181: qualifier applied to reference type ignored
|
||||
#endif
|
||||
|
||||
template <class T> struct add_volatile{ typedef T volatile type; };
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
template <class T> struct add_volatile<T&>{ typedef T& type; };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_ADD_VOLATILE_HPP_INCLUDED
|
119
include/boost/type_traits/alignment_of.hpp
Normal file
119
include/boost/type_traits/alignment_of.hpp
Normal file
@ -0,0 +1,119 @@
|
||||
|
||||
// (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_OF_HPP_INCLUDED
|
||||
#define BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/type_traits/intrinsics.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4121 4512) // alignment is sensitive to packing
|
||||
#endif
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x600)
|
||||
#pragma option push -Vx- -Ve-
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename T> struct alignment_of;
|
||||
|
||||
// get the alignment of some arbitrary type:
|
||||
namespace detail {
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4324) // structure was padded due to __declspec(align())
|
||||
#endif
|
||||
template <typename T>
|
||||
struct alignment_of_hack
|
||||
{
|
||||
char c;
|
||||
T t;
|
||||
alignment_of_hack();
|
||||
};
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
template <unsigned A, unsigned S>
|
||||
struct alignment_logic
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = A < S ? A : S);
|
||||
};
|
||||
|
||||
|
||||
template< typename T >
|
||||
struct alignment_of_impl
|
||||
{
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)
|
||||
//
|
||||
// With MSVC both the native __alignof operator
|
||||
// and our own logic gets things wrong from time to time :-(
|
||||
// Using a combination of the two seems to make the most of a bad job:
|
||||
//
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value =
|
||||
(::boost::detail::alignment_logic<
|
||||
sizeof(::boost::detail::alignment_of_hack<T>) - sizeof(T),
|
||||
__alignof(T)
|
||||
>::value));
|
||||
#elif !defined(BOOST_ALIGNMENT_OF)
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value =
|
||||
(::boost::detail::alignment_logic<
|
||||
sizeof(::boost::detail::alignment_of_hack<T>) - sizeof(T),
|
||||
sizeof(T)
|
||||
>::value));
|
||||
#else
|
||||
//
|
||||
// We put this here, rather than in the definition of
|
||||
// alignment_of below, because MSVC's __alignof doesn't
|
||||
// always work in that context for some unexplained reason.
|
||||
// (See type_with_alignment tests for test cases).
|
||||
//
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = BOOST_ALIGNMENT_OF(T));
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class T> struct alignment_of : public integral_constant<std::size_t, ::boost::detail::alignment_of_impl<T>::value>{};
|
||||
|
||||
// references have to be treated specially, assume
|
||||
// that a reference is just a special pointer:
|
||||
template <typename T> struct alignment_of<T&> : public alignment_of<T*>{};
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
// long double gives an incorrect value of 10 (!)
|
||||
// unless we do this...
|
||||
struct long_double_wrapper{ long double ld; };
|
||||
template<> struct alignment_of<long double> : public alignment_of<long_double_wrapper>{};
|
||||
#endif
|
||||
|
||||
// void has to be treated specially:
|
||||
template<> struct alignment_of<void> : integral_constant<std::size_t, 0>{};
|
||||
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
||||
template<> struct alignment_of<void const> : integral_constant<std::size_t, 0>{};
|
||||
template<> struct alignment_of<void const volatile> : integral_constant<std::size_t, 0>{};
|
||||
template<> struct alignment_of<void volatile> : integral_constant<std::size_t, 0>{};
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x600)
|
||||
#pragma option pop
|
||||
#endif
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED
|
||||
|
29
include/boost/type_traits/composite_traits.hpp
Normal file
29
include/boost/type_traits/composite_traits.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
// (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 composite types:
|
||||
// is_array, is_pointer, is_reference, is_member_pointer, is_enum, is_union.
|
||||
//
|
||||
|
||||
#ifndef BOOST_TT_COMPOSITE_TRAITS_HPP_INCLUDED
|
||||
#define BOOST_TT_COMPOSITE_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_member_pointer.hpp>
|
||||
#include <boost/type_traits/is_member_function_pointer.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/is_union.hpp>
|
||||
|
||||
#endif // BOOST_TT_COMPOSITE_TRAITS_HPP_INCLUDED
|
||||
|
||||
|
||||
|
||||
|
||||
|
42
include/boost/type_traits/detail/ice_and.hpp
Normal file
42
include/boost/type_traits/detail/ice_and.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
// (C) Copyright John Maddock and Steve Cleary 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_DETAIL_ICE_AND_HPP_INCLUDED
|
||||
#define BOOST_TT_DETAIL_ICE_AND_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//
|
||||
// This header is deprecated and no longer used by type_traits:
|
||||
//
|
||||
#if defined(__GNUC__) || defined(_MSC_VER)
|
||||
# pragma message("NOTE: Use of this header (ice_and.hpp) is deprecated")
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace type_traits {
|
||||
|
||||
template <bool b1, bool b2, bool b3 = true, bool b4 = true, bool b5 = true, bool b6 = true, bool b7 = true>
|
||||
struct ice_and;
|
||||
|
||||
template <bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7>
|
||||
struct ice_and
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ice_and<true, true, true, true, true, true, true>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
};
|
||||
|
||||
} // namespace type_traits
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_DETAIL_ICE_AND_HPP_INCLUDED
|
43
include/boost/type_traits/detail/ice_eq.hpp
Normal file
43
include/boost/type_traits/detail/ice_eq.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
// (C) Copyright John Maddock and Steve Cleary 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_DETAIL_ICE_EQ_HPP_INCLUDED
|
||||
#define BOOST_TT_DETAIL_ICE_EQ_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//
|
||||
// This header is deprecated and no longer used by type_traits:
|
||||
//
|
||||
#if defined(__GNUC__) || defined(_MSC_VER)
|
||||
# pragma message("NOTE: Use of this header (ice_eq.hpp) is deprecated")
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace type_traits {
|
||||
|
||||
template <int b1, int b2>
|
||||
struct ice_eq
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = (b1 == b2));
|
||||
};
|
||||
|
||||
template <int b1, int b2>
|
||||
struct ice_ne
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = (b1 != b2));
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
template <int b1, int b2> bool const ice_eq<b1,b2>::value;
|
||||
template <int b1, int b2> bool const ice_ne<b1,b2>::value;
|
||||
#endif
|
||||
|
||||
} // namespace type_traits
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_DETAIL_ICE_EQ_HPP_INCLUDED
|
38
include/boost/type_traits/detail/ice_not.hpp
Normal file
38
include/boost/type_traits/detail/ice_not.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
// (C) Copyright John Maddock and Steve Cleary 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_DETAIL_ICE_NOT_HPP_INCLUDED
|
||||
#define BOOST_TT_DETAIL_ICE_NOT_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//
|
||||
// This header is deprecated and no longer used by type_traits:
|
||||
//
|
||||
#if defined(__GNUC__) || defined(_MSC_VER)
|
||||
# pragma message("NOTE: Use of this header (ice_not.hpp) is deprecated")
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace type_traits {
|
||||
|
||||
template <bool b>
|
||||
struct ice_not
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ice_not<true>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
} // namespace type_traits
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_DETAIL_ICE_NOT_HPP_INCLUDED
|
41
include/boost/type_traits/detail/ice_or.hpp
Normal file
41
include/boost/type_traits/detail/ice_or.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
// (C) Copyright John Maddock and Steve Cleary 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_DETAIL_ICE_OR_HPP_INCLUDED
|
||||
#define BOOST_TT_DETAIL_ICE_OR_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//
|
||||
// This header is deprecated and no longer used by type_traits:
|
||||
//
|
||||
#if defined(__GNUC__) || defined(_MSC_VER)
|
||||
# pragma message("NOTE: Use of this header (ice_or.hpp) is deprecated")
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace type_traits {
|
||||
|
||||
template <bool b1, bool b2, bool b3 = false, bool b4 = false, bool b5 = false, bool b6 = false, bool b7 = false>
|
||||
struct ice_or;
|
||||
|
||||
template <bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7>
|
||||
struct ice_or
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ice_or<false, false, false, false, false, false, false>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
} // namespace type_traits
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_DETAIL_ICE_OR_HPP_INCLUDED
|
44
include/boost/type_traits/has_trivial_destructor.hpp
Normal file
44
include/boost/type_traits/has_trivial_destructor.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
// (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_TRIVIAL_DESTRUCTOR_HPP_INCLUDED
|
||||
#define BOOST_TT_HAS_TRIVIAL_DESTRUCTOR_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/intrinsics.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_TRIVIAL_DESTRUCTOR
|
||||
|
||||
#if defined(BOOST_INTEL) || defined(BOOST_MSVC)
|
||||
#include <boost/type_traits/is_pod.hpp>
|
||||
#endif
|
||||
#ifdef BOOST_HAS_SGI_TYPE_TRAITS
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename T> struct has_trivial_destructor : public integral_constant<bool, BOOST_HAS_TRIVIAL_DESTRUCTOR(T)>{};
|
||||
#else
|
||||
#include <boost/type_traits/is_pod.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <typename T> struct has_trivial_destructor : public integral_constant<bool, ::boost::is_pod<T>::value>{};
|
||||
#endif
|
||||
|
||||
template <> struct has_trivial_destructor<void> : public false_type{};
|
||||
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
||||
template <> struct has_trivial_destructor<void const> : public false_type{};
|
||||
template <> struct has_trivial_destructor<void const volatile> : public false_type{};
|
||||
template <> struct has_trivial_destructor<void volatile> : public false_type{};
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_HAS_TRIVIAL_DESTRUCTOR_HPP_INCLUDED
|
20
include/boost/type_traits/ice.hpp
Normal file
20
include/boost/type_traits/ice.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
// (C) Copyright John Maddock and Steve Cleary 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.
|
||||
//
|
||||
// macros and helpers for working with integral-constant-expressions.
|
||||
|
||||
#ifndef BOOST_TT_ICE_HPP_INCLUDED
|
||||
#define BOOST_TT_ICE_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/detail/yes_no_type.hpp>
|
||||
#include <boost/type_traits/detail/ice_or.hpp>
|
||||
#include <boost/type_traits/detail/ice_and.hpp>
|
||||
#include <boost/type_traits/detail/ice_not.hpp>
|
||||
#include <boost/type_traits/detail/ice_eq.hpp>
|
||||
|
||||
#endif // BOOST_TT_ICE_HPP_INCLUDED
|
61
test/add_cv_test.cpp
Normal file
61
test/add_cv_test.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
// (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.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_cv.hpp>
|
||||
#endif
|
||||
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_1, ::tt::add_cv, const, const volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_2, ::tt::add_cv, volatile, volatile const)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_3, ::tt::add_cv, *, *const volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST2(add_cv_test_4, ::tt::add_cv, const volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_7, ::tt::add_cv, *volatile, *volatile const)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_10, ::tt::add_cv, const*, const*const volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_11, ::tt::add_cv, volatile*, volatile*const volatile )
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_5, ::tt::add_cv, const &, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_6, ::tt::add_cv, &, &)
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_5a, ::tt::add_cv, const &&, const&&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_6a, ::tt::add_cv, &&, &&)
|
||||
#endif
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_8, ::tt::add_cv, const [2], const volatile [2])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_9, ::tt::add_cv, volatile &, volatile&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_12, ::tt::add_cv, [2][3], const volatile[2][3])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_cv_test_13, ::tt::add_cv, (&)[2], (&)[2])
|
||||
|
||||
TT_TEST_BEGIN(add_const)
|
||||
|
||||
add_cv_test_1();
|
||||
add_cv_test_2();
|
||||
add_cv_test_3();
|
||||
add_cv_test_4();
|
||||
add_cv_test_7();
|
||||
add_cv_test_10();
|
||||
add_cv_test_11();
|
||||
add_cv_test_5();
|
||||
add_cv_test_6();
|
||||
add_cv_test_8();
|
||||
add_cv_test_9();
|
||||
add_cv_test_12();
|
||||
add_cv_test_13();
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
add_cv_test_5a();
|
||||
add_cv_test_6a();
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
41
test/add_pointer_test.cpp
Normal file
41
test/add_pointer_test.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
// (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.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_1, ::tt::add_pointer, const, const*)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_2, ::tt::add_pointer, volatile, volatile*)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_3, ::tt::add_pointer, *, **)
|
||||
BOOST_DECL_TRANSFORM_TEST2(add_pointer_test_4, ::tt::add_pointer, *)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_7, ::tt::add_pointer, *volatile, *volatile*)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_10, ::tt::add_pointer, const*, const**)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_pointer_test_11, ::tt::add_pointer, volatile*, volatile**)
|
||||
|
||||
TT_TEST_BEGIN(add_pointer)
|
||||
|
||||
add_pointer_test_1();
|
||||
add_pointer_test_2();
|
||||
add_pointer_test_3();
|
||||
add_pointer_test_4();
|
||||
add_pointer_test_7();
|
||||
add_pointer_test_10();
|
||||
add_pointer_test_11();
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
59
test/add_volatile_test.cpp
Normal file
59
test/add_volatile_test.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
// (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.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_volatile.hpp>
|
||||
#endif
|
||||
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_1, ::tt::add_volatile, const, const volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_2, ::tt::add_volatile, volatile, volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_3, ::tt::add_volatile, *, *volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST2(add_volatile_test_4, ::tt::add_volatile, volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_7, ::tt::add_volatile, *volatile, *volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_10, ::tt::add_volatile, const*, const*volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_11, ::tt::add_volatile, volatile*, volatile*volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_5, ::tt::add_volatile, const &, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_6, ::tt::add_volatile, &, &)
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_6a, ::tt::add_volatile, &&, &&)
|
||||
#endif
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_8, ::tt::add_volatile, const [2], const volatile [2])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_9, ::tt::add_volatile, volatile &, volatile&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_12, ::tt::add_volatile, [2][3], volatile[2][3])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_13, ::tt::add_volatile, (&)[2], (&)[2])
|
||||
|
||||
TT_TEST_BEGIN(add_volatile)
|
||||
|
||||
add_volatile_test_1();
|
||||
add_volatile_test_2();
|
||||
add_volatile_test_3();
|
||||
add_volatile_test_4();
|
||||
add_volatile_test_7();
|
||||
add_volatile_test_10();
|
||||
add_volatile_test_11();
|
||||
add_volatile_test_5();
|
||||
add_volatile_test_6();
|
||||
add_volatile_test_8();
|
||||
add_volatile_test_9();
|
||||
add_volatile_test_12();
|
||||
add_volatile_test_13();
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
add_volatile_test_6a();
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
126
test/alignment_of_a2_test.cpp
Normal file
126
test/alignment_of_a2_test.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(2)
|
||||
#endif
|
||||
|
||||
// (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>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Need to defined some member functions for empty_UDT,
|
||||
// we don't want to put these in the test.hpp as that
|
||||
// causes overly-clever compilers to figure out that they can't throw
|
||||
// which in turn breaks other tests.
|
||||
//
|
||||
empty_UDT::empty_UDT(){}
|
||||
empty_UDT::~empty_UDT(){}
|
||||
empty_UDT::empty_UDT(const empty_UDT&){}
|
||||
empty_UDT& empty_UDT::operator=(const empty_UDT&){ return *this; }
|
||||
bool empty_UDT::operator==(const empty_UDT&)const{ return true; }
|
||||
|
||||
|
||||
//
|
||||
// VC++ emits an awful lot of warnings unless we define these:
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable:4244 4121)
|
||||
//
|
||||
// What follows here is the test case for issue 1946.
|
||||
//
|
||||
#include <boost/function.hpp>
|
||||
// This kind of packing is set within MSVC 9.0 headers.
|
||||
// E.g. std::ostream has it.
|
||||
#pragma pack(push,8)
|
||||
|
||||
// The issue is gone if Root has no data members
|
||||
struct Root { int a; };
|
||||
// The issue is gone if Root is inherited non-virtually
|
||||
struct A : virtual public Root {};
|
||||
|
||||
#pragma pack(pop)
|
||||
//
|
||||
// This class has 8-byte alignment but is 44 bytes in size, which means
|
||||
// that elements in an array of this type will not actually be 8 byte
|
||||
// aligned. This appears to be an MSVC bug, and throws off our
|
||||
// alignment calculations: causing us to report a non-sensical 12-byte
|
||||
// alignment for this type. This is fixed by using the native __alignof
|
||||
// operator.
|
||||
//
|
||||
class issue1946 :
|
||||
public A
|
||||
{
|
||||
public:
|
||||
// The issue is gone if the type is not a boost::function. The signature doesn't matter.
|
||||
typedef boost::function0< void > function_type;
|
||||
function_type m_function;
|
||||
};
|
||||
|
||||
#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(alignment_of)
|
||||
|
||||
#ifndef TEST_STD
|
||||
// This test is not required to work for non-boost implementations:
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<void>::value, 0);
|
||||
#endif
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<char>::value, ALIGNOF(char));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<short>::value, ALIGNOF(short));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<int>::value, ALIGNOF(int));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<long>::value, ALIGNOF(long));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<float>::value, ALIGNOF(float));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<double>::value, ALIGNOF(double));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<long double>::value, ALIGNOF(long double));
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of< ::boost::long_long_type>::value, ALIGNOF(::boost::long_long_type));
|
||||
#endif
|
||||
#ifdef BOOST_HAS_MS_INT64
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<__int64>::value, ALIGNOF(__int64));
|
||||
#endif
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<int[4]>::value, ALIGNOF(int[4]));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<int(*)(int)>::value, ALIGNOF(int(*)(int)));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<int*>::value, ALIGNOF(int*));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<VB>::value, ALIGNOF(VB));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<VD>::value, ALIGNOF(VD));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<enum_UDT>::value, ALIGNOF(enum_UDT));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<mf2>::value, ALIGNOF(mf2));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<POD_UDT>::value, ALIGNOF(POD_UDT));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<empty_UDT>::value, ALIGNOF(empty_UDT));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<union_UDT>::value, ALIGNOF(union_UDT));
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<issue1946>::value, ALIGNOF(issue1946));
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
121
test/alignment_of_test.cpp
Normal file
121
test/alignment_of_test.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
|
||||
// (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>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Need to defined some member function for empty_UDT,
|
||||
// we don't want to put these in the test.hpp as that
|
||||
// causes overly-clever compilers to figure out that they can't throw
|
||||
// which in turn breaks other tests.
|
||||
//
|
||||
empty_UDT::empty_UDT(){}
|
||||
empty_UDT::~empty_UDT(){}
|
||||
empty_UDT::empty_UDT(const empty_UDT&){}
|
||||
empty_UDT& empty_UDT::operator=(const empty_UDT&){ return *this; }
|
||||
bool empty_UDT::operator==(const empty_UDT&)const{ return true; }
|
||||
|
||||
//
|
||||
// VC++ emits an awful lot of warnings unless we define these:
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable:4244)
|
||||
//
|
||||
// What follows here is the test case for issue 1946.
|
||||
//
|
||||
#include <boost/function.hpp>
|
||||
// This kind of packing is set within MSVC 9.0 headers.
|
||||
// E.g. std::ostream has it.
|
||||
#pragma pack(push,8)
|
||||
|
||||
// The issue is gone if Root has no data members
|
||||
struct Root { int a; };
|
||||
// The issue is gone if Root is inherited non-virtually
|
||||
struct A : virtual public Root {};
|
||||
|
||||
#pragma pack(pop)
|
||||
//
|
||||
// This class has 8-byte alignment but is 44 bytes in size, which means
|
||||
// that elements in an array of this type will not actually be 8 byte
|
||||
// aligned. This appears to be an MSVC bug, and throws off our
|
||||
// alignment calculations: causing us to report a non-sensical 12-byte
|
||||
// alignment for this type. This is fixed by using the native __alignof
|
||||
// operator.
|
||||
//
|
||||
class issue1946 :
|
||||
public A
|
||||
{
|
||||
public:
|
||||
// The issue is gone if the type is not a boost::function. The signature doesn't matter.
|
||||
typedef boost::function0< void > function_type;
|
||||
function_type m_function;
|
||||
};
|
||||
|
||||
#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(alignment_of)
|
||||
|
||||
#ifndef TEST_STD
|
||||
// This test is not required to work for non-boost implementations:
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<void>::value, 0);
|
||||
#endif
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<char>::value, ALIGNOF(char));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<short>::value, ALIGNOF(short));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<int>::value, ALIGNOF(int));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<long>::value, ALIGNOF(long));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<float>::value, ALIGNOF(float));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<double>::value, ALIGNOF(double));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<long double>::value, ALIGNOF(long double));
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of< ::boost::long_long_type>::value, ALIGNOF(::boost::long_long_type));
|
||||
#endif
|
||||
#ifdef BOOST_HAS_MS_INT64
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<__int64>::value, ALIGNOF(__int64));
|
||||
#endif
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<int[4]>::value, ALIGNOF(int[4]));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<int(*)(int)>::value, ALIGNOF(int(*)(int)));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<int*>::value, ALIGNOF(int*));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<VB>::value, ALIGNOF(VB));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<VD>::value, ALIGNOF(VD));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<enum_UDT>::value, ALIGNOF(enum_UDT));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<mf2>::value, ALIGNOF(mf2));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<POD_UDT>::value, ALIGNOF(POD_UDT));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<empty_UDT>::value, ALIGNOF(empty_UDT));
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<union_UDT>::value, ALIGNOF(union_UDT));
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of<issue1946>::value, ALIGNOF(issue1946));
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
176
test/has_trivial_destructor_test.cpp
Normal file
176
test/has_trivial_destructor_test.cpp
Normal file
@ -0,0 +1,176 @@
|
||||
|
||||
// (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/has_trivial_destructor.hpp>
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(has_trivial_destructor)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<bool>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<bool const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<bool volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<bool const volatile>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<signed char>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<signed char const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<signed char volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<signed char const volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned char>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<char>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned char const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<char const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned char volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<char volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned char const volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<char const volatile>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned short>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<short>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned short const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<short const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned short volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<short volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned short const volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<short const volatile>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned int>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<int>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned int const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<int const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned int volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<int volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned int const volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<int const volatile>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned long>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<long>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned long const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<long const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned long volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<long volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned long const volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<long const volatile>::value, true);
|
||||
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor< ::boost::ulong_long_type>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor< ::boost::long_long_type>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor< ::boost::ulong_long_type const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor< ::boost::long_long_type const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor< ::boost::ulong_long_type volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor< ::boost::long_long_type volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor< ::boost::ulong_long_type const volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor< ::boost::long_long_type const volatile>::value, true);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_HAS_MS_INT64
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int8>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int8>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int8 const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int8 const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int8 volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int8 volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int8 const volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int8 const volatile>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int16>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int16>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int16 const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int16 const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int16 volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int16 volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int16 const volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int16 const volatile>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int32>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int32>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int32 const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int32 const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int32 volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int32 volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int32 const volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int32 const volatile>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int64>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int64>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int64 const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int64 const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int64 volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int64 volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<unsigned __int64 const volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<__int64 const volatile>::value, true);
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<float>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<float const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<float volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<float const volatile>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<double>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<double const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<double volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<double const volatile>::value, true);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<long double>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<long double const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<long double volatile>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<long double const volatile>::value, true);
|
||||
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<int>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<void*>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<int*const>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<f1>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<f2>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<f3>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<mf1>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<mf2>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<mf3>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<mp>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<cmf>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<enum_UDT>::value, true);
|
||||
|
||||
//
|
||||
// These are commented out for now because it's not clear what the semantics should be:
|
||||
// on the one hand references always have trivial destructors (in the sense that there is
|
||||
// nothing to destruct), on the other hand the thing referenced may not have a trivial
|
||||
// destructor, it really depends upon the users code as to what should happen here:
|
||||
//
|
||||
//BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<int&>::value, false);
|
||||
//BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<const int&>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<int[2]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<int[3][2]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<int[2][4][5][6][3]>::value, true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<UDT>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<empty_UDT>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<void>::value, false);
|
||||
// cases we would like to succeed but can't implement in the language:
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<empty_POD_UDT>::value, true, false);
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<POD_UDT>::value, true, false);
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<POD_union_UDT>::value, true, false);
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<empty_POD_union_UDT>::value, true, false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<trivial_except_destroy>::value, false);
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<trivial_except_copy>::value, true, false);
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<trivial_except_construct>::value, true, false);
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<trivial_except_assign>::value, true, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<wrap<trivial_except_destroy> >::value, false);
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<wrap<trivial_except_copy> >::value, true, false);
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<wrap<trivial_except_construct> >::value, true, false);
|
||||
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<wrap<trivial_except_assign> >::value, true, false);
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "test.hpp"
|
||||
#include <boost/config.hpp>
|
||||
#include "check_integral_constant.hpp"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
|
Reference in New Issue
Block a user