I guess Elysia meant something like this:
Code:
#include <iostream>
using namespace std;
unsigned combine_small_values(int a, int b)
{
return a | (b << 16);
}
template <unsigned a, unsigned b>
struct combine_small_values_at_compile_time
{
static const unsigned value = a | (b << 16);
};
int main()
{
int n = 2, nn = 1;
switch (combine_small_values(n, nn)) {
case combine_small_values_at_compile_time<1, 2>::value:
cout<< "n was 1 and nn was 2." <<endl;
break;
case combine_small_values_at_compile_time<2, 1>::value:
cout<< "n was 2 and nn was 1." <<endl;
break;
default:
cout<< "n wasn't 1 or 2 and neither was nn." <<endl;
}
}
Perhaps also try something along the lines of:
Code:
if ((n == 1 || n == 2) && (nn == 1 || nn == 2)) {
cout << "n was " << n << " and nn was " << nn << ".\n";
}
else {
cout << "n or nn was neither 1 nor 2.\n";
}