From c4ddf6cd6d97e7ce7c2e63e4d393bbeffcb34e4d Mon Sep 17 00:00:00 2001 From: Jochen Nitschke Date: Wed, 28 Jun 2017 21:48:22 +0200 Subject: C++11 remove std::unary_function bases from functors std::unary_function is deprecated since C++11 and removed in C++17 90% done with regexp magic. removed obsolete includes. The std::unary_function base class was used in 3 places: * chart2/source/tools/DataSeriesHelper.cxx: lcl_MatchesRole is used in a std::not1 function helper who uses the members return_type and argument_type. - replace deprecated std::not1 with a lambda * chart2/source/tools/ModifyListenerHelper.cxx: lcl_weakReferenceToSame used the argument_type member in the operator() parameter. - inline the parameter type. * xmloff/source/chart/SchXMLExport.cxx: lcl_SequenceToMapElement used result_type and argument_type in operator(). - inline the types Also fix compile error with gcc about finding std::for_each. Change-Id: I073673beb01410c3108e7d0346d9e7d6b9ad2e2f Reviewed-on: https://gerrit.libreoffice.org/39358 Reviewed-by: Stephan Bergmann Tested-by: Stephan Bergmann --- chart2/source/controller/dialogs/DataBrowserModel.cxx | 6 +++--- chart2/source/controller/dialogs/DialogModel.cxx | 3 +-- chart2/source/controller/main/ObjectHierarchy.cxx | 2 +- chart2/source/inc/CloneHelper.hxx | 3 +-- chart2/source/inc/CommonFunctors.hxx | 11 +++++------ chart2/source/inc/EventListenerHelper.hxx | 5 ++--- chart2/source/inc/ModifyListenerHelper.hxx | 9 ++++----- chart2/source/model/main/ChartModel_Persistence.cxx | 3 +-- chart2/source/model/template/DataInterpreter.cxx | 2 +- chart2/source/tools/DataSeriesHelper.cxx | 7 ++++--- chart2/source/tools/ImplOPropertySet.cxx | 10 +++------- chart2/source/tools/InternalDataProvider.cxx | 12 ++++++------ chart2/source/tools/ModifyListenerHelper.cxx | 10 ++++------ chart2/source/tools/PropertyHelper.cxx | 7 +++---- chart2/source/tools/XMLRangeHelper.cxx | 5 ++--- 15 files changed, 41 insertions(+), 54 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index f1d4c9dccf2d..9dc2478f76f9 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -171,7 +171,7 @@ sal_Int32 lcl_getValuesRepresentationIndex( return nResult; } -struct lcl_RepresentationsOfLSeqMatch : public std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool > +struct lcl_RepresentationsOfLSeqMatch { explicit lcl_RepresentationsOfLSeqMatch( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) : m_aValuesRep( xLSeq.is() ? @@ -189,7 +189,7 @@ private: OUString m_aValuesRep; }; -struct lcl_RolesOfLSeqMatch : public std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool > +struct lcl_RolesOfLSeqMatch { explicit lcl_RolesOfLSeqMatch( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) : m_aRole(DataSeriesHelper::getRole(xLSeq)) {} @@ -262,7 +262,7 @@ DataBrowserModel::~DataBrowserModel() namespace { -struct lcl_DataSeriesOfHeaderMatches : public std::unary_function< ::chart::DataBrowserModel::tDataHeader, bool > +struct lcl_DataSeriesOfHeaderMatches { explicit lcl_DataSeriesOfHeaderMatches( const Reference< chart2::XDataSeries > & xSeriesToCompareWith ) : diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index 8bfc3113ecc8..438fab7d7e61 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -59,8 +59,7 @@ namespace { const OUString lcl_aLabelRole( "label" ); -struct lcl_ChartTypeToSeriesCnt : std::unary_function< - Reference< XChartType >, Reference< XDataSeriesContainer > > +struct lcl_ChartTypeToSeriesCnt { Reference< XDataSeriesContainer > operator() ( const Reference< XChartType > & xChartType ) diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index 7889d679b107..ba54572d5c33 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -54,7 +54,7 @@ using ::com::sun::star::uno::Sequence; namespace { -struct lcl_ObjectToOID : public std::unary_function< Reference< uno::XInterface >, ::chart::ObjectIdentifier > +struct lcl_ObjectToOID { explicit lcl_ObjectToOID( const Reference< chart2::XChartDocument > & xChartDoc ) : m_xModel( xChartDoc, uno::UNO_QUERY ) diff --git a/chart2/source/inc/CloneHelper.hxx b/chart2/source/inc/CloneHelper.hxx index ee625666ab9d..ae739bbc6ab6 100644 --- a/chart2/source/inc/CloneHelper.hxx +++ b/chart2/source/inc/CloneHelper.hxx @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -33,7 +32,7 @@ namespace CloneHelper /// functor that clones a UNO-Reference template< class Interface > - struct CreateRefClone : public std::unary_function< Interface, Interface > + struct CreateRefClone { css::uno::Reference operator() ( const css::uno::Reference & xOther ) { diff --git a/chart2/source/inc/CommonFunctors.hxx b/chart2/source/inc/CommonFunctors.hxx index 4e0eeb680631..8b11df32f3ea 100644 --- a/chart2/source/inc/CommonFunctors.hxx +++ b/chart2/source/inc/CommonFunctors.hxx @@ -20,7 +20,6 @@ #define INCLUDED_CHART2_SOURCE_INC_COMMONFUNCTORS_HXX #include -#include #include #include #include @@ -38,7 +37,7 @@ namespace CommonFunctors (via mem_fun_ptr)

