Re: x3::variant vs boost::variant
Baptiste Wicht <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Feb 21, 2016 at 11:07:57AM +0100, Baptiste Wicht wrote:
> On Sun, Feb 21, 2016 at 09:55:02AM +0800, Joel de Guzman wrote:
> > On 2/20/16 5:14 PM, Baptiste Wicht wrote:
> > > On Sat, Feb 20, 2016 at 05:42:14AM +0800, Joel de Guzman wrote:
> > >> On 2/18/16 4:48 AM, Baptiste Wicht wrote:
> > >>
> > >>> The main problem that remains is with x3::variant and x3::forward_ast:
> > >>>
> > >>> I have a type like this:
> > >>>
> > >>> using Type = boost::spirit::x3::variant<
> > >>> SimpleType,
> > >>> boost::spirit::x3::forward_ast<ArrayType>,
> > >>> boost::spirit::x3::forward_ast<TemplateType>,
> > >>> boost::spirit::x3::forward_ast<PointerType>
> > >>> >;
> > >>>
> > >>> And a lot of code resembling this:
> > >>>
> > >>> if(auto* ptr = boost::get<ast::SimpleType>(&type)){
> > >>> //Do something on *ptr
> > >>> } else if(auto* ptr = boost::get<ast::ArrayType>(&type)){
> > >>> //Do something on *ptr
> > >>> } else if(auto* ptr = boost::get<ast::PointerType>(&type)){
> > >>> //...
> > >>> }
> > >>> //...
> > >>>
> > >>> But this does not work since ArrayType is not a member of the variant
> > >>> because of the forward_ast and I have an error from boost strict_get.
> > >>>
> > >>> I really have a lot of code like this, I won't be able (neither have the
> > >>> motivation for it) to change all of it. If there is no simple solution,
> > >>> I'll use my old AST with boost::variant and recursive_wrapper.
> > >>>
> > >>> Is there anything I can do to use boost::get with forward_ast ?
> > >>
> > >> There should be a solution. tell you what. Give me a minimal test
> > >> case and I can work on getting it compile and run as expected.
> > >
> > > Here it is: http://coliru.stacked-crooked.com/a/641b689346ff322c
> >
> > There is a solution, but it involves some meta code that can slow down CT.
> > I'm not sure if it's worth it. The only reasonable solution is to simply
> > get<forward_ast<T>>(v).
>
> Too bad, tt makes for really inelegant code :(
>
> I'll test the slowdown of my syntax with boost::variant instead of
> x3::variant to see if it's still worth it.
I just replaced all x3::variant/forward_ast by
boost::variant/recursive_wrapper and it is not good... The new parser is
70% slower than the x3::variant one :(
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general
signature.asc
(application/pgp-signature, 801 B)
-----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJWyZ1DAAoJEMVWa2x/iEUyHcEP/0r/IsIpdXuFzSiE59jBW1le 2Pr71Mdzlifr/1LUIPd96LxKlGOpgn1FwrvGsQ0i09bmF7VYHeFraaZEYh1n8lMh 2Hk2uAEp/Ms4fa/B/iwUD+kglfm40O9/JyaMo3qMfbAlF472eewu8puUkm/g6iSy kC5B9qCmrlMhv1SKiNsZTB3/8JAzPG7wu+J0f2GuyH1HCDzDG8DI6pb2x+1FzvQv vsirtEHT7QneqNGs4RpGrnVUlCYWNYFXaL/DksluobaOcMmf2C1qpY62iLqnZIIP cHBoQYGPNu6GATqNcnSyIP2F/jvT3cO/X/4sa9kfh1OIzwht+c6cyhxvJe2cHCi+ 94XJkaNCmasfOpRXQnGWFuKg84cBWHkyOUMHNhPGfMZVYqrp8fQK3fE6J4qOsVbg RYDsslXkC/IBkAlPK3bTnvs9azlJdHT2F7D1SgFt+cwWSOvizxvAS6bhcQQwH5d5 SdSpFme2zK4AODK2/nT2bkAjS/tCT+GrWF8oCqmQY2mX6LIg4emzbAZEFCCsnNUv FtT4EIG1Fj7aW1QQTI6jecuoJEXknK0XswEW/4IedCGd/qLoBJB/GirDwYOm5LoT Le9icwaWGsNrmoQLmNZUuVlP2002dGPomB4CObfyaNB//9E3G5ZXgVECrjW2O9Nq iGslvX3LneHfcM+EwxYM =v2lo -----END PGP SIGNATURE-----