]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpl/doc/src/refmanual/distance.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / distance.rst
CommitLineData
7c673cae
FG
1.. Iterators/Iterator Metafunctions//distance |20
2
3distance
4========
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11 template<
12 typename First
13 , typename Last
14 >
15 struct distance
16 {
17 typedef |unspecified| type;
18 };
19
20
21
22Description
23-----------
24
25Returns the distance between ``First`` and ``Last`` iterators, that is, an
26|Integral Constant| ``n`` such that ``advance<First,n>::type`` is
27identical to ``Last``.
28
29
30Header
31------
32
33.. parsed-literal::
34
35 #include <boost/mpl/distance.hpp>
36
37
38Parameters
39----------
40
41+---------------+---------------------------+-----------------------------------+
42| Parameter | Requirement | Description |
43+===============+===========================+===================================+
44| ``First``, | |Forward Iterator| | Iterators to compute a |
45| ``Last`` | | distance between. |
46+---------------+---------------------------+-----------------------------------+
47
48Model Of
49--------
50
51|Tag Dispatched Metafunction|
52
53
54Expression semantics
55--------------------
56
57For any |Forward Iterator|\ s ``first`` and ``last``:
58
59.. parsed-literal::
60
61 typedef distance<first,last>::type n;
62
63:Return type:
64 |Integral Constant|.
65
66:Precondition:
67 [``first``, ``last``) is a valid range.
68
69:Semantics:
70 Equivalent to
71
72 .. parsed-literal::
73
74 typedef iter_fold<
75 iterator_range<first,last>
76 , long_<0>
77 , next<_1>
78 >::type n;
79
80
81:Postcondition:
82 ``is_same< advance<first,n>::type, last >::value == true``.
83
84
85Complexity
86----------
87
88Amortized constant time if ``first`` and ``last`` are |Random Access Iterator|\ s,
89otherwise linear time.
90
91
92Example
93-------
94
95.. parsed-literal::
96
97 typedef range_c<int,0,10>::type range;
98 typedef begin<range>::type first;
99 typedef end<range>::type last;
100
101 BOOST_MPL_ASSERT_RELATION( (distance<first,last>::value), ==, 10);
102
103
104See also
105--------
106
107|Iterators|, |Tag Dispatched Metafunction|, |advance|, |next|, |prior|
108
109
110