*/ template< typename T > - struct makeAny : public std::unary_function< T, css::uno::Any > + struct makeAny { css::uno::Any operator() ( const T & aVal ) { @@ -51,7 +50,7 @@ template< typename T >

In case no number can be generated from the Any, NaN (see rtl::math::SetNAN()) is returned.

*/ -struct OOO_DLLPUBLIC_CHARTTOOLS AnyToDouble : public std::unary_function< css::uno::Any, double > +struct OOO_DLLPUBLIC_CHARTTOOLS AnyToDouble { double operator() ( const css::uno::Any & rAny ) { @@ -65,7 +64,7 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToDouble : public std::unary_function< css::u /** unary function to convert css::uno::Any into an OUString. */ -struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString : public std::unary_function< css::uno::Any, OUString > +struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString { OUString operator() ( const css::uno::Any & rAny ) { @@ -94,7 +93,7 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString : public std::unary_function< css::u

For conversion rtl::math::StringToDouble is used.

*/ -struct OOO_DLLPUBLIC_CHARTTOOLS OUStringToDouble : public std::unary_function< OUString, double > +struct OOO_DLLPUBLIC_CHARTTOOLS OUStringToDouble { double operator() ( const OUString & rStr ) { @@ -112,7 +111,7 @@ struct OOO_DLLPUBLIC_CHARTTOOLS OUStringToDouble : public std::unary_function< O

For conversion rtl::math::DoubleToOUString is used.

*/ -struct OOO_DLLPUBLIC_CHARTTOOLS DoubleToOUString : public std::unary_function< double, OUString > +struct OOO_DLLPUBLIC_CHARTTOOLS DoubleToOUString { OUString operator() ( double fNumber ) { diff --git a/chart2/source/inc/EventListenerHelper.hxx b/chart2/source/inc/EventListenerHelper.hxx index 7e951a3df3ab..8b9c1ec6c47f 100644 --- a/chart2/source/inc/EventListenerHelper.hxx +++ b/chart2/source/inc/EventListenerHelper.hxx @@ -24,7 +24,6 @@ #include #include -#include #include namespace chart @@ -36,7 +35,7 @@ namespace impl { template< class InterfaceRef > -struct addListenerFunctor : public std::unary_function< InterfaceRef, void > +struct addListenerFunctor { explicit addListenerFunctor( const css::uno::Reference< css::lang::XEventListener > & xListener ) : m_xListener( xListener ) @@ -54,7 +53,7 @@ private: }; template< class InterfaceRef > -struct removeListenerFunctor : public std::unary_function< InterfaceRef, void > +struct removeListenerFunctor { explicit removeListenerFunctor( const css::uno::Reference< css::lang::XEventListener > & xListener ) : m_xListener( xListener ) diff --git a/chart2/source/inc/ModifyListenerHelper.hxx b/chart2/source/inc/ModifyListenerHelper.hxx index 4fe9e178ff9e..48f2e0b149b0 100644 --- a/chart2/source/inc/ModifyListenerHelper.hxx +++ b/chart2/source/inc/ModifyListenerHelper.hxx @@ -32,7 +32,6 @@ #include #include -#include #include namespace chart @@ -103,7 +102,7 @@ namespace impl { template< class InterfaceRef > -struct addListenerFunctor : public std::unary_function< InterfaceRef, void > +struct addListenerFunctor { explicit addListenerFunctor( const css::uno::Reference< css::util::XModifyListener > & xListener ) : m_xListener( xListener ) @@ -121,7 +120,7 @@ private: }; template< class InterfaceRef > -struct removeListenerFunctor : public std::unary_function< InterfaceRef, void > +struct removeListenerFunctor { explicit removeListenerFunctor( const css::uno::Reference< css::util::XModifyListener > & xListener ) : m_xListener( xListener ) @@ -139,7 +138,7 @@ private: }; template< class Pair > -struct addListenerToMappedElementFunctor : public std::unary_function< Pair, void > +struct addListenerToMappedElementFunctor { explicit addListenerToMappedElementFunctor( const css::uno::Reference< css::util::XModifyListener > & xListener ) : m_xListener( xListener ) @@ -157,7 +156,7 @@ private: }; template< class Pair > -struct removeListenerFromMappedElementFunctor : public std::unary_function< Pair, void > +struct removeListenerFromMappedElementFunctor { explicit removeListenerFromMappedElementFunctor( const css::uno::Reference< css::util::XModifyListener > & xListener ) : m_xListener( xListener ) diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx index 834e05c9861c..77aba167c4c6 100644 --- a/chart2/source/model/main/ChartModel_Persistence.cxx +++ b/chart2/source/model/main/ChartModel_Persistence.cxx @@ -59,7 +59,6 @@ #include #include -#include using namespace ::com::sun::star; @@ -69,7 +68,7 @@ using ::osl::MutexGuard; namespace { -struct lcl_PropNameEquals : public std::unary_function< beans::PropertyValue, bool > +struct lcl_PropNameEquals { explicit lcl_PropNameEquals( const OUString & rStrToCompareWith ) : m_aStr( rStrToCompareWith ) diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx index 57f03562e85d..0ca15b013069 100644 --- a/chart2/source/model/template/DataInterpreter.cxx +++ b/chart2/source/model/template/DataInterpreter.cxx @@ -212,7 +212,7 @@ sal_Bool SAL_CALL DataInterpreter::isDataCompatible( namespace { -struct lcl_LabeledSequenceEquals : public std::unary_function< Reference< data::XLabeledDataSequence >, bool > +struct lcl_LabeledSequenceEquals { explicit lcl_LabeledSequenceEquals( const Reference< data::XLabeledDataSequence > & xLSeqToCmp ) : m_bHasLabels ( false ), diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index 849612de0e54..a8a84deb5a67 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -54,7 +53,7 @@ using ::com::sun::star::uno::Sequence; namespace { -class lcl_MatchesRole : public std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool > +class lcl_MatchesRole { public: explicit lcl_MatchesRole( const OUString & aRole, bool bMatchPrefix ) : @@ -233,7 +232,9 @@ std::vector< Reference< chart2::data::XLabeledDataSequence > > std::vector< Reference< chart2::data::XLabeledDataSequence > > aResultVec; std::remove_copy_if( aDataSequences.getConstArray(), aDataSequences.getConstArray() + aDataSequences.getLength(), std::back_inserter( aResultVec ), - std::not1( lcl_MatchesRole( aRole, bMatchPrefix ))); + [&aRole, bMatchPrefix](const Reference< chart2::data::XLabeledDataSequence > & xSeq) + {return !(lcl_MatchesRole(aRole, bMatchPrefix).operator()(xSeq));}); + //TODO replace lambda with std::not_fn(lcl_MatchesRole(aRole, bMatchPrefix) in C++17 return aResultVec; } diff --git a/chart2/source/tools/ImplOPropertySet.cxx b/chart2/source/tools/ImplOPropertySet.cxx index bfe6fdb296a0..8dee149c3f21 100644 --- a/chart2/source/tools/ImplOPropertySet.cxx +++ b/chart2/source/tools/ImplOPropertySet.cxx @@ -22,7 +22,6 @@ #include #include -#include #include using namespace ::com::sun::star; @@ -34,8 +33,7 @@ using ::com::sun::star::uno::Any; namespace { -struct lcl_getPropertyStateByHandle : - public std::unary_function< sal_Int32, beans::PropertyState > +struct lcl_getPropertyStateByHandle { explicit lcl_getPropertyStateByHandle( const ::property::impl::ImplOPropertySet::tPropertyMap & rMap ) @@ -54,8 +52,7 @@ private: }; template< typename K, typename V > -struct lcl_eraseMapEntry : - public std::unary_function< K, void > +struct lcl_eraseMapEntry { explicit lcl_eraseMapEntry( std::map< K, V > & rMap ) : m_rMap( rMap ) @@ -70,8 +67,7 @@ private: std::map< K, V > m_rMap; }; -struct lcl_replaceInterfacePropertiesByClones : - public std::unary_function< ::property::impl::ImplOPropertySet::tPropertyMap::value_type, void > +struct lcl_replaceInterfacePropertiesByClones { void operator() ( ::property::impl::ImplOPropertySet::tPropertyMap::value_type & rProp ) { diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index dad11d5d573f..384420c0681a 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -89,7 +89,7 @@ std::vector< uno::Any > lcl_StringToAnyVector( const css::uno::Sequence< OUStrin return aResult; } -struct lcl_setModified : public std::unary_function< lcl_tSequenceMap, void > +struct lcl_setModified { void operator() ( const lcl_tSequenceMap::value_type & rMapEntry ) { @@ -104,7 +104,7 @@ struct lcl_setModified : public std::unary_function< lcl_tSequenceMap, void > } }; -struct lcl_internalizeSeries : public std::unary_function< Reference< chart2::XDataSeries >, void > +struct lcl_internalizeSeries { lcl_internalizeSeries( InternalData & rInternalData, InternalDataProvider & rProvider, @@ -181,7 +181,7 @@ private: bool m_bDataInColumns; }; -struct lcl_copyFromLevel : public std::unary_function< vector< uno::Any >, uno::Any > +struct lcl_copyFromLevel { public: @@ -200,7 +200,7 @@ private: sal_Int32 m_nLevel; }; -struct lcl_getStringFromLevelVector : public std::unary_function< vector< uno::Any >, OUString > +struct lcl_getStringFromLevelVector { public: @@ -259,7 +259,7 @@ private: sal_Int32 m_nLevel; }; -struct lcl_insertAnyAtLevel : public std::unary_function< vector< uno::Any >, void > +struct lcl_insertAnyAtLevel { public: @@ -282,7 +282,7 @@ private: sal_Int32 m_nLevel; }; -struct lcl_removeAnyAtLevel : public std::unary_function< vector< uno::Any >, void > +struct lcl_removeAnyAtLevel { public: diff --git a/chart2/source/tools/ModifyListenerHelper.cxx b/chart2/source/tools/ModifyListenerHelper.cxx index 87a8f356073a..c6fd1d604773 100644 --- a/chart2/source/tools/ModifyListenerHelper.cxx +++ b/chart2/source/tools/ModifyListenerHelper.cxx @@ -57,17 +57,15 @@ void lcl_fireModifyEvent( } } -struct lcl_weakReferenceToSame : public std::unary_function< - std::pair< - css::uno::WeakReference< css::util::XModifyListener >, - css::uno::Reference< css::util::XModifyListener > >, - bool > +struct lcl_weakReferenceToSame { explicit lcl_weakReferenceToSame( const Reference< util::XModifyListener > & xModListener ) : m_xHardRef( xModListener ) {} - bool operator() ( const argument_type & xElem ) + // argument type is same as tListenerMap::value_type& + bool operator() ( const std::pair, + css::uno::Reference< css::util::XModifyListener> > & xElem ) { Reference< util::XModifyListener > xWeakAsHard( xElem.first ); if( xWeakAsHard.is()) diff --git a/chart2/source/tools/PropertyHelper.cxx b/chart2/source/tools/PropertyHelper.cxx index 8741037b6014..3b0f71839830 100644 --- a/chart2/source/tools/PropertyHelper.cxx +++ b/chart2/source/tools/PropertyHelper.cxx @@ -27,7 +27,6 @@ #include #include #include -#include using namespace ::com::sun::star; using namespace ::com::sun::star::beans; @@ -36,7 +35,7 @@ using ::com::sun::star::uno::Reference; namespace { -struct lcl_EqualsElement : public std::unary_function< OUString, bool > +struct lcl_EqualsElement { explicit lcl_EqualsElement( const Any & rValue, const Reference< container::XNameAccess > & xAccess ) : m_aValue( rValue ), m_xAccess( xAccess ) @@ -62,7 +61,7 @@ private: Reference< container::XNameAccess > m_xAccess; }; -struct lcl_StringMatches : public std::unary_function< OUString ,bool > +struct lcl_StringMatches { explicit lcl_StringMatches( const OUString & rCmpStr ) : m_aCmpStr( rCmpStr ) @@ -77,7 +76,7 @@ private: OUString m_aCmpStr; }; -struct lcl_OUStringRestToInt32 : public std::unary_function< OUString, sal_Int32 > +struct lcl_OUStringRestToInt32 { explicit lcl_OUStringRestToInt32( sal_Int32 nPrefixLength ) : m_nPrefixLength( nPrefixLength ) diff --git a/chart2/source/tools/XMLRangeHelper.cxx b/chart2/source/tools/XMLRangeHelper.cxx index 1a484dbb6db5..e89b1a074f5b 100644 --- a/chart2/source/tools/XMLRangeHelper.cxx +++ b/chart2/source/tools/XMLRangeHelper.cxx @@ -23,7 +23,6 @@ #include #include -#include namespace { @@ -31,7 +30,7 @@ namespace array (which you can get from an OUString with getStr()) and puts the result into the OUStringBuffer given in the CTOR */ -class lcl_Escape : public std::unary_function< sal_Unicode, void > +class lcl_Escape { public: explicit lcl_Escape( OUStringBuffer & aResultBuffer ) : m_aResultBuffer( aResultBuffer ) {} @@ -54,7 +53,7 @@ private: you can get from an OUString with getStr()) and puts the result into the OUStringBuffer given in the CTOR */ -class lcl_UnEscape : public std::unary_function< sal_Unicode, void > +class lcl_UnEscape { public: explicit lcl_UnEscape( OUStringBuffer & aResultBuffer ) : m_aResultBuffer( aResultBuffer ) {} -- cgit