Here are my 2 structs to demonstrate my question. I have a table that has a vector of columns
struct column{
string col_name;
int index;
};
struct table{
vector<vector<stuff>> rows;
vector<column> columns;
};
What I want to do is search if one of my table objects has a column with string col_name I'm interested in.
I'm trying to use std::find, but I'm having a hard time putting the syntax together.
Say I have
vector<table> all_tables;
How would I search a table (lets say table at index 0) to see if it contains bacon as the col_name?
So far I have
find(all_tables[0].columns
And that's where I'm stuck. columns is a vector, and it wants an index, but I'm not sure what index to give. Do I just do columns.begin()? That doesn't seem to be correct since I have multiple member variables. I really want to be looking at the beginning of columns and the end of columns to find if it has the correct string (not int index) I'm interested in.
I understand the syntax for find is usually find(v.begin(), v.end(), "bacon"), but I don't know how to use it when it's in this scenario.
I would appreciate some help. Thank you!
----example-----
I have a table with 3 columns named "pie", "apple", and "bacon" respectively. So the size of vector columns is 3 inside my table struct. I want to be able to, given simply the table index, search through its column vector if it contains a column with the name I'm interested in.