Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Macro BOOST_TTI_TRAIT_HAS_TEMPLATE

BOOST_TTI_TRAIT_HAS_TEMPLATE — A macro which expands to a metafunction which tests whether an inner class template with a particular name exists.

Synopsis

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

BOOST_TTI_TRAIT_HAS_TEMPLATE(trait, ...)

Description

BOOST_TTI_TRAIT_HAS_TEMPLATE is a macro which expands to a metafunction. The metafunction tests whether an inner class template with a particular name exists. The macro takes the form of BOOST_TTI_TRAIT_HAS_TEMPLATE(trait,...) where

trait = the name of the metafunction
... = variadic parameters.

The first variadic parameter is the inner class template name.

Following variadic parameters are optional.

If no following variadic parameters exist, then the inner class template being introspected must be all template type parameters ( template parameters starting with class or typename ) and any number of template type parameters can occur.

If the second variadic parameter is BOOST_PP_NIL and no other variadic parameter is given, then just as in the previous case the inner class template being introspected must be all template type parameters ( template parameters starting with class or typename ) and any number of template type parameters can occur. This form is allowed in order to be consistent with using the non-variadic form of this macro.

If the second variadic parameter is a Boost preprocessor library array and no other variadic parameter is given, then the inner class template must have its template parameters matching the sequence in the tuple portion of the Boost PP array. This form is allowed in order to be consistent with using the non-variadic form of this macro.

Otherwise the inner class template must have its template parameters matching the sequence of the optional variadic parameters.

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

template<class BOOST_TTI_TP_T>
struct trait
  {
  static const value = unspecified;
  typedef mpl::bool_<true-or-false> type;
  };

The metafunction types and return:

  BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
                   The enclosing type can be a class, struct, or union.
  
  returns = 'value' is true if the 'name' template exists within the enclosing type,
            otherwise 'value' is false.

Examples:

1) Search for an inner class template called 'MyTemplate', with all template type parameters,
   nested within the class 'MyClass' using a metafunction name of 'MyMeta'.

   BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate)

   or

   BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,BOOST_PP_NIL) // Non-variadic macro form

   MyMeta<MyClass>::value

   is a compile time boolean constant which is either 'true' or 'false'
   if the nested template exists.

2) Search for an inner class template called 'MyTemplate', with template parameters 
   of 'class T,int x,template<class> class U', nested within the class 'MyClass' 
   using a metafunction name of 'MyMeta'.

   BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,class,int,template<class> class)

   or

   BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,(3,(class,int,template<class> class))) // Non-variadic macro form

   MyMeta<MyClass>::value

   is a compile time boolean constant which is either 'true' or 'false'
   if the nested template exists.


PrevUpHomeNext