From 8137e04218699aaca3c5618bdb50b9d5ac50330b Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Wed, 24 Jul 2024 15:03:43 -0400 Subject: [PATCH] Add noexcept to C++ proxy functions that don't throw (#2560) --- cpp/include/Ice/Proxy.h | 51 +++++++++-------- cpp/include/Ice/ProxyFunctions.h | 30 +++++----- cpp/src/Ice/InstrumentationI.cpp | 8 +-- cpp/src/Ice/Proxy.cpp | 52 ++++++++--------- cpp/src/Ice/Reference.cpp | 52 ++++++++--------- cpp/src/Ice/Reference.h | 98 ++++++++++++++++---------------- 6 files changed, 146 insertions(+), 145 deletions(-) diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index d729ef727c4..0ee718e43f6 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -55,7 +55,7 @@ namespace Ice * It's also aesthetically pleasing when making invocations: the proxy appears like a pointer to the remote * object. */ - const Prx* operator->() const { return &asPrx(); } + const Prx* operator->() const noexcept { return &asPrx(); } // We don't provide the non-const operator-> because only the assignment operators can modify the proxy. @@ -237,7 +237,7 @@ namespace Ice return ref == self._reference ? self : Prx::_fromReference(std::move(ref)); } - const Prx& asPrx() const { return *static_cast(this); } + const Prx& asPrx() const noexcept { return *static_cast(this); } }; /** @@ -536,7 +536,7 @@ namespace Ice * @return The cached connection for this proxy, or nil if the proxy does not have * an established connection. */ - Ice::ConnectionPtr ice_getCachedConnection() const; + Ice::ConnectionPtr ice_getCachedConnection() const noexcept; /** * Flushes any pending batched requests for this communicator. The call blocks until the flush is complete. @@ -586,7 +586,7 @@ namespace Ice * Obtains the facet for this proxy. * @return The facet for this proxy. If the proxy uses the default facet, the return value is the empty string. */ - const std::string& ice_getFacet() const; + std::string ice_getFacet() const; /** * Obtains a proxy that is identical to this proxy, except for the facet. @@ -615,100 +615,100 @@ namespace Ice * Obtains the locator cache timeout of this proxy. * @return The locator cache timeout value (in seconds). */ - std::int32_t ice_getLocatorCacheTimeout() const; + std::int32_t ice_getLocatorCacheTimeout() const noexcept; /** * Determines whether this proxy caches connections. * @return True if this proxy caches connections, false otherwise. */ - bool ice_isConnectionCached() const; + bool ice_isConnectionCached() const noexcept; /** * Obtains the endpoint selection policy for this proxy (randomly or ordered). * @return The endpoint selection policy. */ - Ice::EndpointSelectionType ice_getEndpointSelection() const; + Ice::EndpointSelectionType ice_getEndpointSelection() const noexcept; /** * Determines whether this proxy uses only secure endpoints. * @return True if this proxy communicates only via secure endpoints, false otherwise. */ - bool ice_isSecure() const; + bool ice_isSecure() const noexcept; /** * Obtains the encoding version used to marshal request parameters. * @return The encoding version. */ - Ice::EncodingVersion ice_getEncodingVersion() const; + Ice::EncodingVersion ice_getEncodingVersion() const noexcept; /** * Determines whether this proxy prefers secure endpoints. * @return True if the proxy always attempts to invoke via secure endpoints before it * attempts to use insecure endpoints, false otherwise. */ - bool ice_isPreferSecure() const; + bool ice_isPreferSecure() const noexcept; /** * Obtains the router for this proxy. * @return The router for the proxy. If no router is configured for the proxy, the return value * is nullopt. */ - std::optional ice_getRouter() const; + std::optional ice_getRouter() const noexcept; /** * Obtains the locator for this proxy. * @return The locator for this proxy. If no locator is configured, the return value is nullopt. */ - std::optional ice_getLocator() const; + std::optional ice_getLocator() const noexcept; /** * Determines whether this proxy uses collocation optimization. * @return True if the proxy uses collocation optimization, false otherwise. */ - bool ice_isCollocationOptimized() const; + bool ice_isCollocationOptimized() const noexcept; /** * Obtains the invocation timeout of this proxy. * @return The invocation timeout value (in milliseconds). */ - std::int32_t ice_getInvocationTimeout() const; + std::int32_t ice_getInvocationTimeout() const noexcept; /** * Determines whether this proxy uses twoway invocations. * @return True if this proxy uses twoway invocations, false otherwise. */ - bool ice_isTwoway() const; + bool ice_isTwoway() const noexcept; /** * Determines whether this proxy uses oneway invocations. * @return True if this proxy uses oneway invocations, false otherwise. */ - bool ice_isOneway() const; + bool ice_isOneway() const noexcept; /** * Determines whether this proxy uses batch oneway invocations. * @return True if this proxy uses batch oneway invocations, false otherwise. */ - bool ice_isBatchOneway() const; + bool ice_isBatchOneway() const noexcept; /** * Determines whether this proxy uses datagram invocations. * @return True if this proxy uses datagram invocations, false otherwise. */ - bool ice_isDatagram() const; + bool ice_isDatagram() const noexcept; /** * Determines whether this proxy uses batch datagram invocations. * @return True if this proxy uses batch datagram invocations, false otherwise. */ - bool ice_isBatchDatagram() const; + bool ice_isBatchDatagram() const noexcept; /** * Obtains the compression override setting of this proxy. * @return The compression override setting. If nullopt is returned, no override is set. Otherwise, true * if compression is enabled, false otherwise. */ - std::optional ice_getCompress() const; + std::optional ice_getCompress() const noexcept; /** * Obtains the connection ID of this proxy. @@ -720,7 +720,7 @@ namespace Ice * Determines whether this proxy is a fixed proxy. * @return True if this proxy is a fixed proxy, false otherwise. */ - bool ice_isFixed() const; + bool ice_isFixed() const noexcept; /** * Returns the Slice type ID associated with this type. @@ -732,7 +732,7 @@ namespace Ice * Obtains the communicator that created this proxy. * @return The communicator that created this proxy. */ - Ice::CommunicatorPtr ice_getCommunicator() const; + Ice::CommunicatorPtr ice_getCommunicator() const noexcept; /** * Obtains a stringified version of this proxy. @@ -745,8 +745,11 @@ namespace Ice static ObjectPrx _fromReference(IceInternal::ReferencePtr ref) { return ObjectPrx(std::move(ref)); } - const IceInternal::ReferencePtr& _getReference() const { return _reference; } - const IceInternal::RequestHandlerCachePtr& _getRequestHandlerCache() const { return _requestHandlerCache; } + const IceInternal::ReferencePtr& _getReference() const noexcept { return _reference; } + const IceInternal::RequestHandlerCachePtr& _getRequestHandlerCache() const noexcept + { + return _requestHandlerCache; + } void _checkTwowayOnly(std::string_view) const; diff --git a/cpp/include/Ice/ProxyFunctions.h b/cpp/include/Ice/ProxyFunctions.h index 6a1fcf3b223..f4673fb9d80 100644 --- a/cpp/include/Ice/ProxyFunctions.h +++ b/cpp/include/Ice/ProxyFunctions.h @@ -160,13 +160,13 @@ namespace Ice return proxy ? checkedCast(proxy->ice_facet(std::move(facet)), context) : std::nullopt; } - ICE_API bool operator<(const ObjectPrx&, const ObjectPrx&); - ICE_API bool operator==(const ObjectPrx&, const ObjectPrx&); + ICE_API bool operator<(const ObjectPrx&, const ObjectPrx&) noexcept; + ICE_API bool operator==(const ObjectPrx&, const ObjectPrx&) noexcept; - inline bool operator>(const ObjectPrx& lhs, const ObjectPrx& rhs) { return rhs < lhs; } - inline bool operator<=(const ObjectPrx& lhs, const ObjectPrx& rhs) { return !(lhs > rhs); } - inline bool operator>=(const ObjectPrx& lhs, const ObjectPrx& rhs) { return !(lhs < rhs); } - inline bool operator!=(const ObjectPrx& lhs, const ObjectPrx& rhs) { return !(lhs == rhs); } + inline bool operator>(const ObjectPrx& lhs, const ObjectPrx& rhs) noexcept { return rhs < lhs; } + inline bool operator<=(const ObjectPrx& lhs, const ObjectPrx& rhs) noexcept { return !(lhs > rhs); } + inline bool operator>=(const ObjectPrx& lhs, const ObjectPrx& rhs) noexcept { return !(lhs < rhs); } + inline bool operator!=(const ObjectPrx& lhs, const ObjectPrx& rhs) noexcept { return !(lhs == rhs); } ICE_API std::ostream& operator<<(std::ostream&, const ObjectPrx&); @@ -190,7 +190,7 @@ namespace Ice * @param rhs A proxy. * @return True if the identity in lhs compares less than the identity in rhs, false otherwise. */ - ICE_API bool proxyIdentityLess(const std::optional& lhs, const std::optional& rhs); + ICE_API bool proxyIdentityLess(const std::optional& lhs, const std::optional& rhs) noexcept; /** * Compares the object identities of two proxies. @@ -198,7 +198,7 @@ namespace Ice * @param rhs A proxy. * @return True if the identity in lhs compares equal to the identity in rhs, false otherwise. */ - ICE_API bool proxyIdentityEqual(const std::optional& lhs, const std::optional& rhs); + ICE_API bool proxyIdentityEqual(const std::optional& lhs, const std::optional& rhs) noexcept; /** * Compares the object identities and facets of two proxies. @@ -207,7 +207,8 @@ namespace Ice * @return True if the identity and facet in lhs compare less than the identity and facet * in rhs, false otherwise. */ - ICE_API bool proxyIdentityAndFacetLess(const std::optional& lhs, const std::optional& rhs); + ICE_API bool + proxyIdentityAndFacetLess(const std::optional& lhs, const std::optional& rhs) noexcept; /** * Compares the object identities and facets of two proxies. @@ -216,7 +217,8 @@ namespace Ice * @return True if the identity and facet in lhs compare equal to the identity and facet * in rhs, false otherwise. */ - ICE_API bool proxyIdentityAndFacetEqual(const std::optional& lhs, const std::optional& rhs); + ICE_API bool + proxyIdentityAndFacetEqual(const std::optional& lhs, const std::optional& rhs) noexcept; /** * A functor that compares the object identities of two proxies. Evaluates true if the identity in lhs @@ -226,7 +228,7 @@ namespace Ice struct ProxyIdentityLess { - bool operator()(const std::optional& lhs, const std::optional& rhs) const + bool operator()(const std::optional& lhs, const std::optional& rhs) const noexcept { return proxyIdentityLess(lhs, rhs); } @@ -239,7 +241,7 @@ namespace Ice */ struct ProxyIdentityEqual { - bool operator()(const std::optional& lhs, const std::optional& rhs) const + bool operator()(const std::optional& lhs, const std::optional& rhs) const noexcept { return proxyIdentityEqual(lhs, rhs); } @@ -252,7 +254,7 @@ namespace Ice */ struct ProxyIdentityAndFacetLess { - bool operator()(const std::optional& lhs, const std::optional& rhs) const + bool operator()(const std::optional& lhs, const std::optional& rhs) const noexcept { return proxyIdentityAndFacetLess(lhs, rhs); } @@ -265,7 +267,7 @@ namespace Ice */ struct ProxyIdentityAndFacetEqual { - bool operator()(const std::optional& lhs, const std::optional& rhs) const + bool operator()(const std::optional& lhs, const std::optional& rhs) const noexcept { return proxyIdentityAndFacetEqual(lhs, rhs); } diff --git a/cpp/src/Ice/InstrumentationI.cpp b/cpp/src/Ice/InstrumentationI.cpp index 2f2ea13219f..1654fa80feb 100644 --- a/cpp/src/Ice/InstrumentationI.cpp +++ b/cpp/src/Ice/InstrumentationI.cpp @@ -10,7 +10,6 @@ #include "Ice/LocalExceptions.h" #include "Ice/LoggerUtil.h" #include "Ice/ObjectAdapter.h" - #include "Ice/VersionFunctions.h" using namespace std; @@ -19,8 +18,6 @@ using namespace IceInternal; using namespace Ice::Instrumentation; using namespace IceMX; -#define ICE_OBJECT_PRX Ice::ObjectPrx - namespace { int ThreadMetrics::*getThreadStateMetric(ThreadState s) @@ -294,11 +291,10 @@ namespace { add("parent", &InvocationHelper::getParent); add("id", &InvocationHelper::getId); - add("operation", &InvocationHelper::getOperation); add("identity", &InvocationHelper::getIdentity); - add("facet", &InvocationHelper::getProxy, &ICE_OBJECT_PRX::ice_getFacet); - add("encoding", &InvocationHelper::getProxy, &ICE_OBJECT_PRX::ice_getEncodingVersion); + add("facet", &InvocationHelper::getProxy, &Ice::ObjectPrx::ice_getFacet); + add("encoding", &InvocationHelper::getProxy, &Ice::ObjectPrx::ice_getEncodingVersion); add("mode", &InvocationHelper::getMode); add("proxy", &InvocationHelper::getProxy); diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index e1b6af49f6f..cab8682c7b6 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -86,7 +86,7 @@ Ice::ObjectPrx::ice_getContext() const return _reference->getContext()->getValue(); } -const string& +string Ice::ObjectPrx::ice_getFacet() const { return _reference->getFacet(); @@ -110,99 +110,99 @@ Ice::ObjectPrx::ice_getEndpoints() const } int32_t -Ice::ObjectPrx::ice_getLocatorCacheTimeout() const +Ice::ObjectPrx::ice_getLocatorCacheTimeout() const noexcept { return _reference->getLocatorCacheTimeout(); } bool -Ice::ObjectPrx::ice_isConnectionCached() const +Ice::ObjectPrx::ice_isConnectionCached() const noexcept { return _reference->getCacheConnection(); } EndpointSelectionType -Ice::ObjectPrx::ice_getEndpointSelection() const +Ice::ObjectPrx::ice_getEndpointSelection() const noexcept { return _reference->getEndpointSelection(); } bool -Ice::ObjectPrx::ice_isSecure() const +Ice::ObjectPrx::ice_isSecure() const noexcept { return _reference->getSecure(); } ::Ice::EncodingVersion -Ice::ObjectPrx::ice_getEncodingVersion() const +Ice::ObjectPrx::ice_getEncodingVersion() const noexcept { return _reference->getEncoding(); } bool -Ice::ObjectPrx::ice_isPreferSecure() const +Ice::ObjectPrx::ice_isPreferSecure() const noexcept { return _reference->getPreferSecure(); } optional -Ice::ObjectPrx::ice_getRouter() const +Ice::ObjectPrx::ice_getRouter() const noexcept { RouterInfoPtr routerInfo = _reference->getRouterInfo(); return routerInfo ? make_optional(routerInfo->getRouter()) : nullopt; } optional -Ice::ObjectPrx::ice_getLocator() const +Ice::ObjectPrx::ice_getLocator() const noexcept { LocatorInfoPtr locatorInfo = _reference->getLocatorInfo(); return locatorInfo ? make_optional(locatorInfo->getLocator()) : nullopt; } bool -Ice::ObjectPrx::ice_isCollocationOptimized() const +Ice::ObjectPrx::ice_isCollocationOptimized() const noexcept { return _reference->getCollocationOptimized(); } int32_t -Ice::ObjectPrx::ice_getInvocationTimeout() const +Ice::ObjectPrx::ice_getInvocationTimeout() const noexcept { return _reference->getInvocationTimeout(); } bool -Ice::ObjectPrx::ice_isTwoway() const +Ice::ObjectPrx::ice_isTwoway() const noexcept { return _reference->getMode() == Reference::ModeTwoway; } bool -Ice::ObjectPrx::ice_isOneway() const +Ice::ObjectPrx::ice_isOneway() const noexcept { return _reference->getMode() == Reference::ModeOneway; } bool -Ice::ObjectPrx::ice_isBatchOneway() const +Ice::ObjectPrx::ice_isBatchOneway() const noexcept { return _reference->getMode() == Reference::ModeBatchOneway; } bool -Ice::ObjectPrx::ice_isDatagram() const +Ice::ObjectPrx::ice_isDatagram() const noexcept { return _reference->getMode() == Reference::ModeDatagram; } bool -Ice::ObjectPrx::ice_isBatchDatagram() const +Ice::ObjectPrx::ice_isBatchDatagram() const noexcept { return _reference->getMode() == Reference::ModeBatchDatagram; } optional -Ice::ObjectPrx::ice_getCompress() const +Ice::ObjectPrx::ice_getCompress() const noexcept { return _reference->getCompress(); } @@ -214,19 +214,19 @@ Ice::ObjectPrx::ice_getConnectionId() const } bool -Ice::ObjectPrx::ice_isFixed() const +Ice::ObjectPrx::ice_isFixed() const noexcept { return dynamic_pointer_cast(_reference) != nullptr; } ConnectionPtr -Ice::ObjectPrx::ice_getCachedConnection() const +Ice::ObjectPrx::ice_getCachedConnection() const noexcept { return _requestHandlerCache->getCachedConnection(); } CommunicatorPtr -Ice::ObjectPrx::ice_getCommunicator() const +Ice::ObjectPrx::ice_getCommunicator() const noexcept { return _reference->getCommunicator(); } @@ -606,33 +606,33 @@ IceInternal::throwNullProxyMarshalException(const char* file, int line, const Cu namespace Ice { - bool operator<(const ObjectPrx& lhs, const ObjectPrx& rhs) + bool operator<(const ObjectPrx& lhs, const ObjectPrx& rhs) noexcept { return targetLess(lhs._getReference(), rhs._getReference()); } - bool operator==(const ObjectPrx& lhs, const ObjectPrx& rhs) + bool operator==(const ObjectPrx& lhs, const ObjectPrx& rhs) noexcept { return targetEqualTo(lhs._getReference(), rhs._getReference()); } } bool -Ice::proxyIdentityLess(const optional& lhs, const optional& rhs) +Ice::proxyIdentityLess(const optional& lhs, const optional& rhs) noexcept { return lhs && rhs ? lhs->ice_getIdentity() < rhs->ice_getIdentity() : std::less()(static_cast(lhs), static_cast(rhs)); } bool -Ice::proxyIdentityEqual(const optional& lhs, const optional& rhs) +Ice::proxyIdentityEqual(const optional& lhs, const optional& rhs) noexcept { return lhs && rhs ? lhs->ice_getIdentity() == rhs->ice_getIdentity() : std::equal_to()(static_cast(lhs), static_cast(rhs)); } bool -Ice::proxyIdentityAndFacetLess(const optional& lhs, const optional& rhs) +Ice::proxyIdentityAndFacetLess(const optional& lhs, const optional& rhs) noexcept { if (lhs && rhs) { @@ -669,7 +669,7 @@ Ice::proxyIdentityAndFacetLess(const optional& lhs, const optional& lhs, const optional& rhs) +Ice::proxyIdentityAndFacetEqual(const optional& lhs, const optional& rhs) noexcept { if (lhs && rhs) { diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index e7ca55dfc6c..458f58cefbb 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -35,7 +35,7 @@ using namespace Ice; using namespace IceInternal; CommunicatorPtr -IceInternal::Reference::getCommunicator() const +IceInternal::Reference::getCommunicator() const noexcept { return _communicator; } @@ -105,7 +105,7 @@ IceInternal::Reference::changeCompress(bool newCompress) const } optional -IceInternal::Reference::getCompressOverride() const +IceInternal::Reference::getCompressOverride() const noexcept { DefaultsAndOverridesPtr defaultsAndOverrides = getInstance()->defaultsAndOverrides(); optional compress = @@ -276,7 +276,7 @@ IceInternal::Reference::toString() const } bool -IceInternal::Reference::operator==(const Reference& r) const +IceInternal::Reference::operator==(const Reference& r) const noexcept { // // Note: if(this == &r) test is performed by each non-abstract derived class. @@ -330,7 +330,7 @@ IceInternal::Reference::operator==(const Reference& r) const } bool -IceInternal::Reference::operator<(const Reference& r) const +IceInternal::Reference::operator<(const Reference& r) const noexcept { // // Note: if(this == &r) test is performed by each non-abstract derived class. @@ -504,31 +504,31 @@ IceInternal::FixedReference::getAdapterId() const } bool -IceInternal::FixedReference::getCollocationOptimized() const +IceInternal::FixedReference::getCollocationOptimized() const noexcept { return false; } bool -IceInternal::FixedReference::getCacheConnection() const +IceInternal::FixedReference::getCacheConnection() const noexcept { return true; } bool -IceInternal::FixedReference::getPreferSecure() const +IceInternal::FixedReference::getPreferSecure() const noexcept { return false; } Ice::EndpointSelectionType -IceInternal::FixedReference::getEndpointSelection() const +IceInternal::FixedReference::getEndpointSelection() const noexcept { return EndpointSelectionType::Random; } int -IceInternal::FixedReference::getLocatorCacheTimeout() const +IceInternal::FixedReference::getLocatorCacheTimeout() const noexcept { return 0; } @@ -608,13 +608,13 @@ IceInternal::FixedReference::changeConnection(Ice::ConnectionIPtr newConnection) } bool -IceInternal::FixedReference::isIndirect() const +IceInternal::FixedReference::isIndirect() const noexcept { return false; } bool -IceInternal::FixedReference::isWellKnown() const +IceInternal::FixedReference::isWellKnown() const noexcept { return false; } @@ -690,13 +690,13 @@ IceInternal::FixedReference::getRequestHandler() const } const BatchRequestQueuePtr& -IceInternal::FixedReference::getBatchRequestQueue() const +IceInternal::FixedReference::getBatchRequestQueue() const noexcept { return _fixedConnection->getBatchRequestQueue(); } bool -IceInternal::FixedReference::operator==(const Reference& r) const +IceInternal::FixedReference::operator==(const Reference& r) const noexcept { if (this == &r) { @@ -711,7 +711,7 @@ IceInternal::FixedReference::operator==(const Reference& r) const } bool -IceInternal::FixedReference::operator<(const Reference& r) const +IceInternal::FixedReference::operator<(const Reference& r) const noexcept { if (this == &r) { @@ -796,43 +796,43 @@ IceInternal::RoutableReference::getAdapterId() const } LocatorInfoPtr -IceInternal::RoutableReference::getLocatorInfo() const +IceInternal::RoutableReference::getLocatorInfo() const noexcept { return _locatorInfo; } RouterInfoPtr -IceInternal::RoutableReference::getRouterInfo() const +IceInternal::RoutableReference::getRouterInfo() const noexcept { return _routerInfo; } bool -IceInternal::RoutableReference::getCollocationOptimized() const +IceInternal::RoutableReference::getCollocationOptimized() const noexcept { return _collocationOptimized; } bool -IceInternal::RoutableReference::getCacheConnection() const +IceInternal::RoutableReference::getCacheConnection() const noexcept { return _cacheConnection; } bool -IceInternal::RoutableReference::getPreferSecure() const +IceInternal::RoutableReference::getPreferSecure() const noexcept { return _preferSecure; } Ice::EndpointSelectionType -IceInternal::RoutableReference::getEndpointSelection() const +IceInternal::RoutableReference::getEndpointSelection() const noexcept { return _endpointSelection; } int -IceInternal::RoutableReference::getLocatorCacheTimeout() const +IceInternal::RoutableReference::getLocatorCacheTimeout() const noexcept { return _locatorCacheTimeout; } @@ -996,13 +996,13 @@ IceInternal::RoutableReference::changeConnection(Ice::ConnectionIPtr connection) } bool -IceInternal::RoutableReference::isIndirect() const +IceInternal::RoutableReference::isIndirect() const noexcept { return _endpoints.empty(); } bool -IceInternal::RoutableReference::isWellKnown() const +IceInternal::RoutableReference::isWellKnown() const noexcept { return _endpoints.empty() && _adapterId.empty(); } @@ -1134,7 +1134,7 @@ IceInternal::RoutableReference::hash() const noexcept } bool -IceInternal::RoutableReference::operator==(const Reference& r) const +IceInternal::RoutableReference::operator==(const Reference& r) const noexcept { // // Note: if(this == &r) test is performed by each non-abstract derived class. @@ -1202,7 +1202,7 @@ IceInternal::RoutableReference::operator==(const Reference& r) const } bool -IceInternal::RoutableReference::operator<(const Reference& r) const +IceInternal::RoutableReference::operator<(const Reference& r) const noexcept { if (this == &r) { @@ -1342,7 +1342,7 @@ IceInternal::RoutableReference::getRequestHandler() const } const BatchRequestQueuePtr& -IceInternal::RoutableReference::getBatchRequestQueue() const +IceInternal::RoutableReference::getBatchRequestQueue() const noexcept { return _batchRequestQueue; } diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index c8f29948cca..681fc079f23 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -45,30 +45,30 @@ namespace IceInternal ModeLast = ModeBatchDatagram }; - Mode getMode() const { return _mode; } - bool isBatch() const { return _mode == ModeBatchOneway || _mode == ModeBatchDatagram; } - bool isTwoway() const { return _mode == ModeTwoway; } - bool getSecure() const { return _secure; } - const Ice::ProtocolVersion& getProtocol() const { return _protocol; } - const Ice::EncodingVersion& getEncoding() const { return _encoding; } - const Ice::Identity& getIdentity() const { return _identity; } - const std::string& getFacet() const { return _facet; } - const InstancePtr& getInstance() const { return _instance; } - const SharedContextPtr& getContext() const { return _context; } - int getInvocationTimeout() const { return _invocationTimeout; } - std::optional getCompress() const { return _compress; } - - Ice::CommunicatorPtr getCommunicator() const; + Mode getMode() const noexcept { return _mode; } + bool isBatch() const noexcept { return _mode == ModeBatchOneway || _mode == ModeBatchDatagram; } + bool isTwoway() const noexcept { return _mode == ModeTwoway; } + bool getSecure() const noexcept { return _secure; } + const Ice::ProtocolVersion& getProtocol() const noexcept { return _protocol; } + const Ice::EncodingVersion& getEncoding() const noexcept { return _encoding; } + const Ice::Identity& getIdentity() const noexcept { return _identity; } + const std::string& getFacet() const noexcept { return _facet; } + const InstancePtr& getInstance() const noexcept { return _instance; } + const SharedContextPtr& getContext() const noexcept { return _context; } + int getInvocationTimeout() const noexcept { return _invocationTimeout; } + std::optional getCompress() const noexcept { return _compress; } + + Ice::CommunicatorPtr getCommunicator() const noexcept; virtual std::vector getEndpoints() const = 0; virtual std::string getAdapterId() const = 0; - virtual LocatorInfoPtr getLocatorInfo() const { return 0; } - virtual RouterInfoPtr getRouterInfo() const { return 0; } - virtual bool getCollocationOptimized() const = 0; - virtual bool getCacheConnection() const = 0; - virtual bool getPreferSecure() const = 0; - virtual Ice::EndpointSelectionType getEndpointSelection() const = 0; - virtual int getLocatorCacheTimeout() const = 0; + virtual LocatorInfoPtr getLocatorInfo() const noexcept { return nullptr; } + virtual RouterInfoPtr getRouterInfo() const noexcept { return nullptr; } + virtual bool getCollocationOptimized() const noexcept = 0; + virtual bool getCacheConnection() const noexcept = 0; + virtual bool getPreferSecure() const noexcept = 0; + virtual Ice::EndpointSelectionType getEndpointSelection() const noexcept = 0; + virtual int getLocatorCacheTimeout() const noexcept = 0; virtual std::string getConnectionId() const = 0; // @@ -101,13 +101,13 @@ namespace IceInternal virtual std::size_t hash() const noexcept; // Gets the effective compression setting, taking into account the override. - std::optional getCompressOverride() const; + std::optional getCompressOverride() const noexcept; // // Utility methods. // - virtual bool isIndirect() const = 0; - virtual bool isWellKnown() const = 0; + virtual bool isIndirect() const noexcept = 0; + virtual bool isWellKnown() const noexcept = 0; // // Marshal the reference. @@ -132,10 +132,10 @@ namespace IceInternal // // Get batch request queue. // - virtual const BatchRequestQueuePtr& getBatchRequestQueue() const = 0; + virtual const BatchRequestQueuePtr& getBatchRequestQueue() const noexcept = 0; - virtual bool operator==(const Reference&) const; - virtual bool operator<(const Reference&) const; + virtual bool operator==(const Reference&) const noexcept; + virtual bool operator<(const Reference&) const noexcept; virtual ReferencePtr clone() const = 0; @@ -191,11 +191,11 @@ namespace IceInternal std::vector getEndpoints() const final; std::string getAdapterId() const final; - bool getCollocationOptimized() const final; - bool getCacheConnection() const final; - bool getPreferSecure() const final; - Ice::EndpointSelectionType getEndpointSelection() const final; - int getLocatorCacheTimeout() const final; + bool getCollocationOptimized() const noexcept final; + bool getCacheConnection() const noexcept final; + bool getPreferSecure() const noexcept final; + Ice::EndpointSelectionType getEndpointSelection() const noexcept final; + int getLocatorCacheTimeout() const noexcept final; std::string getConnectionId() const final; ReferencePtr changeEndpoints(std::vector) const final; @@ -211,17 +211,17 @@ namespace IceInternal ReferencePtr changeConnectionId(std::string) const final; ReferencePtr changeConnection(Ice::ConnectionIPtr) const final; - bool isIndirect() const final; - bool isWellKnown() const final; + bool isIndirect() const noexcept final; + bool isWellKnown() const noexcept final; void streamWrite(Ice::OutputStream*) const final; Ice::PropertyDict toProperty(const std::string&) const final; RequestHandlerPtr getRequestHandler() const final; - const BatchRequestQueuePtr& getBatchRequestQueue() const final; + const BatchRequestQueuePtr& getBatchRequestQueue() const noexcept final; - bool operator==(const Reference&) const final; - bool operator<(const Reference&) const final; + bool operator==(const Reference&) const noexcept final; + bool operator<(const Reference&) const noexcept final; ReferencePtr clone() const final; @@ -260,13 +260,13 @@ namespace IceInternal std::vector getEndpoints() const final; std::string getAdapterId() const final; - LocatorInfoPtr getLocatorInfo() const final; - RouterInfoPtr getRouterInfo() const final; - bool getCollocationOptimized() const final; - bool getCacheConnection() const final; - bool getPreferSecure() const final; - Ice::EndpointSelectionType getEndpointSelection() const final; - int getLocatorCacheTimeout() const final; + LocatorInfoPtr getLocatorInfo() const noexcept final; + RouterInfoPtr getRouterInfo() const noexcept final; + bool getCollocationOptimized() const noexcept final; + bool getCacheConnection() const noexcept final; + bool getPreferSecure() const noexcept final; + Ice::EndpointSelectionType getEndpointSelection() const noexcept final; + int getLocatorCacheTimeout() const noexcept final; std::string getConnectionId() const final; ReferencePtr changeEncoding(Ice::EncodingVersion) const final; @@ -285,22 +285,22 @@ namespace IceInternal ReferencePtr changeConnectionId(std::string) const final; ReferencePtr changeConnection(Ice::ConnectionIPtr) const final; - bool isIndirect() const final; - bool isWellKnown() const final; + bool isIndirect() const noexcept final; + bool isWellKnown() const noexcept final; void streamWrite(Ice::OutputStream*) const final; std::string toString() const final; Ice::PropertyDict toProperty(const std::string&) const final; - bool operator==(const Reference&) const final; - bool operator<(const Reference&) const final; + bool operator==(const Reference&) const noexcept final; + bool operator<(const Reference&) const noexcept final; std::size_t hash() const noexcept final; ReferencePtr clone() const final; RequestHandlerPtr getRequestHandler() const final; - const BatchRequestQueuePtr& getBatchRequestQueue() const final; + const BatchRequestQueuePtr& getBatchRequestQueue() const noexcept final; void getConnectionAsync( std::function response,