|Re: [eigen] std::swap doesn't work on Map|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] std::swap doesn't work on Map
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 6 Apr 2010 07:03:47 -0400
- 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:received:message-id:subject:from:to:content-type; bh=TF1oUA14hxQa4UE2xQcFH0yPYP1of2eKPF+2EIA6VPA=; b=Nj8jmJ6TJbnqEhR3sTcwaP/nXOGkGmKsNQ/voI4XksHLFBcJTH2p5QNMkQtcNSF69G s4aAPrGit04d/3JGRMd4D2hF2ZJDK/vB1uMUqf9o7xCTTcxfZK66ZcXbaFOvMtyivW56 NAd7/f5DWDgig0YN+8eE42O8yBhIFTWRTqtKc=
- 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; b=E+wc64gKBjT96IPiKYr0za6+3qFjNycb8hEfOJiTWw8eLijP3Ji92VJ0zt2c4REee/ zQzddw6cxMdcpNJQ42BbIo1lLi2lAfgYL/h9v8TPydyrjM38Dq1vgHpIO3EMfv4TXDaP Q9gApFadVKKGnnv/h3cFhybFrJs/BjQJYaGLc=
2010/4/6 joel falcou <joel.falcou@xxxxxx>:
> Benoit Jacob wrote:
>> We already have a swap() that works well in Eigen, depending on two
>> template parameters. It has a different calling syntax: it is a member
>> function. a.swap(b).
> What I tell you is to have a eigen::swap(a,b) free function in eigen
> and promote its use in place of std::swap ;)
> Then you will be able to specialize it properly AND let ADL do its tricks.
Ok, thanks for your suggestion, actually I think I had understood it,
but I am coming from a different perspective. I was wondering: can I
fix std::swap or do I have to tell the user to do something else? If I
have to tell him to do something else, telling him to do a.swap(b); is
as good, from my perspective, as telling him to do Eigen::swap(a,b);
I think I understand where Boost is coming from: if the namespace
boost is "used" instead of namespace std, then the correct swap is
automatically used, which is great.
But in the case of Eigen, I want it to remain possible to do both:
using namespace std;
using namespace Eigen;
which means that I can't define a global swap() function, as it would
conflict with std::swap ! So I would have to call it ei_swap which
would defeat the point (the ability to switch swap functions just by
using a different namespace).
I guess this is where Eigen is different from Boost and can't do the same.