]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Algorithms/Querying Algorithms//equal |100 |
2 | ||
3 | equal | |
4 | ===== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename Seq1 | |
13 | , typename Seq2 | |
14 | , typename Pred = is_same<_1,_2> | |
15 | > | |
16 | struct equal | |
17 | { | |
18 | typedef |unspecified| type; | |
19 | }; | |
20 | ||
21 | ||
22 | ||
23 | Description | |
24 | ----------- | |
25 | ||
26 | Returns a true-valued |Integral Constant| if the two sequences ``Seq1`` | |
27 | and ``Seq2`` are identical when compared element-by-element. | |
28 | ||
29 | ||
30 | Header | |
31 | ------ | |
32 | ||
33 | .. parsed-literal:: | |
34 | ||
35 | #include <boost/mpl/equal.hpp> | |
36 | ||
37 | ||
38 | ||
39 | Parameters | |
40 | ---------- | |
41 | ||
42 | +-------------------+-------------------------------+-----------------------------------+ | |
43 | | Parameter | Requirement | Description | | |
44 | +===================+===============================+===================================+ | |
45 | | ``Seq1``, ``Seq2``| |Forward Sequence| | Sequences to compare. | | |
46 | +-------------------+-------------------------------+-----------------------------------+ | |
47 | | ``Pred`` | Binary |Lambda Expression| | A comparison criterion. | | |
48 | +-------------------+-------------------------------+-----------------------------------+ | |
49 | ||
50 | ||
51 | Expression semantics | |
52 | -------------------- | |
53 | ||
54 | For any |Forward Sequence|\ s ``s1`` and ``s2`` and a binary |Lambda Expression| ``pred``: | |
55 | ||
56 | ||
57 | .. parsed-literal:: | |
58 | ||
59 | typedef equal<s1,s2,pred>::type c; | |
60 | ||
61 | :Return type: | |
62 | |Integral Constant| | |
63 | ||
64 | :Semantics: | |
65 | ``c::value == true`` is and only if ``size<s1>::value == size<s2>::value`` | |
66 | and for every iterator ``i`` in |begin/end<s1>| ``deref<i>::type`` is identical to | |
67 | ||
68 | .. parsed-literal:: | |
69 | ||
70 | advance< begin<s2>::type, distance< begin<s1>::type,i >::type >::type | |
71 | ||
72 | ||
73 | Complexity | |
74 | ---------- | |
75 | ||
76 | Linear. At most ``size<s1>::value`` comparisons. | |
77 | ||
78 | ||
79 | Example | |
80 | ------- | |
81 | ||
82 | .. parsed-literal:: | |
83 | ||
84 | typedef vector<char,int,unsigned,long,unsigned long> s1; | |
85 | typedef list<char,int,unsigned,long,unsigned long> s2; | |
86 | ||
87 | BOOST_MPL_ASSERT(( equal<s1,s2> )); | |
88 | ||
89 | ||
90 | See also | |
91 | -------- | |
92 | ||
93 | |Querying Algorithms|, |find|, |find_if| | |
94 | ||
95 | ||
96 |