vendredi 8 septembre 2017

simpliyfy C++ if else for multiple condition for range of values

I have multiple C++ if else conditions for checking range of certain variable and call function with same signature like

    if (x < 100 )
{
 call_1();
}
else if (x < 500 )
{
call_2();
}
else 
{
call_3();
}

Is any standard library or structure available so that I can map range and function which can be extended w/o touching conditional statements.?

Aucun commentaire:

Enregistrer un commentaire