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