Better way to say x == Foo::A || x == Foo::B || x == Foo::C || …?

前端 未结 8 693
醉酒成梦
醉酒成梦 2021-02-07 03:23

Let\'s say I have a bunch of well-known values, like this (but const char * is just an example, it could be more complicated):

const char *A = \"A\"         


        
8条回答
  •  萌比男神i
    2021-02-07 03:49

    If not switch, maybe something like this, I didn't use it, but may be a draft to something working?

    template 
    bool average(ReturnType expression, int count, ...)
    {
      va_list ap;
      va_start(ap, count); //Requires the last fixed parameter (to get the address)
      for(int j=0; j

提交回复
热议问题