tdf#165233 Use lambdas instead of std::bind

Change-Id: I1aad4c456ee171b569b49de326c53380d73da071
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182448
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Karthik
2025-03-21 10:38:43 +01:00
committed by Ilmari Lauhakangas
parent 49b71f818d
commit 5a3dd3f0b1
3 changed files with 84 additions and 21 deletions
+12 -3
View File
@@ -644,13 +644,22 @@ void Binding::valueModified()
Reference<XInterface> xSource = static_cast<XPropertySet*>( this );
::std::for_each( maModifyListeners.begin(),
maModifyListeners.end(),
::std::bind( lcl_modified, std::placeholders::_1, xSource ) );
[xSource](const css::uno::Reference<css::util::XModifyListener>& xListener)
{
return lcl_modified(xListener, xSource);
});
::std::for_each( maListEntryListeners.begin(),
maListEntryListeners.end(),
::std::bind( lcl_listentry, std::placeholders::_1, xSource ) );
[xSource](const css::uno::Reference<css::form::binding::XListEntryListener>& xListener)
{
return lcl_listentry(xListener,xSource);
});
::std::for_each( maValidityListeners.begin(),
maValidityListeners.end(),
::std::bind( lcl_validate, std::placeholders::_1, xSource ) );
[xSource](const css::uno::Reference<css::form::validation::XValidityConstraintListener>& xListener)
{
lcl_validate(xListener, xSource);
});
// now distribute MIPs to children
if( xNode.is() )
@@ -187,70 +187,100 @@ void ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers()
case DIST_UNIFORM:
{
std::uniform_real_distribution<> distribution(parameter1, parameter2);
auto rng = std::bind(distribution, seed);
auto rng = [&distribution, seed]() mutable
{
return distribution(seed);
};
GenerateNumbers(rng, STR_DISTRIBUTION_UNIFORM_REAL, aDecimalPlaces);
break;
}
case DIST_UNIFORM_INTEGER:
{
std::uniform_int_distribution<sal_Int64> distribution(parameterInteger1, parameterInteger2);
auto rng = std::bind(distribution, seed);
auto rng = [&distribution, seed]() mutable
{
return distribution(seed);
};
GenerateNumbers(rng, STR_DISTRIBUTION_UNIFORM_INTEGER, aDecimalPlaces);
break;
}
case DIST_NORMAL:
{
std::normal_distribution<> distribution(parameter1, parameter2);
auto rng = std::bind(distribution, seed);
auto rng = [&distribution, seed]() mutable
{
return distribution(seed);
};
GenerateNumbers(rng, STR_DISTRIBUTION_NORMAL, aDecimalPlaces);
break;
}
case DIST_CAUCHY:
{
std::cauchy_distribution<> distribution(parameter1);
auto rng = std::bind(distribution, seed);
auto rng = [&distribution, seed]() mutable
{
return distribution(seed);
};
GenerateNumbers(rng, STR_DISTRIBUTION_CAUCHY, aDecimalPlaces);
break;
}
case DIST_BERNOULLI:
{
std::bernoulli_distribution distribution(parameter1);
auto rng = std::bind(distribution, seed);
auto rng = [&distribution, seed]() mutable
{
return distribution(seed);
};
GenerateNumbers(rng, STR_DISTRIBUTION_BERNOULLI, aDecimalPlaces);
break;
}
case DIST_BINOMIAL:
{
std::binomial_distribution<> distribution(parameterInteger2, parameter1);
auto rng = std::bind(distribution, seed);
auto rng = [&distribution, seed]() mutable
{
return distribution(seed);
};
GenerateNumbers(rng, STR_DISTRIBUTION_BINOMIAL, aDecimalPlaces);
break;
}
case DIST_CHI_SQUARED:
{
std::chi_squared_distribution<> distribution(parameter1);
auto rng = std::bind(distribution, seed);
auto rng = [&distribution, seed]() mutable
{
return distribution(seed);
};
GenerateNumbers(rng, STR_DISTRIBUTION_CHI_SQUARED, aDecimalPlaces);
break;
}
case DIST_GEOMETRIC:
{
std::geometric_distribution<> distribution(parameter1);
auto rng = std::bind(distribution, seed);
auto rng = [&distribution, seed]() mutable
{
return distribution(seed);
};
GenerateNumbers(rng, STR_DISTRIBUTION_GEOMETRIC, aDecimalPlaces);
break;
}
case DIST_NEGATIVE_BINOMIAL:
{
std::negative_binomial_distribution<> distribution(parameterInteger2, parameter1);
auto rng = std::bind(distribution, seed);
auto rng = [&distribution, seed]() mutable
{
return distribution(seed);
};
GenerateNumbers(rng, STR_DISTRIBUTION_NEGATIVE_BINOMIAL, aDecimalPlaces);
break;
}
case DIST_POISSON:
{
std::poisson_distribution<> distribution(parameter1);
auto rng = std::bind(distribution, seed);
auto rng = [&distribution, seed]() mutable
{
return distribution(seed);
};
GenerateNumbers(rng, STR_DISTRIBUTION_POISSON, aDecimalPlaces);
break;
}
+32 -8
View File
@@ -3970,10 +3970,22 @@ SvNFEngine::Accessor SvNFEngine::GetRWPolicy(SvNFFormatData& rFormatData)
{
return
{
std::bind(SvNFEngine::GetCLOffsetRW, std::ref(rFormatData), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3),
std::bind(SvNFEngine::CacheFormatRW, std::ref(rFormatData), std::placeholders::_1, std::placeholders::_2),
std::bind(SvNFEngine::FindFormatRW, std::ref(rFormatData), std::placeholders::_1),
std::bind(SvNFEngine::DefaultCurrencyRW, std::ref(rFormatData), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)
[&rFormatData](SvNFLanguageData& rCurrentLanguage, const NativeNumberWrapper& rNatNum, LanguageType eLnge)
{
return SvNFEngine::GetCLOffsetRW(rFormatData, rCurrentLanguage, rNatNum, eLnge);
},
[&rFormatData](sal_uInt32 nSearch, sal_uInt32 nFormat)
{
return SvNFEngine::CacheFormatRW(rFormatData, nSearch, nFormat);
},
[&rFormatData](sal_uInt32 nSearch)
{
return SvNFEngine::FindFormatRW(rFormatData, nSearch);
},
[&rFormatData](SvNFLanguageData& rCurrentLanguage, const NativeNumberWrapper& rNatNum, sal_uInt32 CLOffset, LanguageType eLnge)
{
return SvNFEngine::DefaultCurrencyRW(rFormatData, rCurrentLanguage, rNatNum, CLOffset, eLnge);
}
};
}
@@ -3993,10 +4005,22 @@ SvNFEngine::Accessor SvNFEngine::GetROPolicy(const SvNFFormatData& rFormatData,
assert(g_CurrencyTableInitialized && "ensure PrepForRoMode is called");
return
{
std::bind(SvNFEngine::GetCLOffsetRO, std::ref(rFormatData), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3),
std::bind(SvNFEngine::CacheFormatRO, std::ref(rFormatCache), std::placeholders::_1, std::placeholders::_2),
std::bind(SvNFEngine::FindFormatRO, std::ref(rFormatData), std::ref(rFormatCache), std::placeholders::_1),
std::bind(SvNFEngine::DefaultCurrencyRO, std::ref(rFormatData), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)
[&rFormatData](SvNFLanguageData& rCurrentLanguage, const NativeNumberWrapper& rNatNum, LanguageType eLnge)
{
return SvNFEngine::GetCLOffsetRO(rFormatData, rCurrentLanguage, rNatNum, eLnge);
},
[&rFormatCache](sal_uInt32 nSearch, sal_uInt32 nFormat)
{
return SvNFEngine::CacheFormatRO(rFormatCache, nSearch, nFormat);
},
[&rFormatData, rFormatCache](sal_uInt32 nSearch)
{
return SvNFEngine::FindFormatRO(rFormatData, rFormatCache, nSearch);
},
[&rFormatData](SvNFLanguageData& rCurrentLanguage, const NativeNumberWrapper& rNatNum, sal_uInt32 CLOffset, LanguageType eLnge)
{
return SvNFEngine::DefaultCurrencyRO(rFormatData, rCurrentLanguage, rNatNum, CLOffset, eLnge);
}
};
}