Thanks a lot.
Unfortunately I am not using c++11 so I can not use those solutions.
I get 'error C3861: 'decltype': identifier not found' for the second solution.
Do you have the solution that works for in Visual studio 2008?
I appreciate your help.
Last edited by dshawul; November 21st, 2012 at 04:13 AM.
of course, you need to specialize the trait for each possible parameter type. It would be easier if Scalar,Vector,Tensor had some high-level info in them ( like a rank grading ), in this way the trait could compute the grad_type automatically at compile time.
Anyway, I think emulating "auto"/"decltype" is possible in this case via some template machinery like SFINAE, but I wouldn't advise it if you don't know what you're doing ...
moreover, another simple solution could be to refactor the code, if possible; something like
You are a life saver. I will use the traits method for now.
Scalar,vector and tensor are 1st,2nd and 3rd rank tensors but they are of completely different types represented by
double, double, and double. So I don't think I can automatically compute them. But anyway it is important to know
the higher or lower ranks in many places of the code so I will use that.
Last edited by dshawul; November 21st, 2012 at 05:48 AM.