]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Sequences/Views//transform_view |
2 | ||
3 | transform_view | |
4 | ============== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename Sequence | |
13 | , typename F | |
14 | > | |
15 | struct transform_view | |
16 | { | |
17 | // |unspecified| | |
18 | // |...| | |
19 | }; | |
20 | ||
21 | ||
22 | Description | |
23 | ----------- | |
24 | ||
25 | A view the full range of ``Sequence``\ 's transformed elements. | |
26 | ||
27 | ||
28 | Header | |
29 | ------ | |
30 | ||
31 | .. parsed-literal:: | |
32 | ||
33 | #include <boost/mpl/transform_view.hpp> | |
34 | ||
35 | ||
36 | Model of | |
37 | -------- | |
38 | ||
39 | * |Forward Sequence| | |
40 | ||
41 | ||
42 | Parameters | |
43 | ---------- | |
44 | ||
45 | +---------------+-------------------------------+-------------------------------+ | |
46 | | Parameter | Requirement | Description | | |
47 | +===============+===============================+===============================+ | |
48 | | ``Sequence`` | |Forward Sequence| | A sequence to wrap. | | |
49 | +---------------+-------------------------------+-------------------------------+ | |
50 | | ``F`` | Unary |Lambda Expression| | A transformation. | | |
51 | +---------------+-------------------------------+-------------------------------+ | |
52 | ||
53 | ||
54 | Expression semantics | |
55 | -------------------- | |
56 | ||
57 | |Semantics disclaimer...| |Forward Sequence|. | |
58 | ||
59 | In the following table, ``v`` is an instance of ``transform_view``, ``s`` is an arbitrary | |
60 | |Forward Sequence|, and ``f`` is an unary |Lambda Expression|. | |
61 | ||
62 | +-----------------------------------+-----------------------------------------------------------+ | |
63 | | Expression | Semantics | | |
64 | +===================================+===========================================================+ | |
65 | | .. parsed-literal:: | A lazy |Forward Sequence| such that for each ``i`` in the | | |
66 | | | range |begin/end<v>| and each ``j`` in for in the range | | |
67 | | transform_view<s,f> | |begin/end<s>| ``deref<i>::type`` is identical to | | |
68 | | transform_view<s,f>::type | ``apply< f, deref<j>::type >::type``. | | |
69 | +-----------------------------------+-----------------------------------------------------------+ | |
70 | | ``size<v>::type`` | The size of ``v``; | | |
71 | | | ``size<v>::value == size<s>::value``; | | |
72 | | | linear complexity; see |Forward Sequence|. | | |
73 | +-----------------------------------+-----------------------------------------------------------+ | |
74 | ||
75 | ||
76 | Example | |
77 | ------- | |
78 | ||
79 | Find the largest type in a sequence. | |
80 | ||
81 | .. parsed-literal:: | |
82 | ||
83 | typedef vector<int,long,char,char[50],double> types; | |
84 | typedef max_element< | |
85 | transform_view< types, size_of<_> > | |
86 | >::type iter; | |
87 | ||
88 | BOOST_MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 50 ); | |
89 | ||
90 | ||
91 | See also | |
92 | -------- | |
93 | ||
94 | |Sequences|, |Views|, |filter_view|, |joint_view|, |zip_view|, |iterator_range| | |
95 | ||
96 | ||
97 |