diff options
author | Max Kellermann <max@duempel.org> | 2014-06-17 10:35:34 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-06-17 10:35:34 +0200 |
commit | eb8fd07900826e95afde15191bb2a0c34b46138a (patch) | |
tree | 8d28a14e7d2491932086678fb63d8ce9779aec75 /src/lib/nfs | |
parent | c99559dbe937eba73376137ceb5551f1c55764d5 (diff) | |
download | mpd-eb8fd07900826e95afde15191bb2a0c34b46138a.tar.gz mpd-eb8fd07900826e95afde15191bb2a0c34b46138a.tar.xz mpd-eb8fd07900826e95afde15191bb2a0c34b46138a.zip |
lib/nfs/Manager: gcc 4.7 compatibility hack
std::map::emplace() is only available from gcc 4.8 on.
Diffstat (limited to 'src/lib/nfs')
-rw-r--r-- | src/lib/nfs/Connection.hxx | 16 | ||||
-rw-r--r-- | src/lib/nfs/Manager.cxx | 9 | ||||
-rw-r--r-- | src/lib/nfs/Manager.hxx | 7 |
3 files changed, 32 insertions, 0 deletions
diff --git a/src/lib/nfs/Connection.hxx b/src/lib/nfs/Connection.hxx index 8850ff6f3..cb4126d25 100644 --- a/src/lib/nfs/Connection.hxx +++ b/src/lib/nfs/Connection.hxx @@ -103,6 +103,22 @@ public: server(_server), export_name(_export_name), context(nullptr) {} +#if defined(__GNUC__) && !defined(__clang__) && !GCC_CHECK_VERSION(4,8) + /* needed for NfsManager::GetConnection() due to lack of + std::map::emplace() */ + NfsConnection(NfsConnection &&other) + :SocketMonitor(((SocketMonitor &)other).GetEventLoop()), + DeferredMonitor(((DeferredMonitor &)other).GetEventLoop()), + server(std::move(other.server)), + export_name(std::move(other.export_name)), + context(nullptr) { + assert(other.context == nullptr); + assert(other.new_leases.empty()); + assert(other.active_leases.empty()); + assert(other.callbacks.IsEmpty()); + } +#endif + ~NfsConnection(); gcc_pure diff --git a/src/lib/nfs/Manager.cxx b/src/lib/nfs/Manager.cxx index 56a3fb79a..5c236552c 100644 --- a/src/lib/nfs/Manager.cxx +++ b/src/lib/nfs/Manager.cxx @@ -39,10 +39,19 @@ NfsManager::GetConnection(const char *server, const char *export_name) const std::string key = Key(server, export_name); +#if defined(__GNUC__) && !defined(__clang__) && !GCC_CHECK_VERSION(4,8) + /* std::map::emplace() not available; this hack uses the move + constructor */ + auto e = connections.insert(std::make_pair(key, + ManagedConnection(*this, loop, + server, + export_name))); +#else auto e = connections.emplace(std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(*this, loop, server, export_name)); +#endif return e.first->second; } diff --git a/src/lib/nfs/Manager.hxx b/src/lib/nfs/Manager.hxx index 4a380bd51..11a779a2a 100644 --- a/src/lib/nfs/Manager.hxx +++ b/src/lib/nfs/Manager.hxx @@ -41,6 +41,13 @@ class NfsManager { :NfsConnection(_loop, _server, _export_name), manager(_manager) {} +#if defined(__GNUC__) && !defined(__clang__) && !GCC_CHECK_VERSION(4,8) + /* needed due to lack of std::map::emplace() */ + ManagedConnection(ManagedConnection &&other) + :NfsConnection(std::move(other)), + manager(other.manager) {} +#endif + protected: /* virtual methods from NfsConnection */ void OnNfsConnectionError(Error &&error) override; |