I am trying to create a std::tuple of several large objects, that I can then subsequently use, ideally to access their methods and do other stuff from within TextureManager
class TextureManager
{
public:
template<typename T , typename... Args>
TextureManager(T t, Args... args)
:graphical_objects{std::make_tuple(t, args...)}
{}
// How to declare graphical_objects ?
std::tuple< /*what to put here*/ > graphical_objects;
};
int main()
{
TextureManager tm1(1, 2, 'a');
// This is how I'd like to use TextureManager
TextureManager text_manager2(my_graphics_obj1, my_graphics_obj2, my_graphics_obj3);
// Or how ever many parameters...
return 0;
}
Here's a toy example of my_graphics_obj1
class GraphicsObject
{
virtual void CreateTextures() = 0;
};
class StringTexture: public GraphicsObject
{
SDL_Texture* CreateTextures (/*params*/)
{
// do rendering and what not
return A_SDL_Texture*;
}
};
Ideally, I'd be able to access CreateTextures() using the tuple graphical_objects.
Is this even possible ?
I have googled just about every possible word combination of 'member','tuple','variadic template', 'extract elements from' and 'declare using' I can think of.
I'm fairly sure it's not this question or this one
I won't link to all the posts I've looked at, to save all concerned some time.
I feel the answer is something simple, or I've got it totally wrong, and it's a lot more involved.
I do have access to C++17, at the moment I'm compiling with clang (for nicer error messages) but that's at C++14 at the mo. A solution in both/either would be fine.