Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:55

0001 
0002 //  (C) Copyright Edward Diener 2011,2012,2013
0003 //  Use, modification and distribution are subject to the Boost Software License,
0004 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 //  http://www.boost.org/LICENSE_1_0.txt).
0006 
0007 #if !defined(BOOST_TTI_MEMBER_TYPE_HPP)
0008 #define BOOST_TTI_MEMBER_TYPE_HPP
0009   
0010 #include <boost/mpl/eval_if.hpp>
0011 #include <boost/mpl/identity.hpp>
0012 #include <boost/mpl/not.hpp>
0013 #include <boost/type_traits/is_same.hpp>
0014 #include <boost/preprocessor/cat.hpp>
0015 #include <boost/tti/gen/member_type_gen.hpp>
0016 #include <boost/tti/gen/namespace_gen.hpp>
0017 #include <boost/tti/detail/dmem_type.hpp>
0018 #include <boost/tti/detail/dnotype.hpp>
0019 
0020 /*
0021 
0022   The succeeding comments in this file are in doxygen format.
0023 
0024 */
0025 
0026 /** \file
0027 */
0028 
0029 /// A macro expands to a metafunction whose typedef 'type' is either the named type or a marker type.
0030 /**
0031 
0032     BOOST_TTI_TRAIT_MEMBER_TYPE is a macro which expands to a metafunction.
0033     The metafunction tests whether an inner type with a particular name exists
0034     by returning the inner type or a marker type.
0035     The macro takes the form of BOOST_TTI_TRAIT_MEMBER_TYPE(trait,name) where
0036     
0037     trait = the name of the metafunction <br/>
0038     name  = the name of the inner type.
0039 
0040     BOOST_TTI_TRAIT_MEMBER_TYPE generates a metafunction called "trait" where 'trait' is the macro parameter.
0041     
0042   @code
0043   
0044               template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_MARKER_TYPE = boost::tti::detail::notype>
0045               struct trait
0046                 {
0047                 typedef unspecified type;
0048                 typedef BOOST_TTI_TP_MARKER_TYPE boost_tti_marker_type;
0049                 };
0050 
0051               The metafunction types and return:
0052               
0053                 BOOST_TTI_TP_T           = the enclosing type.
0054                                            The enclosing type can be a class, struct, or union.
0055                 
0056                 BOOST_TTI_TP_MARKER_TYPE = (optional) a type to use as the marker type.
0057                                            defaults to the internal boost::tti::detail::notype.
0058                 
0059                 returns                  = 'type' is the inner type of 'name' if the inner type exists
0060                                            within the enclosing type, else 'type' is a marker type.
0061                                            if the end-user does not specify a marker type then
0062                                            an internal boost::tti::detail::notype marker type, 
0063                                            which is empty, is used.
0064                           
0065                 The metafunction also encapsulates the type of the marker type as
0066                 a nested 'boost_tti_marker_type'.
0067                           
0068   @endcode
0069   
0070     The purpose of this macro is to encapsulate the 'name' type as the typedef 'type'
0071     of a metafunction, but only if it exists within the enclosing type. This allows for
0072     an evaluation of inner type existence, without generating a compiler error,
0073     which can be used by other metafunctions in this library.
0074     
0075 */
0076 #define BOOST_TTI_TRAIT_MEMBER_TYPE(trait,name) \
0077     BOOST_TTI_DETAIL_TRAIT_HAS_TYPE_MEMBER_TYPE(trait,name) \
0078     BOOST_TTI_DETAIL_TRAIT_MEMBER_TYPE(trait,name) \
0079     template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_MARKER_TYPE = BOOST_TTI_NAMESPACE::detail::notype> \
0080     struct trait : \
0081       boost::mpl::eval_if \
0082         < \
0083         BOOST_PP_CAT(trait,_detail_has_type_member_type)<BOOST_TTI_TP_T>, \
0084         BOOST_PP_CAT(trait,_detail_member_type)<BOOST_TTI_TP_T>, \
0085         boost::mpl::identity<BOOST_TTI_TP_MARKER_TYPE> \
0086         > \
0087       { \
0088       typedef BOOST_TTI_TP_MARKER_TYPE boost_tti_marker_type; \
0089       }; \
0090 /**/
0091 
0092 /// A macro which expands to a metafunction whose typedef 'type' is either the named type or a marker type.
0093 /**
0094 
0095     BOOST_TTI_MEMBER_TYPE is a macro which expands to a metafunction.
0096     The metafunction tests whether an inner type with a particular name exists
0097     by returning the inner type or a marker type.
0098     The macro takes the form of BOOST_TTI_MEMBER_TYPE(name) where
0099     
0100     name  = the name of the inner type.
0101 
0102     BOOST_TTI_MEMBER_TYPE generates a metafunction called "member_type_name" where 'name' is the macro parameter.
0103     
0104   @code
0105   
0106               template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_MARKER_TYPE = boost::tti::detail::notype>
0107               struct member_type_'name'
0108                 {
0109                 typedef unspecified type;
0110                 typedef BOOST_TTI_TP_MARKER_TYPE boost_tti_marker_type;
0111                 };
0112 
0113               The metafunction types and return:
0114               
0115                 BOOST_TTI_TP_T           = the enclosing type.
0116                                            The enclosing type can be a class, struct, or union.
0117                 
0118                 BOOST_TTI_TP_MARKER_TYPE = (optional) a type to use as the marker type.
0119                                            defaults to the internal boost::tti::detail::notype.
0120                 
0121                 returns                  = 'type' is the inner type of 'name' if the inner type exists
0122                                            within the enclosing type, else 'type' is a marker type.
0123                                            if the end-user does not specify a marker type then
0124                                            an internal boost::tti::detail::notype marker type is used.
0125                           
0126                 The metafunction also encapsulates the type of the marker type as
0127                 a nested 'boost_tti_marker_type'.
0128                           
0129   @endcode
0130   
0131     The purpose of this macro is to encapsulate the 'name' type as the typedef 'type'
0132     of a metafunction, but only if it exists within the enclosing type. This allows for
0133     an evaluation of inner type existence, without generating a compiler error,
0134     which can be used by other metafunctions in this library.
0135     
0136 */
0137 #define BOOST_TTI_MEMBER_TYPE(name) \
0138   BOOST_TTI_TRAIT_MEMBER_TYPE \
0139   ( \
0140   BOOST_TTI_MEMBER_TYPE_GEN(name), \
0141   name \
0142   ) \
0143 /**/
0144   
0145 namespace boost
0146   {
0147   namespace tti
0148     {
0149   
0150     /// A metafunction which checks whether the member 'type' returned from invoking the macro metafunction generated by BOOST_TTI_MEMBER_TYPE ( BOOST_TTI_TRAIT_MEMBER_TYPE ) is a valid type.
0151     /**
0152     
0153         The metafunction 'valid_member_type', which is in the boost::tti namespace, takes the form of:
0154 
0155   @code
0156   
0157         template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_MARKER_TYPE = boost::tti::detail::notype>
0158         struct valid_member_type
0159           {
0160           static const value = unspecified;
0161           typedef mpl::bool_<true-or-false> type;
0162           };
0163 
0164         The metafunction types and return:
0165 
0166           BOOST_TTI_TP_T           = returned inner 'type' from invoking the macro metafunction generated by BOOST_TTI_MEMBER_TYPE ( BOOST_TTI_TRAIT_MEMBER_TYPE ).
0167           
0168           BOOST_TTI_TP_MARKER_TYPE = (optional) a type to use as the marker type.
0169                                      defaults to the internal boost::tti::detail::notype.
0170       
0171           returns                  = 'value' is true if the type is valid, otherwise 'value' is false.
0172                                      A valid type means that the returned inner 'type' is not the marker type.
0173                           
0174   @endcode
0175   
0176     */
0177     template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_MARKER_TYPE = BOOST_TTI_NAMESPACE::detail::notype>
0178     struct valid_member_type :
0179       boost::mpl::not_
0180         <
0181         boost::is_same<BOOST_TTI_TP_T,BOOST_TTI_TP_MARKER_TYPE>
0182         >
0183       {
0184       };
0185       
0186     /// A metafunction which checks whether the invoked macro metafunction generated by BOOST_TTI_MEMBER_TYPE ( BOOST_TTI_TRAIT_MEMBER_TYPE ) hold a valid type.
0187     /**
0188 
0189         The metafunction 'valid_member_metafunction', which is in the boost::tti namespace, takes the form of:
0190 
0191   @code
0192   
0193         template<class BOOST_TTI_METAFUNCTION>
0194         struct valid_member_metafunction
0195           {
0196           static const value = unspecified;
0197           typedef mpl::bool_<true-or-false> type;
0198           };
0199 
0200         The metafunction types and return:
0201 
0202           BOOST_TTI_METAFUNCTION = The invoked macro metafunction generated by BOOST_TTI_MEMBER_TYPE ( BOOST_TTI_TRAIT_MEMBER_TYPE ).
0203       
0204           returns          = 'value' is true if the nested type of the invoked metafunction is valid, otherwise 'value' is false.
0205                              A valid type means that the invoked metafunction's inner 'type' is not the marker type.
0206                           
0207   @endcode
0208   
0209     */
0210     template<class BOOST_TTI_METAFUNCTION>
0211     struct valid_member_metafunction :
0212       boost::mpl::not_
0213         <
0214         boost::is_same<typename BOOST_TTI_METAFUNCTION::type,typename BOOST_TTI_METAFUNCTION::boost_tti_marker_type>
0215         >
0216       {
0217       };
0218     }
0219   }
0220   
0221 #endif // BOOST_TTI_MEMBER_TYPE_HPP