2014-01-29 35 views
1

我有以下的語法:問題提振精神已經過時

#include <boost/spirit.hpp> 

struct point_grammar 
: public boost::spirit::grammar<point_grammar> 
{ 
    template <typename Scanner> 
    struct definition 
    { 
     boost::spirit::rule<Scanner> E, S, V; 

     definition(const point_grammar &self) 
     { 
     using namespace boost::spirit; 
     E = S >> V; 
     S = '@' >> +(~ch_p('@') - V); 
     V = str_p("[email protected]") | str_p("[email protected]"); 
     } 

     const boost::spirit::rule<Scanner> &start() 
        { 
     return E; 
        } 
    }; 
}; 

當我編譯,編譯器告訴我下面的警告:

/usr/include/boost/spirit.hpp:18:4: warning: "This header is deprecated. Please use: boost/spirit/include/classic.hpp"

但是,當變化中的#include升壓/精神/include/classic.hpp,我有以下錯誤:

(expected template-name before ‘<’ token) in the line where is: : public boost::spirit::grammar.

我能做什麼呢?

回答

5

應該升級到Spirit V2。我實際上向你展示瞭如何在「Problems with grammar」:)中做到這一點。
說真的。 Boost 1_36於2008年8月14日發佈。現在

,該文檔(http://boost-spirit.com/home/doc/)解釋

To avoid namespace conflicts with the new Spirit V2 library we moved Spirit Classic into the namespace boost::spirit::classic . All references to the former namespace boost::spirit need to be adjusted as soon as the header names are corrected as described above. As an alternative you can define the preprocessor constant BOOST_SPIRIT_USE_OLD_NAMESPACE , which will force the Spirit Classic code to be in the namespace boost::spirit as before. This is not recommended, though, as it may result in naming clashes.

(來源頁面:http://www.boost.org/doc/libs/1_55_0/libs/spirit/doc/html/spirit/what_s_new.html下的 「經典」)

所以,你可以繼續使用相同的代碼,如果你更新命名空間引用。