I hope to inherit all the methods including constructors of std::array. I try
template<class T, size_t N>
class Vec : public array<T, N>
{
public:
using array<T, N>::array;
Vec operator+(Vec const& rhs) const
{
Vec res;
transform(begin(), end(), rhs.begin(), res.begin(), plus);
return res;
}
};
But got some compilation errors.
- 'begin': no matching overloaded function found
- I cannot do
Vec<int, 2> v{1, 2};
like std arrays even constructors are inherited.
I may misunderstand something. How to solve those errors. Any better ideas to add arithmetic operators on std::array. Thanks!