Unordered: construct_from_tuple for old versions of sun.

Not properly tested, as I haven't got the compiler fully working on my
machine.

[SVN r75341]
This commit is contained in:
Daniel James
2011-11-06 09:34:54 +00:00
parent c3477b2624
commit 9cb361f35e

View File

@ -175,6 +175,8 @@ BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT, BOOST_UNORDERED_EARGS,
//
// Used for piecewise construction.
#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590)
#define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(n, namespace_) \
template<typename T> \
void construct_from_tuple(T* ptr, namespace_::tuple<>) \
@ -210,6 +212,49 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std::tr1)
#undef BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE_IMPL
#undef BOOST_UNORDERED_GET_TUPLE_ARG
#else
template <int N> struct length {};
template<typename T>
void construct_from_tuple_impl(
boost::unordered::detail::length<0>, T* ptr,
boost::tuple<>)
{
new ((void*) ptr) T();
}
#define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE_IMPL(z, n, _) \
template<typename T, BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
void construct_from_tuple_impl( \
boost::unordered::detail::length<n>, T* ptr, \
namespace_::tuple<BOOST_PP_ENUM_PARAMS_Z(z, n, A)> const& x) \
{ \
new ((void*) ptr) T( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_GET_TUPLE_ARG, namespace_) \
); \
}
#define BOOST_UNORDERED_GET_TUPLE_ARG(z, n, _) \
boost::get<n>(x)
BOOST_PP_REPEAT_FROM_TO(1, 10, \
BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE_IMPL, _)
template <typename T, typename Tuple>
void construct_from_tuple(T* ptr, Tuple const& x)
{
construct_from_tuple_impl(
boost::unordered::detail::length<
boost::tuples::length<Tuple>::value>(),
ptr, x);
}
#undef BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE_IMPL
#undef BOOST_UNORDERED_GET_TUPLE_ARG
#endif
////////////////////////////////////////////////////////////////////////////
// SFINAE traits for construction.