Re: x3::variant vs boost::variant

Baptiste Wicht <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
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

Thanks :)

> Regards,
> --
> Joel de Guzman
> http://www.ciere.com
> http://boost-spirit.com
> http://www.cycfi.com/
>
>
> ------------------------------------------------------------------------------
> 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

------------------------------------------------------------------------------
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-----

iQIcBAEBCgAGBQJWyC6JAAoJEMVWa2x/iEUyEwcP/R0nWDzjtYG+W/1r9X1g4UE5
b8O5kmMI8tbUzvO9alOTzsibPRbKrUWAuiGsGXCLS3R+dTbO1SrLnUUb6ldI7pZC
MjBriSsJTYBl+7JI5tJ+HeOqyYwTHLS4W7IPZEFc3fTmNjjoXcsBa4aVwj/nr9YF
BLlm5iMrSjpIsbmRv57kVuOHVZhMxLEfdvf7bPOlRELaKGMtNmfjOk1G09vOA74O
0Y244IdlVEXOop7C9FRKJEllKgsfgpVuJCtvTcnMbSmHNRWa1hBfIjPy9ghgHwn7
v0Fhs0BdBNGb2v0+u8eQEesTanZev9/2DzOlUPSSu6ziF2Cybk6ILPs5US9gucQR
PqEuG4o0UHPWOeGnvIR3WKbARRAGPSWMvtcyZR+QclHM8Q9UcnO4mQ4scWXcikqw
qdEBDakndVr8DrnEPzI/6Z33Fzof/jeSoWlAz8O+3Ym+neGlbGUHHkJm9l5K3QpD
V8f3v7Py3dmF6Fi+OeAjXF7bXgi+UpGUr6wJbc4Z9q0+BAAKky7BVLeGvL3hn28n
BmPBbHy4cyHYuhWzhMPUF/eOoE5g3d92mejU0AjKqSO8lwNXkLw3zEUS9Axq0x2W
vMQnqRMxF27RqAYUK/I6P3jQ9lwNh4pclnv282DLwN6HR5ASnU1X+JuqoTWLDlVt
qZxqwUxpMMMIJH9JPbn7
=IWzc
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.