I have a data-structure and a processor-class for the data, the data is stacked without pointers for faster SIMD processing:
struct trajectory_data {
float position[3];
float velocity[3];
float acceleration[3];
...
};
class trajectory_processor{
private:
vector<trajectory_data> tdata;
vector<trajectory_data> default_data;
...
};
But I fail to actually add a data-set to the vector, neither of those work:
trajectory_processor::trajectory_processor(){
// gives error: no match for ‘operator=’ in ...
trajectory_data d0();
default_data[0] = d0;
// gives error: no matching function for call to
// ‘std::vector<trajectory_data>::push_back(trajectory_data (&)())
trajectory_data d1();
default_data.push_back(d1);
};
According to push_back reference and C++ vector push_back I assumed this should be easy, but even after several google searches I just can't find any answer.
This project involves cross-coding in html/javascript and I seem to hit a wall like this one every time I switch back to c++, it starts wearing on my nerves.
You seem to be a victim of the Most Vexing Parse. Basically, the line
trajectory_data d1();
is actually declaring a function d1 that takes no argument and returns a trajectory_data
object.
Changing it to
trajectory_data d1;
should fix your problem, same for d0
. The default constructor will be called anyways, no need for the ()
.
Try this: default_data.push_back(trajectory_data());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With