Skip to content

Commit a5986b8

Browse files
committed
Use C++11 foreach loop and auto
1 parent 6bb6281 commit a5986b8

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/vp8_streamer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ void Vp8Streamer::initializeEncoder()
5656
av_opt_map["drop_frame"] = "1";
5757
av_opt_map["error-resilient"] = "1";
5858

59-
for (AvOptMap::iterator itr = av_opt_map.begin(); itr != av_opt_map.end(); ++itr) {
60-
av_opt_set(codec_context_->priv_data, itr->first.c_str(), itr->second.c_str(), 0);
59+
for (auto & opt : av_opt_map) {
60+
av_opt_set(codec_context_->priv_data, opt.first.c_str(), opt.second.c_str(), 0);
6161
}
6262

6363
// Buffering settings

src/web_video_server.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#include <chrono>
3434
#include <vector>
3535

36-
#include <boost/foreach.hpp>
37-
#include <boost/lexical_cast.hpp>
3836
#include <boost/algorithm/string/predicate.hpp>
3937
#include <opencv2/opencv.hpp>
4038

@@ -137,23 +135,20 @@ void WebVideoServer::restreamFrames(double max_age)
137135
{
138136
std::scoped_lock lock(subscriber_mutex_);
139137

140-
typedef std::vector<std::shared_ptr<ImageStreamer>>::iterator itr_type;
141-
142-
for (itr_type itr = image_subscribers_.begin(); itr < image_subscribers_.end(); ++itr) {
143-
(*itr)->restreamFrame(max_age);
138+
for (auto& subscriber : image_subscribers_) {
139+
subscriber->restreamFrame(max_age);
144140
}
145141
}
146142

147143
void WebVideoServer::cleanup_inactive_streams()
148144
{
149145
std::unique_lock lock(subscriber_mutex_, std::try_to_lock);
150146
if (lock) {
151-
typedef std::vector<std::shared_ptr<ImageStreamer>>::iterator itr_type;
152-
itr_type new_end = std::partition(
147+
auto new_end = std::partition(
153148
image_subscribers_.begin(), image_subscribers_.end(),
154149
!boost::bind(&ImageStreamer::isInactive, _1));
155150
if (verbose_) {
156-
for (itr_type itr = new_end; itr < image_subscribers_.end(); ++itr) {
151+
for (auto itr = new_end; itr < image_subscribers_.end(); ++itr) {
157152
RCLCPP_INFO(node_->get_logger(), "Removed Stream: %s", (*itr)->getTopic().c_str());
158153
}
159154
}
@@ -326,8 +321,7 @@ bool WebVideoServer::handle_list_streams(
326321
"<head><title>ROS Image Topic List</title></head>"
327322
"<body><h1>Available ROS Image Topics:</h1>");
328323
connection->write("<ul>");
329-
BOOST_FOREACH(std::string & camera_info_topic, camera_info_topics)
330-
{
324+
for(std::string & camera_info_topic : camera_info_topics) {
331325
if (boost::algorithm::ends_with(camera_info_topic, "/camera_info")) {
332326
std::string base_topic = camera_info_topic.substr(
333327
0,

0 commit comments

Comments
 (0)