...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The directive duplicate[]
duplicates its attribute to all elements
of the embedded generator if this is a sequence generator. Otherwise
it does nothing.
// forwards to <boost/spirit/home/karma/directive/duplicate.hpp> #include <boost/spirit/include/karma_duplicate.hpp>
Also, see Include Structure.
Name |
---|
|
Notation
a
A generator object
A
Attribute type of generator a
Semantics of an expression is defined only where it differs from, or
is not defined in UnaryGenerator
.
Expression |
Semantics |
---|---|
|
The |
See Compound Attribute Notation.
Expression |
Attribute |
---|---|
|
a: A --> duplicate[a]: A a: tuple<A, A, ...> --> duplicate[a]: A a: Unused --> duplicate[a]: Unused
|
If the embedded generator of the duplicate[]
directive is a sequence it is expected
that all elements of this sequence expose either the same attribute type,
an compatible attribute type, or unused
.
In this case, the duplicate[]
directive exposes the attribute type
of its first element. The behavior of the duplicate[]
directive is undefined if the elements
of an embedded sequence do not expose the same attributes. Most likely,
the corresponding expression will not compile.
The overall complexity of the
duplicate[]
directive depends on the complexity of the embedded generator.
Note | |
---|---|
The test harness for the example(s) below is presented in the Basics Examples section. |
Some includes:
#include <boost/spirit/include/karma.hpp> #include <boost/spirit/include/support_utree.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/fusion/include/std_pair.hpp> #include <iostream> #include <string>
Some using declarations:
using boost::spirit::karma::double_; using boost::spirit::karma::duplicate; using boost::spirit::karma::space;
Basic usage of the duplicate
generators:
test_generator_attr("2.02.0", duplicate[double_ << double_], 2.0); test_generator_attr_delim("2.0 2.0 ", duplicate[double_ << double_], space, 2.0);