Boost logo

Boost :

From: Samuel Krempp (krempp_at_[hidden])
Date: 2002-01-25 13:34:03


On Fri, 2002-01-25 at 18:23, Peter Dimov wrote:

> I haven't looked at this in detail, but the T & / T const & overload is
> ambiguous when the argument is const.

I am not sure about that.

Of course, if T is a const type,
void foo(const T& );
and
void foo( T& );
are the exact same thing.

But the template parameters deduction system apparently disambiguate the
call.
the paragraph 14.8.2.1, "Deducing template arguments from a function
call", in the standard says :
"""
if A is a cv-qualified type, the top level cv-qualifiers of A's type
are ignored for type deduction
"""

Isn't that the case here ?

What is known for sure, is that gcc and comeau both accepts the
following :

class A {
int n;
};

template<class T>
void foo(T&) {
        A errorMaker;
        errorMaker.n = 10;
//for comeau online test. We only get to know compilation results.
//with -tused, it gives us a way to know which function is called
}

template<class T>
void foo(T const &) {
}

void mymain() {
int const y = 5;
foo( y );
}

-- 
Samuel

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