本文介绍了Boost :: MPL Vector和For_Each:如何打印avector作为元组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以想象我们有一个mpl :: vector,我们要打印(cout例如)它作为这样的字符串: int,string,char
。如何做这样的事情与boost :: mpl?
So imagine we had a mpl::vector we want to print (cout for example) it as such string: int, string, char
. How to do such thing with boost::mpl?
推荐答案
创建一个函子并调用boost :: for_each:
Make a functor and call 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());
这篇关于Boost :: MPL Vector和For_Each:如何打印avector作为元组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!