dimanche 18 novembre 2018

How to transform this list of types with brigand?

I have the following list of types:

using ComponentList = brigand::list<TransformComponent, ObjectComponent, BodyComponent>

How can I transform the previous list into a new list that would look like this:

using ComponentHandleList = brigand::list<entityx::ComponentHandle<TransformComponent>, entityx::ComponentHandle<ObjectComponent>, entityx::ComponentHandle<BodyComponent>>;

I basically want to generate a new list that has wrappers for every element in the previous list. I tried doing it by using:

using ComponentHandleList = brigand::transform<ComponentList, AddComponentHandle<brigand::_1>>;

But I don't know much about meta-programming and failed to implement the struct AddComponentHandle<>, that would take a type T and convert it into entityx::ComponentHandle<T>. Brigand includes relevant documentation about transforming a list of types by showing an example of converting every type T to T* by using std::add_pointer<>. Which is the same thing I want to do but going from T to entityx::ComponentHandle<T>. How can I convert the first list so it looks like the second one?

Aucun commentaire:

Enregistrer un commentaire