← Back to team overview

dolfin team mailing list archive

Re: Use of explicit

 

2008/7/8 Garth N. Wells <gnw20@xxxxxxxxx>:
>
>
> Anders Logg wrote:
>> On Thu, Jun 26, 2008 at 02:55:30PM +0200, Andy Ray Terrel wrote:
>>> You probably don't need the explicit keyword for copy constructors as
>>> done in Functions.h , PetscMatrix.h, uBlasMatrix.h, EpetraMatrix.h.
>>> This has the added effect of not being able to pass functions as
>>> arguments (perhaps that is bad but anyhow).  Having just pulled this
>>> seemed to make my code a bit unhappy.
>>
>> You should not need to have a copy constructor to pass a Function as
>> argument (at least by reference or as a pointer). Or are you passing
>> it by value? That's probably not a good idea since it would involve
>> copying the entire mesh as well as the vector of dofs.
>>
>
> This has become an annoyance for me because I do want to pass a Function
> by value (I really do want a copy) and I can't do
>
>   Function f(mesh);
>   std::vector<Function> F;
>   F.push_back(f);
>
> when explicit is used.
>
> Garth

Then remove the explicit keyword. I may have added it in too many places.
The point is to avoid strange situations leading to memory leaks and the like.

-- 
Martin


Follow ups

References