I'm writing a constructor and would like it to be defined for any type that implements [][]
for integral arguments. In other words the type T
must have T[]
defined and the type returned when using []
on T
itself also has []
defined, allowing for example, T[2][3]
to be called.
I know how to check for the existence of an overloaded operator using the answer here which shows the approach for operator==
, which can easily be extended to my case.
The issue however is that I'd like to check that the type of T[]
also has operator[]
.
As aforementioned, I also need to check that the arguments accepted by the overloaded operator[]
includes any integral type, so operator[](const T& i)
would have some T
which yields std::is_integral<T>::value
being true.
Obviously, the purpose is for me to allow the interface to accept anything that behaves like a matrix with the standard means of accessing its elements.