So I'm very new to Boost but I'm running into problems trying to do some of the most basic of things in my win32 application project in vs2010.
所以我对Boost很新,但我在尝试在vs2010的win32应用程序项目中做一些最基本的事情时遇到了问题。
I have gone into my vs2010 project properties and made sure that my include files are looking in the right places, and when I build I don't get errors including hpp files from boost in my stdafx.h, however when I read the documentation on their site here: http://www.boost.org/doc/libs/1_43_0/libs/spirit/doc/html/spirit/support/multi_pass.html I just get a bunch of basic errors like multi_pass is undefined.
我已经进入了我的vs2010项目属性,并确保我的包含文件正在查找正确的位置,当我构建时,我不会在stdafx.h中获取包括来自boost的hpp文件的错误,但是当我阅读文档时他们的网站在这里:http://www.boost.org/doc/libs/1_43_0/libs/spirit/doc/html/spirit/support/multi_pass.html我刚刚收到一堆基本错误,例如multi_pass未定义。
I only need boost for one thing, and that is to create a forward operator from my current input operator so I can pass it through a function. Below is the declaration for my input operator.
我只需要提升一件事,那就是从我当前的输入操作符创建一个前向运算符,这样我就可以通过一个函数传递它。下面是我的输入操作符的声明。
std::istreambuf_iterator<char> eof;
I found an alternative solution on that same page where the std::basic_istream_iterator is actually a forward operator but when I compile I get an error saying that basic_istream_iterator is not part of the std library.
我在同一页面上找到了一个替代解决方案,其中std :: basic_istream_iterator实际上是一个前向运算符,但是当我编译时,我得到一个错误,指出basic_istream_iterator不是std库的一部分。
In the end I'm just really new to iterators themselves and boost. I would like to know how I can get my input iterator transformed into a forward iterator so I can iterator through a file.
最后,我对迭代器本身并不感兴趣。我想知道如何将我的输入迭代器转换为转发迭代器,以便我可以通过文件迭代。
1 个解决方案
#1
3
Like the commenter siad, you need to include the right support headers.
与评论者siad一样,您需要包含正确的支持标题。
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/support_multi_pass.hpp>
Howeever, the simplest way is:
然而,最简单的方法是:
std::ifstream file("myfile.txt", std::ios::binary);
file.unsetf(std::ios::skipws);
// use the ready-made:
boost::spirit::istream_iterator f(file), l;
// parse!
book ok = qi::parse(f, l, my_grammar);
#1
3
Like the commenter siad, you need to include the right support headers.
与评论者siad一样,您需要包含正确的支持标题。
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/support_multi_pass.hpp>
Howeever, the simplest way is:
然而,最简单的方法是:
std::ifstream file("myfile.txt", std::ios::binary);
file.unsetf(std::ios::skipws);
// use the ready-made:
boost::spirit::istream_iterator f(file), l;
// parse!
book ok = qi::parse(f, l, my_grammar);