num_list4.qbk

来自「Boost provides free peer-reviewed portab」· QBK 代码 · 共 51 行

QBK
51
字号
[/==============================================================================    Copyright (C) 2001-2008 Joel de Guzman    Copyright (C) 2001-2008 Hartmut Kaiser    Distributed under the Boost Software License, Version 1.0. (See accompanying    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)===============================================================================/][section Number List Attribute - one more, with style]You've seen that the `double_` parser has a `double` attribute. All parsers havean attribute, even complex parsers, those that are composed from primitivesusing operators, like the list parser, also have an attribute. It so happens thatthe the attribute of a list parser:    p % dis a `std::vector` of the attribute of `p`. So, for our parser:    double_ % ','we'll have an attribute of:    std::vector<double>So, what does this give us? Well, we can simply pass in a `std::vector<double>`to our number list parser and it will happily churn out our result in ourvector. For that to happen, we'll use a variation of the `phrase_parse` withan additional argument: the parser's attribute:# An iterator pointing to the start of the input# An iterator pointing to one past the end of the input# The parser object# The parser's attribute# Another parser called the skip parserSo, our parser now is further simplified to:[import ../../example/qi/num_list4.cpp][tutorial_numlist4]The full cpp file for this example can be found here: [@../../example/qi/num_list4.cpp][*Hey, no more actions!!!] Now we're entering the realm of attribute grammars.Cool eh?[endsect]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?