Boost logo

Boost :

From: Michael Stevens (mail_at_[hidden])
Date: 2005-06-30 03:04:58


On Wednesday 29 June 2005 19:40, "Peter Dimov" <pdimov_at_[hidden]> wrote:

> Michael Stevens wrote:
> > template<class V>
> > void hard (V &data, const typename vector_range<V>::range_type &r)
> > {}
> > template<class V>
> > void hard (vector_slice<V> &data, const typename
> > vector_slice<V>::range_type &r)
> > {}
>
> [...]
>
> > It thinks the functions 'hard' are ambiguous despite the fact that
> > the first parameter is more specialised in the second version.
>
> The functions do seem ambiguous to me. I see no partial ordering between
> them.

I'm being a little hard on the compiler here.

In the single parameter case. Things are easy, the second template is more
specialised. The difficultly is the second parameter. In the first case we
have
        vector_range<V>::range_type
in the second
        vector_slice<V>::range_type

The crux of the problem is these two are actually the same type! I think VC is
missing this when it performs 'argument deduction against the other function
template' to determine if the templates are 'at least as specialized'. See
14.5.5.2 para 4.

At least some other modern compilers (GCC4.0, Intel 8.0 CW-9.4) are with on
this on this! VC has no problems if we help it by using
'vector_range<V>::range_type' in both cases.

Thanks,
        Michael


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