dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #08432
Re: Use of explicit
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.
On Tue, Apr 29, 2008 at 9:22 AM, Martin Sandve Alnæs <martinal@xxxxxxxxx> wrote:
> Without it, the constructor may be automatically transformed to an
> operator= for the same type. Take for example this code:
>
> class A
> {
> public:
> A(int N) { x = new real[N]; }
> ~A() { delete [] x; }
> };
>
> A a(100);
> a = 200; // legal without explicit above
>
> which will lead to disaster.
>
> --
> Martin
>
>
> 2008/4/29 <kent-and@xxxxxxxxx>:
>> > All constructors with a single argument.
>> >
>> > --
>> > Martin
>> >
>> >
>>
>> Why ? What does it mean ?
>>
>> Kent
>>
>>
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
>
Follow ups
References