Add some more traits back.

This commit is contained in:
jzmaddock committed 2015-01-17 13:35:26 +00:00
1 parent 1b1f90fdea
commit 6aa0878fb3
13 files changed
+1411

No files matched your search

@@ -0,0 +1,146 @@
// (C) Copyright Runar Undheim, Robert Ramey & John Maddock 2008.
// 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_NEW_OPERATOR_HPP_INCLUDED
#define BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
#include <new> // std::nothrow_t
#include <cstddef> // std::size_t
#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/detail/yes_no_type.hpp>
#if defined(new)
# if BOOST_WORKAROUND(BOOST_MSVC, >= 1310)
# define BOOST_TT_AUX_MACRO_NEW_DEFINED
# pragma push_macro("new")
# undef new
# else
# error "Sorry but you can't include this header if 'new' is defined as a macro."
# endif
#endif
namespace boost {
namespace detail {
template <class U, U x>
struct test;
template <typename T>
struct has_new_operator_impl {
template<class U>
static type_traits::yes_type check_sig1(
U*,
test<
void *(*)(std::size_t),
&U::operator new
>* = NULL
);
template<class U>
static type_traits::no_type check_sig1(...);
template<class U>
static type_traits::yes_type check_sig2(
U*,
test<
void *(*)(std::size_t, const std::nothrow_t&),
&U::operator new
>* = NULL
);
template<class U>
static type_traits::no_type check_sig2(...);
template<class U>
static type_traits::yes_type check_sig3(
U*,
test<
void *(*)(std::size_t, void*),
&U::operator new
>* = NULL
);
template<class U>
static type_traits::no_type check_sig3(...);
template<class U>
static type_traits::yes_type check_sig4(
U*,
test<
void *(*)(std::size_t),
&U::operator new[]
>* = NULL
);
template<class U>
static type_traits::no_type check_sig4(...);
template<class U>
static type_traits::yes_type check_sig5(
U*,
test<
void *(*)(std::size_t, const std::nothrow_t&),
&U::operator new[]
>* = NULL
);
template<class U>
static type_traits::no_type check_sig5(...);
template<class U>
static type_traits::yes_type check_sig6(
U*,
test<
void *(*)(std::size_t, void*),
&U::operator new[]
>* = NULL
);
template<class U>
static type_traits::no_type check_sig6(...);
// GCC2 won't even parse this template if we embed the computation
// of s1 in the computation of value.
#ifdef __GNUC__
BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(has_new_operator_impl<T>::template check_sig1<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(has_new_operator_impl<T>::template check_sig2<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s3 = sizeof(has_new_operator_impl<T>::template check_sig3<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s4 = sizeof(has_new_operator_impl<T>::template check_sig4<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s5 = sizeof(has_new_operator_impl<T>::template check_sig5<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s6 = sizeof(has_new_operator_impl<T>::template check_sig6<T>(0)));
#else
#if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
#pragma warning(push)
#pragma warning(disable:6334)
#endif
BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig1<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(check_sig2<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s3 = sizeof(check_sig3<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s4 = sizeof(check_sig4<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s5 = sizeof(check_sig5<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s6 = sizeof(check_sig6<T>(0)));
#if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
#pragma warning(pop)
#endif
#endif
BOOST_STATIC_CONSTANT(bool, value =
(s1 == sizeof(type_traits::yes_type)) ||
(s2 == sizeof(type_traits::yes_type)) ||
(s3 == sizeof(type_traits::yes_type)) ||
(s4 == sizeof(type_traits::yes_type)) ||
(s5 == sizeof(type_traits::yes_type)) ||
(s6 == sizeof(type_traits::yes_type))
);
};
} // namespace detail
template <class T> struct has_new_operator : public integral_constant<bool, ::boost::detail::has_new_operator_impl<T>::value>{};
} // namespace boost
#if defined(BOOST_TT_AUX_MACRO_NEW_DEFINED)
# pragma pop_macro("new")
#endif
#endif // BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
@@ -0,0 +1,46 @@
// (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_CONSTRUCTOR_HPP_INCLUDED
#define BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED
#include <boost/type_traits/intrinsics.hpp>
#include <boost/type_traits/integral_constant.hpp>
#ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR
#if defined(BOOST_MSVC) || defined(BOOST_INTEL)
#include <boost/type_traits/has_trivial_constructor.hpp>
#endif
namespace boost {
template <class T> struct has_nothrow_constructor : public integral_constant<bool, BOOST_HAS_NOTHROW_CONSTRUCTOR(T)>{};
#else
#include <boost/type_traits/has_trivial_constructor.hpp>
namespace boost {
template <class T> struct has_nothrow_constructor : public ::boost::has_trivial_constructor<T> {};
#endif
template<> struct has_nothrow_constructor<void> : public false_type {};
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
template<> struct has_nothrow_constructor<void const> : public false_type{};
template<> struct has_nothrow_constructor<void const volatile> : public false_type{};
template<> struct has_nothrow_constructor<void volatile> : public false_type{};
#endif
template <class T> struct has_nothrow_default_constructor : public has_nothrow_constructor<T>{};
} // namespace boost
#endif // BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED
@@ -0,0 +1,39 @@
// (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_CONSTRUCTOR_HPP_INCLUDED
#define BOOST_TT_HAS_TRIVIAL_CONSTRUCTOR_HPP_INCLUDED
#include <boost/type_traits/intrinsics.hpp>
#include <boost/type_traits/is_pod.hpp>
#ifdef BOOST_HAS_TRIVIAL_CONSTRUCTOR
#ifdef BOOST_HAS_SGI_TYPE_TRAITS
#include <boost/type_traits/is_same.hpp>
#elif defined(__GNUC__)
#include <boost/type_traits/is_volatile.hpp>
#ifdef BOOST_INTEL
#include <boost/type_traits/is_pod.hpp>
#endif
#endif
#endif
namespace boost {
template <typename T> struct has_trivial_constructor
#ifdef BOOST_HAS_TRIVIAL_CONSTRUCTOR
: public integral_constant <bool, (::boost::is_pod<T>::value || BOOST_HAS_TRIVIAL_CONSTRUCTOR(T))>{};
#else
: public integral_constant <bool, ::boost::is_pod<T>::value>{};
#endif
template <class T> struct has_trivial_default_constructor : public has_trivial_constructor<T> {};
} // namespace boost
#endif // BOOST_TT_HAS_TRIVIAL_CONSTRUCTOR_HPP_INCLUDED
@@ -0,0 +1,26 @@
// (C) Copyright John Maddock 2005.
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
//
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
#ifndef BOOST_TT_HAS_VIRTUAL_DESTRUCTOR_HPP_INCLUDED
#define BOOST_TT_HAS_VIRTUAL_DESTRUCTOR_HPP_INCLUDED
#include <boost/type_traits/intrinsics.hpp>
#include <boost/type_traits/integral_constant.hpp>
namespace boost {
#ifdef BOOST_HAS_VIRTUAL_DESTRUCTOR
template <class T> struct has_virtual_destructor : public integral_constant<bool, BOOST_HAS_VIRTUAL_DESTRUCTOR(T)>{};
#else
template <class T> struct has_virtual_destructor : public integral_constant<bool, false>{};
#endif
} // namespace boost
#endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED
+131
View File
@@ -0,0 +1,131 @@
// (C) Copyright John Maddock 2007.
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
//
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
#ifndef BOOST_TT_MAKE_SIGNED_HPP_INCLUDED
#define BOOST_TT_MAKE_SIGNED_HPP_INCLUDED
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/type_traits/is_unsigned.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_volatile.hpp>
#include <boost/static_assert.hpp>
namespace boost {
template <class T>
struct make_signed
{
private:
BOOST_STATIC_ASSERT_MSG(( ::boost::is_integral<T>::value || ::boost::is_enum<T>::value), "The template argument to make_signed must be an integer or enum type.");
BOOST_STATIC_ASSERT_MSG(!(::boost::is_same<typename remove_cv<T>::type, bool>::value), "The template argument to make_signed must not be the type bool.");
typedef typename remove_cv<T>::type t_no_cv;
typedef typename conditional<
(::boost::is_signed<T>::value
&& ::boost::is_integral<T>::value
&& ! ::boost::is_same<t_no_cv, char>::value
&& ! ::boost::is_same<t_no_cv, wchar_t>::value
&& ! ::boost::is_same<t_no_cv, bool>::value),
T,
typename conditional<
(::boost::is_integral<T>::value
&& ! ::boost::is_same<t_no_cv, char>::value
&& ! ::boost::is_same<t_no_cv, wchar_t>::value
&& ! ::boost::is_same<t_no_cv, bool>::value),
typename conditional<
is_same<t_no_cv, unsigned char>::value,
signed char,
typename conditional<
is_same<t_no_cv, unsigned short>::value,
signed short,
typename conditional<
is_same<t_no_cv, unsigned int>::value,
int,
typename conditional<
is_same<t_no_cv, unsigned long>::value,
long,
#if defined(BOOST_HAS_LONG_LONG)
#ifdef BOOST_HAS_INT128
typename conditional<
sizeof(t_no_cv) == sizeof(boost::long_long_type),
boost::long_long_type,
boost::int128_type
>::type
#else
boost::long_long_type
#endif
#elif defined(BOOST_HAS_MS_INT64)
__int64
#else
long
#endif
>::type
>::type
>::type
>::type,
// Not a regular integer type:
typename conditional<
sizeof(t_no_cv) == sizeof(unsigned char),
signed char,
typename conditional<
sizeof(t_no_cv) == sizeof(unsigned short),
signed short,
typename conditional<
sizeof(t_no_cv) == sizeof(unsigned int),
int,
typename conditional<
sizeof(t_no_cv) == sizeof(unsigned long),
long,
#if defined(BOOST_HAS_LONG_LONG)
#ifdef BOOST_HAS_INT128
typename conditional<
sizeof(t_no_cv) == sizeof(boost::long_long_type),
boost::long_long_type,
boost::int128_type
>::type
#else
boost::long_long_type
#endif
#elif defined(BOOST_HAS_MS_INT64)
__int64
#else
long
#endif
>::type
>::type
>::type
>::type
>::type
>::type base_integer_type;
// Add back any const qualifier:
typedef typename conditional<
is_const<T>::value,
typename add_const<base_integer_type>::type,
base_integer_type
>::type const_base_integer_type;
public:
// Add back any volatile qualifier:
typedef typename conditional<
is_volatile<T>::value,
typename add_volatile<const_base_integer_type>::type,
const_base_integer_type
>::type type;
};
} // namespace boost
#endif // BOOST_TT_ADD_REFERENCE_HPP_INCLUDED
+130
View File
@@ -0,0 +1,130 @@
// (C) Copyright John Maddock 2007.
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
//
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
#ifndef BOOST_TT_MAKE_UNSIGNED_HPP_INCLUDED
#define BOOST_TT_MAKE_UNSIGNED_HPP_INCLUDED
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/type_traits/is_unsigned.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_volatile.hpp>
#include <boost/static_assert.hpp>
namespace boost {
template <class T>
struct make_unsigned
{
private:
BOOST_STATIC_ASSERT_MSG((::boost::is_integral<T>::value || ::boost::is_enum<T>::value), "The template argument to make_unsigned must be an integer or enum type.");
BOOST_STATIC_ASSERT_MSG((! ::boost::is_same<typename remove_cv<T>::type, bool>::value), "The template argument to make_unsigned must not be the type bool");
typedef typename remove_cv<T>::type t_no_cv;
typedef typename conditional<
(::boost::is_unsigned<T>::value && ::boost::is_integral<T>::value
&& ! ::boost::is_same<t_no_cv, char>::value
&& ! ::boost::is_same<t_no_cv, wchar_t>::value
&& ! ::boost::is_same<t_no_cv, bool>::value),
T,
typename conditional<
(::boost::is_integral<T>::value
&& ! ::boost::is_same<t_no_cv, char>::value
&& ! ::boost::is_same<t_no_cv, wchar_t>::value
&& ! ::boost::is_same<t_no_cv, bool>::value),
typename conditional<
is_same<t_no_cv, signed char>::value,
unsigned char,
typename conditional<
is_same<t_no_cv, short>::value,
unsigned short,
typename conditional<
is_same<t_no_cv, int>::value,
unsigned int,
typename conditional<
is_same<t_no_cv, long>::value,
unsigned long,
#if defined(BOOST_HAS_LONG_LONG)
#ifdef BOOST_HAS_INT128
typename conditional<
sizeof(t_no_cv) == sizeof(boost::ulong_long_type),
boost::ulong_long_type,
boost::uint128_type
>::type
#else
boost::ulong_long_type
#endif
#elif defined(BOOST_HAS_MS_INT64)
unsigned __int64
#else
unsigned long
#endif
>::type
>::type
>::type
>::type,
// Not a regular integer type:
typename conditional<
sizeof(t_no_cv) == sizeof(unsigned char),
unsigned char,
typename conditional<
sizeof(t_no_cv) == sizeof(unsigned short),
unsigned short,
typename conditional<
sizeof(t_no_cv) == sizeof(unsigned int),
unsigned int,
typename conditional<
sizeof(t_no_cv) == sizeof(unsigned long),
unsigned long,
#if defined(BOOST_HAS_LONG_LONG)
#ifdef BOOST_HAS_INT128
typename conditional<
sizeof(t_no_cv) == sizeof(boost::ulong_long_type),
boost::ulong_long_type,
boost::uint128_type
>::type
#else
boost::ulong_long_type
#endif
#elif defined(BOOST_HAS_MS_INT64)
unsigned __int64
#else
unsigned long
#endif
>::type
>::type
>::type
>::type
>::type
>::type base_integer_type;
// Add back any const qualifier:
typedef typename conditional<
is_const<T>::value,
typename add_const<base_integer_type>::type,
base_integer_type
>::type const_base_integer_type;
public:
// Add back any volatile qualifier:
typedef typename conditional<
is_volatile<T>::value,
typename add_volatile<const_base_integer_type>::type,
const_base_integer_type
>::type type;
};
} // namespace boost
#endif // BOOST_TT_ADD_REFERENCE_HPP_INCLUDED
@@ -0,0 +1,33 @@
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
//
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
//
// defines object traits classes:
// is_object, is_scalar, is_class, is_compound, is_pod,
// has_trivial_constructor, has_trivial_copy, has_trivial_assign,
// has_trivial_destructor, is_empty.
//
#ifndef BOOST_TT_OBJECT_TRAITS_HPP_INLCUDED
#define BOOST_TT_OBJECT_TRAITS_HPP_INLCUDED
#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_nothrow_constructor.hpp>
#include <boost/type_traits/has_nothrow_copy.hpp>
#include <boost/type_traits/has_nothrow_assign.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_compound.hpp>
#include <boost/type_traits/is_empty.hpp>
#include <boost/type_traits/is_object.hpp>
#include <boost/type_traits/is_pod.hpp>
#include <boost/type_traits/is_scalar.hpp>
#include <boost/type_traits/is_stateless.hpp>
#endif // BOOST_TT_OBJECT_TRAITS_HPP_INLCUDED