Boost logo

Boost :

Subject: Re: [boost] metaprogramming: associating a type with another type
From: DE (satan66613_at_[hidden])
Date: 2010-01-29 16:34:54


on 30.01.2010 at 0:06
 Matt Calabrese wrote :
> I can see this being very useful for traits class specializations (by that I
> mean the technique of using ADL to provide a type). As a practical example
> of why this is convenient in practice is Boost.Fusion. As a part of the
> library, there is a helper macro called BOOST_FUSION_ADAPT_STRUCT which, as
> the name suggests, maps a struct to the fusion random access sequence
> concept. When using the macro you have to do so at global scope since it has
> to specialize templates in a boost namespace. If, instead, the default
> definitions of these templates being specialized were altered to use an ADL
> trick, you could easily create a BOOST_FUSION_ADAPT_STRUCT macro that were
> usable from within the namespace itself. You'd no longer have to leave the
> namespace simply to use the macro. All fusion would have to do is declare a
> dummy "no_specialization get_traits(...);" kind of function in its own
> namespace, then have the default definition of its traits detect if the
> return type of a call to it using the specified type is "no_specialization".
> If not, that means that traits were provided by the type via ADL and can be
> used accordingly.

> Really, it would be convenient if all traits templates used this technique.

i'm happy this "by product" of design works elsewhere besides my
scope

by the way it compiles with msvc2005, icc11 and g++ (codepad.org
version) so the the portability shouldn't be an issue although i
didn't try other compilers

-- 
Pavel

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