1.. Metafunctions/Invocation//apply |10 2 3apply 4===== 5 6Synopsis 7-------- 8 9.. parsed-literal:: 10 11 template< 12 typename F 13 > 14 struct apply0 15 { 16 typedef |unspecified| type; 17 }; 18 19 template< 20 typename F, typename A1 21 > 22 struct apply1 23 { 24 typedef |unspecified| type; 25 }; 26 27 |...| 28 29 template< 30 typename F, typename A1,\ |...| typename An 31 > 32 struct apply\ *n* 33 { 34 typedef |unspecified| type; 35 }; 36 37 template< 38 typename F 39 , typename A1 = |unspecified| 40 |...| 41 , typename An = |unspecified| 42 > 43 struct apply 44 { 45 typedef |unspecified| type; 46 }; 47 48 49 50Description 51----------- 52 53Invokes a |Metafunction Class| or a |Lambda Expression| ``F`` with arguments ``A1``,... ``An``. 54 55 56Header 57------ 58 59.. parsed-literal:: 60 61 #include <boost/mpl/apply.hpp> 62 63 64Parameters 65---------- 66 67+---------------+-----------------------------------+-----------------------------------------------+ 68| Parameter | Requirement | Description | 69+===============+===================================+===============================================+ 70| ``F`` | |Lambda Expression| | An expression to invoke. | 71+---------------+-----------------------------------+-----------------------------------------------+ 72| |A1...An| | Any type | Invocation arguments. | 73+---------------+-----------------------------------+-----------------------------------------------+ 74 75 76Expression semantics 77-------------------- 78 79For any |Lambda Expression| ``f`` and arbitrary types ``a1``,... ``an``: 80 81 82.. parsed-literal:: 83 84 typedef apply\ *n*\<f,a1,\ |...|\ a\ *n*\>::type t; 85 typedef apply<f,a1,\ |...|\ a\ *n*\>::type t; 86 87:Return type: 88 Any type. 89 90:Semantics: 91 Equivalent to ``typedef apply_wrap``\ *n*\ ``< lambda<f>::type,a1,... an>::type t;``. 92 93 94Example 95------- 96 97.. parsed-literal:: 98 99 template< typename N1, typename N2 > struct int_plus 100 : int_<( N1::value + N2::value )> 101 { 102 }; 103 104 typedef apply< int_plus<_1,_2>, int_<2>, int_<3> >::type r1; 105 typedef apply< quote\ ``2``\ <int_plus>, int_<2>, int_<3> >::type r2; 106 107 BOOST_MPL_ASSERT_RELATION( r1::value, ==, 5 ); 108 BOOST_MPL_ASSERT_RELATION( r2::value, ==, 5 ); 109 110 111See also 112-------- 113 114|Metafunctions|, |apply_wrap|, |lambda|, |quote|, |bind| 115 116 117.. copyright:: Copyright � 2001-2009 Aleksey Gurtovoy and David Abrahams 118 Distributed under the Boost Software License, Version 1.0. (See accompanying 119 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 120