Topic: can publish non-type arg from template class?


Author: ajb@panix.com (Atman Binstock)
Date: 1995/10/19
Raw View
C++ allows you to publish class-type template arguments
to class templates:
template<class T> struct X {
 typdef T the_type;
};

Will the C++ std allow a way to do this with non-type
template arguments?

The only two ways I can think of are:

template<int I> struct X {
 enum { the_int = I };
};
Drawback: can't do floats, let alone user-class types

template<int I> struct X {
 static const the_int = I;
};
Does this work?
Drawback: need to define the_int somewhere.
Will this work for an arbitrary user-defined class?


Thanks,
Atman Binstock
ajb@panix.com
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]