Anders Logg wrote: > On Tue, Sep 29, 2009 at 12:42:54PM +0100, Garth N. Wells wrote: >> >> Anders Logg wrote: >>> On Tue, Sep 29, 2009 at 07:39:01AM +0100, Garth N. Wells wrote: >>>> Is there a reason why the MeshFunction.get(..) functions return by value >>>> rather then reference, e.g. it is currently >>>> >>>> inline T get(const MeshEntity& entity) const >>>> >>>> rather than >>>> >>>> inline T& get(const MeshEntity& entity) const >>>> >>>> Garth >>> Yes, we have a set() function for setting the values. >>> >> I know, but I would like to get a reference rather than copying data >> >> unsigned int index = 3; >> const std::vector<double>& vec = mesh_function.get(index) >> >> I can do this when I have the MeshEntitiy, but not when using the index. > > Does it work if you do > > &vec[0] = mesh_function.values(); >
Probably, bit it's not what I want. I have a std::vector attached to mesh entities (MeshFunction<std::vector<double> >). I want a reference to the std::vector attached to a particular entity std::vector<double> vec& = mesh_function(my_entity); is fine, but std::vector<double> vec& = mesh_function.get(my_index); is not. Back to my question: Is there a reason why MeshFunction::get returns by value and not by reference? Garth > ? > > > -- > Anders > > > ------------------------------------------------------------------------ > > _______________________________________________ > DOLFIN-dev mailing list > [email protected] > http://www.fenics.org/mailman/listinfo/dolfin-dev _______________________________________________ DOLFIN-dev mailing list [email protected] http://www.fenics.org/mailman/listinfo/dolfin-dev
