I have following class
template<class T> class CT
{
T& operator()(int i,int j) const noexcept
{ return indx[i*N+j]; }
private:
T *indx;
int N;
};
Now some where in my application I have something as the following
CT<double> arr, (...);
(...)
decltype(arr) *alias;
if(usearr)alias = &arr;
(...)
alias(0,0) = 3.0; // Compiler ERROR!
The compiler complains that the object type I am accessing through decltype
is not a function or function pointer.
The problem can be solved if I remove the pointer in declaring alias
and replaces the line to an assignment overload
decltype(arr) alias;
if(usearr)alias = arr;
What is wrong with the former approach ?
Aucun commentaire:
Enregistrer un commentaire