I have a struct as defined below
struct valindex {
int x;
int y;
valindex(int val, int index) : x(val), y(index) {}
};
I'm getting an error when trying to initialize a vector of this struct
vector<valindex> vals() // this works fine
vector<valindex> vals(20) // throws the error mentioned below when the size is specified
required from 'static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = valindex*; _Size = long unsigned int; bool _TrivialValueType = false]'
Can someone explain the cause of this error and provide a solution?
Thanks!