Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Custom swap in std namespace (http://www.velocityreviews.com/forums/t450295-custom-swap-in-std-namespace.html)

Marcin Kalicinski 12-05-2005 10:59 PM

Custom swap in std namespace
 
Is it well formed C++ to define free swap function for my custom container
in std namespace?

cheers,
Marcin



Victor Bazarov 12-05-2005 11:15 PM

Re: Custom swap in std namespace
 
Marcin Kalicinski wrote:
> Is it well formed C++ to define free swap function for my custom container
> in std namespace?


Yes. You are allowed to _specialise_ any of 'std' templates for your
particular types.

V

red floyd 12-05-2005 11:36 PM

Re: Custom swap in std namespace
 
Victor Bazarov wrote:
> Marcin Kalicinski wrote:
>
>> Is it well formed C++ to define free swap function for my custom
>> container in std namespace?

>
>
> Yes. You are allowed to _specialise_ any of 'std' templates for your
> particular types.
>
> V


So, the first of the following two functions is OK, but not the second,
since the second is an overload and not a specialization?

class MyClass;

namespace std {
template<>
void swap<MyClass>(MyClass&, MyClass&);
}

namespace std {
void swap(MyClass&, MyClass&);
}



All times are GMT. The time now is 09:44 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.