I have something like this:
template<typename PrimitiveType>
struct PackedVector
{
std::unordered_map<uint32_t, uint32_t> m_ID_to_Index;
std::unordered_map<uint32_t, uint32_t> m_Index_to_ID;
std::vector<PrimitiveType> m_Data;
void Add(uint32_t ID, PrimitiveType Type)
{
// Do stuff
}
void Remove(uint32_t ID)
{
// Do stuff
printf("Remove\n");
}
};
template<typename ...Args>
class RenderProxyClass
{
private:
std::tuple<PackedVector<Args>...> m_PrimitiveTuple;
public:
RenderProxyClass() = default;
void Remove(uint32_t ID)
{
std::get<PackedVector<int>>(m_PrimitiveTuple).Remove(ID);
std::get<PackedVector<double>>(m_PrimitiveTuple).Remove(ID);
std::get<PackedVector<std::string>>(m_PrimitiveTuple).Remove(ID);
}
};
using RenderProxy = RenderProxyClass<int, double, std::string>;
// Main
int main()
{
RenderProxy Proxy;
Proxy.Remove(0);
return 0;
}
This works, but I want to iterate over the tuple and call the remove function with each "arg" parameter type, instead of having to manually call ::Remove for each type.
I did something like this using folding expressions:
// Inside the PackedVector class
using Type = PrimitiveType;
// Inside the proxy class
void Remove(uint32_t ID)
{
std::apply([this, ID](auto&&...args)
{ ((this->Remove<typename auto::Type>(ID)), ...); } , m_PrimitiveTuple
);
}
But this doesnt compile and complains with:
'auto' was unexpected here; expected 'id-expression'
So what should I do to get the ::Type type?
Thank you
