...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The Attribute parser does not consume any input, for this reason it always matches an empty string and always succeeds. It's purpose is to expose its specified parameter as an attribute.
// forwards to <boost/spirit/home/qi/auxiliary/attr.hpp> #include <boost/spirit/include/qi_attr.hpp>
Also, see Include Structure.
Name |
---|
|
Notation
a
A arbitrary typed constant value, e.g. 0.0, "Hello", or a variable of arbitrary type or a Lazy Argument that evaluates to an arbitrary type.
A
The type of a
or
if it is a Lazy
Argument, its return type.
Semantics of an expression is defined only where it differs from, or
is not defined in PrimitiveParser
.
Expression |
Semantics |
---|---|
|
Create a pseudo parser exposing the current value of |
Expression |
Attribute |
---|---|
|
|
O(1)
The complexity is constant as no input is consumed and no matching is done.
Note | |
---|---|
The test harness for the example(s) below is presented in the Basics Examples section. |
Some using declarations:
namespace phx = boost::phoenix; using boost::spirit::qi::attr;
Using attr
with literals:
std::string str; test_parser_attr("", attr("boost"), str); std::cout << str << std::endl; // will print 'boost' double d; test_parser_attr("", attr(1.0), d); std::cout << d << std::endl; // will print '1.0'
Using attr
with Phoenix function objects:
d = 0.0; double d1 = 1.2; test_parser_attr("", attr(phx::ref(d1)), d); std::cout << d << std::endl; // will print '1.2'