想象一下,我们有一个 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());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)