2012-09-06 132 views
0

我想根据某些模板参数类型的常量使用boost :: mpl来控制某些指针类型的常量。这里是我的尝试:使用boost编译错误:: mpl :: if_

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 

任何线索我在做什么错?

谢谢!

+0

那么,你的结构后面没有分号,如果有帮助的话。 – chris

+0

我错过了这篇文章,但我确实在代码中有。 –

+0

什么是'list'? –

回答

0

我可以用它来is_const修复:

typedef typename boost::mpl::if_<boost::is_const<T>, const sexpr *, sexpr *>::type pointer; 

谢谢!