Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以想象我们有一个 mpl::vector 我们想要打印(例如 cout)它作为这样的字符串:int, string, char。如何用 boost::mpl 做这样的事情?
int, string, char
制作一个仿函数并调用 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());