We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
While defining semantic actions in Spirit X3, if find myself doing this a lot:
[](auto&& ctx){_val(ctx)=fusion::invoke([](auto const&... x){return MyType<U>{x...};}, _attr(ctx));}
That is to "invoke" a function just to construct an object of a type (which might or might not be the final representation assigned.)
Of course, I could fusion adapt MyType, but sometimes this is an overkill.
I think this can be condensed by a simple construct function in fusion. For example implemented like this:
construct
template<class T, class Seq> auto construct(Seq&& seq){ return invoke([](auto const&... x){return T{x...};}, seq); }
This way the semantic action can be reduced to:
[](auto&& ctx){_val(ctx)=fusion::construct<MyType<U>>(_attr(ctx));}
The real power would be to use it in conjunction with CTAD (in c++17):
template<template<class...> class T, class Seq> auto construct(Seq&& seq){ return invoke([](auto const&... x){return T{x...};}, seq); }
[](auto&& ctx){_val(ctx)=fusion::construct<MyType>(_attr(ctx));}
(fusion::construct could be called fusion::make alternatively).
fusion::construct
fusion::make
Does something like this exists in Fusion already?
Would this be a useful addition to Boost.Fusion or is it too specific?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
While defining semantic actions in Spirit X3, if find myself doing this a lot:
That is to "invoke" a function just to construct an object of a type (which might or might not be the final representation assigned.)
Of course, I could fusion adapt MyType, but sometimes this is an overkill.
I think this can be condensed by a simple
construct
function in fusion.For example implemented like this:
This way the semantic action can be reduced to:
The real power would be to use it in conjunction with CTAD (in c++17):
(
fusion::construct
could be calledfusion::make
alternatively).Does something like this exists in Fusion already?
Would this be a useful addition to Boost.Fusion or is it too specific?
The text was updated successfully, but these errors were encountered: