Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2003-01-12 18:49:34


----- Original Message -----
From: "David Abrahams" <dave_at_[hidden]>

> >> template <class T>
> >> struct X
> >> {
> >> template <class U>
> >> X(X<U> const&, typename enable_if<some_property_of<U>::value,
> > int*>::type = 0);
> > ^
> > It chokes here?
>
> Sorry, no. I mean the 2nd '<' in that line.

Okay.

> > Is it legal to use the template parameter 'U' in a non-deduced
> > context like that? I'm curious because I thought that it wasn't
> > (though I could be wrong).
>
> Why do you say that's non-deduced? Up to the point of enable_if, it's
> standard stuff; that's how shared_ptr conversion works.

I didn't know that this was legal:

template<class T> struct identity {
    typedef T type;
};

template<class T> void func(const T&, typename identity<T>::type* = 0);

int main() {
    func(10);
    return 0;
}

Paul Mensonides


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