lib/nfs/Manager: gcc 4.7 compatibility hack

std::map::emplace() is only available from gcc 4.8 on.
This commit is contained in:
Max Kellermann
2014-06-17 10:35:34 +02:00
parent c99559dbe9
commit eb8fd07900
3 changed files with 32 additions and 0 deletions

View File

@@ -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;
}