Split up emplace and emplace_hint code

Busywork I guess, but I think it's more readable this way. The emplace
macros are still unreadable, but I think they're rarely used.

Btw. a bit weird that clang format has removed the indentation on the
'// emplace' comment, not sure why that is.
This commit is contained in:
Daniel James
2017-04-20 22:59:00 +01:00
parent d8969c71fc
commit e2e9959389
2 changed files with 177 additions and 116 deletions

View File

@ -234,18 +234,13 @@ template <class K, class T, class H, class P, class A> class unordered_map
// emplace
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <class... Args>
std::pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args)
{
return table_.emplace(boost::forward<Args>(args)...);
}
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint(hint, boost::forward<Args>(args)...);
}
#else
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
@ -262,6 +257,46 @@ template <class K, class T, class H, class P, class A> class unordered_map
return this->emplace(boost::move(v));
}
#endif
template <typename A0>
std::pair<iterator, bool> emplace(BOOST_FWD_REF(A0) a0)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
}
template <typename A0, typename A1>
std::pair<iterator, bool> emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1, typename A2>
std::pair<iterator, bool> emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)));
}
#endif
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint(hint, boost::forward<Args>(args)...);
}
#else
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
iterator emplace_hint(const_iterator hint,
boost::unordered::detail::empty_emplace =
boost::unordered::detail::empty_emplace(),
@ -272,13 +307,6 @@ template <class K, class T, class H, class P, class A> class unordered_map
#endif
template <typename A0>
std::pair<iterator, bool> emplace(BOOST_FWD_REF(A0) a0)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
}
template <typename A0>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0)
{
@ -287,14 +315,6 @@ template <class K, class T, class H, class P, class A> class unordered_map
boost::forward<A0>(a0)));
}
template <typename A0, typename A1>
std::pair<iterator, bool> emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1>
iterator emplace_hint(
const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
@ -304,15 +324,6 @@ template <class K, class T, class H, class P, class A> class unordered_map
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1, typename A2>
std::pair<iterator, bool> emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)));
}
template <typename A0, typename A1, typename A2>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0,
BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
@ -323,6 +334,10 @@ template <class K, class T, class H, class P, class A> class unordered_map
boost::forward<A2>(a2)));
}
#endif
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
std::pair<iterator, bool> emplace( \
@ -971,16 +986,12 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
// emplace
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <class... Args> iterator emplace(BOOST_FWD_REF(Args)... args)
{
return table_.emplace(boost::forward<Args>(args)...);
}
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint(hint, boost::forward<Args>(args)...);
}
#else
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
@ -996,14 +1007,6 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
return this->emplace(boost::move(v));
}
iterator emplace_hint(const_iterator hint,
boost::unordered::detail::empty_emplace =
boost::unordered::detail::empty_emplace(),
value_type v = value_type())
{
return this->emplace_hint(hint, boost::move(v));
}
#endif
template <typename A0> iterator emplace(BOOST_FWD_REF(A0) a0)
@ -1012,14 +1015,6 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
boost::forward<A0>(a0)));
}
template <typename A0>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0)
{
return table_.emplace_hint(
hint, boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
}
template <typename A0, typename A1>
iterator emplace(BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
@ -1027,15 +1022,6 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1>
iterator emplace_hint(
const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return table_.emplace_hint(
hint, boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1, typename A2>
iterator emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
@ -1045,6 +1031,46 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
boost::forward<A2>(a2)));
}
#endif
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint(hint, boost::forward<Args>(args)...);
}
#else
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
iterator emplace_hint(const_iterator hint,
boost::unordered::detail::empty_emplace =
boost::unordered::detail::empty_emplace(),
value_type v = value_type())
{
return this->emplace_hint(hint, boost::move(v));
}
#endif
template <typename A0>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0)
{
return table_.emplace_hint(
hint, boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
}
template <typename A0, typename A1>
iterator emplace_hint(
const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return table_.emplace_hint(
hint, boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1, typename A2>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0,
BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
@ -1055,6 +1081,10 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
boost::forward<A2>(a2)));
}
#endif
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
iterator emplace(BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \

View File

@ -232,17 +232,13 @@ template <class T, class H, class P, class A> class unordered_set
// emplace
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <class... Args>
std::pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args)
{
return table_.emplace(boost::forward<Args>(args)...);
}
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint(hint, boost::forward<Args>(args)...);
}
#else
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
@ -259,6 +255,46 @@ template <class T, class H, class P, class A> class unordered_set
return this->emplace(boost::move(v));
}
#endif
template <typename A0>
std::pair<iterator, bool> emplace(BOOST_FWD_REF(A0) a0)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
}
template <typename A0, typename A1>
std::pair<iterator, bool> emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1, typename A2>
std::pair<iterator, bool> emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)));
}
#endif
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint(hint, boost::forward<Args>(args)...);
}
#else
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
iterator emplace_hint(const_iterator hint,
boost::unordered::detail::empty_emplace =
boost::unordered::detail::empty_emplace(),
@ -269,13 +305,6 @@ template <class T, class H, class P, class A> class unordered_set
#endif
template <typename A0>
std::pair<iterator, bool> emplace(BOOST_FWD_REF(A0) a0)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
}
template <typename A0>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0)
{
@ -284,14 +313,6 @@ template <class T, class H, class P, class A> class unordered_set
boost::forward<A0>(a0)));
}
template <typename A0, typename A1>
std::pair<iterator, bool> emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1>
iterator emplace_hint(
const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
@ -301,15 +322,6 @@ template <class T, class H, class P, class A> class unordered_set
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1, typename A2>
std::pair<iterator, bool> emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)));
}
template <typename A0, typename A1, typename A2>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0,
BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
@ -320,6 +332,10 @@ template <class T, class H, class P, class A> class unordered_set
boost::forward<A2>(a2)));
}
#endif
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
std::pair<iterator, bool> emplace( \
@ -703,11 +719,6 @@ template <class T, class H, class P, class A> class unordered_multiset
return table_.emplace(boost::forward<Args>(args)...);
}
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint(hint, boost::forward<Args>(args)...);
}
#else
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
@ -723,6 +734,44 @@ template <class T, class H, class P, class A> class unordered_multiset
return this->emplace(boost::move(v));
}
#endif
template <typename A0> iterator emplace(BOOST_FWD_REF(A0) a0)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
}
template <typename A0, typename A1>
iterator emplace(BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1, typename A2>
iterator emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)));
}
#endif
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint(hint, boost::forward<Args>(args)...);
}
#else
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
iterator emplace_hint(const_iterator hint,
boost::unordered::detail::empty_emplace =
boost::unordered::detail::empty_emplace(),
@ -733,12 +782,6 @@ template <class T, class H, class P, class A> class unordered_multiset
#endif
template <typename A0> iterator emplace(BOOST_FWD_REF(A0) a0)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
}
template <typename A0>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0)
{
@ -747,13 +790,6 @@ template <class T, class H, class P, class A> class unordered_multiset
boost::forward<A0>(a0)));
}
template <typename A0, typename A1>
iterator emplace(BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1>
iterator emplace_hint(
const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
@ -763,15 +799,6 @@ template <class T, class H, class P, class A> class unordered_multiset
boost::forward<A0>(a0), boost::forward<A1>(a1)));
}
template <typename A0, typename A1, typename A2>
iterator emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)));
}
template <typename A0, typename A1, typename A2>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0,
BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
@ -782,6 +809,10 @@ template <class T, class H, class P, class A> class unordered_multiset
boost::forward<A2>(a2)));
}
#endif
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
iterator emplace(BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \