"if" evaluated at compile time

Hello to everybody
Is there any way to have an “if” test evaluated at compile time?
I would like to have the following type of code to work

int n=30;
mesh Th=square(n,n);

int algo=2; // possible values 1,2,3

if (algo==1){
fespace Uh(Th,P1);
fespace Ph(Th,P0);
}
else if (algo==2){
fespace Uh(Th,P2);
fespace Ph(Th,P1);
}
else if (algo==3){
fespace Uh(Th,P2);
fespace Ph(Th,P1dc);
}
else {
cout << "undefined algorithm " << endl;
}

Uh u,v,uu,vv;
Ph p,pp;

// etc

This produces an error at compilation: “Uh The Identifier Uh does not exist”.
It seems that at compile time the “if” is not evaluated, and the “fespace” declaration is not applied.
Any solution to be able to do such multi-task coding ?
Thank you.

You should use macros

macro algo(      )2// End Of Macro  

IFMACRO(algo,1)
fespace Uh(Th,P1);
fespace Ph(Th,P0);
ENDIFMACRO
IFMACRO(algo,2)
fespace Uh(Th,P2);
fespace Ph(Th,P1);
ENDIFMACRO

Thank you, this is very helpful in order to avoid having many codes with similar content!
Best,
Francois.