[mpl] Using at_c within find_if

Hi there, I'm trying to find a solution for looking for type vector
containing a specific type. On another thread I was suggested to use
at_c within the find_if algorithm. Unfortunately the code doesn't
compile.
#include "boost/mpl/vector.hpp"
#include

Christian Henning wrote:
Hi there, I'm trying to find a solution for looking for type vector containing a specific type. On another thread I was suggested to use at_c within the find_if algorithm. Unfortunately the code doesn't compile.
Placeholder substitution won't work in templates taking non-type arguments, such as at_c.
typedef mpl::find_if
mpl::_1,1, int> >::type iter;
Try using 'at' and 'int_':
typedef find_if

Thanks a lot for your hint. It works perfectly. Here is the code:
#include "boost/mpl/vector.hpp"
#include

On 3/28/07, Tobias Schwinger
Christian Henning wrote:
Hi there, I'm trying to find a solution for looking for type vector containing a specific type. On another thread I was suggested to use at_c within the find_if algorithm. Unfortunately the code doesn't compile.
Placeholder substitution won't work in templates taking non-type arguments, such as at_c.
typedef mpl::find_if
mpl::_1,1, int> >::type iter; Try using 'at' and 'int_':
typedef find_if
>, int> >::type iter; Regards, Tobias
I am curious why at_c doesn't do the same thing. Shouldn't these be equivalent. Chris

Chris Weed wrote:
On 3/28/07, Tobias Schwinger
wrote: Christian Henning wrote:
Hi there, I'm trying to find a solution for looking for type vector containing a specific type. On another thread I was suggested to use at_c within the find_if algorithm. Unfortunately the code doesn't compile. Placeholder substitution won't work in templates taking non-type arguments, such as at_c.
typedef mpl::find_if
mpl::_1,1, int> >::type iter; Try using 'at' and 'int_': typedef find_if
>, int> >::type iter; Regards, Tobias
I am curious why at_c doesn't do the same thing. Shouldn't these be equivalent.
Yes, ideally. But it would be rather heavy, implementation-wise.
You can decompose a type created by specializing a template like this:
template<typename T> struct template_traits;
template
struct template_traits< Tpl<T0> >
{
static const int arity = 1;
typedef T0 first_type;
};
template class Tpl, typename T0,
typename T1>
struct template_traits< Tpl
participants (3)
-
Chris Weed
-
Christian Henning
-
Tobias Schwinger