This is a continuation off of this original question here: Original Question that was focused more towards a design decision. This question is more to the actual how to towards the implementation if it can even be done.
I have this in my current source:
template <typename ClassType,typename... Dimensions>
class DimensionPack {
public:
typename std::tuple<ClassType, std::tuple<Dimensions...> >::type Dim;
const unsigned int numarguments = sizeof...(Dimensions);
};
That would be used with a series of classes that are related with the following prototypes:
template<typename ClassType, typename... Args> class MatrixReference;
template<typename ClassType, typename... Args> class MatrixStorage;
template<typename ClassType, typename... Args> class MatrixAllocation;
I have already been asked why couldn't I just use std::size_t...
After considerable thought I'm still leaning towards using the variadic parameter pack with the helper template that would store it into an std::tuple
to help pack and unpack the parameters. Also I have a need to test these parameters to be in the range of {x; x > 0}
so they must all be + integers. So the parameter pack itself or the contents of it can be either std::size_t
or unsigned int
but they all need to be one or the other. I also need to test these parameters to check if their value is even or odd and to save those results into a container. The use of a helper function will do that for me.
Knowing this I'm leaning towards staying with the parameter pack so I can easily pass that pack as a reference from one template to another since the set of these templates will work together, and I can also pass the parameter pack to my helper function to test for odd and even values.
So the questions become:
- Can a parameter pack with
<typename... Args>
be restricted to a specific type such asstd::size_t
orunsigned int
? - If so, how can this be done?
- If not what are my options towards achieving this?