I want to have code included in a function based on a compile time constant value, but static_if is not a construct in C++.
So I can write functions like this
class TA {
public:
template<bool flag>
void func() {
if(flag)
a++;
}
int a;
};
int main() {
TA a;
a.func<true>();
a.func<false>();
}
And I want to have a guarantee that the compiler makes two functions. One where 'if(flag) a++' is compiled into the function and one where it is not.
Is it possible to get this guarantee based on the C++17 standard, or am I at the mercy of the compiler vendor?
Thanks.