Compile with g++-4.7
g++-4.7 lacks thread_local, which can be workaround by --disable-threads. What left remaining is std::map::emplace, which is what this change deals with. First check availability of std::map::emplace, if there is none, use std::map::insert.
This commit is contained in:
parent
13a14ecda8
commit
3817798905
16
configure.ac
16
configure.ac
|
@ -197,6 +197,22 @@ std::vector<std::future<int>> v;
|
||||||
[have_std_future=no
|
[have_std_future=no
|
||||||
AC_MSG_RESULT([no])])
|
AC_MSG_RESULT([no])])
|
||||||
|
|
||||||
|
# Check that std::map::emplace is available for g++-4.7.
|
||||||
|
AC_MSG_CHECKING([whether std::map::emplace is available])
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
||||||
|
[[
|
||||||
|
#include <map>
|
||||||
|
]],
|
||||||
|
[[
|
||||||
|
std::map<int, int>().emplace(1, 2);
|
||||||
|
]])],
|
||||||
|
[AC_DEFINE([HAVE_STD_MAP_EMPLACE], [1],
|
||||||
|
[Define to 1 if you have the `std::map::emplace`.])
|
||||||
|
have_std_map_emplace=yes
|
||||||
|
AC_MSG_RESULT([yes])],
|
||||||
|
[have_std_map_emplace=no
|
||||||
|
AC_MSG_RESULT([no])])
|
||||||
|
|
||||||
AC_LANG_POP()
|
AC_LANG_POP()
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
|
|
|
@ -55,7 +55,12 @@ DownstreamQueue::HostEntry &
|
||||||
DownstreamQueue::find_host_entry(const std::string &host) {
|
DownstreamQueue::find_host_entry(const std::string &host) {
|
||||||
auto itr = host_entries_.find(host);
|
auto itr = host_entries_.find(host);
|
||||||
if (itr == std::end(host_entries_)) {
|
if (itr == std::end(host_entries_)) {
|
||||||
|
#ifdef HAVE_STD_MAP_EMPLACE
|
||||||
std::tie(itr, std::ignore) = host_entries_.emplace(host, HostEntry());
|
std::tie(itr, std::ignore) = host_entries_.emplace(host, HostEntry());
|
||||||
|
#else // !HAVE_STD_MAP_EMPLACE
|
||||||
|
// for g++-4.7
|
||||||
|
std::tie(itr, std::ignore) = host_entries_.insert({host, HostEntry()});
|
||||||
|
#endif // !HAVE_STD_MAP_EMPLACE
|
||||||
}
|
}
|
||||||
return (*itr).second;
|
return (*itr).second;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue