I have a simple yet daunting problem I can\'t solve by myself. I have something like
template
T* create(SomeCastableType* args,
Suppose
SomeCastableTypeis castable to any type. Obviously what I can't get is thatINDEX_OF_EXPANSION.
Since C++14, you can do the indices trick @Xeo mentioned with the support from the standard library, by using the std::make_index_sequence helper, as follows:
template
T* create(SomeCastableType* p, std::index_sequence)
{
return new T(static_cast(p[Is])...);
}
template
T* create(SomeCastableType* p, std::size_t num_args)
{
return create(p, std::make_index_sequence());
}