Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:10

0001 #ifndef BOOST_TT_IS_ABSTRACT_CLASS_HPP
0002 #define BOOST_TT_IS_ABSTRACT_CLASS_HPP
0003 
0004 #if defined(_MSC_VER)
0005 # pragma once
0006 #endif
0007 
0008 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0009 // is_abstract_class.hpp:
0010 //
0011 //  (C) Copyright 2002 Rani Sharoni (rani_sharoni@hotmail.com) and Robert Ramey
0012 //  Use, modification and distribution is subject to the Boost Software
0013 //  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0014 //  http://www.boost.org/LICENSE_1_0.txt)
0015 //  
0016 //  See http://www.boost.org for updates, documentation, and revision history.
0017 //
0018 
0019 // Compile type discovery whether given type is abstract class or not.
0020 //
0021 //   Requires DR 337 to be supported by compiler
0022 //   (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#337).
0023 //
0024 //
0025 // Believed (Jan 2004) to work on:
0026 //  - GCC 3.4
0027 //  - VC++ 7.1
0028 //  - compilers with new EDG frontend (Intel C++ 7, Comeau 4.3.2)
0029 //
0030 // Doesn't work on:
0031 //  - VC++6, VC++7.0 and less
0032 //  - GCC 3.3.X and less
0033 //  - Borland C++ 6 and less
0034 //      
0035 //
0036 // History:
0037 //  - Originally written by Rani Sharoni, see
0038 //    http://groups.google.com/groups?selm=df893da6.0207110613.75b2fe90%40posting.google.com
0039 //    At this time supported by EDG (Intel C++ 7, Comeau 4.3.2) and VC7.1.
0040 //  - Adapted and added into Boost.Serialization library by Robert Ramey 
0041 //    (starting with submission #10).
0042 //  - Jan 2004: GCC 3.4 fixed to support DR337 (Giovanni Bajo).
0043 //  - Jan 2004: modified to be part of Boost.TypeTraits (Pavel Vozenilek).
0044 //  - Nov 2004: Christoph Ludwig found that the implementation did not work with
0045 //              template types and gcc-3.4 or VC7.1, fix due to Christoph Ludwig
0046 //              and John Maddock.
0047 //  - Dec 2004: Added new config macro BOOST_NO_IS_ABSTRACT which causes the template
0048 //              to degrade gracefully, rather than trash the compiler (John Maddock).
0049 //
0050 
0051 #include <cstddef> // size_t
0052 #include <boost/type_traits/intrinsics.hpp>
0053 #include <boost/type_traits/integral_constant.hpp>
0054 #ifndef BOOST_IS_ABSTRACT
0055 #include <boost/static_assert.hpp>
0056 #include <boost/type_traits/detail/yes_no_type.hpp>
0057 #include <boost/type_traits/is_class.hpp>
0058 #ifdef BOOST_NO_IS_ABSTRACT
0059 #include <boost/type_traits/is_polymorphic.hpp>
0060 #endif
0061 #endif
0062 
0063 namespace boost {
0064 
0065 namespace detail{
0066 
0067 #ifdef BOOST_IS_ABSTRACT
0068 template <class T>
0069 struct is_abstract_imp
0070 {
0071    BOOST_STATIC_CONSTANT(bool, value = BOOST_IS_ABSTRACT(T));
0072 };
0073 #elif !defined(BOOST_NO_IS_ABSTRACT)
0074 template<class T>
0075 struct is_abstract_imp2
0076 {
0077    // Deduction fails if T is void, function type, 
0078    // reference type (14.8.2/2)or an abstract class type 
0079    // according to review status issue #337
0080    //
0081    template<class U>
0082    static type_traits::no_type check_sig(U (*)[1]);
0083    template<class U>
0084    static type_traits::yes_type check_sig(...);
0085    //
0086    // T must be a complete type, further if T is a template then
0087    // it must be instantiated in order for us to get the right answer:
0088    //
0089    BOOST_STATIC_ASSERT(sizeof(T) != 0);
0090 
0091    // GCC2 won't even parse this template if we embed the computation
0092    // of s1 in the computation of value.
0093 #ifdef __GNUC__
0094    BOOST_STATIC_CONSTANT(std::size_t, s1 = sizeof(is_abstract_imp2<T>::template check_sig<T>(0)));
0095 #else
0096 #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
0097 #pragma warning(push)
0098 #pragma warning(disable:6334)
0099 #endif
0100    BOOST_STATIC_CONSTANT(std::size_t, s1 = sizeof(check_sig<T>(0)));
0101 #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
0102 #pragma warning(pop)
0103 #endif
0104 #endif
0105     
0106    BOOST_STATIC_CONSTANT(bool, value = 
0107       (s1 == sizeof(type_traits::yes_type)));
0108 };
0109 
0110 template <bool v>
0111 struct is_abstract_select
0112 {
0113    template <class T>
0114    struct rebind
0115    {
0116       typedef is_abstract_imp2<T> type;
0117    };
0118 };
0119 template <>
0120 struct is_abstract_select<false>
0121 {
0122    template <class T>
0123    struct rebind
0124    {
0125       typedef false_type type;
0126    };
0127 };
0128 
0129 template <class T>
0130 struct is_abstract_imp
0131 {
0132    typedef is_abstract_select< ::boost::is_class<T>::value> selector;
0133    typedef typename selector::template rebind<T> binder;
0134    typedef typename binder::type type;
0135 
0136    BOOST_STATIC_CONSTANT(bool, value = type::value);
0137 };
0138 
0139 #endif
0140 }
0141 
0142 #ifndef BOOST_NO_IS_ABSTRACT
0143 template <class T> struct is_abstract : public integral_constant<bool, ::boost::detail::is_abstract_imp<T>::value> {};
0144 #else
0145 template <class T> struct is_abstract : public integral_constant<bool, ::boost::detail::is_polymorphic_imp<T>::value> {};
0146 #endif
0147 
0148 } // namespace boost
0149 
0150 #endif //BOOST_TT_IS_ABSTRACT_CLASS_HPP