|
Boost : |
From: Jeff Mirwaisi (jeff_mirwaisi_at_[hidden])
Date: 2005-02-23 09:00:57
documentation, but just for completeness.
Given a type trait TT which you want to select upon.
Given a template function TF which you would like to
call only for types that TT selects from within
template function G.
We need a type which will delegate to TF, that doesn't
bind the template parameter types and is a first class
type (a holder)
template <typename T> void TF(T) {}
struct TF_holder
{
typedef void result_type;
template <typename T> result_type invoke(T t)
{return TF(t);}
};
template <typename U> void G(U u) { execute_if< TT< U
>::invoke< TF_holder >(u); }
G is the generic template function for all types, TF
is the conditionally targeted template function for
types for which TT is true.
Hope that helps.
Jeff Mirwaisi
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk