2
我正在学习Boost.MPL,我刚刚开始。所以如果解决方案是明显的,请原谅我。我看这样的例子:C++ Boost MPL:如何摆脱向量和callnot内部函数?
#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>>();
}
,并不能帮助,但不知道如何调用FooALL(把它变成a.FooAll<int, float, long>();
)时摆脱boost::mpl::vector
并为每个参数调用一些静态/全球/或类的内部函数,而不是*this
这让我困惑?
@ user1072853我已经更新了更多的细节的例子。我无法访问编译器,因此请仅将此代码视为草图。 – Marcin