Skip to content
New issue

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

Passing a tuple of systems to execute_systems() instead of a variadic param pack #16

Open
bjadamson opened this issue Dec 23, 2016 · 1 comment

Comments

@bjadamson
Copy link
Contributor

Hey, I got a quick question for you. I've been doing some meta programming in my game lately, and I would like to group my list of "systems" into a tuple (so I can pass it around) and then later pass that tuple to the execute_systems() function located here:

https://github.com/SuperV1234/ecst/blob/master/include/ecst/context/data/step/step.hpp#L33-L34

This doesn't work currently because I don't see a straight-forward way to destructure my std::tuple (actually I'm using hana::tuple but it's the same problem) back into a list of variadic arguments to pass to:

template <typename... TStartSystemTags>
auto execute_systems_from(TStartSystemTags... sts) noexcept;

Here's the diff of what I was thinking of as an approach:
bjadamson@c308eea

Questions, do you already support this and I don't see it?
Does this seem like something that seems like a good idea to support?
How would you go about supporting this if you were the one implementing this? (I'm asking because I assume I'll have more time to work on it in the very near future, but my approach seems flawed).

Thanks as always!

@vittorioromeo
Copy link
Owner

This doesn't work currently because I don't see a straight-forward way to destructure my std::tuple (actually I'm using hana::tuple but it's the same problem) back into a list of variadic arguments

I think you're looking for boost::hana::unpack or std::experimental::apply:

auto sum = [](auto... xs)
{
    return (0 + ... + xs);  
};

auto x = boost::hana::make_tuple(1, 2, 3);

assert(boost::hana::unpack(x, sum) == 1 + 2 + 3);

Here's a working example on Wandbox.

Let me know if this helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants