Commit 38177989 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

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.
parent 13a14ecd
......@@ -197,6 +197,22 @@ std::vector<std::future<int>> v;
[have_std_future=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()
# Checks for libraries.
......
......@@ -55,7 +55,12 @@ DownstreamQueue::HostEntry &
DownstreamQueue::find_host_entry(const std::string &host) {
auto itr = host_entries_.find(host);
if (itr == std::end(host_entries_)) {
#ifdef HAVE_STD_MAP_EMPLACE
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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment