2012-09-06 51 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; 

謝謝!