forked from boostorg/type_traits
Many fixes for MSVC6, esp. with ABCs
[SVN r13188]
This commit is contained in:
85
include/boost/type_traits/array_traits.hpp
Normal file
85
include/boost/type_traits/array_traits.hpp
Normal file
@ -0,0 +1,85 @@
|
||||
// (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
|
||||
// Hinnant & John Maddock 2000. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
//
|
||||
#ifndef BOOST_TT_ARRAY_TRAITS_HPP
|
||||
# define BOOST_TT_ARRAY_TRAITS_HPP
|
||||
# include <boost/type_traits/utility.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
/**********************************************
|
||||
*
|
||||
* is_array
|
||||
*
|
||||
**********************************************/
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template <typename T> struct is_array
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <typename T, std::size_t N> struct is_array<T[N]>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
template <typename T, std::size_t N> struct is_array<const T[N]>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
template <typename T, std::size_t N> struct is_array<volatile T[N]>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
template <typename T, std::size_t N> struct is_array<const volatile T[N]>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
namespace detail
|
||||
{
|
||||
using ::boost::type_traits::yes_type;
|
||||
using ::boost::type_traits::no_type;
|
||||
using ::boost::type_traits::wrap;
|
||||
|
||||
template <class T> T(* is_array_helper1(wrap<T>) )(wrap<T>);
|
||||
char is_array_helper1(...);
|
||||
|
||||
template <class T> no_type is_array_helper2(T(*)(wrap<T>));
|
||||
yes_type is_array_helper2(...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_array
|
||||
{
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, value = sizeof(
|
||||
::boost::detail::is_array_helper2(
|
||||
::boost::detail::is_array_helper1(
|
||||
::boost::type_traits::wrap<T>()))) == 1
|
||||
);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_array<void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
# ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
||||
template <>
|
||||
struct is_array<const void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
template <>
|
||||
struct is_array<volatile void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
template <>
|
||||
struct is_array<const volatile void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
# endif
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_ARRAY_TRAITS_HPP
|
@ -1,8 +1,9 @@
|
||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
||||
// Permission to copy, use, modify, sell and
|
||||
// distribute this software is granted provided this copyright notice appears
|
||||
// in all copies. This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
|
||||
// Hinnant & John Maddock 2000. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
//
|
||||
@ -27,43 +28,33 @@
|
||||
#define BOOST_COMPOSITE_TYPE_TRAITS_HPP
|
||||
|
||||
#ifndef BOOST_ICE_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/ice.hpp>
|
||||
# include <boost/type_traits/ice.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_FWD_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/fwd.hpp>
|
||||
# include <boost/type_traits/fwd.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_CONVERSION_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/conversion_traits.hpp>
|
||||
# include <boost/type_traits/conversion_traits.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_CV_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/cv_traits.hpp>
|
||||
# include <boost/type_traits/cv_traits.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/arithmetic_traits.hpp>
|
||||
# include <boost/type_traits/arithmetic_traits.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_TRANSFORM_TRAITS_HPP
|
||||
#include <boost/type_traits/transform_traits.hpp>
|
||||
# include <boost/type_traits/transform_traits.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_TT_REFERENCE_TRAITS_HPP
|
||||
# include <boost/type_traits/reference_traits.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_TT_ARRAY_TRAITS_HPP
|
||||
# include <boost/type_traits/array_traits.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
/**********************************************
|
||||
*
|
||||
* is_array
|
||||
*
|
||||
**********************************************/
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template <typename T> struct is_array
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <typename T, std::size_t N> struct is_array<T[N]>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
template <typename T, std::size_t N> struct is_array<const T[N]>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
template <typename T, std::size_t N> struct is_array<volatile T[N]>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
template <typename T, std::size_t N> struct is_array<const volatile T[N]>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
namespace detail{
|
||||
|
||||
struct pointer_helper
|
||||
@ -137,55 +128,21 @@ template <class R, class A0, class A1, class A2, class A3, class A4, class A5, c
|
||||
template <class R, class A0, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14, class A15, class A16, class A17, class A18, class A19, class A20, class A21, class A22, class A23, class A24, class A25, class A26, class A27, class A28, class A29>
|
||||
::boost::type_traits::yes_type is_function_tester(R (*)(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29));
|
||||
} // namespace detail
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <class T> struct wrap {};
|
||||
|
||||
template <class T> T(* is_array_helper1(wrap<T>) )(wrap<T>);
|
||||
char is_array_helper1(...);
|
||||
|
||||
template <class T> no_type is_array_helper2(T(*)(wrap<T>));
|
||||
yes_type is_array_helper2(...);
|
||||
// Utility metafunction which returns true if its argument is not an
|
||||
// array and not a reference.
|
||||
template <class T>
|
||||
struct neither_array_nor_reference : ::boost::type_traits::ice_not<
|
||||
::boost::type_traits::ice_or<
|
||||
::boost::is_reference<T>::value
|
||||
, ::boost::is_array<T>::value
|
||||
>::value>
|
||||
{};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_array
|
||||
{
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, value = sizeof(
|
||||
::boost::detail::is_array_helper2(
|
||||
::boost::detail::is_array_helper1(
|
||||
::boost::detail::wrap<T>()))) == 1
|
||||
);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_array<void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
||||
template <>
|
||||
struct is_array<const void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
template <>
|
||||
struct is_array<volatile void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
template <>
|
||||
struct is_array<const volatile void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
/**********************************************
|
||||
*
|
||||
* is_pointer
|
||||
@ -207,26 +164,37 @@ template <typename T> struct is_pointer_helper<T*const volatile>
|
||||
template <typename T> struct is_pointer
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_and< ::boost::detail::is_pointer_helper<T>::value, ::boost::type_traits::ice_not< ::boost::is_member_pointer<T>::value >::value >::value)); };
|
||||
#else
|
||||
template <typename T>
|
||||
struct is_pointer
|
||||
{
|
||||
private:
|
||||
static T t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(::boost::type_traits::ice_and<
|
||||
::boost::type_traits::ice_not<
|
||||
::boost::is_reference<T>::value
|
||||
>::value,
|
||||
::boost::type_traits::ice_not<
|
||||
::boost::is_array<T>::value
|
||||
>::value,
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// is_pointer implementation
|
||||
template <bool maybe = false>
|
||||
struct is_pointer_select : ::boost::type_traits::false_unary_metafunction
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_pointer_select<true>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
static T& make_t();
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(::boost::type_traits::ice_or<
|
||||
(1 == sizeof(detail::is_pointer_helper(t))),
|
||||
(1 == sizeof(detail::is_function_tester(t)))
|
||||
>::value)
|
||||
>::value ) );
|
||||
};
|
||||
(1 == sizeof(is_pointer_helper(make_t()))),
|
||||
(1 == sizeof(is_function_tester(make_t())))
|
||||
>::value));
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_pointer : ::boost::detail::is_pointer_select<
|
||||
::boost::detail::neither_array_nor_reference<T>::value
|
||||
>::template apply<T>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct is_pointer <void>
|
||||
{
|
||||
@ -251,71 +219,6 @@ struct is_pointer <const volatile void>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**********************************************
|
||||
*
|
||||
* is_reference
|
||||
*
|
||||
**********************************************/
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template <typename T> struct is_reference
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <typename T> struct is_reference<T&>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
#if defined(__BORLANDC__)
|
||||
// these are illegal specialisations; cv-qualifies applied to
|
||||
// references have no effect according to [8.3.2p1],
|
||||
// C++ Builder requires them though as it treats cv-qualified
|
||||
// references as distinct types...
|
||||
template <typename T> struct is_reference<T&const>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
template <typename T> struct is_reference<T&volatile>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
template <typename T> struct is_reference<T&const volatile>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
#endif
|
||||
#else
|
||||
# ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4181)
|
||||
#endif // BOOST_MSVC
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <class T> T&(* is_reference_helper1(wrap<T>) )(wrap<T>);
|
||||
char is_reference_helper1(...);
|
||||
|
||||
template <class T> no_type is_reference_helper2(T&(*)(wrap<T>));
|
||||
yes_type is_reference_helper2(...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_reference
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, value = sizeof(
|
||||
::boost::detail::is_reference_helper2(
|
||||
::boost::detail::is_reference_helper1(::boost::detail::wrap<T>()))) == 1
|
||||
);
|
||||
};
|
||||
|
||||
template <> struct is_reference<void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
||||
template <> struct is_reference<const void>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <> struct is_reference<volatile void>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <> struct is_reference<const volatile void>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
#endif
|
||||
|
||||
# ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
# endif // BOOST_MSVC
|
||||
#endif
|
||||
|
||||
/**********************************************
|
||||
*
|
||||
* is_union
|
||||
@ -936,14 +839,35 @@ template <class R, class T>
|
||||
::boost::type_traits::no_type BOOST_TT_DECL is_member_pointer_helper(...);
|
||||
|
||||
}
|
||||
template <typename T>
|
||||
struct is_member_function_pointer
|
||||
|
||||
namespace detail
|
||||
{
|
||||
private:
|
||||
static T t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value = (1 == sizeof(detail::is_member_function_pointer_helper(t))) );
|
||||
};
|
||||
template <bool maybe = false>
|
||||
struct is_member_function_pointer_select
|
||||
: ::boost::type_traits::false_unary_metafunction
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_member_function_pointer_select<true>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
static T& make_t();
|
||||
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, value = (1 == sizeof(detail::is_member_function_pointer_helper(make_t()))) );
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_member_function_pointer : ::boost::detail::is_member_function_pointer_select<
|
||||
::boost::detail::neither_array_nor_reference<T>::value
|
||||
>::template apply<T>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct is_member_function_pointer<void>
|
||||
{
|
||||
@ -972,16 +896,37 @@ template <typename T> struct is_member_pointer
|
||||
template <typename T, typename U> struct is_member_pointer<U T::*>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
#else
|
||||
template <typename T>
|
||||
struct is_member_pointer
|
||||
|
||||
namespace detail
|
||||
{
|
||||
private:
|
||||
static T t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(1 == sizeof(detail::is_member_function_pointer_helper(t)))
|
||||
|| (1 == sizeof(detail::is_member_pointer_helper(t))) );
|
||||
};
|
||||
template <bool maybe = false>
|
||||
struct is_member_pointer_select
|
||||
: ::boost::type_traits::false_unary_metafunction
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_member_pointer_select<true>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
static T& make_t();
|
||||
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, value = (
|
||||
1 == sizeof(detail::is_member_function_pointer_helper(make_t())))
|
||||
|| (1 == sizeof(detail::is_member_pointer_helper(make_t()))) );
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_member_pointer : ::boost::detail::is_member_pointer_select<
|
||||
::boost::detail::neither_array_nor_reference<T>::value
|
||||
>::template apply<T>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct is_member_pointer<void>
|
||||
{
|
||||
|
@ -1,8 +1,9 @@
|
||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
||||
// Permission to copy, use, modify, sell and
|
||||
// distribute this software is granted provided this copyright notice appears
|
||||
// in all copies. This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
// (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
|
||||
// Hinnant & John Maddock 2000. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
//
|
||||
@ -22,6 +23,15 @@
|
||||
#ifndef BOOST_FWD_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/fwd.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_TT_REFERENCE_TRAITS_HPP
|
||||
# include <boost/type_traits/reference_traits.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_TT_ARRAY_TRAITS_HPP
|
||||
# include <boost/type_traits/array_traits.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_TT_UTILITY_HPP
|
||||
# include <boost/type_traits/utility.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
@ -179,13 +189,47 @@ namespace detail{
|
||||
no_type is_volatile_helper(const void *);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <bool is_ref = true, bool array>
|
||||
struct is_const_impl
|
||||
: ::boost::type_traits::false_unary_metafunction
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct is_const_impl<false,false>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value = (sizeof(detail::yes_type) == sizeof(detail::is_const_helper(t))));
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_const_impl<false,true>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
private:
|
||||
static T t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value = (sizeof(detail::yes_type) == sizeof(detail::is_const_helper(&t))));
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_const
|
||||
: ::boost::detail::is_const_impl<
|
||||
is_reference<T>::value
|
||||
, is_array<T>::value
|
||||
>::template apply<T>
|
||||
{
|
||||
private:
|
||||
static T t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value = (sizeof(detail::yes_type) == sizeof(detail::is_const_helper(&t))));
|
||||
};
|
||||
|
||||
template <>
|
||||
@ -211,15 +255,50 @@ struct is_const<const volatile void>
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <bool is_ref = true, bool array>
|
||||
struct is_volatile_impl
|
||||
: ::boost::type_traits::false_unary_metafunction
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct is_volatile_impl<false,false>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value = (sizeof(detail::yes_type) == sizeof(detail::is_volatile_helper(t))));
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_volatile_impl<false,true>
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
private:
|
||||
static T t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value = (sizeof(detail::yes_type) == sizeof(detail::is_volatile_helper(&t))));
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_volatile
|
||||
{
|
||||
private:
|
||||
static T t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value = (sizeof(detail::yes_type) == sizeof(detail::is_volatile_helper(&t))));
|
||||
: ::boost::detail::is_volatile_impl<
|
||||
is_reference<T>::value
|
||||
, is_array<T>::value
|
||||
>::template apply<T>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct is_volatile<void>
|
||||
{
|
||||
|
90
include/boost/type_traits/reference_traits.hpp
Normal file
90
include/boost/type_traits/reference_traits.hpp
Normal file
@ -0,0 +1,90 @@
|
||||
// (C) Copyright David Abrahams Steve Cleary, Beman Dawes, Howard
|
||||
// Hinnant & John Maddock 2000-2002. Permission to copy, use,
|
||||
// modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
//
|
||||
#ifndef BOOST_TT_REFERENCE_TRAITS_HPP
|
||||
# define BOOST_TT_REFERENCE_TRAITS_HPP
|
||||
|
||||
# ifndef BOOST_TT_UTILITY_HPP
|
||||
# include <boost/type_traits/utility.hpp>
|
||||
# endif // BOOST_TT_UTILITY_HPP
|
||||
|
||||
namespace boost {
|
||||
|
||||
/**********************************************
|
||||
*
|
||||
* is_reference
|
||||
*
|
||||
**********************************************/
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template <typename T> struct is_reference
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <typename T> struct is_reference<T&>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
#if defined(__BORLANDC__)
|
||||
// these are illegal specialisations; cv-qualifies applied to
|
||||
// references have no effect according to [8.3.2p1],
|
||||
// C++ Builder requires them though as it treats cv-qualified
|
||||
// references as distinct types...
|
||||
template <typename T> struct is_reference<T&const>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
template <typename T> struct is_reference<T&volatile>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
template <typename T> struct is_reference<T&const volatile>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = true); };
|
||||
#endif
|
||||
#else
|
||||
# ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4181)
|
||||
#endif // BOOST_MSVC
|
||||
|
||||
namespace detail
|
||||
{
|
||||
using ::boost::type_traits::yes_type;
|
||||
using ::boost::type_traits::no_type;
|
||||
using ::boost::type_traits::wrap;
|
||||
|
||||
template <class T> T&(* is_reference_helper1(wrap<T>) )(wrap<T>);
|
||||
char is_reference_helper1(...);
|
||||
|
||||
template <class T> no_type is_reference_helper2(T&(*)(wrap<T>));
|
||||
yes_type is_reference_helper2(...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct is_reference
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, value = sizeof(
|
||||
::boost::detail::is_reference_helper2(
|
||||
::boost::detail::is_reference_helper1(::boost::type_traits::wrap<T>()))) == 1
|
||||
);
|
||||
};
|
||||
|
||||
template <> struct is_reference<void>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
||||
template <> struct is_reference<const void>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <> struct is_reference<volatile void>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <> struct is_reference<const volatile void>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
#endif
|
||||
|
||||
# ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
# endif // BOOST_MSVC
|
||||
#endif
|
||||
|
||||
} // namespace boost::type_traits
|
||||
|
||||
#endif // BOOST_TT_REFERENCE_TRAITS_HPP
|
24
include/boost/type_traits/utility.hpp
Normal file
24
include/boost/type_traits/utility.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright David Abrahams 2002. Permission to copy, use,
|
||||
// modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
#ifndef BOOST_TT_UTILITY_HPP
|
||||
# define BOOST_TT_UTILITY_HPP
|
||||
|
||||
namespace boost { namespace type_traits
|
||||
{
|
||||
// Utility metafunction class which always returns false
|
||||
struct false_unary_metafunction
|
||||
{
|
||||
template <class T>
|
||||
struct apply
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
};
|
||||
|
||||
template <class T> struct wrap {};
|
||||
}} // namespace boost::type_traits
|
||||
|
||||
#endif // BOOST_TT_UTILITY_HPP
|
@ -79,9 +79,7 @@ int cpp_main(int argc, char* argv[])
|
||||
value_test(false, boost::is_pointer<mf2>::value)
|
||||
value_test(false, boost::is_pointer<mf3>::value)
|
||||
value_test(false, boost::is_pointer<mf4>::value)
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
value_test(false, boost::is_pointer<test_abc1>::value)
|
||||
#endif
|
||||
|
||||
value_test(false, boost::is_reference<bool>::value)
|
||||
value_test(true, boost::is_reference<int&>::value)
|
||||
@ -105,9 +103,7 @@ int cpp_main(int argc, char* argv[])
|
||||
value_test(true, boost::is_member_pointer<cmf>::value)
|
||||
value_test(true, boost::is_member_pointer<mp>::value)
|
||||
value_test(false, boost::is_member_pointer<void>::value)
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
value_test(false, boost::is_member_pointer<test_abc1>::value)
|
||||
#endif
|
||||
|
||||
value_test(false, boost::is_member_function_pointer<f1>::value)
|
||||
value_test(false, boost::is_member_function_pointer<f2>::value)
|
||||
@ -120,9 +116,7 @@ int cpp_main(int argc, char* argv[])
|
||||
value_test(true, boost::is_member_function_pointer<cmf>::value)
|
||||
value_test(false, boost::is_member_function_pointer<mp>::value)
|
||||
value_test(false, boost::is_member_function_pointer<void>::value)
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__BORLANDC__)
|
||||
value_test(false, boost::is_member_function_pointer<test_abc1>::value)
|
||||
#endif
|
||||
|
||||
value_test(false, boost::is_enum<int>::value)
|
||||
value_test(true, boost::is_enum<enum_UDT>::value)
|
||||
|
@ -27,10 +27,8 @@ int cpp_main(int argc, char* argv[])
|
||||
|
||||
value_test(false, boost::is_const<void>::value)
|
||||
value_test(true, boost::is_const<const void>::value)
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC)
|
||||
value_test(false, boost::is_const<test_abc1>::value)
|
||||
value_test(true, boost::is_const<const test_abc1>::value)
|
||||
#endif
|
||||
value_test(false, boost::is_const<int>::value)
|
||||
value_test(true, boost::is_const<const int>::value)
|
||||
value_test(true, boost::is_const<const UDT>::value)
|
||||
@ -45,10 +43,8 @@ int cpp_main(int argc, char* argv[])
|
||||
|
||||
value_test(false, boost::is_volatile<void>::value)
|
||||
value_test(true, boost::is_volatile<volatile void>::value)
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC)
|
||||
value_test(false, boost::is_volatile<test_abc1>::value)
|
||||
value_test(true, boost::is_volatile<volatile test_abc1>::value)
|
||||
#endif
|
||||
value_test(false, boost::is_volatile<int>::value)
|
||||
value_test(true, boost::is_volatile<volatile int>::value)
|
||||
value_test(true, boost::is_volatile<volatile UDT>::value)
|
||||
@ -60,7 +56,7 @@ int cpp_main(int argc, char* argv[])
|
||||
//
|
||||
// define the number of failures expected for given compilers:
|
||||
#ifdef BOOST_MSVC
|
||||
unsigned int expected_failures = 3;
|
||||
unsigned int expected_failures = 2;
|
||||
#elif defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x530)
|
||||
unsigned int expected_failures = 1;
|
||||
#else
|
||||
|
@ -365,14 +365,12 @@ BOOST_DECL_TRANSFORM_TEST(add_const_test_3, ::boost::add_const, *, *const)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_const_test_7, ::boost::add_const, *volatile, *volatile const)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_const_test_10, ::boost::add_const, const*, const*const)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_const_test_11, ::boost::add_const, volatile*, volatile*const)
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
BOOST_DECL_TRANSFORM_TEST(add_const_test_5, ::boost::add_const, const &, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_const_test_6, ::boost::add_const, &, &)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_const_test_8, ::boost::add_const, const [2], const [2])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_const_test_9, ::boost::add_const, volatile &, volatile&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_const_test_12, ::boost::add_const, [2][3], const[2][3])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_const_test_13, ::boost::add_const, (&)[2], (&)[2])
|
||||
#endif
|
||||
|
||||
void check_add_const()
|
||||
{
|
||||
@ -383,14 +381,12 @@ void check_add_const()
|
||||
add_const_test_7();
|
||||
add_const_test_10();
|
||||
add_const_test_11();
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
add_const_test_5();
|
||||
add_const_test_6();
|
||||
add_const_test_8();
|
||||
add_const_test_9();
|
||||
add_const_test_12();
|
||||
add_const_test_13();
|
||||
#endif
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
@ -406,14 +402,12 @@ BOOST_DECL_TRANSFORM_TEST(add_volatile_test_3, ::boost::add_volatile, *, *volati
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_7, ::boost::add_volatile, *volatile, *volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_10, ::boost::add_volatile, const*, const*volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_11, ::boost::add_volatile, volatile*, volatile*volatile)
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_5, ::boost::add_volatile, const &, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_6, ::boost::add_volatile, &, &)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_8, ::boost::add_volatile, const [2], const volatile [2])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_9, ::boost::add_volatile, volatile &, volatile&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_12, ::boost::add_volatile, [2][3], volatile[2][3])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_volatile_test_13, ::boost::add_volatile, (&)[2], (&)[2])
|
||||
#endif
|
||||
|
||||
void check_add_volatile()
|
||||
{
|
||||
@ -424,14 +418,12 @@ void check_add_volatile()
|
||||
add_volatile_test_7();
|
||||
add_volatile_test_10();
|
||||
add_volatile_test_11();
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
add_volatile_test_5();
|
||||
add_volatile_test_6();
|
||||
add_volatile_test_8();
|
||||
add_volatile_test_9();
|
||||
add_volatile_test_12();
|
||||
add_volatile_test_13();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -464,21 +456,21 @@ int cpp_main(int argc, char* argv[])
|
||||
//
|
||||
// define the number of failures expected for given compilers:
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef SHORT_TRANSFORM_TEST
|
||||
# ifdef SHORT_TRANSFORM_TEST
|
||||
unsigned int expected_failures = 97; // cv-qualifiers
|
||||
#else
|
||||
# else
|
||||
unsigned int expected_failures = 474; // cv-qualifiers
|
||||
#endif
|
||||
# endif
|
||||
#elif defined(BOOST_MSVC)
|
||||
unsigned int expected_failures = 84; // partial specialisation (fails for UDT's)
|
||||
#elif defined(__SUNPRO_CC)
|
||||
unsigned int expected_failures = 1; // cv-qualified references
|
||||
#elif defined(__GNUC__)
|
||||
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
||||
# if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
||||
unsigned int expected_failures = 0;
|
||||
#else
|
||||
# else
|
||||
unsigned int expected_failures = 1; // cv-qualified references
|
||||
#endif
|
||||
# endif
|
||||
#elif defined(__HP_aCC)
|
||||
unsigned int expected_failures = 272; // remove_const/remove_volatile/remove_cv don't work
|
||||
#elif defined(__EDG_VERSION__) && __EDG_VERSION__ < 238
|
||||
|
Reference in New Issue
Block a user