~tsarev/boostdc/cmake

« back to all changes in this revision

Viewing changes to boost/boost/fusion/view/zip_view/detail/distance_impl.hpp

  • Committer: bigmuscle
  • Date: 2010-05-08 08:47:15 UTC
  • Revision ID: svn-v4:5fb55d53-692c-0410-a46a-e90ab66e00ee:trunk:497
removed old boost version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*=============================================================================
2
 
    Copyright (c) 2001-2006 Joel de Guzman
3
 
    Copyright (c) 2006 Dan Marsden
4
 
 
5
 
    Distributed under the Boost Software License, Version 1.0. (See accompanying 
6
 
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
 
==============================================================================*/
8
 
#if !defined(FUSION_DISTANCE_IMPL_20060124_2033)
9
 
#define FUSION_DISTANCE_IMPL_20060124_2033
10
 
 
11
 
#include <boost/mpl/eval_if.hpp>
12
 
#include <boost/mpl/placeholders.hpp>
13
 
#include <boost/mpl/assert.hpp>
14
 
#include <boost/fusion/iterator/distance.hpp>
15
 
#include <boost/fusion/support/category_of.hpp>
16
 
#include <boost/fusion/algorithm/query/find_if.hpp>
17
 
#include <boost/fusion/sequence/intrinsic/end.hpp>
18
 
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
19
 
#include <boost/type_traits/is_same.hpp>
20
 
 
21
 
namespace boost { namespace fusion {
22
 
 
23
 
    struct zip_view_iterator_tag;
24
 
 
25
 
    struct random_access_iterator_tag;
26
 
 
27
 
    namespace detail
28
 
    {
29
 
        template<typename FoundIt, typename SearchIt>
30
 
        struct best_distance
31
 
        {
32
 
            typedef typename result_of::find_if<
33
 
                typename SearchIt::iterators, is_same<traits::category_of<mpl::_>, random_access_iterator_tag> > finder;
34
 
 
35
 
            BOOST_MPL_ASSERT_NOT((is_same<typename finder::type, result_of::end<typename SearchIt::iterators> >));
36
 
 
37
 
            typedef typename result_of::distance<FoundIt, typename finder::type>::type type;
38
 
        };
39
 
 
40
 
        template<typename It1, typename It2>
41
 
        struct default_distance
42
 
            : result_of::distance<
43
 
            typename result_of::value_at_c<typename It1::iterators, 0>::type,
44
 
            typename result_of::value_at_c<typename It2::iterators, 0>::type>
45
 
        {};
46
 
 
47
 
        template<typename It1, typename It2>
48
 
        struct zip_view_iterator_distance
49
 
        {
50
 
            typedef typename result_of::find_if<
51
 
                typename It1::iterators, is_same<traits::category_of<mpl::_>, random_access_iterator_tag> > finder;
52
 
                
53
 
            typedef typename mpl::eval_if<
54
 
                is_same<typename finder::type, typename result_of::end<typename It1::iterators>::type>,
55
 
                detail::default_distance<It1, It2> ,
56
 
                detail::best_distance<typename finder::type, It2> >::type type;               
57
 
        };
58
 
    }
59
 
 
60
 
    namespace extension
61
 
    {
62
 
        template<typename Tag>
63
 
        struct distance_impl;
64
 
 
65
 
        template<>
66
 
        struct distance_impl<zip_view_iterator_tag>
67
 
        {
68
 
            template<typename It1, typename It2>
69
 
            struct apply
70
 
                : detail::zip_view_iterator_distance<It1, It2>::type
71
 
            {
72
 
                static typename detail::zip_view_iterator_distance<It1, It2>::type
73
 
                call(It1 const& it1, It2 const& it2)
74
 
                {
75
 
                    return typename detail::zip_view_iterator_distance<It1, It2>::type();
76
 
                }                
77
 
            };
78
 
        };
79
 
    }
80
 
}}
81
 
 
82
 
#endif