Boost logo

Boost :

Subject: Re: [boost] Boost.Hana - Type Classes, data types and categories (tags).
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2014-09-23 07:25:45


On 20 Sep 2014 at 17:13, Benedek Thaler wrote:

> I'm not sure what Niall is referring to, but namespaces come into handy
> when using the swap trick described in effective STL:
>
> template<typename T>
> library_function(T& a, T& b)
> {
> using std::swap;
> swap(a,b); // will use specialized swap in namespace of T if available
> }

I'm not a fan of publicly exposed ADL usage personally. It's too
brittle - the non-specialised swap may get called inadvertently and
performance suffer in a highly unobvious way to detect. For example,
if T is not perfectly a type in namespace X (e.g. it's a trivial
descendent), any X::swap() will *not* get invoked even when it would
make absolute sense.

I am personally a huge fan of when expected optimisations fail to
apply, it should never be silent. Preferably a compile time error,
but I am not adverse to an abort() either.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



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