1.. Metafunctions/Composition and Argument Binding//arg |50
2
3arg
4===
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template< int n > struct arg;
12
13    template<> struct arg<1>
14    {
15        template< typename A1,\ |...| typename A\ *n* = |unspecified| >
16        struct apply
17        {
18            typedef A1 type;
19        };
20    };
21
22    |...|
23
24    template<> struct arg<\ *n*\>
25    {
26        template< typename A1,\ |...| typename A\ *n* >
27        struct apply
28        {
29            typedef A\ *n* type;
30        };
31    };
32
33
34Description
35-----------
36
37``arg<n>`` specialization is a |Metafunction Class| that return the ``n``\ th of its arguments.
38
39
40Header
41------
42
43.. parsed-literal::
44
45    #include <boost/mpl/arg.hpp>
46
47
48Parameters
49----------
50
51+---------------+-----------------------------------+-----------------------------------------------+
52| Parameter     | Requirement                       | Description                                   |
53+===============+===================================+===============================================+
54| ``n``         | An integral constant              | A number of argument to return.               |
55+---------------+-----------------------------------+-----------------------------------------------+
56
57
58Expression semantics
59--------------------
60
61For any integral constant ``n`` in the range [1, |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|\] and
62arbitrary types |a1...an|:
63
64.. parsed-literal::
65
66    typedef apply_wrap\ *n*\< arg<\ *n*\ >,a1,\ |...|\a\ *n* >::type x;
67
68:Return type:
69    A type.
70
71:Semantics:
72    ``x`` is identical to ``an``.
73
74
75Example
76-------
77
78.. parsed-literal::
79
80    typedef apply_wrap\ ``5``\< arg<1>,bool,char,short,int,long >::type t1;
81    typedef apply_wrap\ ``5``\< arg<3>,bool,char,short,int,long >::type t3;
82
83    BOOST_MPL_ASSERT(( is_same< t1, bool > ));
84    BOOST_MPL_ASSERT(( is_same< t3, short > ));
85
86
87See also
88--------
89
90|Composition and Argument Binding|, |Placeholders|, |lambda|, |bind|, |apply|, |apply_wrap|
91
92
93.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
94   Distributed under the Boost Software License, Version 1.0. (See accompanying
95   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
96