D
digz
#include<cstdio>
template <int role>
struct A
{
void f(){
switch(role) {
case 0:
case 1:
printf("did match\n");
default:
printf("did not match\n");
}
}
};
int main()
{
A<0> a;
A<1> b;
}
This is a simplified representation of a C++ program I came across.
Can someone explain any possible motivation behind this kind of a
construct and what feature of templates has been used while writing
this class. Also is the switch case evaluated at compile time. ? and
as I have said in the subject whats role here , a variable of a
template type or what ?
--Digz
template <int role>
struct A
{
void f(){
switch(role) {
case 0:
case 1:
printf("did match\n");
default:
printf("did not match\n");
}
}
};
int main()
{
A<0> a;
A<1> b;
}
This is a simplified representation of a C++ program I came across.
Can someone explain any possible motivation behind this kind of a
construct and what feature of templates has been used while writing
this class. Also is the switch case evaluated at compile time. ? and
as I have said in the subject whats role here , a variable of a
template type or what ?
--Digz