Sprit-2 equivalent of nothing_p

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Sprit-2 equivalent of nothing_p

Kent Hauser
I have a mpl vector of parser types I’d like to combine into a single parser. 

My fusion code to do this looks like:

using type_v  = mpl::vector<qi::int_parser<int>
                                            , qi::real_parser<double,
                                                                      qi::strict_real_policies<double>>
                                            >;
auto term_p = fusion::accumulate(
                                                  type_v
                                               ,  nothing_p
                                               , std::bit_or<>
                                               );

Which would be fine, except that there is no “nothing_p”. What would be the best spirit-2 equivalent?

Thanks. Kent




Sent from Mailbox

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Sprit-2 equivalent of nothing_p

TONGARI J
2015-05-06 11:24 GMT+08:00 Kent Hauser <[hidden email]>:
I have a mpl vector of parser types I’d like to combine into a single parser. 

My fusion code to do this looks like:

using type_v  = mpl::vector<qi::int_parser<int>
                                            , qi::real_parser<double,
                                                                      qi::strict_real_policies<double>>
                                            >;
auto term_p = fusion::accumulate(
                                                  type_v
                                               ,  nothing_p
                                               , std::bit_or<>
                                               );

Which would be fine, except that there is no “nothing_p”. What would be the best spirit-2 equivalent?

Maybe qi::eps(false)?

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Sprit-2 equivalent of nothing_p

Kent Hauser
I had thought that as well. In my test code, i replace my fusion::accumulate initial value of “qi:double_” with, “qi:eps(false)”. The result seg faults. 

So I had a brainwave & tried qi:eps(std::false_type()) — with success.

Thanks for the help. I had given up on qi::eps too easily. 


Sent from Mailbox


On Wed, May 6, 2015 at 1:11 AM, TONGARI J <[hidden email]> wrote:

2015-05-06 11:24 GMT+08:00 Kent Hauser <[hidden email]>:
I have a mpl vector of parser types I’d like to combine into a single parser. 

My fusion code to do this looks like:

using type_v  = mpl::vector<qi::int_parser<int>
                                            , qi::real_parser<double,
                                                                      qi::strict_real_policies<double>>
                                            >;
auto term_p = fusion::accumulate(
                                                  type_v
                                               ,  nothing_p
                                               , std::bit_or<>
                                               );

Which would be fine, except that there is no “nothing_p”. What would be the best spirit-2 equivalent?

Maybe qi::eps(false)?


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Sprit-2 equivalent of nothing_p

TONGARI J
2015-05-06 14:40 GMT+08:00 Kent Hauser <[hidden email]>:
I had thought that as well. In my test code, i replace my fusion::accumulate initial value of “qi:double_” with, “qi:eps(false)”. The result seg faults. 

So I had a brainwave & tried qi:eps(std::false_type()) — with success.

Thanks for the help. I had given up on qi::eps too easily. 

Actually you should use BOOST_SPIRIT_AUTO from <boost/spirit/include/support_auto.hpp>.
Spirit V2 is based on Proto, which, IIRC, holds reference by default, so you have the problem of dangling reference in your code.
BOOST_SPIRIT_AUTO uses proto::deep_copy internally and thus the problem should be avoided.

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general