]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpl/doc/src/refmanual/unique.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / unique.rst
1 .. Algorithms/Transformation Algorithms//unique |80
2
3 unique
4 ======
5
6 Synopsis
7 --------
8
9 .. parsed-literal::
10
11 template<
12 typename Seq
13 , typename Pred
14 , typename In = |unspecified|
15 >
16 struct unique
17 {
18 typedef |unspecified| type;
19 };
20
21
22 Description
23 -----------
24
25 Returns a sequence of the initial elements of every subrange of the
26 original sequence ``Seq`` whose elements are all the same.
27
28 |transformation algorithm disclaimer|
29
30 Header
31 ------
32
33 .. parsed-literal::
34
35 #include <boost/mpl/unique.hpp>
36
37
38 Model of
39 --------
40
41 |Reversible Algorithm|
42
43
44 Parameters
45 ----------
46
47 +---------------+-----------------------------------+-------------------------------+
48 | Parameter | Requirement | Description |
49 +===============+===================================+===============================+
50 | ``Sequence`` | |Forward Sequence| | An original sequence. |
51 +---------------+-----------------------------------+-------------------------------+
52 | ``Pred`` | Binary |Lambda Expression| | An equivalence relation. |
53 +---------------+-----------------------------------+-------------------------------+
54 | ``In`` | |Inserter| | An inserter. |
55 +---------------+-----------------------------------+-------------------------------+
56
57
58 Expression semantics
59 --------------------
60
61 |Semantics disclaimer...| |Reversible Algorithm|.
62
63 For any |Forward Sequence| ``s``, a binary |Lambda Expression| ``pred``,
64 and an |Inserter| ``in``:
65
66
67 .. parsed-literal::
68
69 typedef unique<s,pred,in>::type r;
70
71 :Return type:
72 A type.
73
74 :Semantics:
75 If ``size<s>::value <= 1``, then equivalent to
76
77 .. parsed-literal::
78
79 typedef copy<s,in>::type r;
80
81 otherwise equivalent to
82
83 .. parsed-literal::
84
85 typedef lambda<pred>::type p;
86 typedef lambda<in::operation>::type in_op;
87 typedef apply_wrap\ ``2``\<
88 in_op
89 , in::state
90 , front<types>::type
91 >::type in_state;
92
93 typedef fold<
94 s
95 , pair< in_state, front<s>::type >
96 , eval_if<
97 apply_wrap\ ``2``\<p, second<_1>, _2>
98 , identity< first<_1> >
99 , apply_wrap\ ``2``\<in_op, first<_1>, _2>
100 >
101 >::type::first r;
102
103
104 Complexity
105 ----------
106
107 Linear. Performs exactly ``size<s>::value - 1`` applications of ``pred``, and at
108 most ``size<s>::value`` insertions.
109
110
111 Example
112 -------
113
114 .. parsed-literal::
115
116 typedef vector<int,float,float,char,int,int,int,double> types;
117 typedef vector<int,float,char,int,double> expected;
118 typedef unique< types, is_same<_1,_2> >::type result;
119
120 BOOST_MPL_ASSERT(( equal< result,expected > ));
121
122
123 See also
124 --------
125
126 |Transformation Algorithms|, |Reversible Algorithm|, |reverse_unique|, |remove|, |copy_if|, |replace_if|
127
128
129 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
130 Distributed under the Boost Software License, Version 1.0. (See accompanying
131 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)