2010-12-10 2 views
1

다른 스레드에 대한 내용은 copy or reference semantics for boost::spirt::qi::rule입니다. 부스트 1.42를 사용하고 있습니다.std :: list에 boost :: spirit :: qi :: rule을 저장하는 중

using boost::spirit::qi::phrase_parse; 
typedef boost::spirit::qi::rule < std::string::const_iterator, boost::spirit::ascii::space_type > rule_type; 
std::list <rule_type> ruleList; 
std::string const s("abcdef"); 
std::string::const_iterator iter = s.begin(), end = s.end(); 
std::cout << typeid(char_).name() << std::endl; 
ruleList.push_back(char_); 
ruleList.push_back(*ruleList.back()); 
assert(phrase_parse(iter, s.end(), ruleList.back(), boost::spirit::ascii::space)); 
assert(iter == s.end()); 

이것은 STL 목록이나 양단 큐에 규칙을 저장하는 방법이 있나요으로 ...

Assertion `phrase_parse(iter, s.end(), ruleList.back(), traits::space())' failed. 
Aborted (core dumped) 

실패? (참고 문헌은 제거 될 때까지 사망하지 않습니다).

답변

2

이 (위에서 기본적으로 코드)는 문제없이 작동합니다 (MSVC2010를, g ++ 4.5.1) : 따라서

#include <list> 
#include <string> 
#include <iostream> 
#include <boost/spirit/include/qi.hpp> 

using namespace boost::spirit; 

int main() 
{ 
    typedef qi::rule<std::string::const_iterator, ascii::space_type> rule_type; 
    std::list<rule_type> ruleList; 

    std::string const s("abcdef"); 
    std::string::const_iterator iter = s.begin(), end = s.end(); 
    std::cout << typeid(qi::char_).name() << std::endl; 

    ruleList.push_back(qi::char_); 
    ruleList.push_back(*ruleList.back()); 

    assert(qi::phrase_parse(iter, s.end(), ruleList.back(), ascii::space)); 
    assert(iter == s.end()); 

    return 0; 
} 

, 나는 그것이 성령 당신의 버전에서 버그 가정 다시 사용하고있어.

0

예제를 컴파일 할 수 없습니다. using이 아닌 ...::qi의 올바른 유형을 제외하고 유형에 ()을 추가했습니다.

이 나를 위해 문제를 O (1.44 부스트) 승/작동

~>g++ test.cpp && ./a.out
~>

#include <boost/spirit/include/qi.hpp> 
#include <string> 
#include <vector> 
#include <cassert> 

using boost::spirit::qi::phrase_parse; 

typedef boost::spirit::qi::rule < std::string::const_iterator, boost::spirit::qi::space_type > rule_type; 

int main() { 

std::list <rule_type> ruleList; 
std::string const s("abcdef"); 
std::string::const_iterator iter = s.begin(), end = s.end(); 
ruleList.push_back(*boost::spirit::qi::char_); 
assert(phrase_parse(iter, s.end(), ruleList.back(), boost::spirit::qi::space)); 
assert(iter == s.end()); 

} 
내가 qi::space_type 대신 ascii 네임 스페이스의 `qi::space를 사용 유의하시기 바랍니다. trait 네임 스페이스가 무엇인지/어디 있는지 모르겠습니다. 부스트 V1.45와

관련 문제