On 7 June 2012 18:52, Jonathan Wakely wrote:
> On 7 June 2012 18:09, Arthur Schwarz wrote:
>>
>>
>> I am using g++ 4.5.3 as my compiler and NetBeans 7.1.2 as my IDE.
>>
>> What I wnat to do is to overload operators using all selected types. What I get
>> are error messages indicating that the usage is ambiquous. I understaad that
>> the runtime usage may be ambiguous using literal values.
>
> Literals are not run-time values, they are compile-time values, a call
> using a literal must be resolved at compile-time like any other call.
>
>> I don't understand why
>> a typed variable would cause ambiguity. And I would like to know how to code
>> around the issue. The issue (to me) is that char can be widened to long, and
>> unsigned char can be widened to unsigned long, but how do I take care of issues
char can be promoted to int, and unsigned char can be promoted to unsigned int.
>> between unsigned (char or long) and signed (char or long) since their ranges
>> are different.
>
> A long can be converted to any of the types you have overloaded the
> function for, there is no "hierarchy" of types that a long would
> prefer to convert to.
Actually that's not accurate, there is a conversion rank for integers,
but for the types you've used long doesn't "prefer" to convert to any
of them.
> You should overload the function for all types you need it for or
> explicitly convert the argument to one of the types you have
> overloaded the function for.
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]