Boost logo

Boost :

From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2007-03-30 11:39:12


On 3/30/07, Guillaume Melquiond <guillaume.melquiond_at_[hidden]> wrote:
> Quoting Daniel Walker:
>
> > Is this a substitution failure?
>
> There is no substitution in your code, so a substitution failure cannot
> happen.
> Here is a real substitution, that does fail properly:
>
> template<class T>
> struct foo {
> template<class U> struct bar;
> };
>
> template<class T, class U>
> void f(T,U) {}
>
> template<class T, class U>
> void f(T, typename foo<T>::template bar<T,U>) {}
>
> int main()
> {
> f(0,0);
> }

OK, thanks for the help. I was trying to simplify my code to replicate
the error I'm getting, and I may have gone to far. Can you tell me if
the following contains a substitution?

struct foo {
    template<class U> struct bar;
};

template<class T, class U, class V>
struct baz {
    template<class W>
    static int f(W*, ...) {}

    template<class W>
    static int f(W*, typename W::template bar<U,V>*) {}

    static const int size = sizeof(f<T>(0, 0));
    // error: wrong number of template arguments (2, should be
    // 1) provided for `template<class U> struct foo::bar'
};

int main()
{
   baz<foo, int, int>::size;
}

This is closer to the has_xxx implementation. Any suggestions would be
greatly appreciated!

>
> I am not sure if it will help you though, as I don't know if you can afford to
> protect the class you want to test (bar) into a dummy template (foo),
> so that a
> substitution happens. No template typedef...
>
> Best regards,
>
> Guillaume
>
> _______________________________________________
> 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