Using template instead of switch

前端 未结 5 1192
眼角桃花
眼角桃花 2020-12-13 22:42

I want to perform a set of tests in my code that are similar but change only depending on a parameter.

I could write this using a switch statement:

b         


        
5条回答
  •  情书的邮戳
    2020-12-13 23:04

    It is impossible to use templates in the following case:

    const  EnumSensorFamily familyCompileTime = FAM3; // Compile time constant
    EnumSensorFamily family = GetFimilyInRunTime(); // Run time variable
    doTest1(family, proposed); // ok
    doTest2(proposed); // error;
    doTest2(proposed); // OK;
    

提交回复
热议问题