I'm trying to hiper-optimize a code and i find that the program would run like 10% faster if i separate an action in 2 parts in case the programer want to run the method in true or false, so i tried to do this:
template<bool way> void action(){
#if way
cout << "Do true actions" << endl;
#else
cout << "Do false actions" << endl;
#endif // way
}
int main()
{
action<true>();
action<false>();
return 0;
}
But of course when i compile this code it prints:
Do false actions
Do false actions
Of course a way to do this would be do 2 different functions but in my code this would significantly increase the number of functions just for one boolean. So, how can i do this? (Pass arguments of a template to a preprocessor #if)