I have a manager class, allows the user to create components via a public interface. The use can specify the component type, and pass in the construction arguments to the manager class, which will create the component object.
However I am trying to restrict the user from creating certain component type, so their specialisations are private. But because the component type is not a function argument, I can’t figure out how to specialise it.
I am getting the error non-class, non-variable partial specialization 'add_component<transform, Args ...>' is not allowed
.
class ecs_manager {
public:
// Allow users to add components via a public interface.
template<typename T, typename... Args>
T *add_component(ecs_id_t _entity, Args &&... _args) {
return get_or_create_pool<T>()->add_component(_entity, std::forward<Args>(_args)...);
}
private:
// But there are certain components that should only be added by the manager.
// So we put the specialisations in private.
template<typename T, typename... Args>
transform* add_component<transform, ...Args>(ecs_id_t _entity, Args &&... _args) {
return get_or_create_pool<transform>()->add_component(_entity, std::forward<Args>(_args)...);
}
};