Preprocessor and template arguments or conditional compilation of piece of code

前端 未结 4 953
抹茶落季
抹茶落季 2021-01-18 19:05

How I can compile template function with pre-processor condition? Like that (but it is not working):

template 
void f()
{
    #if (var == tru         


        
4条回答
  •  無奈伤痛
    2021-01-18 19:15

    You can't. The preprocessor, as this names indicates, processes the source file before the compiler. It has therefore no knowledge of the values of your template arguments.

提交回复
热议问题