Re: [eigen] std::swap doesn't work on Map

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


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
> namespace
> 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.

Cheers,
Benoit

>
>
>



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