Simplify code with four-legged std::equal

This commit is contained in:
Zhihao Yuan 2019-11-16 21:26:49 -06:00
parent 50c91a0bcc
commit 955e1e1e6c
No known key found for this signature in database
GPG Key ID: A2E474BDAA37E11C

View File

@ -270,15 +270,11 @@ public:
operator==(const T &aRhs) const { operator==(const T &aRhs) const {
using ValueType = typename T::value_type; using ValueType = typename T::value_type;
auto tLhs = get<T>(); auto tLhs = get<T>();
if (tLhs.size() != aRhs.size())
return false;
else {
return std::equal(std::begin(tLhs), std::end(tLhs), std::begin(aRhs), return std::equal(std::begin(tLhs), std::end(tLhs), std::begin(aRhs),
[](const auto &lhs, const auto &rhs) { std::end(aRhs), [](const auto &lhs, const auto &rhs) {
return std::any_cast<const ValueType &>(lhs) == rhs; return std::any_cast<const ValueType &>(lhs) == rhs;
}); });
} }
}
private: private:
static bool is_integer(const std::string &aValue) { static bool is_integer(const std::string &aValue) {