Implementing variadic min / max functions

后端 未结 6 1869
灰色年华
灰色年华 2020-12-14 06:06

I\'m implementing variadic min/max functions. A goal is to take advantage of the compile time known number of arguments and perform an unrolled evaluation (

6条回答
  •  醉梦人生
    2020-12-14 06:44

    You cannot bind a temporary to a non-const reference, that is why you probably get the compilation error. That is, in vmin(3, 2, 1, 2, 5), the parameters are temporaries. It will work if you declare them as for example int first=3,second=2 and so on, then invoke vmin(first,second...)

提交回复
热议问题