我正试图使用boost::mpl基于某些模板参数类型的常量来控制某些指针类型的常量。这是我的尝试:
template<typename T>
struct iter {
typedef typename boost::mpl::if_<boost::is_same<T, const list>, const sexpr *, sexpr *>::type pointer;
};
然而编译器拒绝接受这样的说法:
sexpr.h:154: error: ISO C++ forbids declaration of `type name' with no type
sexpr.h:154: error: template argument 2 is invalid
sexpr.h:154: error: template argument 1 is invalid
sexpr.h:154: error: `type' does not name a type
知道我做错了什么吗?
谢谢!
我能够使用is_const:修复它
typedef typename boost::mpl::if_<boost::is_const<T>, const sexpr *, sexpr *>::type pointer;
谢谢!