mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 10:25:36 +08:00
Use fold expressions (C++17 feature)
This commit is contained in:
@@ -165,13 +165,8 @@ namespace BlackMisc
|
|||||||
template <typename T, typename F, size_t... Is>
|
template <typename T, typename F, size_t... Is>
|
||||||
void tupleForEachPairImpl(T &&tuple, F &&visitor, std::index_sequence<Is...>)
|
void tupleForEachPairImpl(T &&tuple, F &&visitor, std::index_sequence<Is...>)
|
||||||
{
|
{
|
||||||
// parameter pack swallow idiom
|
// cppcheck-suppress accessForwarded
|
||||||
static_cast<void>(std::initializer_list<int>
|
(static_cast<void>(std::forward<F>(visitor)(std::get<Is * 2>(std::forward<T>(tuple)), std::get<Is * 2 + 1>(std::forward<T>(tuple)))), ...);
|
||||||
{
|
|
||||||
//! \fixme C-style cast is needed due to a clang bug: https://bugs.llvm.org/show_bug.cgi?id=39375
|
|
||||||
// cppcheck-suppress accessForwarded
|
|
||||||
((void)(std::forward<F>(visitor)(std::get<Is * 2>(std::forward<T>(tuple)), std::get<Is * 2 + 1>(std::forward<T>(tuple)))), 0)...
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -280,12 +280,7 @@ namespace BlackMisc
|
|||||||
template <typename F>
|
template <typename F>
|
||||||
static void forEachMember(F &&visitor)
|
static void forEachMember(F &&visitor)
|
||||||
{
|
{
|
||||||
// parameter pack swallow idiom
|
(static_cast<void>(std::forward<F>(visitor)(members().at(index<Is>()))), ...);
|
||||||
static_cast<void>(std::initializer_list<int>
|
|
||||||
{
|
|
||||||
//! \fixme C-style cast is needed due to a clang bug: https://bugs.llvm.org/show_bug.cgi?id=39375
|
|
||||||
((void)(std::forward<F>(visitor)(members().at(index<Is>()))), 0)...
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
return [vs...](const auto &a, const auto &b)
|
return [vs...](const auto &a, const auto &b)
|
||||||
{
|
{
|
||||||
return std::forward_as_tuple((a.*vs)()...) == std::forward_as_tuple((b.*vs)()...);
|
return (((a.*vs)() == (b.*vs)()) && ...);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user