jeudi 5 novembre 2020

Convert a boring list of switch statements to something shorter and pleasing to look at?

I have a switch statement that runs like this

switch (abc) {
  case FILE_0:
       lf = m_a->olf[0];
       kf = m_a->pkf[0];
  case FILE_1:
       lf = m_a->olf[1];
       kf = m_a->pkf[1];
  .
  .
  default:
}

This happens about 30 times and i end up with 30 cases in this single switch. Any way to shorten it in C++ 11 ? E.g. using templates.

Aucun commentaire:

Enregistrer un commentaire