From af0e42f13e0d2ff624a37ebd01b2a1da2a5ff4b5 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Sun, 20 Jul 2008 23:14:15 +0000 Subject: [PATCH] list-at optimization [SVN r47643] --- .../fusion/container/list/detail/at_impl.hpp | 85 +++++++++++++++---- 1 file changed, 69 insertions(+), 16 deletions(-) diff --git a/include/boost/fusion/container/list/detail/at_impl.hpp b/include/boost/fusion/container/list/detail/at_impl.hpp index 54ba6bb8..4dee15dc 100644 --- a/include/boost/fusion/container/list/detail/at_impl.hpp +++ b/include/boost/fusion/container/list/detail/at_impl.hpp @@ -1,7 +1,7 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(FUSION_AT_IMPL_07172005_0726) @@ -15,6 +15,71 @@ namespace boost { namespace fusion { + namespace detail + { + template + struct cons_deref + { + typedef typename Cons::car_type type; + }; + + template + struct cons_advance + { + typedef typename + cons_advance::type::cdr_type + type; + }; + + template + struct cons_advance + { + typedef Cons type; + }; + + template + struct cons_advance + { + typedef typename Cons::cdr_type type; + }; + + template + struct cons_advance + { +#if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above + typedef typename Cons::cdr_type::cdr_type type; +#else + typedef typename Cons::cdr_type _a; + typedef typename _a::cdr_type type; +#endif + }; + + template + struct cons_advance + { +#if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above + typedef typename Cons::cdr_type::cdr_type::cdr_type type; +#else + typedef typename Cons::cdr_type _a; + typedef typename _a::cdr_type _b; + typedef typename _b::cdr_type type; +#endif + }; + + template + struct cons_advance + { +#if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above + typedef typename Cons::cdr_type::cdr_type::cdr_type::cdr_type type; +#else + typedef typename Cons::cdr_type _a; + typedef typename _a::cdr_type _b; + typedef typename _b::cdr_type _c; + typedef typename _c::cdr_type type; +#endif + }; + } + struct cons_tag; namespace extension @@ -26,22 +91,10 @@ namespace boost { namespace fusion struct at_impl { template - struct apply + struct apply { - typedef typename - mpl::eval_if< - is_const - , add_const - , mpl::identity - >::type - cdr_type; - - typedef typename - mpl::eval_if< - mpl::bool_ - , mpl::identity - , apply > - > + typedef detail::cons_deref< + typename detail::cons_advance::type> element; typedef typename