I have a vector of structs as follows. The struct holds the relevant data for a plot.
struct DATA_T
{
double x;
double y;
double z;
}
std::vector<DATA_T> results;
I need to be able to retrieve all the x
values within results vector and store them as a vector of doubles
I know that I could create these vector programmatically.
std::vector<double> x_values;
x_values.reserve(results.size());
for(auto const &data : results)
{
x_values.push_back(data.x);
}
However, I was wondering if there is a more concise solution. Perhaps using a similar approach to how I can search for specific data points using find_if
?