mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 18:04:32 +00:00
Use forwarding reference when passing function objects
So instead of passing every function objects by value (a copy is made), now function objects will be handled properly by reference (for lvalues) or by value (for rvalues).
This commit is contained in:
parent
6738cdd715
commit
c75500670d
@ -50,7 +50,7 @@ namespace Algorithm
|
|||||||
// To be used with associative array types, such as QMap, QHash and it's variants
|
// To be used with associative array types, such as QMap, QHash and it's variants
|
||||||
template <typename T, typename BinaryPredicate
|
template <typename T, typename BinaryPredicate
|
||||||
, typename std::enable_if_t<HasMappedType<T>::value, int> = 0>
|
, typename std::enable_if_t<HasMappedType<T>::value, int> = 0>
|
||||||
void removeIf(T &dict, BinaryPredicate p)
|
void removeIf(T &dict, BinaryPredicate &&p)
|
||||||
{
|
{
|
||||||
auto it = dict.begin();
|
auto it = dict.begin();
|
||||||
while (it != dict.end())
|
while (it != dict.end())
|
||||||
@ -60,7 +60,7 @@ namespace Algorithm
|
|||||||
// To be used with set types, such as QSet, std::set
|
// To be used with set types, such as QSet, std::set
|
||||||
template <typename T, typename UnaryPredicate
|
template <typename T, typename UnaryPredicate
|
||||||
, typename std::enable_if_t<!HasMappedType<T>::value, int> = 0>
|
, typename std::enable_if_t<!HasMappedType<T>::value, int> = 0>
|
||||||
void removeIf(T &set, UnaryPredicate p)
|
void removeIf(T &set, UnaryPredicate &&p)
|
||||||
{
|
{
|
||||||
auto it = set.begin();
|
auto it = set.begin();
|
||||||
while (it != set.end())
|
while (it != set.end())
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
// T proxyFunc(const T &a);
|
// T proxyFunc(const T &a);
|
||||||
template <typename ProxyFunc>
|
template <typename ProxyFunc>
|
||||||
explicit CachedSettingValue(const char *keyName, const T &defaultValue
|
explicit CachedSettingValue(const char *keyName, const T &defaultValue
|
||||||
, ProxyFunc proxyFunc)
|
, ProxyFunc &&proxyFunc)
|
||||||
: m_keyName(QLatin1String(keyName))
|
: m_keyName(QLatin1String(keyName))
|
||||||
, m_value(proxyFunc(loadValue(defaultValue)))
|
, m_value(proxyFunc(loadValue(defaultValue)))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user