
On 9/21/06, Neal Becker <ndbecker2@gmail.com> wrote:
Maybe I'm missing something obvious. How do I get a compile-time constant for the numDim from a multi_array?
For example:
template<typename matrix_t> void F (matrix_t const& m) { typedef typename matrix_t::value_type value_type; const int dim = ???
Maybe I'm missing something too, but I couldn't find member for that. Is there some reason you aren't doing: template<typename T, int Dims> void F(boost::multi_array<T, Dims>& m) { typedef T value_type; const int dim = Dims; } Alternatively, you could use this class: template<typename Matrix> struct get_dims {}; // partial template specialization template<typename T, int Dims> struct get_dims<boost::multi_array<T, Dims> > { const int dims = Dims; }; template<typename matrix_t> void F (matrix_t const& m) { typedef typename matrix_t::value_type value_type; const int dim = get_dims<matrix_t>::dims; // ... Which perhaps is a little more flexible. Kevin Spinar