Skip to content

Commit 85b8220

Browse files
committed
NO-JIRA: Trivial changes for pedantic C++17 compliance
1 parent 8d2f825 commit 85b8220

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cpp/examples/broker.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ class Queue {
151151
if (credit>0) {
152152
DOUT(std::cerr << sender << " ";);
153153
auto msg = messages_.front();
154-
sender->add([=]{sender->sendMsg(msg);});
154+
auto& s = sender; // C++17 doesn't allow lambda capture of structured bindings
155+
sender->add([=]{s->sendMsg(msg);});
155156
messages_.pop_front();
156157
--credit;
157158
++current_;
@@ -226,15 +227,16 @@ void Sender::on_tracker_settle(proton::tracker& tracker) {
226227
auto delivery_count = msg.delivery_count();
227228
if (delivery_count<redelivery_limit) {
228229
msg.delivery_count(delivery_count + 1);
229-
queue_->add([=] {queue_->queueMsg(msg);});
230+
auto& m = msg; // C++17 doesn't allow lambda capture of structured bindings
231+
queue_->add([=] {queue_->queueMsg(m);});
230232
} else {
231233
DOUT(std::cerr << "Sender: " << this << " on_tracker_settle: " << tag << ": Too many redeliveries: " << delivery_count << "\n";);
232234
}
233235
}
234236
}
235237
unsettled_messages_.erase(i);
236238
}
237-
};
239+
}
238240

239241
void Sender::boundQueue(Queue* q, std::string qn) {
240242
DOUT(std::cerr << "Sender: " << this << " bound to Queue: " << q <<"(" << qn << ")\n";);

0 commit comments

Comments
 (0)