// Use of the Select template struct for selection anmong a number of different types. // Select corresponds to the switch control structure. #include #include #include "select-stuff.cc" // Integer::type is an integer type of N bytes: (4ed, page 782) template struct Integer{ using Error = void; using type = Select; }; int main(){ using namespace std; typename Integer<1>::type i = 65; // similar to: unsigned char i = 10; // 'A' typename Integer<2>::type j = 66; // similar to: short int j = 8; cout << "i: " << i << " of size: " << sizeof(i) << endl; // i: A of size 1 cout << "j: " << j << " of size: " << sizeof(j) << endl; // j: 66 of size 2 }