【发布时间】:2011-11-30 07:44:42
【问题描述】:
我正在学习 Boost.MPL,我才刚刚开始。因此,如果解决方案是明显的,请原谅我。我看这样的样本:
#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 时摆脱boost::mpl::vector(将其转换为a.FooAll<int, float, long>();)并且为每个参数调用一些静态/全局/或类内部函数,而不是让我感到困惑的*this?
【问题讨论】: