1 /*============================================================================= 2 Copyright (c) 2001-2011 Joel de Guzman 3 4 Distributed under the Boost Software License, Version 1.0. (See accompanying 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 ==============================================================================*/ 7 #if !defined(FUSION_DISTANCE_09172005_0730) 8 #define FUSION_DISTANCE_09172005_0730 9 10 #include <boost/fusion/support/config.hpp> 11 #include <boost/mpl/int.hpp> 12 #include <boost/mpl/if.hpp> 13 #include <boost/mpl/eval_if.hpp> 14 #include <boost/mpl/next.hpp> 15 #include <boost/mpl/identity.hpp> 16 #include <boost/fusion/iterator/next.hpp> 17 #include <boost/fusion/iterator/equal_to.hpp> 18 19 namespace boost { namespace fusion { namespace distance_detail 20 { 21 // Default distance implementation, linear 22 // search for the Last iterator. 23 24 template <typename First, typename Last> 25 struct linear_distance; 26 27 template <typename First, typename Last> 28 struct next_distance 29 { 30 typedef typename 31 mpl::next< 32 typename linear_distance< 33 typename result_of::next<First>::type 34 , Last 35 >::type 36 >::type 37 type; 38 }; 39 40 template <typename First, typename Last> 41 struct linear_distance 42 : mpl::eval_if< 43 result_of::equal_to<First, Last> 44 , mpl::identity<mpl::int_<0> > 45 , next_distance<First, Last> 46 >::type 47 { 48 typedef typename 49 mpl::eval_if< 50 result_of::equal_to<First, Last> 51 , mpl::identity<mpl::int_<0> > 52 , next_distance<First, Last> 53 >::type 54 type; 55 56 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED 57 static type callboost::fusion::distance_detail::linear_distance58 call(First const&, Last const&) 59 { 60 return type(); 61 } 62 }; 63 64 }}} 65 66 #endif 67