I'm implementing a N-dimensional array library. Consider this code:
template<int Rank, class Type>
class Array {
{
public:
// constructor for vectors, valid when Rank==1
Array(int dim0, Type val = Type());
// constructor for matrices, valid when Rank==2
Array(int dim0, int dim1, Type val = Type());
...
}
The problem is that if Type == int
, the compiler will complain about ambiguous constructor call (for example, Array<1,int>(1,1)
). Is there a trick like enable_if
that makes the compiler ignore constructors that don't match Rank
? (without C++11 please)
Thank you