~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to boost/boost/mpl/distance.hpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//-----------------------------------------------------------------------------
 
2
// boost mpl/distance.hpp header file
 
3
// See http://www.boost.org for updates, documentation, and revision history.
 
4
//-----------------------------------------------------------------------------
 
5
//
 
6
// Copyright (c) 2000-02
 
7
// Aleksey Gurtovoy
 
8
//
 
9
// Permission to use, copy, modify, distribute and sell this software
 
10
// and its documentation for any purpose is hereby granted without fee, 
 
11
// provided that the above copyright notice appears in all copies and 
 
12
// that both the copyright notice and this permission notice appear in 
 
13
// supporting documentation. No representations are made about the 
 
14
// suitability of this software for any purpose. It is provided "as is" 
 
15
// without express or implied warranty.
 
16
 
 
17
#ifndef BOOST_MPL_DISTANCE_HPP_INCLUDED
 
18
#define BOOST_MPL_DISTANCE_HPP_INCLUDED
 
19
 
 
20
#include "boost/mpl/aux_/iter_distance.hpp"
 
21
#include "boost/mpl/aux_/iterator_category.hpp"
 
22
#include "boost/mpl/iterator_tag.hpp"
 
23
#include "boost/mpl/iter_fold.hpp"
 
24
#include "boost/mpl/iterator_range.hpp"
 
25
#include "boost/mpl/integral_c.hpp"
 
26
#include "boost/mpl/next.hpp"
 
27
#include "boost/mpl/aux_/common_name_wknd.hpp"
 
28
#include "boost/mpl/aux_/void_spec.hpp"
 
29
#include "boost/config.hpp"
 
30
 
 
31
namespace boost {
 
32
namespace mpl {
 
33
 
 
34
BOOST_MPL_AUX_COMMON_NAME_WKND(distance)
 
35
 
 
36
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
 
37
 
 
38
namespace aux {
 
39
 
 
40
// forward/bidirectional iterators
 
41
template< typename Category, typename First, typename Last >
 
42
struct distance_impl
 
43
    : iter_fold<
 
44
          iterator_range<First,Last>
 
45
        , integral_c<long, 0>
 
46
        , next<>
 
47
        >
 
48
{
 
49
};
 
50
 
 
51
template< typename First, typename Last >
 
52
struct distance_impl<ra_iter_tag_,First,Last>
 
53
    : aux::iter_distance<First,Last>
 
54
{
 
55
};
 
56
 
 
57
} // namespace aux
 
58
 
 
59
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_BEGIN
 
60
 
 
61
template<
 
62
      typename BOOST_MPL_AUX_VOID_SPEC_PARAM(First)
 
63
    , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Last)
 
64
    >
 
65
struct distance
 
66
{
 
67
    // agurt, 29/sep/02: Borland doesn't like inheritance here
 
68
    typedef typename aux::distance_impl<
 
69
          typename BOOST_MPL_AUX_ITERATOR_CATEGORY(First)
 
70
        , First
 
71
        , Last
 
72
        >::type type;
 
73
};
 
74
 
 
75
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_END
 
76
 
 
77
#else
 
78
 
 
79
namespace aux {
 
80
 
 
81
// forward/bidirectional iterators
 
82
template< typename Category >
 
83
struct distance_impl
 
84
{
 
85
    template< typename First, typename Last > struct result_
 
86
        : iter_fold<
 
87
              iterator_range<First,Last>
 
88
            , integral_c<long, 0>
 
89
            , next<>
 
90
            >
 
91
    {
 
92
    };
 
93
};
 
94
 
 
95
template<>
 
96
struct distance_impl<ra_iter_tag_>
 
97
{
 
98
    template< typename First, typename Last > struct result_
 
99
        : aux::iter_distance<First,Last>
 
100
    {
 
101
    };
 
102
};
 
103
 
 
104
} // namespace aux
 
105
 
 
106
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_BEGIN
 
107
 
 
108
template<
 
109
      typename BOOST_MPL_AUX_VOID_SPEC_PARAM(First)
 
110
    , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Last)
 
111
    >
 
112
struct distance
 
113
#if !defined(BOOST_MSVC) || BOOST_MSVC != 1300
 
114
    : aux::distance_impl< typename BOOST_MPL_AUX_ITERATOR_CATEGORY(First) >
 
115
#else
 
116
    : aux::distance_impl< fwd_iter_tag_ >
 
117
#endif
 
118
        ::template result_<First,Last>
 
119
{
 
120
};
 
121
 
 
122
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_END
 
123
 
 
124
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 
125
 
 
126
BOOST_MPL_AUX_ALGORITHM_VOID_SPEC(2, distance)
 
127
 
 
128
} // namespace mpl
 
129
} // namespace boost
 
130
 
 
131
#endif // BOOST_MPL_DISTANCE_HPP_INCLUDED