epoc32/include/stdapis/boost/serialization/is_abstract.hpp
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 #ifndef BOOST_TT_IS_ABSTRACT_CLASS_HPP
     1 #ifndef BOOST_SERIALIZATION_IS_ABSTRACT_CLASS_HPP
     2 #define BOOST_TT_IS_ABSTRACT_CLASS_HPP
     2 #define BOOST_SERIALIZATION_IS_ABSTRACT_CLASS_HPP
     3 
     3 
       
     4 // MS compatible compilers support #pragma once
     4 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
     5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
     5 # pragma once
     6 # pragma once
     6 #endif
     7 #endif
     7 
     8 
     8 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
     9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
     9 // is_abstract_class.hpp:
    10 // is_abstract_class.hpp:
    10 //
    11 
    11 //  (C) Copyright 2002 Rani Sharoni (rani_sharoni@hotmail.com) and Robert Ramey
    12 // (C) Copyright 2002 Rani Sharoni (rani_sharoni@hotmail.com) and Robert Ramey
    12 //  Use, modification and distribution is subject to the Boost Software
    13 // Use, modification and distribution is subject to the Boost Software
    13 //  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    14 //  http://www.boost.org/LICENSE_1_0.txt)
    15 // http://www.boost.org/LICENSE_1_0.txt)
    15 //  
    16 
    16 //  See http://www.boost.org for updates, documentation, and revision history.
    17 //  See http://www.boost.org for updates, documentation, and revision history.
    17 //
       
    18 
    18 
    19 // Compile type discovery whether given type is abstract class or not.
    19 #include <boost/config.hpp>
    20 //
    20 #include <boost/mpl/bool.hpp>
    21 //   Requires DR 337 to be supported by compiler
    21 #include <boost/type_traits/is_abstract.hpp>
    22 //   (http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#337).
       
    23 //
       
    24 //
       
    25 // Believed (Jan 2004) to work on:
       
    26 //  - GCC 3.4
       
    27 //  - VC++ 7.1
       
    28 //  - compilers with new EDG frontend (Intel C++ 7, Comeau 4.3.2)
       
    29 //
       
    30 // Doesn't work on:
       
    31 //  - VC++6, VC++7.0 and less
       
    32 //  - GCC 3.3.X and less
       
    33 //  - Borland C++ 6 and less
       
    34 //      
       
    35 //
       
    36 // History:
       
    37 //  - Originally written by Rani Sharoni, see
       
    38 //    http://groups.google.com/groups?selm=df893da6.0207110613.75b2fe90%40posting.google.com
       
    39 //    At this time supported by EDG (Intel C++ 7, Comeau 4.3.2) and VC7.1.
       
    40 //  - Adapted and added into Boost.Serialization library by Robert Ramey 
       
    41 //    (starting with submission #10).
       
    42 //  - Jan 2004: GCC 3.4 fixed to suport DR337 (Giovanni Bajo).
       
    43 //  - Jan 2004: modified to be part of Boost.TypeTraits (Pavel Vozenilek).
       
    44 //  - Nov 2004: Christoph Ludwig found that the implementation did not work with
       
    45 //              template types and gcc-3.4 or VC7.1, fix due to Christoph Ludwig
       
    46 //              and John Maddock.
       
    47 //  - Dec 2004: Added new config macro BOOST_NO_IS_ABSTRACT which causes the template
       
    48 //              to degrade gracefully, rather than trash the compiler (John Maddock).
       
    49 //
       
    50 
       
    51 #include <boost/static_assert.hpp>
       
    52 #include <boost/type_traits/detail/yes_no_type.hpp>
       
    53 #include <boost/type_traits/is_class.hpp>
       
    54 #include <boost/type_traits/detail/ice_and.hpp>
       
    55 #ifdef BOOST_NO_IS_ABSTRACT
       
    56 #include <boost/type_traits/is_polymorphic.hpp>
       
    57 #endif
       
    58 // should be the last #include
       
    59 #include <boost/type_traits/detail/bool_trait_def.hpp>
       
    60 
       
    61 
    22 
    62 namespace boost {
    23 namespace boost {
    63 namespace detail{
    24 namespace serialization {
    64 
    25     template<class T>
    65 #ifndef BOOST_NO_IS_ABSTRACT
    26     struct is_abstract {
    66 template<class T>
    27         // default to false if not supported
    67 struct is_abstract_imp2
    28         #ifdef BOOST_NO_IS_ABSTRACT
    68 {
    29             typedef BOOST_DEDUCED_TYPENAME mpl::bool_<false> type;
    69    // Deduction fails if T is void, function type, 
    30             BOOST_STATIC_CONSTANT(bool, value = false); 
    70    // reference type (14.8.2/2)or an abstract class type 
    31         #else
    71    // according to review status issue #337
    32             typedef BOOST_DEDUCED_TYPENAME boost::is_abstract<T>::type type;
    72    //
    33             BOOST_STATIC_CONSTANT(bool, value = type::value); 
    73    template<class U>
    34         #endif
    74    static type_traits::no_type check_sig(U (*)[1]);
    35     };
    75    template<class U>
    36 } // namespace serialization
    76    static type_traits::yes_type check_sig(...);
       
    77    //
       
    78    // T must be a complete type, further if T is a template then
       
    79    // it must be instantiated in order for us to get the right answer:
       
    80    //
       
    81    BOOST_STATIC_ASSERT(sizeof(T) != 0);
       
    82 
       
    83    // GCC2 won't even parse this template if we embed the computation
       
    84    // of s1 in the computation of value.
       
    85 #ifdef __GNUC__
       
    86    BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(is_abstract_imp2<T>::template check_sig<T>(0)));
       
    87 #else
       
    88    BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig<T>(0)));
       
    89 #endif
       
    90     
       
    91    BOOST_STATIC_CONSTANT(bool, value = 
       
    92       (s1 == sizeof(type_traits::yes_type)));
       
    93 };
       
    94 
       
    95 template <bool v>
       
    96 struct is_abstract_select
       
    97 {
       
    98    template <class T>
       
    99    struct rebind
       
   100    {
       
   101       typedef is_abstract_imp2<T> type;
       
   102    };
       
   103 };
       
   104 template <>
       
   105 struct is_abstract_select<false>
       
   106 {
       
   107    template <class T>
       
   108    struct rebind
       
   109    {
       
   110       typedef false_type type;
       
   111    };
       
   112 };
       
   113 
       
   114 template <class T>
       
   115 struct is_abstract_imp
       
   116 {
       
   117    typedef is_abstract_select< ::boost::is_class<T>::value> selector;
       
   118    typedef typename selector::template rebind<T> binder;
       
   119    typedef typename binder::type type;
       
   120 
       
   121    BOOST_STATIC_CONSTANT(bool, value = type::value);
       
   122 };
       
   123 
       
   124 #endif
       
   125 }
       
   126 
       
   127 #ifndef BOOST_NO_IS_ABSTRACT
       
   128 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_abstract,T,::boost::detail::is_abstract_imp<T>::value)
       
   129 #else
       
   130 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_abstract,T,::boost::detail::is_polymorphic_imp<T>::value)
       
   131 #endif
       
   132 
       
   133 } // namespace boost
    37 } // namespace boost
   134 
    38 
   135 #include <boost/type_traits/detail/bool_trait_undef.hpp>
    39 // define a macro to make explicit designation of this more transparent
       
    40 #define BOOST_IS_ABSTRACT(T)                          \
       
    41 namespace boost {                                     \
       
    42 namespace serialization {                             \
       
    43 template<>                                            \
       
    44 struct is_abstract< T > {                             \
       
    45     typedef mpl::bool_<true> type;                    \
       
    46     BOOST_STATIC_CONSTANT(bool, value = true);        \
       
    47 };                                                    \
       
    48 }                                                     \
       
    49 }                                                     \
       
    50 /**/
   136 
    51 
   137 #endif //BOOST_TT_IS_ABSTRACT_CLASS_HPP
    52 #endif //BOOST_SERIALIZATION_IS_ABSTRACT_CLASS_HPP