From 55a83b64082418a10c2f5f756e38e0eb3371b63d Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 13 Jan 2002 12:09:39 +0000 Subject: [PATCH] Added forwarding get functions to solve problems with using::tuples::get statement. [SVN r12290] --- include/boost/tuple/tuple.hpp | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/include/boost/tuple/tuple.hpp b/include/boost/tuple/tuple.hpp index 01772e6..5960314 100644 --- a/include/boost/tuple/tuple.hpp +++ b/include/boost/tuple/tuple.hpp @@ -37,7 +37,50 @@ namespace boost { using tuples::tuple; using tuples::make_tuple; using tuples::tie; +#if !defined(BOOST_NO_USING_TEMPLATE) using tuples::get; +#elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +// +// The "using tuples::get" statement causes the +// Borland compiler to ICE, use forwarding +// functions instead: +// +template +inline typename tuples::access_traits< + typename tuples::element >::type + >::non_const_type +get(tuples::cons& c) { + return tuples::get(c); +} +// get function for const cons-lists, returns a const reference to +// the element. If the element is a reference, returns the reference +// as such (that is, can return a non-const reference) +template +inline typename tuples::access_traits< + typename tuples::element >::type + >::const_type +get(const tuples::cons& c) { + return tuples::get(c); +} +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +// +// MSVC, using declarations don't mix with templates well, +// so use forwarding functions instead: +// +template +typename tuples::detail::element_ref >::RET +get(tuples::cons& t, tuples::detail::workaround_holder* = 0) +{ + return tuples::detail::get_class::get(t); +} + +template +typename tuples::detail::element_const_ref >::RET +get(const tuples::cons& t, tuples::detail::workaround_holder* = 0) +{ + return tuples::detail::get_class::get(t); +} +#endif // BOOST_NO_USING_TEMPLATE } // end namespace boost