mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
refs #624 Use lambda init-capture.
This commit is contained in:
@@ -202,28 +202,21 @@ namespace BlackCore
|
|||||||
|
|
||||||
std::function<const char **()> CNetworkVatlib::toFSD(QStringList qstrList) const
|
std::function<const char **()> CNetworkVatlib::toFSD(QStringList qstrList) const
|
||||||
{
|
{
|
||||||
struct Closure
|
QVector<QByteArray> bytesVec;
|
||||||
|
for (auto i = qstrList.cbegin(); i != qstrList.cend(); ++i)
|
||||||
{
|
{
|
||||||
QVector<QByteArray> m_bytesVec;
|
bytesVec.push_back(toFSD(*i));
|
||||||
QVector<const char *> m_cstrVec;
|
}
|
||||||
Closure(QStringList qsl, const CNetworkVatlib *creator)
|
|
||||||
|
return [ cstrVec = QVector<const char *>(), bytesVec = std::move(bytesVec) ]() mutable
|
||||||
|
{
|
||||||
|
Q_ASSERT(cstrVec.isEmpty());
|
||||||
|
for (auto i = bytesVec.cbegin(); i != bytesVec.cend(); ++i)
|
||||||
{
|
{
|
||||||
for (auto i = qsl.begin(); i != qsl.end(); ++i)
|
cstrVec.push_back(i->constData());
|
||||||
{
|
|
||||||
m_bytesVec.push_back(creator->toFSD(*i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const char **operator()()
|
|
||||||
{
|
|
||||||
Q_ASSERT(m_cstrVec.isEmpty());
|
|
||||||
for (auto i = m_bytesVec.begin(); i != m_bytesVec.end(); ++i)
|
|
||||||
{
|
|
||||||
m_cstrVec.push_back(i->constData());
|
|
||||||
}
|
|
||||||
return const_cast<const char **>(m_cstrVec.constData());
|
|
||||||
}
|
}
|
||||||
|
return const_cast<const char **>(cstrVec.constData());
|
||||||
};
|
};
|
||||||
return Closure(qstrList, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CNetworkVatlib::fromFSD(const char *cstr) const
|
QString CNetworkVatlib::fromFSD(const char *cstr) const
|
||||||
|
|||||||
@@ -257,8 +257,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
void CDataCacheSerializer::deliverPromises(std::vector<std::promise<void>> i_promises)
|
void CDataCacheSerializer::deliverPromises(std::vector<std::promise<void>> i_promises)
|
||||||
{
|
{
|
||||||
auto promises = std::make_shared<decltype(i_promises)>(std::move(i_promises)); // \todo use C++14 lambda init-capture
|
QTimer::singleShot(0, Qt::PreciseTimer, this, [this, promises = std::make_shared<decltype(i_promises)>(std::move(i_promises))]()
|
||||||
QTimer::singleShot(0, Qt::PreciseTimer, this, [this, promises]
|
|
||||||
{
|
{
|
||||||
for (auto &promise : *promises)
|
for (auto &promise : *promises)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user