Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C++03 incompatibility from local struct in template parameter #504

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading