clang-tidy: replace std::bind with lambdas

Found with modernize-avoid-bind

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2020-11-05 17:11:33 -08:00
parent afbcac9fb1
commit 071d3c71d8
No known key found for this signature in database
GPG Key ID: 36D31CFA845F0E3B
3 changed files with 17 additions and 20 deletions

View File

@ -120,19 +120,20 @@ static void
ParseInterface(Object &o, const char *interface,
ODBus::ReadMessageIter &&i) noexcept
{
using namespace std::placeholders;
if (StringIsEqual(interface, "org.freedesktop.UDisks2.Drive")) {
i.ForEachProperty(std::bind(ParseDriveDictEntry,
std::ref(o), _1, _2));
i.ForEachProperty([&](auto n, auto v) {
return ParseDriveDictEntry(o, n, std::move(v));
});
} else if (StringIsEqual(interface, "org.freedesktop.UDisks2.Block")) {
i.ForEachProperty(std::bind(ParseBlockDictEntry,
std::ref(o), _1, _2));
i.ForEachProperty([&](auto n, auto v) {
return ParseBlockDictEntry(o, n, std::move(v));
});
} else if (StringIsEqual(interface, "org.freedesktop.UDisks2.Filesystem")) {
o.is_filesystem = true;
i.ForEachProperty(std::bind(ParseFileesystemDictEntry,
std::ref(o), _1, _2));
i.ForEachProperty([&](auto n, auto v) {
return ParseFileesystemDictEntry(o, n, std::move(v));
});
}
}

View File

@ -128,9 +128,9 @@ UdisksNeighborExplorer::DoOpen()
UDISKS2_PATH,
DBUS_OM_INTERFACE,
"GetManagedObjects");
list_request.Send(connection, *msg.Get(),
std::bind(&UdisksNeighborExplorer::OnListNotify,
this, std::placeholders::_1));
list_request.Send(connection, *msg.Get(), [this](auto o) {
return OnListNotify(std::move(o));
});
} catch (...) {
dbus_connection_remove_filter(connection,
HandleMessage,
@ -229,9 +229,8 @@ inline void
UdisksNeighborExplorer::OnListNotify(ODBus::Message reply) noexcept
{
try{
ParseObjects(reply,
std::bind(&UdisksNeighborExplorer::Insert,
this, std::placeholders::_1));
UDisks2::ParseObjects(reply,
[this](auto p) { return Insert(std::move(p)); });
} catch (...) {
LogError(std::current_exception(),
"Failed to parse GetManagedObjects reply");

View File

@ -227,8 +227,7 @@ try {
DBUS_OM_INTERFACE,
"GetManagedObjects");
list_request.Send(connection, *msg.Get(),
std::bind(&UdisksStorage::OnListReply,
this, std::placeholders::_1));
[this](auto o) { return OnListReply(std::move(o)); });
return;
}
@ -239,8 +238,7 @@ try {
AppendMessageIter(*msg.Get()).AppendEmptyArray<DictEntryTypeTraits<StringTypeTraits, VariantTypeTraits>>();
mount_request.Send(connection, *msg.Get(),
std::bind(&UdisksStorage::OnMountNotify,
this, std::placeholders::_1));
[this](auto o) { return OnMountNotify(std::move(o)); });
} catch (...) {
const std::lock_guard<Mutex> lock(mutex);
mount_error = std::current_exception();
@ -297,8 +295,7 @@ try {
AppendMessageIter(*msg.Get()).AppendEmptyArray<DictEntryTypeTraits<StringTypeTraits, VariantTypeTraits>>();
mount_request.Send(connection, *msg.Get(),
std::bind(&UdisksStorage::OnUnmountNotify,
this, std::placeholders::_1));
[this](auto u) { return OnUnmountNotify(std::move(u)); });
} catch (...) {
const std::lock_guard<Mutex> lock(mutex);
mount_error = std::current_exception();