On Sat, 2009-02-21 at 21:07 +0100, Csaba Halász wrote: 
> On Sat, Feb 21, 2009 at 7:34 PM, Geoff McLane <ubu...@geoffair.info> wrote:
> >
> > IMHO the _MSC_VER and _DEBUG switches do NOT need to be applied. I am
> > forever puzzled how gcc resolves this since the comparison is indeed two
> > pointers ...
> 
> No it isn't. Both uses in lower_bound and upper_bound take an iterator
> range and a const Type&. So it is a pointer and a reference. gcc is
> right.
> 
Hi Csaba/Jester, ZhiYong Huang, and Fred, 

Hmmm, it has been quite a few months since I looked this up, but trying again 
with your idea,
I find, in the MSVC HELP :-

<quote>
Finds the position of the first element in an ordered range that has a value 
greater than or
equivalent to a specified value, where the ordering criterion may be specified 
by a binary predicate.

template<class ForwardIterator, class Type>
ForwardIterator lower_bound(
 ForwardIterator _First,
 ForwardIterator _Last,
 const Type& _Val ); 
template<class ForwardIterator, class Type, class BinaryPredicate>
ForwardIterator lower_bound(
 ForwardIterator _First, 
 ForwardIterator _Last,
 const Type& _Val,
 BinaryPredicate _Comp );
</quote>
And similarly for upper_bound ...

Then in positioned.cxx we have :-
BucketEntry::const_iterator l = std::lower_bound(it->second.begin(), 
it->second.end(), aLower, LowerLimitOfType());
BucketEntry::const_iterator u = std::upper_bound(l, it->second.end(), aUpper, 
LowerLimitOfType());

which is using the 2nd template, where BucketEntry is defined as -
typedef std::set<FGPositioned*, OrderByType> BucketEntry;

So no problem here, but it is the 'BinaryPredicate _Comp', that is 
LowerLimitOfType(), 
which is defined as :-

class LowerLimitOfType
{
public:
bool operator()(const FGPositioned* a, const FGPositioned::Type b) const
{
return a->type() < b;
}
bool operator()(const FGPositioned::Type a, const FGPositioned* b) const
{
return a < b->type();
}
};

It seems here the comparator, LowerLimitOfType(), is 'missing' a comparison 
given 2
pointers - so the patch code provides this :-

+ bool operator()(const FGPositioned* a, const FGPositioned* b) const
+ {
+ return a->type() < b->type();
+ }

So this is NOT upper_bound or lower_bound case, but a user class case, but what 
do I know?

There is no 'competition' between which compiler is 'right' here ;=)) Just a 
case of finding
the lower limit of, given two pointers... Again I am forever 'puzzled' when any
compiler 'resolves' this without the above suggested addition to 
'LowerLimitOfType()???

Maybe Fred is right in suggesting the MSVC 'debugging code in the STL' triggers 
this, but
are we correct in 'ignoring' this extra help? this extra information?... at 
least for MSVC?

Alternatively, what can be WRONG with providing a clear cut solution to ANY and 
ALL 
compilers, and that is showing it EXACTLY what we want? The lower limit of the 
'type' 
of two pointer... if that is what we want!

But even if you decide to put the patch under a switch -
#if defined(_MSC_VER) && defined(_DEBUG)
then NO PROBLEM! 

Any patch is BETTER than NONE ;=))

Regards,

Geoff.



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to