Boost logo

Boost :

Subject: Re: [boost] Boost.Hana - Type Classes, data types and categories (tags).
From: Benedek Thaler (thalerbenedek_at_[hidden])
Date: 2014-09-20 11:13:53


On Sat, Sep 20, 2014 at 5:03 PM, Louis Dionne <ldionne.2_at_[hidden]> wrote:

> Niall Douglas <s_sourceforge <at> nedprod.com> writes:
>
> > namespaces can be used for disambiguation, but they are actually much
> > more useful and powerful than that. You can map namespaces into other
> > namespaces, mash up namespaces into customised variants and with
> > template aliasing you can now easily metaprogram namespacing too, so
> > you could have the results of a Hana operation cause one set of
> > things to be mapped into some destination namespace as against
> > another set of things. And then, you see, a bind() function can
> > actually have metaprogrammed meaning and implementation which is not
> > only neato, but very intuitive for the end user.
>
> I'm not sure I understand you. I do understand how we can map namespaces
> into
> other namespaces:
>
> namespace A { }
> namespace B = A;
>
> I also understand how we can mash up namespaces:
>
> namespace A { }
> namespace B { }
> namespace mash {
> using namespace A;
> using namespace B;
> }
>
> But I don't understand how template aliases come into play and give me more
> flexibility. Would you care to give a basic example of what you meant?
>
> Thanks,
> Louis
>

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
}

Benedek

>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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