build: align minimum build dependencies with ndn-cxx
* Recommend gcc >= 7.4.0
* Require clang >= 4.0, or Xcode >= 9.0 on macOS
* Silence an ABI-related diagnostic message from gcc on armv7
* Update Travis CI job matrix
Refs: #5087, #5106
Change-Id: I71aef00147a7ad93b537904bb309745fed77f509
diff --git a/src/state.cpp b/src/state.cpp
index c6b3ead..533a451 100644
--- a/src/state.cpp
+++ b/src/state.cpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2017 University of California, Los Angeles
+ * Copyright (c) 2012-2020 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -24,6 +24,8 @@
#include "state.hpp"
+#include <boost/range/adaptor/reversed.hpp>
+
namespace chronosync {
State::~State() = default;
@@ -52,8 +54,7 @@
}
SeqNo old = (*leaf)->getSeq();
- m_leaves.modify(leaf,
- [=] (LeafPtr& leaf) { leaf->setSeq(seq); } );
+ m_leaves.modify(leaf, [=] (LeafPtr& leaf) { leaf->setSeq(seq); } );
return make_tuple(false, true, old);
}
}
@@ -63,16 +64,14 @@
{
m_digest.reset();
- BOOST_FOREACH (ConstLeafPtr leaf, m_leaves.get<ordered>())
- {
- BOOST_ASSERT(leaf != 0);
- m_digest.update(leaf->getDigest()->data(), leaf->getDigest()->size());
- }
+ for (const auto& leaf : m_leaves.get<ordered>()) {
+ BOOST_ASSERT(leaf != nullptr);
+ m_digest.update(leaf->getDigest()->data(), leaf->getDigest()->size());
+ }
return m_digest.computeDigest();
}
-
void
State::reset()
{
@@ -82,12 +81,10 @@
State&
State::operator+=(const State& state)
{
- BOOST_FOREACH (ConstLeafPtr leaf, state.getLeaves())
- {
- BOOST_ASSERT(leaf != 0);
- update(leaf->getSessionName(), leaf->getSeq());
- }
-
+ for (const auto& leaf : state.getLeaves()) {
+ BOOST_ASSERT(leaf != nullptr);
+ update(leaf->getSessionName(), leaf->getSeq());
+ }
return *this;
}
@@ -97,15 +94,14 @@
{
size_t totalLength = 0;
- BOOST_REVERSE_FOREACH (ConstLeafPtr leaf, m_leaves.get<ordered>())
- {
- size_t entryLength = 0;
- entryLength += prependNonNegativeIntegerBlock(block, tlv::SeqNo, leaf->getSeq());
- entryLength += leaf->getSessionName().wireEncode(block);
- entryLength += block.prependVarNumber(entryLength);
- entryLength += block.prependVarNumber(tlv::StateLeaf);
- totalLength += entryLength;
- }
+ for (const auto& leaf : m_leaves.get<ordered>() | boost::adaptors::reversed) {
+ size_t entryLength = 0;
+ entryLength += prependNonNegativeIntegerBlock(block, tlv::SeqNo, leaf->getSeq());
+ entryLength += leaf->getSessionName().wireEncode(block);
+ entryLength += block.prependVarNumber(entryLength);
+ entryLength += block.prependVarNumber(tlv::StateLeaf);
+ totalLength += entryLength;
+ }
totalLength += block.prependVarNumber(totalLength);
totalLength += block.prependVarNumber(tlv::SyncReply);
@@ -144,12 +140,11 @@
wire.parse();
m_wire = wire;
- for (Block::element_const_iterator it = wire.elements_begin();
- it != wire.elements_end(); it++) {
+ for (auto it = wire.elements_begin(); it != wire.elements_end(); it++) {
if (it->type() == tlv::StateLeaf) {
it->parse();
- Block::element_const_iterator val = it->elements_begin();
+ auto val = it->elements_begin();
Name info(*val);
val++;