All Questions
Tagged with entity-component-system templates
14 questions
1
vote
2
answers
74
views
Template function with variadic arguments speciaization
Is it possible somehow to do template function specialization like this:
template<typename T, typename... Args>
void Func(size_t id, Args... args) { std::cout << "1\n" }
...
0
votes
0
answers
20
views
How to cast a unique_ptr of base class to template derived class?
I have a base class for components and a derived class for my ECS arch. I need to store different types of values so my derived class is a template class.
Base class & template derived class :
...
1
vote
1
answer
30
views
No matching function call insert for unorded_map containing shared pointer templates
I am trying to implement a toy ECS for a hobby engine, and am following a small tutorial to kick-start it. An extremely bare-bones implementation using the tutorial is the following
#pragma once
#...
0
votes
1
answer
379
views
Wrapper over a templated class with more than one template parameter pack
I'm writting a thin wrapper over a class from a third-party library.
My code looks like this:
template<typename TArg1, typename... TPack1, typename... TPack2>
class MyWrapper<TArg1, TPack1...,...
1
vote
1
answer
211
views
How to get all derived classes from a base class in C++?
I'm implementing a game engine in C++ which uses an ECS (Entity-Component-System).
Each GameObject can have multiple Components (stored in GameObject's std::vector<Component*> _components).
I ...
2
votes
2
answers
933
views
C++ How to cache a variable of template type T in a class?
Suppose that I have a Foo class like this, and I need many instances of it.
class Foo {
public:
Pool* bars; // a global list of bars, each may have a different type
template<typename T&...
0
votes
0
answers
61
views
Templated function static members
I'm currently working on an entity-component system in which I need to create unique IDs for different component types, preferably without storing any additional data in the component class (as that ...
0
votes
1
answer
125
views
How to use a templated alias or const variable to abbreviate a static const variable?
I am writing an entity component system as an exercise with C++17. I'd like to have each component type, represented as a struct, to be associated with a unique identifier that may be used as a index ...
0
votes
1
answer
210
views
How do I iterate over/get static members from the variadic template types in a function with no arguments?
I need to write a function for an ECS that takes in a variable number of template parameters (Components) and no arguments and will return a list of entities with those components attached.
The format ...
0
votes
2
answers
173
views
Creating a unique id by combining different types
I want to create a unique id by "combining" types. The order of input types shouldn't matter and inputting the same combination of types should always return the same id (in the same runtime)...
0
votes
0
answers
396
views
initialize a union with template parameter packs
I'm writing an engine with ECS and the data-oriented model. I'm trying to avoid inheritance and dynamic dispatch to avoid trashing the cache with every update() call. What I came up with was this:
...
1
vote
2
answers
2k
views
Template classes and calling different constructors depending on iteration
I am learning ECS and I am now trying to implement components for my project.
So to put you in context, I have an aquarium, and many components in it (let's say seaweeds and fish). Both have an age, ...
0
votes
0
answers
60
views
Using an external class in templated method from dll
I'm trying to use my game engine into an external project. Everything works fine but I have a problem when I'm trying to create a custom component (That inherits from ABhaviour which is an abstract ...
2
votes
1
answer
2k
views
c++ entity component system and accessing components using a template
I've been working on creating my own entity component system, and I'm set on being able to get a component by doing the following:
const auto& component = entity->GetComponent<ComponentType&...