Re: [eigen] private copy ctors

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


2009/12/14 mmoll <Markus.Moll@xxxxxxxxxxxxxxxx>:
> Zitat von Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
>> It would probably not complain but why would this be the cleanest
>> solution? Boost's noncopyable does exactly the same as I did -
>> private, unimplemented assignment (plus and copy ctor). You just move
>> the linker errors to the base class.
>
> Yes. The biggest advantage is that it documents what you're doing.
>
> class X : nonassignable
> {
>  ...
> };
>
> is much easier to understand than
>
> class X
> {
>   X& operator= (const X&);
>   ...
> };
>
> (you wouldn't even know whether or not it's defined!)

There's a potential practical problem however: if the class X already
inherited a base class, you now have multiple inheritance, and this
tells compilers "now you have a great pretext to go crazy and people
will blame multiple inheritance, not you". I can't speak specifically
for operator=, but I know that MSVC gave us very strange errors when
we tried to do that for overloading operator new. We had to go for a
macro EIGEN_MAKE_ALIGNED_OPERATOR_NEW instead of such a base class,
because of that.

Benoit



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/