From 4f5a2dabe924168fae63d59b55d4d4bc6d3ac993 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 19 May 2017 08:46:54 +0100 Subject: [PATCH] Try to fix std::tuple on old Sun compilers In order to use the workaround for both `boost::tuple` and `std::tuple` the function would need to detect which was being used, in order to decide whether to use `boost::tuples::length` or `std::tuple_size`. Probably not difficult, but I don't have any way to test an implementation. So instead Just assume that if `std::tuple` is available it will work without any workaround. Presumably once the compiler was able to support `std::tuple` it will also support the necessary overloads. I've left the version check as 5.21 so that failures will still show up in the tests, but I'm sure it can be 5.20 and probably earlier. Will change before release. --- .../boost/unordered/detail/implementation.hpp | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index f70e6fbf..a681f9a3 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -111,11 +111,6 @@ // Already defined, so do nothing #if defined(BOOST_UNORDERED_TUPLE_ARGS) -// I had problems with tuples on older versions of the sunpro. -// Might be fixed in an earlier version than I specified here. -#elif BOOST_UNORDERED_SUN_WORKAROUNDS1 -#define BOOST_UNORDERED_TUPLE_ARGS 0 - // Assume if we have C++11 tuple it's properly variadic, // and just use a max number of 10 arguments. #elif !defined(BOOST_NO_CXX11_HDR_TUPLE) @@ -1349,8 +1344,6 @@ inline void construct_value(T* address, BOOST_FWD_REF(A0) a0) // // Used to emulate piecewise construction. -#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 - #define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(z, n, namespace_) \ template \ @@ -1364,6 +1357,9 @@ inline void construct_value(T* address, BOOST_FWD_REF(A0) a0) #define BOOST_UNORDERED_GET_TUPLE_ARG(z, n, namespace_) namespace_::get(x) // construct_from_tuple for boost::tuple +// The workaround for old Sun compilers comes later in the file. + +#if !BOOST_UNORDERED_SUN_WORKAROUNDS1 template void construct_from_tuple(Alloc&, T* ptr, boost::tuple<>) @@ -1382,6 +1378,8 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 8, boost) BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 9, boost) BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(1, 10, boost) +#endif + // construct_from_tuple for std::tuple #if !BOOST_UNORDERED_CXX11_CONSTRUCTION && BOOST_UNORDERED_TUPLE_ARGS @@ -1408,7 +1406,14 @@ BOOST_PP_REPEAT_FROM_TO(6, BOOST_PP_INC(BOOST_UNORDERED_TUPLE_ARGS), #undef BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE #undef BOOST_UNORDERED_GET_TUPLE_ARG -#else // BOOST_UNORDERED_SUN_WORKAROUNDS1 +// construct_from_tuple for boost::tuple on old versions of sunpro. +// +// Old versions of Sun C++ had problems with template overloads of +// boost::tuple, so to fix it I added a distinct type for each length to +// the overloads. That means there's no possible ambiguity between the +// different overloads, so that the compiler doesn't get confused + +#if BOOST_UNORDERED_SUN_WORKAROUNDS1 template struct length { @@ -1427,8 +1432,6 @@ template struct length #define BOOST_UNORDERED_GET_TUPLE_ARG(z, n, namespace_) namespace_::get(x) -// construct_from_tuple for boost::tuple - template void construct_from_tuple_impl( boost::unordered::detail::func::length<0>, Alloc&, T* ptr, boost::tuple<>)