1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
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
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>
19 namespace boost { namespace fusion { namespace distance_detail
21 // Default distance implementation, linear
22 // search for the Last iterator.
24 template <typename First, typename Last>
25 struct linear_distance;
27 template <typename First, typename Last>
32 typename linear_distance<
33 typename result_of::next<First>::type
40 template <typename First, typename Last>
41 struct linear_distance
43 result_of::equal_to<First, Last>
44 , mpl::identity<mpl::int_<0> >
45 , next_distance<First, Last>
50 result_of::equal_to<First, Last>
51 , mpl::identity<mpl::int_<0> >
52 , next_distance<First, Last>
56 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
58 call(First const&, Last const&)