- the code is taken from OpenCV 2.2 about nearest neighbour algorithm, flann.hpp. Need some help in understanding this line about usage of template and casting.
Below is my interpretation:
-the first <T> set the m_quries template type ie setting return type of function m_queries.
- the second T (T*) cast the queries.ptr as pointer type T
- the third <T> seem to suggest to define the class variable ptr as type T
Is that right? The compiler seem to have difficulty understanding the last <T>... I am using gcc 3.3.2
ptr is a (very much) overloaded member function of class Mat (queries is a variable of class Mat).
Some of these overloads are templated functions. template<typename _Tp> _Tp* ptr(int i0, int i1, int i2);
The line itself ::cvflann::Matrix<T> m_queries((T*)queries.ptr<T>(0), queries.rows, queries.cols); looks acceptable.
I wonder if it is because of the age of your compiler.
I know that at one time if you declared/define a template function member in a class that was not a template
class (class Mat is not a template class) then you needed to use the template keyword when
using that member function.
Was given an invalid use of class template error. At first, I supposed the problem requires the class template usage be explicitly declared. So I have used