Preprocessor and template arguments or conditional compilation of piece of code

c++, c-preprocessor, templates

Solution

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.

Problem

How I can compile template function with pre-processor condition? Like that (but it is not working): ``` template <bool var> void f() { #if (var == true) // ... #endif } ```

Original source

Related problems