summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2018-09-07 18:47:28 +0200
committerJose <jose@zeroc.com>2018-09-07 18:47:28 +0200
commit8cddd264e57ab89fc4c6952b2b390457a4bfbedf (patch)
tree66bb34aa13289ed0017a9460e800740516bb1278 /cpp
parentEnable test workers for PHP, Ruby and Python (diff)
downloadice-8cddd264e57ab89fc4c6952b2b390457a4bfbedf.tar.bz2
ice-8cddd264e57ab89fc4c6952b2b390457a4bfbedf.tar.xz
ice-8cddd264e57ab89fc4c6952b2b390457a4bfbedf.zip
Fixes for C++17 mode
Close #180
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/Functional.h2
-rw-r--r--cpp/include/Ice/MetricsObserverI.h14
-rw-r--r--cpp/include/IceUtil/Functional.h4
-rw-r--r--cpp/include/IceUtil/Random.h34
-rw-r--r--cpp/src/Ice/ConnectionFactory.cpp98
-rw-r--r--cpp/src/Ice/Instance.cpp7
-rw-r--r--cpp/src/Ice/LocatorInfo.cpp8
-rwxr-xr-xcpp/src/Ice/Network.cpp34
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp8
-rw-r--r--cpp/src/Ice/Reference.cpp70
-rw-r--r--cpp/src/IceDiscovery/LocatorI.cpp4
-rw-r--r--cpp/src/IceGrid/AdapterCache.cpp9
-rw-r--r--cpp/src/IceGrid/AllocatableObjectCache.cpp3
-rw-r--r--cpp/src/IceGrid/Database.cpp3
-rw-r--r--cpp/src/IceGrid/Util.h8
-rw-r--r--cpp/test/Ice/binding/AllTests.cpp26
-rw-r--r--cpp/test/Ice/optional/AllTests.cpp4
-rw-r--r--cpp/test/Ice/optional/StringView.h13
-rw-r--r--cpp/test/Ice/optional/TestI.cpp12
-rw-r--r--cpp/test/IceSSL/configuration/AllTests.cpp4
-rw-r--r--cpp/test/IceUtil/timer/Client.cpp3
21 files changed, 286 insertions, 82 deletions
diff --git a/cpp/include/Ice/Functional.h b/cpp/include/Ice/Functional.h
index 96f1d2d24e9..bf4cfeb50b3 100644
--- a/cpp/include/Ice/Functional.h
+++ b/cpp/include/Ice/Functional.h
@@ -10,7 +10,7 @@
#ifndef ICE_FUNCTIONAL_H
#define ICE_FUNCTIONAL_H
-# if !defined(ICE_CPP11_MAPPING) || defined(ICE_BUILDING_SRC)
+#ifndef ICE_CPP11_MAPPING
#include <IceUtil/Functional.h>
#include <Ice/Handle.h>
diff --git a/cpp/include/Ice/MetricsObserverI.h b/cpp/include/Ice/MetricsObserverI.h
index d5848d2f4ae..a360be048ee 100644
--- a/cpp/include/Ice/MetricsObserverI.h
+++ b/cpp/include/Ice/MetricsObserverI.h
@@ -132,6 +132,20 @@ protected:
memberFn)));
}
+#if ICE_CPLUSPLUS >= 201703L
+ //
+ // Since C++17 the noexcept-specification is part of the function type and we need a separate
+ // overload to handle memberFn being noexcept
+ //
+ template<typename I, typename O, typename Y> void
+ add(const std::string& name, O (Helper::*getFn)() const, Y (I::*memberFn)() const noexcept)
+ {
+ _attributes.insert(typename std::map<std::string,
+ Resolver*>::value_type(name, new MemberFunctionResolver<I, O, Y>(name, getFn,
+ memberFn)));
+ }
+#endif
+
private:
template<typename Y> class HelperMemberResolver : public Resolver
diff --git a/cpp/include/IceUtil/Functional.h b/cpp/include/IceUtil/Functional.h
index 9f0db18104e..f370d0099a3 100644
--- a/cpp/include/IceUtil/Functional.h
+++ b/cpp/include/IceUtil/Functional.h
@@ -10,6 +10,8 @@
#ifndef ICE_UTIL_FUNCTIONAL_H
#define ICE_UTIL_FUNCTIONAL_H
+#ifndef ICE_CPP11_MAPPING
+
#include <IceUtil/Handle.h>
#include <functional>
@@ -386,3 +388,5 @@ secondConstVoidMemFun1(void (T::*p)(A) const)
}
#endif
+
+#endif
diff --git a/cpp/include/IceUtil/Random.h b/cpp/include/IceUtil/Random.h
index f576205d201..69d4c0b4dea 100644
--- a/cpp/include/IceUtil/Random.h
+++ b/cpp/include/IceUtil/Random.h
@@ -13,12 +13,46 @@
#include <IceUtil/Config.h>
#include <IceUtil/Exception.h>
+#ifdef ICE_CPP11_COMPILER
+# include <algorithm>
+# include <random>
+#endif
+
namespace IceUtilInternal
{
ICE_API void generateRandom(char*, size_t);
ICE_API unsigned int random(int = 0);
+#ifdef ICE_CPP11_COMPILER
+
+template<class T>
+void shuffle(T first, T last)
+{
+ std::random_device rd;
+ std::mt19937 rng(rd());
+ std::shuffle(first, last, rng);
+}
+
+#else
+
+struct RandomNumberGenerator : public std::unary_function<std::ptrdiff_t, std::ptrdiff_t>
+{
+ std::ptrdiff_t operator()(std::ptrdiff_t d)
+ {
+ return IceUtilInternal::random(static_cast<int>(d));
+ }
+};
+
+template<class T>
+void shuffle(T first, T last)
+{
+ RandomNumberGenerator rng;
+ random_shuffle(first, last, rng);
+}
+
+#endif
+
}
#endif
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp
index 744e261e3cd..cc81ec65f12 100644
--- a/cpp/src/Ice/ConnectionFactory.cpp
+++ b/cpp/src/Ice/ConnectionFactory.cpp
@@ -53,14 +53,6 @@ IceUtil::Shared* IceInternal::upCast(IncomingConnectionFactory* p) { return p; }
namespace
{
-struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t>
-{
- ptrdiff_t operator()(ptrdiff_t d)
- {
- return IceUtilInternal::random(static_cast<int>(d));
- }
-};
-
#ifdef ICE_CPP11_MAPPING
template <typename Map> void
remove(Map& m, const typename Map::key_type& k, const typename Map::mapped_type& v)
@@ -178,10 +170,16 @@ IceInternal::OutgoingConnectionFactory::destroy()
return;
}
+#ifdef ICE_CPP11_COMPILER
+ for(const auto& p : _connections)
+ {
+ p.second->destroy(ConnectionI::CommunicatorDestroyed);
+ }
+#else
for_each(_connections.begin(), _connections.end(),
bind2nd(Ice::secondVoidMemFun1<const ConnectorPtr, ConnectionI, ConnectionI::DestructionReason>
(&ConnectionI::destroy), ConnectionI::CommunicatorDestroyed));
-
+#endif
_destroyed = true;
_communicator = 0;
@@ -192,8 +190,15 @@ void
IceInternal::OutgoingConnectionFactory::updateConnectionObservers()
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+#ifdef ICE_CPP11_COMPILER
+ for(const auto& p : _connections)
+ {
+ p.second->updateObserver();
+ }
+#else
for_each(_connections.begin(), _connections.end(),
Ice::secondVoidMemFun<const ConnectorPtr, ConnectionI>(&ConnectionI::updateObserver));
+#endif
}
void
@@ -221,9 +226,15 @@ IceInternal::OutgoingConnectionFactory::waitUntilFinished()
connections = _connections;
}
+#ifdef ICE_CPP11_COMPILER
+ for(const auto& p : _connections)
+ {
+ p.second->waitUntilFinished();
+ }
+#else
for_each(connections.begin(), connections.end(),
Ice::secondVoidMemFun<const ConnectorPtr, ConnectionI>(&ConnectionI::waitUntilFinished));
-
+#endif
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
// Ensure all the connections are finished and reapable at this point.
@@ -436,7 +447,15 @@ IceInternal::OutgoingConnectionFactory::findConnection(const vector<EndpointIPtr
assert(!endpoints.empty());
for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
+#ifdef ICE_CPP11_MAPPING
+ auto connection = find(_connectionsByEndpoint, *p,
+ [](const ConnectionIPtr& conn)
+ {
+ return conn->isActiveOrHolding();
+ });
+#else
ConnectionIPtr connection = find(_connectionsByEndpoint, *p, Ice::constMemFun(&ConnectionI::isActiveOrHolding));
+#endif
if(connection)
{
if(defaultsAndOverrides->overrideCompress)
@@ -466,7 +485,15 @@ IceInternal::OutgoingConnectionFactory::findConnection(const vector<ConnectorInf
continue;
}
+#ifdef ICE_CPP11_MAPPING
+ auto connection = find(_connections, p->connector,
+ [](const ConnectionIPtr& conn)
+ {
+ return conn->isActiveOrHolding();
+ });
+#else
ConnectionIPtr connection = find(_connections, p->connector, Ice::constMemFun(&ConnectionI::isActiveOrHolding));
+#endif
if(connection)
{
if(defaultsAndOverrides->overrideCompress)
@@ -1193,7 +1220,14 @@ void
IceInternal::IncomingConnectionFactory::updateConnectionObservers()
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+#ifdef ICE_CPP11_COMPILER
+ for(const auto& conn : _connections)
+ {
+ conn->updateObserver();
+ }
+#else
for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::updateObserver));
+#endif
}
void
@@ -1223,7 +1257,14 @@ IceInternal::IncomingConnectionFactory::waitUntilHolding() const
//
// Now we wait until each connection is in holding state.
//
+#ifdef ICE_CPP11_COMPILER
+ for(const auto& conn : connections)
+ {
+ conn->waitUntilHolding();
+ }
+#else
for_each(connections.begin(), connections.end(), Ice::constVoidMemFun(&ConnectionI::waitUntilHolding));
+#endif
}
void
@@ -1253,7 +1294,14 @@ IceInternal::IncomingConnectionFactory::waitUntilFinished()
connections = _connections;
}
+#ifdef ICE_CPP11_COMPILER
+ for(const auto& conn : connections)
+ {
+ conn->waitUntilFinished();
+ }
+#else
for_each(connections.begin(), connections.end(), Ice::voidMemFun(&ConnectionI::waitUntilFinished));
+#endif
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
@@ -1311,9 +1359,16 @@ IceInternal::IncomingConnectionFactory::connections() const
//
// Only copy connections which have not been destroyed.
//
+#ifdef ICE_CPP11_COMPILER
+ remove_copy_if(_connections.begin(), _connections.end(), back_inserter(result),
+ [](const ConnectionIPtr& conn)
+ {
+ return !conn->isActiveOrHolding();
+ });
+#else
remove_copy_if(_connections.begin(), _connections.end(), back_inserter(result),
not1(Ice::constMemFun(&ConnectionI::isActiveOrHolding)));
-
+#endif
return result;
}
@@ -1737,7 +1792,14 @@ IceInternal::IncomingConnectionFactory::setState(State state)
}
_adapter->getThreadPool()->_register(ICE_SHARED_FROM_THIS, SocketOperationRead);
}
+#ifdef ICE_CPP11_COMPILER
+ for(const auto& conn : _connections)
+ {
+ conn->activate();
+ }
+#else
for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::activate));
+#endif
break;
}
@@ -1756,7 +1818,14 @@ IceInternal::IncomingConnectionFactory::setState(State state)
}
_adapter->getThreadPool()->unregister(ICE_SHARED_FROM_THIS, SocketOperationRead);
}
+#ifdef ICE_CPP11_COMPILER
+ for(const auto& conn : _connections)
+ {
+ conn->hold();
+ }
+#else
for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::hold));
+#endif
break;
}
@@ -1781,8 +1850,15 @@ IceInternal::IncomingConnectionFactory::setState(State state)
state = StateFinished;
}
+#ifdef ICE_CPP11_COMPILER
+ for(const auto& conn : _connections)
+ {
+ conn->destroy(ConnectionI::ObjectAdapterDeactivated);
+ }
+#else
for_each(_connections.begin(), _connections.end(),
bind2nd(Ice::voidMemFun1(&ConnectionI::destroy), ConnectionI::ObjectAdapterDeactivated));
+#endif
break;
}
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 1d4b14f67ad..734823cdc06 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -1664,8 +1664,15 @@ IceInternal::Instance::destroy()
}
#endif
+#ifdef ICE_CPP11_COMPILER
+ for(const auto& p : _objectFactoryMap)
+ {
+ p.second->destroy();
+ }
+#else
for_each(_objectFactoryMap.begin(), _objectFactoryMap.end(),
Ice::secondVoidMemFun<const string, ObjectFactory>(&ObjectFactory::destroy));
+#endif
_objectFactoryMap.clear();
if(_routerManager)
diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp
index 1ceb0fb8fe6..126e6a1e808 100644
--- a/cpp/src/Ice/LocatorInfo.cpp
+++ b/cpp/src/Ice/LocatorInfo.cpp
@@ -778,8 +778,16 @@ IceInternal::LocatorInfo::trace(const string& msg, const ReferencePtr& ref, cons
const char* sep = endpoints.size() > 1 ? ":" : "";
ostringstream o;
+#ifdef ICE_CPP11_MAPPING
+ transform(endpoints.begin(), endpoints.end(), ostream_iterator<string>(o, sep),
+ [](const EndpointPtr& endpoint)
+ {
+ return endpoint->toString();
+ });
+#else
transform(endpoints.begin(), endpoints.end(), ostream_iterator<string>(o, sep),
Ice::constMemFun(&Endpoint::toString));
+#endif
out << "endpoints = " << o.str();
}
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index 36a4e16c0c8..f4629771ac6 100755
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -116,6 +116,9 @@ public:
};
#ifndef ICE_OS_UWP
+
+# ifndef ICE_CPP11_COMPILER
+
struct AddressIsIPv6 : public unary_function<Address, bool>
{
public:
@@ -126,26 +129,36 @@ public:
return ss.saStorage.ss_family == AF_INET6;
}
};
-
-struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t>
-{
- ptrdiff_t operator()(ptrdiff_t d)
- {
- return IceUtilInternal::random(static_cast<int>(d));
- }
-};
+# endif
void
sortAddresses(vector<Address>& addrs, ProtocolSupport protocol, Ice::EndpointSelectionType selType, bool preferIPv6)
{
if(selType == Ice::ICE_ENUM(EndpointSelectionType, Random))
{
- RandomNumberGenerator rng;
- random_shuffle(addrs.begin(), addrs.end(), rng);
+ IceUtilInternal::shuffle(addrs.begin(), addrs.end());
}
if(protocol == EnableBoth)
{
+#ifdef ICE_CPP11_COMPILER
+ if(preferIPv6)
+ {
+ stable_partition(addrs.begin(), addrs.end(),
+ [](const Address& ss)
+ {
+ return ss.saStorage.ss_family == AF_INET6;
+ });
+ }
+ else
+ {
+ stable_partition(addrs.begin(), addrs.end(),
+ [](const Address& ss)
+ {
+ return ss.saStorage.ss_family != AF_INET6;
+ });
+ }
+#else
if(preferIPv6)
{
stable_partition(addrs.begin(), addrs.end(), AddressIsIPv6());
@@ -154,6 +167,7 @@ sortAddresses(vector<Address>& addrs, ProtocolSupport protocol, Ice::EndpointSel
{
stable_partition(addrs.begin(), addrs.end(), not1(AddressIsIPv6()));
}
+#endif
}
}
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 283832c4ea9..f93a028d68a 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -1422,8 +1422,16 @@ ObjectAdapterI::updateLocatorRegistry(const IceInternal::LocatorInfoPtr& locator
{
EndpointSeq endpts = proxy ? proxy->ice_getEndpoints() : EndpointSeq();
ostringstream o;
+#ifdef ICE_CPP11_COMPILER
+ transform(endpts.begin(), endpts.end(), ostream_iterator<string>(o, endpts.size() > 1 ? ":" : ""),
+ [](const EndpointPtr& endpoint)
+ {
+ return endpoint->toString();
+ });
+#else
transform(endpts.begin(), endpts.end(), ostream_iterator<string>(o, endpts.size() > 1 ? ":" : ""),
Ice::constMemFun(&Endpoint::toString));
+#endif
out << o.str();
}
}
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index 1e7a9be8008..c54e62ab92d 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -65,14 +65,6 @@ public:
Init init;
-struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t>
-{
- ptrdiff_t operator()(ptrdiff_t d)
- {
- return IceUtilInternal::random(static_cast<int>(d));
- }
-};
-
}
CommunicatorPtr
@@ -507,6 +499,7 @@ IceInternal::Reference::operator<(const Reference& r) const
return false;
}
+#ifndef ICE_CPP11_COMPILER
class ConnectionIsDatagram : public unary_function<ConnectionIPtr, bool>
{
public:
@@ -528,6 +521,7 @@ public:
return p->endpoint()->secure();
}
};
+#endif
IceInternal::Reference::Reference(const InstancePtr& instance,
const CommunicatorPtr& communicator,
@@ -1907,6 +1901,7 @@ IceInternal::RoutableReference::RoutableReference(const RoutableReference& r) :
namespace
{
+#ifndef ICE_CPP11_COMPILER
struct EndpointIsOpaque : public unary_function<EndpointIPtr, bool>
{
public:
@@ -1917,6 +1912,7 @@ public:
return dynamic_cast<OpaqueEndpointI*>(p.get()) != 0;
}
};
+#endif
}
@@ -1928,8 +1924,16 @@ IceInternal::RoutableReference::filterEndpoints(const vector<EndpointIPtr>& allE
//
// Filter out unknown endpoints.
//
+#ifdef ICE_CPP11_COMPILER
+ endpoints.erase(remove_if(endpoints.begin(), endpoints.end(),
+ [](const EndpointIPtr& p)
+ {
+ return dynamic_cast<OpaqueEndpointI*>(p.get()) != 0;
+ }),
+ endpoints.end());
+#else
endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), EndpointIsOpaque()), endpoints.end());
-
+#endif
//
// Filter out endpoints according to the mode of the reference.
//
@@ -1942,8 +1946,17 @@ IceInternal::RoutableReference::filterEndpoints(const vector<EndpointIPtr>& allE
//
// Filter out datagram endpoints.
//
+#ifdef ICE_CPP11_COMPILER
+ endpoints.erase(remove_if(endpoints.begin(), endpoints.end(),
+ [](const EndpointIPtr& p)
+ {
+ return p->datagram();
+ }),
+ endpoints.end());
+#else
endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::datagram)),
endpoints.end());
+#endif
break;
}
@@ -1953,9 +1966,18 @@ IceInternal::RoutableReference::filterEndpoints(const vector<EndpointIPtr>& allE
//
// Filter out non-datagram endpoints.
//
+#ifdef ICE_CPP11_COMPILER
+ endpoints.erase(remove_if(endpoints.begin(), endpoints.end(),
+ [](const EndpointIPtr& p)
+ {
+ return !p->datagram();
+ }),
+ endpoints.end());
+#else
endpoints.erase(remove_if(endpoints.begin(), endpoints.end(),
not1(Ice::constMemFun(&EndpointI::datagram))),
endpoints.end());
+#endif
break;
}
}
@@ -1967,8 +1989,7 @@ IceInternal::RoutableReference::filterEndpoints(const vector<EndpointIPtr>& allE
{
case ICE_ENUM(EndpointSelectionType, Random):
{
- RandomNumberGenerator rng;
- random_shuffle(endpoints.begin(), endpoints.end(), rng);
+ IceUtilInternal::shuffle(endpoints.begin(), endpoints.end());
break;
}
case ICE_ENUM(EndpointSelectionType, Ordered):
@@ -1992,8 +2013,17 @@ IceInternal::RoutableReference::filterEndpoints(const vector<EndpointIPtr>& allE
DefaultsAndOverridesPtr overrides = getInstance()->defaultsAndOverrides();
if(overrides->overrideSecure ? overrides->overrideSecureValue : getSecure())
{
+#ifdef ICE_CPP11_COMPILER
+ endpoints.erase(remove_if(endpoints.begin(), endpoints.end(),
+ [](const EndpointIPtr& p)
+ {
+ return !p->secure();
+ }),
+ endpoints.end());
+#else
endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), not1(Ice::constMemFun(&EndpointI::secure))),
endpoints.end());
+#endif
}
else if(getPreferSecure())
{
@@ -2002,7 +2032,15 @@ IceInternal::RoutableReference::filterEndpoints(const vector<EndpointIPtr>& allE
// partition(), because otherwise some STL implementations
// order our now randomized endpoints.
//
- stable_partition(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::secure));
+#ifdef ICE_CPP11_COMPILER
+ stable_partition(endpoints.begin(), endpoints.end(),
+ [](const EndpointIPtr& p)
+ {
+ return p->secure();
+ });
+#else
+ stable_partition(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::secure));
+#endif
}
else
{
@@ -2011,7 +2049,15 @@ IceInternal::RoutableReference::filterEndpoints(const vector<EndpointIPtr>& allE
// partition(), because otherwise some STL implementations
// order our now randomized endpoints.
//
+#ifdef ICE_CPP11_COMPILER
+ stable_partition(endpoints.begin(), endpoints.end(),
+ [](const EndpointIPtr& p)
+ {
+ return !p->secure();
+ });
+#else
stable_partition(endpoints.begin(), endpoints.end(), not1(Ice::constMemFun(&EndpointI::secure)));
+#endif
}
return endpoints;
diff --git a/cpp/src/IceDiscovery/LocatorI.cpp b/cpp/src/IceDiscovery/LocatorI.cpp
index 81f1d638323..abd65211118 100644
--- a/cpp/src/IceDiscovery/LocatorI.cpp
+++ b/cpp/src/IceDiscovery/LocatorI.cpp
@@ -14,6 +14,8 @@
#include <Ice/Communicator.h>
#include <Ice/ObjectAdapter.h>
+#include <IceUtil/Random.h>
+
#include <iterator>
using namespace std;
@@ -172,7 +174,7 @@ LocatorRegistryI::findObject(const Ice::Identity& id) const
return 0;
}
- random_shuffle(adapterIds.begin(), adapterIds.end());
+ IceUtilInternal::shuffle(adapterIds.begin(), adapterIds.end());
return prx->ice_adapterId(adapterIds[0]);
}
diff --git a/cpp/src/IceGrid/AdapterCache.cpp b/cpp/src/IceGrid/AdapterCache.cpp
index 4d0aa887d5a..cb3593bd874 100644
--- a/cpp/src/IceGrid/AdapterCache.cpp
+++ b/cpp/src/IceGrid/AdapterCache.cpp
@@ -645,8 +645,7 @@ ReplicaGroupEntry::getLocatorAdapterInfo(LocatorAdapterInfoSeq& adapters, int& n
else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
{
replicas = _replicas;
- RandomNumberGenerator rng;
- random_shuffle(replicas.begin(), replicas.end(), rng);
+ IceUtilInternal::shuffle(replicas.begin(), replicas.end());
loadSample = _loadSample;
adaptive = true;
}
@@ -658,8 +657,7 @@ ReplicaGroupEntry::getLocatorAdapterInfo(LocatorAdapterInfoSeq& adapters, int& n
else if(RandomLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
{
replicas = _replicas;
- RandomNumberGenerator rng;
- random_shuffle(replicas.begin(), replicas.end(), rng);
+ IceUtilInternal::shuffle(replicas.begin(), replicas.end());
}
}
@@ -762,8 +760,7 @@ ReplicaGroupEntry::getLeastLoadedNodeLoad(LoadSample loadSample) const
}
else
{
- RandomNumberGenerator rng;
- random_shuffle(replicas.begin(), replicas.end(), rng);
+ IceUtilInternal::shuffle(replicas.begin(), replicas.end());
vector<pair<float, ServerAdapterEntryPtr> > rl;
transform(replicas.begin(), replicas.end(), back_inserter(rl), TransformToReplicaLoad(loadSample));
return min_element(rl.begin(), rl.end(), ReplicaLoadComp())->first;
diff --git a/cpp/src/IceGrid/AllocatableObjectCache.cpp b/cpp/src/IceGrid/AllocatableObjectCache.cpp
index 234bce4f3b3..a99f81eccfc 100644
--- a/cpp/src/IceGrid/AllocatableObjectCache.cpp
+++ b/cpp/src/IceGrid/AllocatableObjectCache.cpp
@@ -216,8 +216,7 @@ AllocatableObjectCache::allocateByType(const string& type, const ObjectAllocatio
}
vector<AllocatableObjectEntryPtr> objects = p->second.getObjects();
- RandomNumberGenerator rng;
- random_shuffle(objects.begin(), objects.end(), rng); // TODO: OPTIMIZE
+ IceUtilInternal::shuffle(objects.begin(), objects.end()); // TODO: OPTIMIZE
int allocatable = 0;
try
{
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp
index 985631371a1..cc903e5df9c 100644
--- a/cpp/src/IceGrid/Database.cpp
+++ b/cpp/src/IceGrid/Database.cpp
@@ -1751,8 +1751,7 @@ Database::getObjectByTypeOnLeastLoadedNode(const string& type, LoadSample sample
return 0;
}
- RandomNumberGenerator rng;
- random_shuffle(objs.begin(), objs.end(), rng);
+ IceUtilInternal::shuffle(objs.begin(), objs.end());
vector<pair<Ice::ObjectPrx, float> > objectsWithLoad;
objectsWithLoad.reserve(objs.size());
for(Ice::ObjectProxySeq::const_iterator p = objs.begin(); p != objs.end(); ++p)
diff --git a/cpp/src/IceGrid/Util.h b/cpp/src/IceGrid/Util.h
index dd213e3489b..ad1ce766338 100644
--- a/cpp/src/IceGrid/Util.h
+++ b/cpp/src/IceGrid/Util.h
@@ -21,14 +21,6 @@
namespace IceGrid
{
-struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t>
-{
- ptrdiff_t operator()(ptrdiff_t d)
- {
- return IceUtilInternal::random(static_cast<int>(d));
- }
-};
-
template<typename T> std::insert_iterator<T>
inline set_inserter(T& container)
{
diff --git a/cpp/test/Ice/binding/AllTests.cpp b/cpp/test/Ice/binding/AllTests.cpp
index 7aafd6d0f95..ca2a64f2c41 100644
--- a/cpp/test/Ice/binding/AllTests.cpp
+++ b/cpp/test/Ice/binding/AllTests.cpp
@@ -18,14 +18,6 @@
using namespace std;
using namespace Test;
-struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t>
-{
- ptrdiff_t operator()(ptrdiff_t d)
- {
- return IceUtilInternal::random(static_cast<int>(d));
- }
-};
-
#ifndef ICE_CPP11_MAPPING
class GetAdapterNameCB : public IceUtil::Shared, public IceUtil::Monitor<IceUtil::Mutex>
{
@@ -107,8 +99,6 @@ allTests(Test::TestHelper* helper)
string ref = "communicator:" + helper->getTestEndpoint();
RemoteCommunicatorPrxPtr com = ICE_UNCHECKED_CAST(RemoteCommunicatorPrx, communicator->stringToProxy(ref));
- RandomNumberGenerator rng;
-
cout << "testing binding with single endpoint... " << flush;
{
RemoteObjectAdapterPrxPtr adapter = com->createObjectAdapter("Adapter", "default");
@@ -162,9 +152,9 @@ allTests(Test::TestHelper* helper)
vector<RemoteObjectAdapterPrxPtr> adpts = adapters;
TestIntfPrxPtr test1 = createTestIntfPrx(adpts);
- random_shuffle(adpts.begin(), adpts.end(), rng);
+ IceUtilInternal::shuffle(adpts.begin(), adpts.end());
TestIntfPrxPtr test2 = createTestIntfPrx(adpts);
- random_shuffle(adpts.begin(), adpts.end(), rng);
+ IceUtilInternal::shuffle(adpts.begin(), adpts.end());
TestIntfPrxPtr test3 = createTestIntfPrx(adpts);
test(test1->ice_getConnection() == test2->ice_getConnection());
@@ -210,9 +200,9 @@ allTests(Test::TestHelper* helper)
vector<RemoteObjectAdapterPrxPtr> adpts = adapters;
TestIntfPrxPtr test1 = createTestIntfPrx(adpts);
- random_shuffle(adpts.begin(), adpts.end(), rng);
+ IceUtilInternal::shuffle(adpts.begin(), adpts.end());
TestIntfPrxPtr test2 = createTestIntfPrx(adpts);
- random_shuffle(adpts.begin(), adpts.end(), rng);
+ IceUtilInternal::shuffle(adpts.begin(), adpts.end());
TestIntfPrxPtr test3 = createTestIntfPrx(adpts);
test(test1->ice_getConnection() == test2->ice_getConnection());
@@ -342,9 +332,9 @@ allTests(Test::TestHelper* helper)
vector<RemoteObjectAdapterPrxPtr> adpts = adapters;
TestIntfPrxPtr test1 = createTestIntfPrx(adpts);
- random_shuffle(adpts.begin(), adpts.end(), rng);
+ IceUtilInternal::shuffle(adpts.begin(), adpts.end());
TestIntfPrxPtr test2 = createTestIntfPrx(adpts);
- random_shuffle(adpts.begin(), adpts.end(), rng);
+ IceUtilInternal::shuffle(adpts.begin(), adpts.end());
TestIntfPrxPtr test3 = createTestIntfPrx(adpts);
test(test1->ice_getConnection() == test2->ice_getConnection());
@@ -390,9 +380,9 @@ allTests(Test::TestHelper* helper)
vector<RemoteObjectAdapterPrxPtr> adpts = adapters;
TestIntfPrxPtr test1 = createTestIntfPrx(adpts);
- random_shuffle(adpts.begin(), adpts.end(), rng);
+ IceUtilInternal::shuffle(adpts.begin(), adpts.end());
TestIntfPrxPtr test2 = createTestIntfPrx(adpts);
- random_shuffle(adpts.begin(), adpts.end(), rng);
+ IceUtilInternal::shuffle(adpts.begin(), adpts.end());
TestIntfPrxPtr test3 = createTestIntfPrx(adpts);
test(test1->ice_getConnection() == test2->ice_getConnection());
diff --git a/cpp/test/Ice/optional/AllTests.cpp b/cpp/test/Ice/optional/AllTests.cpp
index 8a19969ac03..6a5fb48be57 100644
--- a/cpp/test/Ice/optional/AllTests.cpp
+++ b/cpp/test/Ice/optional/AllTests.cpp
@@ -1523,8 +1523,8 @@ allTests(Test::TestHelper* helper, bool)
Ice::OutputStream out(communicator);
out.startEncapsulation();
#ifdef ICE_CPP11_MAPPING
- out.write(1, make_optional(f));
- out.write(2, make_optional(f->ae));
+ out.write(1, Ice::make_optional(f));
+ out.write(2, Ice::make_optional(f->ae));
#else
out.write(1, makeOptional(f));
out.write(2, makeOptional(f->ae));
diff --git a/cpp/test/Ice/optional/StringView.h b/cpp/test/Ice/optional/StringView.h
index 18ac2d2bd80..29a67c201b1 100644
--- a/cpp/test/Ice/optional/StringView.h
+++ b/cpp/test/Ice/optional/StringView.h
@@ -12,6 +12,15 @@
#include <Ice/Ice.h>
+//
+// COMPILERFIX: G++ false positive "maybe-uninitialized" warnings when using
+// string_view with Ice::optional in C++17 mode.
+//
+#if defined(__GNUC__) && ICE_CPLUSPLUS >= 201703L
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
namespace Util
{
@@ -186,4 +195,8 @@ struct StreamHelper<Util::string_view, StreamHelperCategoryBuiltin>
}
+#if defined(__GNUC__) && ICE_CPLUSPLUS >= 201703L
+# pragma GCC diagnostic pop
+#endif
+
#endif
diff --git a/cpp/test/Ice/optional/TestI.cpp b/cpp/test/Ice/optional/TestI.cpp
index a6953c1ec9d..1696df988f2 100644
--- a/cpp/test/Ice/optional/TestI.cpp
+++ b/cpp/test/Ice/optional/TestI.cpp
@@ -277,9 +277,9 @@ InitialI::opDoubleSeq(ICE_IN(Optional<pair<const Double*, const Double*> >) p1,
}
#ifdef ICE_CPP11_MAPPING
-optional<Ice::StringSeq>
-InitialI::opStringSeq(optional<Ice::StringSeq> p1,
- optional<Ice::StringSeq>& p3, const Current&)
+Ice::optional<Ice::StringSeq>
+InitialI::opStringSeq(Ice::optional<Ice::StringSeq> p1,
+ Ice::optional<Ice::StringSeq>& p3, const Current&)
{
if(p1)
{
@@ -345,9 +345,9 @@ InitialI::opFixedStructList(ICE_IN(Optional<pair<const FixedStruct*, const Fixed
}
#ifdef ICE_CPP11_MAPPING
-optional<VarStructSeq>
-InitialI::opVarStructSeq(optional<VarStructSeq> p1,
- optional<VarStructSeq>& p3, const Current&)
+Ice::optional<VarStructSeq>
+InitialI::opVarStructSeq(Ice::optional<VarStructSeq> p1,
+ Ice::optional<VarStructSeq>& p3, const Current&)
{
if(p1)
{
diff --git a/cpp/test/IceSSL/configuration/AllTests.cpp b/cpp/test/IceSSL/configuration/AllTests.cpp
index 9460b31ac6a..59b0f3a519d 100644
--- a/cpp/test/IceSSL/configuration/AllTests.cpp
+++ b/cpp/test/IceSSL/configuration/AllTests.cpp
@@ -1675,7 +1675,7 @@ allTests(Test::TestHelper* helper, const string& testDir, bool p12)
Test::ServerPrxPtr server = fact->createServer(d);
try
{
- ICE_DYNAMIC_CAST(IceSSL::ConnectionInfo, server->ice_getConnection()->getInfo());
+ server->ice_getConnection()->getInfo();
import.cleanup();
test(false);
}
@@ -1728,7 +1728,7 @@ allTests(Test::TestHelper* helper, const string& testDir, bool p12)
Test::ServerPrxPtr server = fact->createServer(d);
try
{
- ICE_DYNAMIC_CAST(IceSSL::ConnectionInfo, server->ice_getConnection()->getInfo());
+ server->ice_getConnection()->getInfo();
import.cleanup();
test(false);
}
diff --git a/cpp/test/IceUtil/timer/Client.cpp b/cpp/test/IceUtil/timer/Client.cpp
index d24313493e6..1c8a1c5166a 100644
--- a/cpp/test/IceUtil/timer/Client.cpp
+++ b/cpp/test/IceUtil/timer/Client.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <IceUtil/Timer.h>
+#include <IceUtil/Random.h>
#include <TestHelper.h>
#include <vector>
@@ -206,7 +207,7 @@ Client::run(int, char* argv[])
tasks.push_back(ICE_MAKE_SHARED(TestTask, IceUtil::Time::milliSeconds(500 + i * 50)));
}
- random_shuffle(tasks.begin(), tasks.end());
+ IceUtilInternal::shuffle(tasks.begin(), tasks.end());
vector<TestTaskPtr>::const_iterator p;
for(p = tasks.begin(); p != tasks.end(); ++p)
{