summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@novell.com>2011-08-17 18:35:21 +0300
committerTor Lillqvist <tlillqvist@novell.com>2011-08-17 20:59:50 +0300
commit9890c98480161040e048f37d94004b7b05f6c79f (patch)
treeaf268b62d1103808cc0bb83b3db0aea9a66062e1 /comphelper
parent44c513636f67d7710d5046e3212c77dc438ffaa3 (diff)
Fix dubious std::lower_bound() usage that breaks a _DEBUG MSVC build
Always pass the value to search for of type equal to what the iterators return.
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/inc/comphelper/property.hxx13
-rw-r--r--comphelper/source/property/propagg.cxx3
-rw-r--r--comphelper/source/property/property.cxx6
-rw-r--r--comphelper/source/property/propertycontainerhelper.cxx26
4 files changed, 16 insertions, 32 deletions
diff --git a/comphelper/inc/comphelper/property.hxx b/comphelper/inc/comphelper/property.hxx
index 662fa84903b8..a294b3363b5d 100644
--- a/comphelper/inc/comphelper/property.hxx
+++ b/comphelper/inc/comphelper/property.hxx
@@ -51,19 +51,6 @@ namespace comphelper
/** compare two properties by name
*/
- struct PropertyStringLessFunctor : ::std::binary_function< ::com::sun::star::beans::Property, ::rtl::OUString, bool >
- {
- // ................................................................
- inline bool operator()( const ::com::sun::star::beans::Property& lhs, const ::rtl::OUString& rhs ) const
- {
- return lhs.Name.compareTo(rhs) < 0;
- }
- // ................................................................
- inline bool operator()( const ::rtl::OUString& lhs, const ::com::sun::star::beans::Property& rhs ) const
- {
- return lhs.compareTo(rhs.Name) < 0;
- }
- };
//--------------------------------------------------------------------------
// comparing two property instances
struct PropertyCompareByName : public ::std::binary_function< ::com::sun::star::beans::Property, ::com::sun::star::beans::Property, bool >
diff --git a/comphelper/source/property/propagg.cxx b/comphelper/source/property/propagg.cxx
index b83c292689dc..945ace837808 100644
--- a/comphelper/source/property/propagg.cxx
+++ b/comphelper/source/property/propagg.cxx
@@ -60,7 +60,8 @@ namespace comphelper
{
sal_Int32 nLen = _rProps.getLength();
const Property* pProperties = _rProps.getConstArray();
- const Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen,_rName, ::comphelper::PropertyStringLessFunctor());
+ Property aNameProp(_rName, 0, Type(), 0);
+ const Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen, aNameProp, PropertyCompareByName());
if ( pResult && ( pResult == pProperties + nLen || pResult->Name != _rName) )
pResult = NULL;
diff --git a/comphelper/source/property/property.cxx b/comphelper/source/property/property.cxx
index 37bb62cc98ef..b20eba9c47f9 100644
--- a/comphelper/source/property/property.cxx
+++ b/comphelper/source/property/property.cxx
@@ -180,7 +180,8 @@ void RemoveProperty(Sequence<Property>& _rProps, const rtl::OUString& _rPropName
// binaere Suche
const Property* pProperties = _rProps.getConstArray();
- const Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen, _rPropName,PropertyStringLessFunctor());
+ Property aNameProp(_rPropName, 0, Type(), 0);
+ const Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen, aNameProp, PropertyCompareByName());
// gefunden ?
if ( pResult && (pResult != pProperties + nLen) && (pResult->Name == _rPropName) )
@@ -197,7 +198,8 @@ void ModifyPropertyAttributes(Sequence<Property>& seqProps, const ::rtl::OUStrin
// binaere Suche
Property* pProperties = seqProps.getArray();
- Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen,sPropName, PropertyStringLessFunctor());
+ Property aNameProp(sPropName, 0, Type(), 0);
+ Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen, aNameProp, PropertyCompareByName());
// gefunden ?
if ( pResult && (pResult != pProperties + nLen) && (pResult->Name == sPropName) )
diff --git a/comphelper/source/property/propertycontainerhelper.cxx b/comphelper/source/property/propertycontainerhelper.cxx
index 6233efbc011f..b984c3a2e635 100644
--- a/comphelper/source/property/propertycontainerhelper.cxx
+++ b/comphelper/source/property/propertycontainerhelper.cxx
@@ -60,15 +60,11 @@ namespace
}
};
// comparing two property descriptions
- struct PropertyDescriptionHandleCompare : public ::std::binary_function< PropertyDescription, sal_Int32, bool >
+ struct PropertyDescriptionHandleCompare : public ::std::binary_function< PropertyDescription, PropertyDescription, bool >
{
- bool operator() (const PropertyDescription& x, const sal_Int32& y) const
- {
- return x.aProperty.Handle < y;
- }
- bool operator() (const sal_Int32& x, const PropertyDescription& y) const
+ bool operator() (const PropertyDescription& x, const PropertyDescription& y) const
{
- return x < y.aProperty.Handle;
+ return x.aProperty.Handle < y.aProperty.Handle;
}
};
// comparing two property descriptions (by name)
@@ -194,15 +190,11 @@ sal_Bool OPropertyContainerHelper::isRegisteredProperty( const ::rtl::OUString&
//--------------------------------------------------------------------------
namespace
{
- struct ComparePropertyWithHandle
+ struct ComparePropertyHandles
{
- bool operator()( const PropertyDescription& _rLHS, sal_Int32 _nRHS ) const
- {
- return _rLHS.aProperty.Handle < _nRHS;
- }
- bool operator()( sal_Int32 _nLHS, const PropertyDescription& _rRHS ) const
+ bool operator()( const PropertyDescription& _rLHS, const PropertyDescription& _nRHS ) const
{
- return _nLHS < _rRHS.aProperty.Handle;
+ return _rLHS.aProperty.Handle < _nRHS.aProperty.Handle;
}
};
}
@@ -223,7 +215,7 @@ void OPropertyContainerHelper::implPushBackProperty(const PropertyDescription& _
PropertiesIterator pos = ::std::lower_bound(
m_aProperties.begin(), m_aProperties.end(),
- _rProp.aProperty.Handle, ComparePropertyWithHandle() );
+ _rProp, ComparePropertyHandles() );
m_aProperties.insert( pos, _rProp );
}
@@ -466,11 +458,13 @@ void OPropertyContainerHelper::getFastPropertyValue(Any& _rValue, sal_Int32 _nHa
//--------------------------------------------------------------------------
OPropertyContainerHelper::PropertiesIterator OPropertyContainerHelper::searchHandle(sal_Int32 _nHandle)
{
+ PropertyDescription aHandlePropDesc;
+ aHandlePropDesc.aProperty.Handle = _nHandle;
// search a lower bound
PropertiesIterator aLowerBound = ::std::lower_bound(
m_aProperties.begin(),
m_aProperties.end(),
- _nHandle,
+ aHandlePropDesc,
PropertyDescriptionHandleCompare());
// check for identity