mirror of
https://github.com/boostorg/type_traits.git
synced 2025-07-31 13:07:22 +02:00
is_virtual_base_of.hpp: Reinstate old version for old broken compilers.
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
#define BOOST_TT_IS_VIRTUAL_BASE_OF_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
@ -22,6 +23,8 @@ namespace detail {
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) && !defined(BOOST_NO_CXX11_NULLPTR)
|
||||
|
||||
template<class Base, class Derived>
|
||||
struct is_virtual_base_of_impl
|
||||
{
|
||||
@ -60,6 +63,84 @@ struct is_virtual_base_of_impl
|
||||
|
||||
template <class Base, class Derived> struct is_virtual_base_of : public integral_constant<bool, (::boost::detail::is_virtual_base_of_impl<Base, Derived>::value)>{};
|
||||
|
||||
#else
|
||||
|
||||
template<typename Base, typename Derived, typename tag>
|
||||
struct is_virtual_base_of_impl
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
template<typename Base, typename Derived>
|
||||
struct is_virtual_base_of_impl<Base, Derived, true_type>
|
||||
{
|
||||
union max_align
|
||||
{
|
||||
unsigned u;
|
||||
unsigned long ul;
|
||||
void* v;
|
||||
double d;
|
||||
long double ld;
|
||||
#ifndef BOOST_NO_LONG_LONG
|
||||
long long ll;
|
||||
#endif
|
||||
};
|
||||
#ifdef __BORLANDC__
|
||||
struct boost_type_traits_internal_struct_X : public virtual Derived, public virtual Base
|
||||
{
|
||||
boost_type_traits_internal_struct_X();
|
||||
boost_type_traits_internal_struct_X(const boost_type_traits_internal_struct_X&);
|
||||
boost_type_traits_internal_struct_X& operator=(const boost_type_traits_internal_struct_X&);
|
||||
~boost_type_traits_internal_struct_X()throw();
|
||||
max_align data[4];
|
||||
};
|
||||
struct boost_type_traits_internal_struct_Y : public virtual Derived
|
||||
{
|
||||
boost_type_traits_internal_struct_Y();
|
||||
boost_type_traits_internal_struct_Y(const boost_type_traits_internal_struct_Y&);
|
||||
boost_type_traits_internal_struct_Y& operator=(const boost_type_traits_internal_struct_Y&);
|
||||
~boost_type_traits_internal_struct_Y()throw();
|
||||
max_align data[4];
|
||||
};
|
||||
#else
|
||||
struct boost_type_traits_internal_struct_X : public Derived, virtual Base
|
||||
{
|
||||
boost_type_traits_internal_struct_X();
|
||||
boost_type_traits_internal_struct_X(const boost_type_traits_internal_struct_X&);
|
||||
boost_type_traits_internal_struct_X& operator=(const boost_type_traits_internal_struct_X&);
|
||||
~boost_type_traits_internal_struct_X()throw();
|
||||
max_align data[16];
|
||||
};
|
||||
struct boost_type_traits_internal_struct_Y : public Derived
|
||||
{
|
||||
boost_type_traits_internal_struct_Y();
|
||||
boost_type_traits_internal_struct_Y(const boost_type_traits_internal_struct_Y&);
|
||||
boost_type_traits_internal_struct_Y& operator=(const boost_type_traits_internal_struct_Y&);
|
||||
~boost_type_traits_internal_struct_Y()throw();
|
||||
max_align data[16];
|
||||
};
|
||||
#endif
|
||||
BOOST_STATIC_CONSTANT(bool, value = (sizeof(boost_type_traits_internal_struct_X) == sizeof(boost_type_traits_internal_struct_Y)));
|
||||
};
|
||||
|
||||
template<typename Base, typename Derived>
|
||||
struct is_virtual_base_of_impl2
|
||||
{
|
||||
typedef boost::integral_constant<bool, (boost::is_base_of<Base, Derived>::value && !boost::is_same<Base, Derived>::value)> tag_type;
|
||||
typedef is_virtual_base_of_impl<Base, Derived, tag_type> imp;
|
||||
BOOST_STATIC_CONSTANT(bool, value = imp::value);
|
||||
};
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <class Base, class Derived> struct is_virtual_base_of : public integral_constant<bool, (::boost::detail::is_virtual_base_of_impl2<Base, Derived>::value)> {};
|
||||
|
||||
#endif
|
||||
|
||||
template <class Base, class Derived> struct is_virtual_base_of<Base&, Derived> : public false_type{};
|
||||
template <class Base, class Derived> struct is_virtual_base_of<Base, Derived&> : public false_type{};
|
||||
template <class Base, class Derived> struct is_virtual_base_of<Base&, Derived&> : public false_type{};
|
||||
|
Reference in New Issue
Block a user