Convert templated class into vector
First sorry for creating a new thread but I could not find what I was looking for.
I'm creating a new boundary and the boundary should be build up as templated version so to make it usable for any kind of quantity. The problem now is that I would like to do a coordinate transform to the velocity.
Therefore I need to grab the internal field like
Field<Type> iField = this->internalField();
In a next step I wanted to create a vectorField if "Type" is vector
Field<vector> myField = iField;
As you may probably already notice this want work since iField is templated so it can't be given to a vector field since the compiler doesn't know that my if-statement only allows the operation if Type==vector.
Has anybody an idea how to circumvent this problem?
You are correct. Since things are templated, you would normally not like that. What you need is a template specialization for the type vector that implements what you want. If you haven't worked with this before, it may take you a few attempts to get it going. The important points:
From the UList.H:
In your particular case, you can either specialize the entire method for various vector, or factor it out as a private method. In either case, you can view the specialization as being a compile-time version of an 'if' or a 'switch'.
I hope this helps you get going.
|All times are GMT -4. The time now is 20:18.|