Expand calls to emplace implementation

Also manually call the emplace macro up to 9 arguments, nicer error
messages for little effort.

Does it matter that there's no longer a nice backend for
`please_ignore_this_overload`? I don't think so, I was worried that it
would be confusing if triggered, but I'm not really aware of that ever
happening.
This commit is contained in:
Daniel James
2017-04-23 10:09:18 +01:00
parent 42b6b13943
commit f6f5ecdc00
3 changed files with 224 additions and 229 deletions

View File

@@ -220,7 +220,9 @@ template <class K, class T, class H, class P, class A> class unordered_map
template <class... Args>
std::pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args)
{
return table_.emplace(boost::forward<Args>(args)...);
return table_.emplace_impl(
table::extractor::extract(boost::forward<Args>(args)...),
boost::forward<Args>(args)...);
}
#else
@@ -244,25 +246,33 @@ template <class K, class T, class H, class P, class A> class unordered_map
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)));
return table_.emplace_impl(
table::extractor::extract(boost::forward<A0>(a0)),
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)));
return table_.emplace_impl(
table::extractor::extract(
boost::forward<A0>(a0), boost::forward<A1>(a1)),
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)));
return table_.emplace_impl(
table::extractor::extract(
boost::forward<A0>(a0), boost::forward<A1>(a1)),
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)));
}
#endif
@@ -272,7 +282,9 @@ template <class K, class T, class H, class P, class A> class unordered_map
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint(hint, boost::forward<Args>(args)...);
return table_.emplace_hint_impl(hint,
table::extractor::extract(boost::forward<Args>(args)...),
boost::forward<Args>(args)...);
}
#else
@@ -292,28 +304,33 @@ template <class K, class T, class H, class P, class A> class unordered_map
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)));
return table_.emplace_hint_impl(hint,
table::extractor::extract(boost::forward<A0>(a0)),
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)));
return table_.emplace_hint_impl(
hint, table::extractor::extract(
boost::forward<A0>(a0), boost::forward<A1>(a1)),
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)
{
return table_.emplace_hint(
hint, boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)));
return table_.emplace_hint_impl(
hint, table::extractor::extract(
boost::forward<A0>(a0), boost::forward<A1>(a1)),
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)));
}
#endif
@@ -325,21 +342,32 @@ template <class K, class T, class H, class P, class A> class unordered_map
std::pair<iterator, bool> emplace( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \
{ \
return table_.emplace(boost::unordered::detail::create_emplace_args( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))); \
return table_.emplace_impl( \
table::extractor::extract( \
boost::forward<A0>(a0), boost::forward<A1>(a1)), \
boost::unordered::detail::create_emplace_args( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))); \
} \
\
template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
iterator emplace_hint(const_iterator hint, \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \
{ \
return table_.emplace_hint( \
hint, boost::unordered::detail::create_emplace_args( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))); \
return table_.emplace_hint_impl( \
hint, table::extractor::extract( \
boost::forward<A0>(a0), boost::forward<A1>(a1)), \
boost::unordered::detail::create_emplace_args( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))); \
}
BOOST_PP_REPEAT_FROM_TO(
4, BOOST_PP_INC(BOOST_UNORDERED_EMPLACE_LIMIT), BOOST_UNORDERED_EMPLACE, _)
BOOST_UNORDERED_EMPLACE(1, 4, _)
BOOST_UNORDERED_EMPLACE(1, 5, _)
BOOST_UNORDERED_EMPLACE(1, 6, _)
BOOST_UNORDERED_EMPLACE(1, 7, _)
BOOST_UNORDERED_EMPLACE(1, 8, _)
BOOST_UNORDERED_EMPLACE(1, 9, _)
BOOST_PP_REPEAT_FROM_TO(10, BOOST_PP_INC(BOOST_UNORDERED_EMPLACE_LIMIT),
BOOST_UNORDERED_EMPLACE, _)
#undef BOOST_UNORDERED_EMPLACE
@@ -625,8 +653,8 @@ template <class K, class T, class H, class P, class A> class unordered_map
n, BOOST_UNORDERED_CALL_FORWARD, a))); \
}
BOOST_PP_REPEAT_FROM_TO(
4, BOOST_PP_INC(BOOST_UNORDERED_EMPLACE_LIMIT), BOOST_UNORDERED_TRY_EMPLACE, _)
BOOST_PP_REPEAT_FROM_TO(4, BOOST_PP_INC(BOOST_UNORDERED_EMPLACE_LIMIT),
BOOST_UNORDERED_TRY_EMPLACE, _)
#undef BOOST_UNORDERED_TRY_EMPLACE
@@ -972,7 +1000,9 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
template <class... Args> iterator emplace(BOOST_FWD_REF(Args)... args)
{
return table_.emplace(boost::forward<Args>(args)...);
return iterator(table_.emplace_impl(
boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(), boost::forward<Args>(args)...)));
}
#else
@@ -994,24 +1024,33 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
template <typename A0> iterator emplace(BOOST_FWD_REF(A0) a0)
{
return table_.emplace(boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
return iterator(table_.emplace_impl(
boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
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)));
return iterator(table_.emplace_impl(
boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
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)));
return iterator(table_.emplace_impl(
boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)))));
}
#endif
@@ -1021,7 +1060,9 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint(hint, boost::forward<Args>(args)...);
return iterator(table_.emplace_hint_impl(
hint, boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(), boost::forward<Args>(args)...)));
}
#else
@@ -1041,27 +1082,34 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
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)));
return iterator(table_.emplace_hint_impl(
hint, boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
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)));
return iterator(table_.emplace_hint_impl(
hint, boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
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)
{
return table_.emplace_hint(
hint, boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)));
return iterator(table_.emplace_hint_impl(
hint, boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0), boost::forward<A1>(a1),
boost::forward<A2>(a2)))));
}
#endif
@@ -1072,21 +1120,33 @@ template <class K, class T, class H, class P, class A> class unordered_multimap
template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
iterator emplace(BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \
{ \
return table_.emplace(boost::unordered::detail::create_emplace_args( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))); \
return iterator(table_.emplace_impl( \
boost::unordered::detail::func::construct_node_from_args( \
table_.node_alloc(), \
boost::unordered::detail::create_emplace_args( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))))); \
} \
\
template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
iterator emplace_hint(const_iterator hint, \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \
{ \
return table_.emplace_hint( \
hint, boost::unordered::detail::create_emplace_args( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))); \
return iterator(table_.emplace_hint_impl( \
hint, \
boost::unordered::detail::func::construct_node_from_args( \
table_.node_alloc(), \
boost::unordered::detail::create_emplace_args( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, a))))); \
}
BOOST_PP_REPEAT_FROM_TO(
4, BOOST_PP_INC(BOOST_UNORDERED_EMPLACE_LIMIT), BOOST_UNORDERED_EMPLACE, _)
BOOST_UNORDERED_EMPLACE(1, 4, _)
BOOST_UNORDERED_EMPLACE(1, 5, _)
BOOST_UNORDERED_EMPLACE(1, 6, _)
BOOST_UNORDERED_EMPLACE(1, 7, _)
BOOST_UNORDERED_EMPLACE(1, 8, _)
BOOST_UNORDERED_EMPLACE(1, 9, _)
BOOST_PP_REPEAT_FROM_TO(10, BOOST_PP_INC(BOOST_UNORDERED_EMPLACE_LIMIT),
BOOST_UNORDERED_EMPLACE, _)
#undef BOOST_UNORDERED_EMPLACE