util: backport std::experimental::ostream_joiner
Change-Id: I4d12269ac41f07d224772abc0e50039be519fdcc
Refs: #3962
diff --git a/src/mgmt/nfd/fib-entry.cpp b/src/mgmt/nfd/fib-entry.cpp
index e3633aa..db3b69f 100644
--- a/src/mgmt/nfd/fib-entry.cpp
+++ b/src/mgmt/nfd/fib-entry.cpp
@@ -269,13 +269,9 @@
os << "FibEntry(Prefix: " << entry.getPrefix() << ",\n"
<< " NextHops: [";
- bool first = true;
- for (const auto& nh : entry.getNextHopRecords()) {
- if (!first)
- os << ",\n ";
- first = false;
- os << nh;
- }
+ std::copy(entry.getNextHopRecords().begin(), entry.getNextHopRecords().end(),
+ make_ostream_joiner(os, ",\n "));
+
os << "]\n";
return os << " )";
diff --git a/src/mgmt/nfd/rib-entry.cpp b/src/mgmt/nfd/rib-entry.cpp
index c7ec47a..315b4bd 100644
--- a/src/mgmt/nfd/rib-entry.cpp
+++ b/src/mgmt/nfd/rib-entry.cpp
@@ -348,13 +348,9 @@
os << "RibEntry(Prefix: " << entry.getName() << ",\n"
<< " Routes: [";
- bool isFirst = true;
- for (const auto& route : entry.getRoutes()) {
- if (!isFirst)
- os << ",\n ";
- isFirst = false;
- os << route;
- }
+ std::copy(entry.getRoutes().begin(), entry.getRoutes().end(),
+ make_ostream_joiner(os, ",\n "));
+
os << "]\n";
return os << " )";