【发布时间】:2013-05-27 07:30:42
【问题描述】:
我最近尝试了 boost::mpl,它看起来既棒又可怕。有时编译错误信息相当混乱。
这次我遇到了以下代码的问题:
#include <iostream>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/integral_c_tag.hpp>
#include <boost/mpl/tag.hpp>
#include <typeinfo>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/copy.hpp>
//使用元函数标签获取类型,使得mpl只输出整数。
struct mpl_func2
{
template<typename T>
void operator()(T t)
{
if(boost::is_same<boost::mpl::tag<T>::type, boost::mpl::integral_c_tag>::value)
{cout<<t<<',';}
}
};
这里是错误信息:
错误:'template struct boost::is_same'的模板参数列表中参数 1 的类型/值不匹配
错误:需要一个类型,得到 'boost::mpl::tag::type'
【问题讨论】: