Boost logo

Boost :

From: rwgk (rwgk_at_[hidden])
Date: 2002-01-21 14:40:49


--- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
David Abrahams wrote:
> The library provides the dispatching function:
>
> template <class X, class Y>
> void copy(X x1, X x2, Y y)
> {
> copy(typename concept<X>::type(), x1
> , typename concept<X>::type(), x2
> , typename concept<Y>::type(), y);
> }
>

This looks very interesting in its own right. However, this
does not seem to address Howard Hinnant's problem (correct?):

Howard Hinnant wrote:
> As a library writer I would like to be able to create a restricted
> template foo that would accept only (for example) arithmetic types.
But
> if client code creates a function foo that takes a user-defined
type, I
> want it to behave as if there is no template foo, even if he has
brought
> it into scope.

But I guess smart use of namespaces could help here.

David wrote:
> Things get a lot more interesting when you have return values
involved. At
> that point we need __typeof__():
>
> template <class X, class Y>
>
> __typeof__(copy(typename concept<X>::type(), *((X*)())
> , typename concept<X>::type(), *((X*)())
> , typename concept<Y>::type(), *((Y*)()))
> void copy(X x1, X x2, Y y)
> {
> return copy(typename concept<X>::type(), x1
> , typename concept<X>::type(), x2
> , typename concept<Y>::type(), y);
> }
>
> Fortunately, you only need to write one of these ugly dispatching
functions.

"typeof" does not appear in the ISO standard. How can I learn
more about this?

Thanks,
        Ralf


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