Re: [eigen] private copy ctors |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] private copy ctors
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Mon, 14 Dec 2009 06:25:44 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=ZpSpISgL91OXjRW6jeQqGXAiPcztzWcx7Rzwexmuta8=; b=GcO0rBBEr828YOt4M2xDI0amLmz9sLLLWdd7nf2IuRlG8P1NylVV0PAK9/6PkTKt/Y /jcHVcJxoZEh/G1RMill9zFWkHlLhut/dWP8vznCZSKbmxUzNz+h4Dv5qhM7WvommoR6 ufVXODMxapZJvC8ktiVrerU8GDSqxLcSt8gVE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=BRUDegK6Q4Fhae/Dek/4V+JkGy185HwJdUgTclx+4rYo+GSY5E6SrNRlNaRnV2kCiL mdTRjGu4GTcp/mYEsWL9QyE+IvZb1htm8NCU1KUkcLtGjuJgGjKjX/mpLw+bwvVbqMEa N/6sifdDtGz4XVHQyAYUvlc5XPYZkpaUAGel8=
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