I have a class like this:
template<std::size_t T, std::size_t... Args>
class A{
public:
std::array<int,summation<Args...>::value> x;
}
where summation
is defined as:
template<std::size_t size, std::size_t... sizes>
struct summation
{
static const std::size_t value = size + summation<sizes...>::value;
};
template<std::size_t size>
struct summation<size>
{
static const std::size_t value = size;
};
The problem is that when Args is empty (i.e., I only specify the T
template) the base case does not work and I get a compilation error message:
error: wrong number of template arguments (0, should be 1 or more)
How can I modify the recursion of summation
to also properly handle the case when sizeof...(Args)==0
and return a value of 0 for the summation in this case? I am using C++11. Thanks
Aucun commentaire:
Enregistrer un commentaire