Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2004-01-26 18:44:39


On Jan 26, 2004, at 3:12 PM, Daryle Walker wrote:

> On 1/24/04 8:31 PM, "Howard Hinnant" <hinnant_at_[hidden]> wrote:
>
>> On Jan 24, 2004, at 7:20 PM, Daryle Walker wrote:
>>
>>> Can you have both? The built-in signed integral types would go to
>>> the
>>> "ptrdiff_t" version and the built-in unsigned integral types would
>>> go to the
>>> "size_t" version. Or do the conversion rules produce an ambiguity
>>> error
>>> instead?
>>
>> If you simply define both, you're setting yourself up for an
>> ambiguity error.
>> For example if:
>>
>> ptrdiff_t == long
>> size_t == unsigned long
>>
>> then an int argument might be able to convert to either with equal
>> ease.
>
> I know that an "int" value could fit in an "unsigned long" at
> run-time. But
> at compile-time, are the two conversions considered equal, or will the
> compiler always prefer the "long" version?

On my system:

void f(long) {}
void f(unsigned long) {}

int main()
{
        f(1);
}

Error : ambiguous access to overloaded function
'f(unsigned long)'
'f(long)'
HelloWorld.cp line 6 f(1);

-Howard


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