On Monday, March 25, 2002, at 11:41 PM, Bernie Bright wrote:

> Geoff McLane wrote:
>>
>> Hi,
>>
>> I can see nothing 'wrong' in the construct in
>> FGPropertyManager.h that should give 'pause'
>> to a compiler ... as other compilers have proved.
>>
>
> The construct is legal Std C++.  MSVC is at fault.
>
>> You will note msvc does NOT require any such
>> 'agressively additional casting' when used in the
>> 5 parameters case -
>>
>> That is, from say FGAircraft.cpp -
>> This FAILS ????
>>   PropertyManager->Tie("metrics/eyepoint-z-ft", this,3,
>>                        &FGAircraft::GetXYZep);
>>
>> While this WORKS ???? Why ???
>>   PropertyManager->Tie("metrics/alpha-max-deg", this,
>>                        &FGAircraft::GetAlphaCLMax,
>>                        &FGAircraft::SetAlphaCLMax,
>>                        true);
>>
>> The difference is in the 'casting' of the (*getter).
>>
>> In the second the getter is 'double get()' style, while
>> the 'other' getter is 'double get(index)' style, and the
>> compiler misses the connection ...
>>
>
> The difference is that there are two FGAircraft::GetXYZep functions:
>
> class FGAircraft {
>   inline FGColumnVector3& GetXYZep(void) { return vXYZep; }
>   inline double GetXYZep(int idx) const { return vXYZep(idx); }
>
> MSVC is unable to disambiguate them given that the
> FGPropertyManager::Tie prototype is visible and that "V
> (T::*getter)(int) const" is an exact match when T=FGAircraft and
> V=double.  Removing the inlines doesn't help either.  The conclusion is
> that MSVC is wrong but we can help it by providing a "hint" in the form
> of an appropriate cast.
>
> Your second example works because there is only one
> FGAircraft::GetAlphaCLMax().  As a test I added an overloaded
> "GetAlphaCLMax(int) const" member function and got the same compilation
> error.
>

Given that M$ most likely won't be fixing this "feature," what is the best 
solution?  Personally, I am not a fan of the type cast as a solution, but 
is renaming the function (my preference) to remove the ambiguity any 
better?

i.e., inline FGColumnVector3& GetXYZep_V(void) { return vXYZep; } //_V for 
VECTOR
and
       inline double GetXYZep(int idx) const { return vXYZep(idx); }

Just a thought,

Jonathan Polley

> Cheers,
> Bernie
>
> _______________________________________________
> Flightgear-devel mailing list
> [EMAIL PROTECTED]
> http://mail.flightgear.org/mailman/listinfo/flightgear-devel


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to