• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Sequences/Intrinsic Metafunctions//front
2
3front
4=====
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template<
12          typename Sequence
13        >
14    struct front
15    {
16        typedef |unspecified| type;
17    };
18
19
20
21Description
22-----------
23
24Returns the first element in the sequence.
25
26
27Header
28------
29
30.. parsed-literal::
31
32    #include <boost/mpl/front.hpp>
33
34
35Model of
36--------
37
38|Tag Dispatched Metafunction|
39
40
41Parameters
42----------
43
44+---------------+-----------------------+-----------------------------------------------+
45| Parameter     | Requirement           | Description                                   |
46+===============+=======================+===============================================+
47| ``Sequence``  | |Forward Sequence|    | A sequence to be examined.                    |
48+---------------+-----------------------+-----------------------------------------------+
49
50
51Expression semantics
52--------------------
53
54For any |Forward Sequence| ``s``:
55
56
57.. parsed-literal::
58
59    typedef front<s>::type t;
60
61:Return type:
62    A type.
63
64:Precondition:
65    ``empty<s>::value == false``.
66
67:Semantics:
68    Equivalent to
69
70    .. parsed-literal::
71
72       typedef deref< begin<s>::type >::type t;
73
74
75
76Complexity
77----------
78
79Amortized constant time.
80
81
82Example
83-------
84
85.. parsed-literal::
86
87    typedef list<long>::type types1;
88    typedef list<int,long>::type types2;
89    typedef list<char,int,long>::type types3;
90
91    BOOST_MPL_ASSERT(( is_same< front<types1>::type, long > ));
92    BOOST_MPL_ASSERT(( is_same< front<types2>::type, int> ));
93    BOOST_MPL_ASSERT(( is_same< front<types3>::type, char> ));
94
95
96
97See also
98--------
99
100|Forward Sequence|, |back|, |push_front|, |begin|, |deref|, |at|
101
102
103.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
104   Distributed under the Boost Software License, Version 1.0. (See accompanying
105   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
106