Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Spirit Karma: how to store generator?
From: Lee Clagett (forum_at_[hidden])
Date: 2016-02-28 14:58:22


On Sun, 28 Feb 2016 22:05:44 +0300
"Matwey V. Kornilov" <matwey.kornilov_at_[hidden]> wrote:
> Hello,
>
> After reading Karma tutorial, I still don't understand whether there a
> way to store generator except
>
> auto my_generator = ...
>
> I would like to generate text representation for many similar objects
> and I think that it is worth to use single generate object and pass it
> to generate_delimited() by const reference.
>
> Are there such things like qi::rule<> and qi::grammar for Karma?
>

Karma has both a rule and a grammar [0]. The C++11 auto can be used
with Karma in various ways, but be careful of copies. Karma
uses C++03 Boost.Proto which stores references and does a shallow copy
in its copy constructor. See Boost.Proto.DeepCopy [1].

Lee

[0]http://www.boost.org/doc/libs/1_60_0/libs/spirit/doc/html/spirit/karma/reference/nonterminal.html
[1]http://www.boost.org/doc/libs/1_60_0/doc/html/boost/proto/functional/deep_copy.html


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net