Skip to content

Commit

Permalink
Fix C++03 incompatibility from local struct in template parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Foxhall <[email protected]>
  • Loading branch information
hallfox committed Nov 7, 2024
1 parent 4577b69 commit f1b715f
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,22 @@ void stopChannelFactory(bmqio::ChannelFactory* channelFactory)
factory->stop();
}

/// A predicate functor for comparing a [mqbcfg::TcpInterfaceListener] by their
/// `port()` member.
struct PortMatcher {
int d_port;

PortMatcher(int port)
: d_port(port)
{
}

bool operator()(const mqbcfg::TcpInterfaceListener& listener)
{
return listener.port() == d_port;
}
};

} // close unnamed namespace

// -----------------------------------------
Expand Down Expand Up @@ -1529,16 +1545,7 @@ bool TCPSessionFactory::isEndpointLoopback(const bslstl::StringRef& uri) const
bmqio::ChannelUtil::isLocalHost(endpoint.host());
}

struct PortMatcher {
int d_port;

bool operator()(const mqbcfg::TcpInterfaceListener& listener)
{
return listener.port() == d_port;
}
};

PortMatcher portMatcher = {endpoint.port()};
PortMatcher portMatcher(endpoint.port());
return bsl::any_of(d_config.listeners().cbegin(),
d_config.listeners().cend(),
portMatcher);
Expand Down Expand Up @@ -1578,7 +1585,7 @@ TCPSessionFactory::PortManager::addChannelContext(bmqst::StatContext* parent,
bsl::shared_ptr<bmqst::StatContext> portStatContext =
parent->addSubcontext(
portConfig.storeExpiredSubcontextValues(true));
channelStatContext = portStatContext->addSubcontext(statConfig);
channelStatContext = portStatContext->addSubcontext(statConfig);
PortContext portContext = {portStatContext, 1};
d_portMap.emplace(port, portContext);
}
Expand Down

0 comments on commit f1b715f

Please sign in to comment.