Boost logo

Boost Users :

From: Tanton Gibbs (thgibbs_at_[hidden])
Date: 2002-12-19 01:11:00


I'm trying to create a template class based on user input. For example:

template< int i, int j, int k > class T {};

int main() {
  int i, j, k;
  cin >> i >> j >> k;
  T<i, j, k> t;
}

Naturally, this is not possible, as i, j, and k must be constants. Therefore, I would like to limit the maximum value of i, j, and k to 100 and create all permutations for T<i,,j,k> at compile time. Basically, something like this:

int main() {
  int i, j, k;
  cin >> i >> j >> k;
  if( i == 0 && j == 0 && k == 0 ) {
    T<0,0,0> t;
  }
  else if( i == 0 && j == 0 && k == 1 ) {
    T<0,0,1> t;
  }
  ...
  else if( i == 100 && j == 100 && k == 100 ) {
    T<100,100,100> t;
  }
}

Naturally, I don't want to type all that in myself, so I was hoping the boost preprocessor library could do it for me. If someone knows of a way to do it, please let me know.

Thanks!
Tanton

[Non-text portions of this message have been removed]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net