diff --git a/include/boost/tuple/detail/tuple_basic.hpp b/include/boost/tuple/detail/tuple_basic.hpp index 348fd80..afdb50f 100644 --- a/include/boost/tuple/detail/tuple_basic.hpp +++ b/include/boost/tuple/detail/tuple_basic.hpp @@ -86,45 +86,28 @@ namespace detail { template class generate_error; -// - cons getters -------------------------------------------------------- -// called: get_class::get(aTuple) - -template< int N > -struct get_class { - template - inline static RET get(const cons& t) - { -#if BOOST_WORKAROUND(__IBMCPP__,==600) - // vacpp 6.0 is not very consistent regarding the member template keyword - // Here it generates an error when the template keyword is used. - return get_class::get(t.tail); -#else - return get_class::BOOST_NESTED_TEMPLATE get(t.tail); -#endif - } - template - inline static RET get(cons& t) - { -#if BOOST_WORKAROUND(__IBMCPP__,==600) - return get_class::get(t.tail); -#else - return get_class::BOOST_NESTED_TEMPLATE get(t.tail); -#endif - } +template +struct drop_front { + template + struct apply { + typedef BOOST_DEDUCED_TYPENAME drop_front::BOOST_NESTED_TEMPLATE + apply next; + typedef BOOST_DEDUCED_TYPENAME next::type::tail_type type; + static const type& call(const Tuple& tup) { + return next::call(tup).tail; + } + }; }; template<> -struct get_class<0> { - template - inline static RET get(const cons& t) - { - return t.head; - } - template - inline static RET get(cons& t) - { - return t.head; - } +struct drop_front<0> { + template + struct apply { + typedef Tuple type; + static const type& call(const Tuple& tup) { + return tup; + } + }; }; } // end of namespace detail @@ -140,41 +123,23 @@ struct get_class<0> { template struct element { -private: - typedef typename T::tail_type Next; -public: - typedef typename element::type type; -}; -template -struct element<0,T> -{ - typedef typename T::head_type type; + typedef BOOST_DEDUCED_TYPENAME detail::drop_front::BOOST_NESTED_TEMPLATE + apply::type::head_type type; }; template struct element { private: - typedef typename T::tail_type Next; - typedef typename element::type unqualified_type; + typedef BOOST_DEDUCED_TYPENAME detail::drop_front::BOOST_NESTED_TEMPLATE + apply::type::head_type unqualified_type; public: #if BOOST_WORKAROUND(__BORLANDC__,<0x600) typedef const unqualified_type type; #else - typedef typename boost::add_const::type type; -#endif - -}; -template -struct element<0,const T> -{ -#if BOOST_WORKAROUND(__BORLANDC__,<0x600) - typedef const typename T::head_type type; -#else - typedef typename boost::add_const::type type; + typedef BOOST_DEDUCED_TYPENAME boost::add_const::type type; #endif }; - #else // def BOOST_NO_CV_SPECIALIZATIONS namespace detail { @@ -182,31 +147,16 @@ namespace detail { template struct element_impl { -private: - typedef typename T::tail_type Next; -public: - typedef typename element_impl::type type; + typedef BOOST_DEDUCED_TYPENAME detail::drop_front::BOOST_NESTED_TEMPLATE + apply::type::head_type type; }; template struct element_impl { -private: - typedef typename T::tail_type Next; -public: - typedef const typename element_impl::type type; -}; - -template -struct element_impl<0, T, false /* IsConst */> -{ - typedef typename T::head_type type; -}; - -template -struct element_impl<0, T, true /* IsConst */> -{ - typedef const typename T::head_type type; + typedef BOOST_DEDUCED_TYPENAME detail::drop_front::BOOST_NESTED_TEMPLATE + apply::type::head_type unqualified_type; + typedef const unqualified_type type; }; } // end of namespace detail @@ -258,17 +208,10 @@ inline typename access_traits< typename element >::type >::non_const_type get(cons& c BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int, N)) { -#if BOOST_WORKAROUND(__IBMCPP__,==600 ) - return detail::get_class:: -#else - return detail::get_class::BOOST_NESTED_TEMPLATE -#endif - get< - typename access_traits< - typename element >::type - >::non_const_type, - HT,TT - >(c); + typedef BOOST_DEDUCED_TYPENAME detail::drop_front::BOOST_NESTED_TEMPLATE + apply > impl; + typedef BOOST_DEDUCED_TYPENAME impl::type cons_element; + return const_cast(impl::call(c)).head; } // get function for const cons-lists, returns a const reference to @@ -279,17 +222,10 @@ inline typename access_traits< typename element >::type >::const_type get(const cons& c BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(int, N)) { -#if BOOST_WORKAROUND(__IBMCPP__,==600) - return detail::get_class:: -#else - return detail::get_class::BOOST_NESTED_TEMPLATE -#endif - get< - typename access_traits< - typename element >::type - >::const_type, - HT,TT - >(c); + typedef BOOST_DEDUCED_TYPENAME detail::drop_front::BOOST_NESTED_TEMPLATE + apply > impl; + typedef BOOST_DEDUCED_TYPENAME impl::type cons_element; + return impl::call(c).head; } // -- the cons template --------------------------------------------------