www.digitalmars.com         C & C++   DMDScript  

c++ - template parameter non-type deduction

Can't find a directly relevant section on this other than 14.8.2.4, but that
seems restricted to function templates. This is used in a low level boost lib.

#include <cstddef>

template <typename T> struct A { };

template <typename T, std::size_t N> struct A<T [N]> { };

void main() {

std::size_t bound = 3;

typedef int B[bound];

A<B> a;
// Error: template-argument 'N' has no value
// in template function specialization
}

The standard is pretty clear on this for function argument deduction (that array
type and array size may be deduced from well formed array syntax), but iffy on
class template parameter deduction, and other resources seem undecided. But a
code fragement like this probably works for VC++, Borland, etc (as in their are
no preprocessor exclusions based on compiler type). In any case, DM is unable to
produce an explicit definition that is based on a deduced non-type parameter.
Any one have some previous dealings with something like this?

Richard
Jan 12 2003