Commit 4791d1d0 authored by Fabian Kosmale's avatar Fabian Kosmale
Browse files

use std::accumulate

parent 66376199
......@@ -29,8 +29,8 @@ find_package(PolkitQt-1 REQUIRED)
INCLUDE(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS} -W -Wall)
#add_definitions(-std=c++11)
add_definitions(-Werror)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(
BEFORE SYSTEM
......
......@@ -18,6 +18,7 @@
#include <QThreadPool>
#include <QDebug>
#include <numeric>
namespace Akabei
{
......@@ -124,28 +125,26 @@ qint64 OperationRunner::count() const
{
Q_D(const OperationRunner);
QMutexLocker locker(d->mutex);
qint64 retcount = 0;
QHash<Operation::Phase, QList< Operation* > >::const_iterator i;
for (i = d->operations.constBegin(); i != d->operations.constEnd(); ++i) {
retcount += i.value().count();
}
return retcount;
return std::accumulate(d->operations.constBegin(),
d->operations.constEnd(),
0,
[](qint64 sum, const QList<Akabei::Operation *> elem)
{return sum + elem.count();}
);
}
QList<Operation*> OperationRunner::operations() const
{
Q_D(const OperationRunner);
QMutexLocker locker(d->mutex);
QList<Operation*> retlist;
QHash<Operation::Phase, QList< Operation* > >::const_iterator i;
for (i = d->operations.constBegin(); i != d->operations.constEnd(); ++i) {
retlist << i.value();
}
return std::accumulate(d->operations.constBegin(),
d->operations.constEnd(),
QList<Akabei::Operation*>(),
[](QList<Akabei::Operation*> l, const QList<Akabei::Operation *> elem)
{return l << elem;}
);
return retlist;
}
QList<Operation*> OperationRunner::operationsForPhase(Operation::Phase phase) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment