Boost logo

Boost :

From: Alan Griffiths (alan_at_[hidden])
Date: 2000-04-08 10:33:51


In message <B5148158.3DF7%abrahams_at_[hidden]>, Dave Abrahams
<abrahams_at_[hidden]> writes
>on 4/8/00 11:12 AM, Alan Griffiths at alan_at_[hidden] wrote:
>
>>>> namespace std {
>>>> swap(viewType &a,viewType &b)
>>>> {
>>>> a.swap(b);
>>>> }
>>>> }
>>>>
>>>> I've been following a discussion in C.L.C++.M on swap and I'm confused. Is
>>>> it illegal to make more std::swap() specializations?
>>
>> No this is fine - although adherents of option "A" (below) would
>> probably advise against since it is inconsistent with the more general
>> case.
>>
>> It is overloading that is illegal. That is:
>>
>
>I think that technically the original code _was_ an overload (note that
>template<> is missing).

Agreed, I saw what I expected - not what was there. The original is
also missing a return type!

The original code isn't acceptable, but (what I was)...

    class viewType;

    namespace std {
        template<>
        void swap(::viewType &a, ::viewType &b)
        {
          a.swap(b);
        }
    }

...would be fine.

-- 
Alan Griffiths  (alan_at_[hidden])  http://www.octopull.demon.co.uk/
ACCU Chairman   (chair_at_[hidden])             http://www.accu.org/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk