Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards



BOOST_TTI_TRAIT_MEMBER_TYPE — A macro expands to a metafunction whose typedef 'type' is either the named type or a marker type.


// In header: <boost/tti/member_type.hpp>



BOOST_TTI_TRAIT_MEMBER_TYPE is a macro which expands to a metafunction. The metafunction tests whether an inner type with a particular name exists by returning the inner type or a marker type. The macro takes the form of BOOST_TTI_TRAIT_MEMBER_TYPE(trait,name) where

trait = the name of the metafunction
name = the name of the inner type.

BOOST_TTI_TRAIT_MEMBER_TYPE generates a metafunction called "trait" where 'trait' is the macro parameter.

template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_MARKER_TYPE = boost::tti::detail::notype>
struct trait
  typedef unspecified type;
  typedef BOOST_TTI_TP_MARKER_TYPE boost_tti_marker_type;

The metafunction types and return:

  BOOST_TTI_TP_T           = the enclosing type.
                             The enclosing type can be a class, struct, or union.
  BOOST_TTI_TP_MARKER_TYPE = (optional) a type to use as the marker type.
                             defaults to the internal boost::tti::detail::notype.
  returns                  = 'type' is the inner type of 'name' if the inner type exists
                             within the enclosing type, else 'type' is a marker type.
                             if the end-user does not specify a marker type then
                             an internal boost::tti::detail::notype marker type, 
                             which is empty, is used.
  The metafunction also encapsulates the type of the marker type as
  a nested 'boost_tti_marker_type'.

The purpose of this macro is to encapsulate the 'name' type as the typedef 'type' of a metafunction, but only if it exists within the enclosing type. This allows for an evaluation of inner type existence, without generating a compiler error, which can be used by other metafunctions in this library.