I am creating a template class and inheriting std::vector. Along with all the constructors of std::vector
, I want to overload the constructor of the derived class with a custom class. However when I do this, I get the compilation error for the default constructor call.
Code below:
template<typename T, unsigned int N>
class _std_vector : public std::vector<T>
{
public:
using std::vector<T>::vector;
_std_vector(const MyCustomClass& that)
{
//Do Something
}
}
And I call as follows:
MyCustomClass my;
_std_vector<int, 8> sv{ my};
The above works fine the moment I overload the constructor. However the default non parametrized constructor gives compilation error.
Error C2512 '_std_vector< int,8>': no appropriate default constructor available
_std_vector <int, 8> svv; //This works fine until I add _std_vector(const MyCustomClass& that)
However please note, all the other parametrized constructor of std::vector
seem to compile fine.
Am I missing something here?