Reputation: 4937
I have code that kinda looks like the following:
#include <array>
class DoubleArray: std::array<double, 16> {
public:
void clear() {
fill(0.0);
}
};
Now I would like to use the size of the std::array
as a compile time constant. If DoubleArray
was just a typedef
to std::array
I could use std::tuple_size<DoubleArray>::value
but using inheritance instead I get the following compiler error:
error: incomplete type ‘std::tuple_size<DoubleArray>’ used in nested name specifier
I have seen tuple_size and an inhereted class from tuple? but since that only talks about std::tuple I don't think it can be applied. Any ideas why this doesn't work and if there is an easy way to make it work?
Upvotes: 2
Views: 648
Reputation: 11116
Just call size()
- for arrays it is a constexpr
.
See here: http://en.cppreference.com/w/cpp/container/array/size
or check § 23.3.2.1.3 where it is defined as constexpr size_type size() noexcept;
Upvotes: 0