I am stuck on a logic problem.

I have the following struct:
Qt Code:
  1. struct MeasurementData
  2. {
  3. bool complete = false;
  4. std::bitset<3> mode;
  5. std::bitset<12> frame_counter;
  6. std::bitset<16> expo_time;
  7. std::bitset<16> expo_time_max;
  8. std::bitset<24> ntc_val0_ref_2_4V;
  9. std::bitset<24> ntc_val0_ref_2_1V;
  10. std::bitset<24> ntc_val0_temp_2_4V;
  11. std::bitset<24> ntc_val0_temp_2_1V;
  12. };
To copy to clipboard, switch view to plain text mode 

Where the field frame_counter is a progressive number incremented after each measurement (starting from value 0).
To fill in the fields of the structure I analyze an input file where each row contains the values that I have to insert in the structure.
So I create a vector of structures and I create a new struct each time I parse a new row

Qt Code:
  1. std::vector<MeasurementData> frames;
  2. std::string line;
  3. while (std::getline(input, line))
  4. {
  5. processLine(line, frames); // <- Here I create a new struct instance and add it to the vector
  6. }
  7. input.close();
To copy to clipboard, switch view to plain text mode 

My need is to find the missing frame_counter values when processing the corresponding file line

For example:
In my file I have 48 rows, this implies the creation of 48 struct instances and the frame_counter should start at 0 and end at 47 but in my case I have 3 missing measurement

frame_counter = 0 is missing
frame_counter = 9 is missing
frame_counter = 12 is missing

I determine it by postprocessing the vector of structs. Is not what I want, I would determine it at the "file line processing" time but I can not find a good logic that solves my problem.

Below is how I do it now:
Qt Code:
  1. std::vector<MeasurementData> frames;
  2. std::vector<int> counters;
  3.  
  4. for (const auto& frame : frames) // frames is my structs vector
  5. {
  6. int counter = (int)(frame.frame_counter.to_ulong());
  7. counters.push_back(counter);
  8. }
  9.  
  10. // And search for missing frames (assuming vector is ordered)
  11. for (int i = 0; i < counters.size(); i++)
  12. {
  13. if (!std::binary_search(counters.begin(), counters.end(), i))
  14. {
  15. std::cout << "Frame " << i << " is missing" << std::endl;
  16. }
  17. }
To copy to clipboard, switch view to plain text mode