[英]use of deleted function CONSTRUCTOR, no matching function for call to
這段代碼在My_grammar g;
行給了我以下錯誤: :
no matching function for call to boost::spirit::qi::grammar<My_grammar>::grammar()’
use of deleted function ‘My_grammar::My_grammar()’
我不明白,是不是應該有一個默認的(未刪除)構造函數? 但是問題可能出在其他地方。
我會實現一個構造函數,但是會帶來新的錯誤,並且教程/示例從不使用相同的方法(有些使用構造函數,有些則沒有),或者使用類我,文檔,編譯器或Google都不了解( CParser ?? )。 我認為可能是因為我(不包括)標頭,因為有很多我可以在boost / spirit下選擇。 再說一次,可能是過時的教程中的人似乎並沒有提供相同的內容,或者使用了我昨天未獲得的,易於獲取的,最有可能是最新版本的boost。 我正在使用Eclipse,以防萬一。
#include <iostream>
#include <cstdlib>
#include <string>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_rule.hpp>
using namespace boost::spirit;
#define BOOST_SPIRIT_DEBUG
struct My_grammar :
public boost::spirit::qi::grammar<My_grammar>
{
public:
template <typename ScannerT>
struct definition
{
public:
definition(My_grammar const& self)
{
sentence
= 'a';
}
boost::spirit::qi::rule<ScannerT> sentence;
boost::spirit::qi::rule<ScannerT> const& start() const { return sentence; }
};
};
int main() {
My_grammar g;
return EXIT_SUCCESS;
}
我感到接下來會有更多問題(例如:我已經嘗試過parse()函數,但失敗了),但是我想一次解決一個問題。
似乎您被“經典”精神分析器框架所困擾。
Spirit V2截然不同,已經取代了V1:
這是您在Spirit V2中編寫語法定義的方法:
#define BOOST_SPIRIT_DEBUG
#include <boost/spirit/include/qi.hpp>
namespace qi = boost::spirit::qi;
template <typename It>
struct My_grammar : public qi::grammar<It> {
My_grammar() : My_grammar::base_type(sentence) {
sentence = 'a';
}
qi::rule<It> sentence;
};
int main() {
My_grammar<std::string::const_iterator> g;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.