• Advertisement
Sign in to follow this  

boost mpl for_each problems

This topic is 3654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
Sign in to follow this  

  • Advertisement