ivankelly commented on a change in pull request #2219: Cpp client: add
PatternMultiTopicsConsumerImpl to support regex subscribe
URL: https://github.com/apache/incubator-pulsar/pull/2219#discussion_r207466942
##########
File path: pulsar-client-cpp/lib/ClientConnection.cc
##########
@@ -856,28 +856,35 @@ void ClientConnection::handleIncomingCommand() {
<< " -- req_id: " <<
error.request_id());
Lock lock(mutex_);
- PendingRequestsMap::iterator it =
pendingRequests_.find(error.request_id());
- if (it != pendingRequests_.end()) {
+ if (pendingRequests_.find(error.request_id()) !=
pendingRequests_.end()) {
Review comment:
Ah, you need to declare the iterator outside of the if.
```
#include <iostream>
#include <unordered_map>
int main() {
std::unordered_map<int,int> m;
m.insert({1, 2});
m.insert({2, 3});
std::unordered_map<int,int>::iterator it;
if ((it = m.find(2)) != m.end()) {
std::cout << "found " << it->second << std::endl;
} else {
std::cout << "not found" << std::endl;
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services