The OpenFOAM library defines two types, volMesh
and surfaceMesh
, both of which inherit from GeoMesh<fvMesh>
. I want to define a function that accepts an argument:
void foo(GeometricField<vector, fvsPatchField, GeoMesh<fvMesh> >& field) { ... }
However, g++ gives the error "invalid initialization of reference type" when I try to call the function:
// surfaceVectorField is a typedef GeometricField<vector, fvsPatchField, surfaceMesh>
surfaceVectorField Uf( /* initialisation arguments */ );
foo(Uf);
Coming from a Java background, this problem seems similar to forgetting to use a declaration such as
void foo(GeometricField<vector, fvsPatchField, ? extends GeoMesh<fvMesh>> field) { ... }
I need to avoid C++11-specific features if possible.