【发布时间】:2011-12-05 14:05:50
【问题描述】:
假设我们有一个 mpl::vector 我们想要打印(例如 cout)它作为这样的字符串:int, string, char。如何用 boost::mpl 做这样的事情?
【问题讨论】:
假设我们有一个 mpl::vector 我们想要打印(例如 cout)它作为这样的字符串:int, string, char。如何用 boost::mpl 做这样的事情?
【问题讨论】:
制作一个仿函数并调用 boost::for_each:
struct print_class_name {
template <typename T>
void operator()( T t ) const {
std::cout << typeid(t).name() << " ";
}
};
boost::mpl::for_each< Sequence >(print_class_name());
【讨论】: