问题描述
有人可以解释一下最后一行吗?我最终需要确定是否连接了两个顶点.
Can Someone Please explain this Last line? I need to eventually determine if two vertexes are connected.
include <boost/fusion/adapted/std_pair.hpp>
include <boost/spirit/include/qi.hpp>
include <boost/graph/edge_list.hpp>
include <fstream>
typedef std::pair<int,int> Edge;
typedef std::vector<Edge> EdgeList;
typedef boost::edge_list<EdgeList::iterator> Graph;
namespace qi = boost::spirit::qi;
int main()
{
std::ifstream ifs("Graph.txt");
ifs >> std::noskipws;
//std::cout << ifs;
boost::spirit::istream_iterator f(ifs), l;
std::vector<Edge> edges;
bool parse_ok = qi::phrase_parse(f, l, (qi::int_ >> qi::int_) % qi::eol, qi::blank, edges);
有人可以解释一下最后一行吗?:
Can some please explain this last line?:
bool parse_ok = qi::phrase_parse(f, l, (qi::int_ >> qi::int_) % qi::eol, qi::blank, edges);
推荐答案
查看文档,看起来像是该库提供了一些免费的函数来进行快照的解析.这些解析器函数有两种形式.第一种形式分析在字符级别上起作用.第二个短语_分析在短语级别上起作用并且需要跳过分析器.这两个版本都可以通过引用来获取属性,这些属性将在成功的分析中保留所分析的值." phrase_parse()定义为
Looking at the documentation, looks like " The library provides a couple of free functions to make parsing a snap. These parser functions have two forms. The first form parse works on the character level. The second phrase_parse works on the phrase level and requires skip parser. Both versions can take in attributes by reference that will hold the parsed values on a successful parse." phrase_parse() is defined as
template <typename Iterator, typename Expr, typename Skipper>
inline bool
phrase_parse(
Iterator& first
, Iterator last
, Expr const& expr
, Skipper const& skipper
, BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip);
也许这是一个不错的起点.
Maybe this is a good place to start.
这篇关于增强图形和精神的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!