Sign in to follow this  
Dragon_Strike

boost mpl for_each problems

Recommended Posts

Dragon_Strike    264
this is what i want to do... class A { template <class T> Foo() { } template <class TypeVector> FooAll() { boost::mpl::for_each<TypeVector>(Foo()); } } main() { A a; a.<boost:mpl::vector<int, float, long>FooAll(); } however this doesnt work since for some reason mpl::for_each in this example doesnt call Foo() as <T>Foo... why is that? in the reference they specify a seperate class for the function call.. is this necessary?

Share this post


Link to post
Share on other sites
the_edd    2109
It might be a good idea to post the actual code. This will make it easier to debug. Currently you have

* missing colon(s)
* missing semi-colon(s)
* missing angle bracket(s)
* missing return types
* angle brackets in the wrong place
* no #includes

Help us to help you :)

Share this post


Link to post
Share on other sites
El Greco    182
I'm not really sure what you want to accomplish, but do you mean something like this?

(This compiles and runs with VS2005)

#include <boost/mpl/vector.hpp>
#include <boost/mpl/for_each.hpp>
#include <iostream>

using namespace std;

struct A
{
template <class T>
void operator()(T t)
{
cout << typeid(T).name() << "\t" << t << endl;
}

template <class TypeVector>
void FooAll(void)
{
boost::mpl::for_each<TypeVector>(*this);
}
};

void main(void)
{
A a;
a.FooAll<boost::mpl::vector<int, float, long>>();
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this