Boost C++ Libraries

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

PrevUpHomeNext

Macro BOOST_TTI_HAS_TEMPLATE

BOOST_TTI_HAS_TEMPLATE — 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_HAS_TEMPLATE(...)

Description

... = 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.

generates a metafunction called "has_template_'name'" where 'name' is the first variadic parameter. template<class BOOST_TTI_TP_T> struct has_template_'name' { 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'. 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'.

BOOST_TTI_HAS_TEMPLATE(MyTemplate)

or

BOOST_TTI_HAS_TEMPLATE(MyTemplate,BOOST_PP_NIL) // Non-variadic macro form

has_template_MyTemplate<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'.

BOOST_TTI_HAS_TEMPLATE(MyTemplate,class,int,template<class> class)

or

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

has_template_MyTemplate<MyClass>::value

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


PrevUpHomeNext