1.. Metafunctions/Composition and Argument Binding//protect |60 2 3protect 4======= 5 6Synopsis 7-------- 8 9.. parsed-literal:: 10 11 template< 12 typename F 13 > 14 struct protect 15 { 16 // |unspecified| 17 // |...| 18 }; 19 20 21 22Description 23----------- 24 25``protect`` is an identity wrapper for a |Metafunction Class| that prevents 26its argument from being recognized as a |bind expression|. 27 28 29Header 30------ 31 32.. parsed-literal:: 33 34 #include <boost/mpl/protect.hpp> 35 36 37Parameters 38---------- 39 40+---------------+---------------------------+---------------------------------------+ 41| Parameter | Requirement | Description | 42+===============+===========================+=======================================+ 43| ``F`` | |Metafunction Class| | A metafunction class to wrap. | 44+---------------+---------------------------+---------------------------------------+ 45 46 47Expression semantics 48-------------------- 49 50For any |Metafunction Class| ``f``: 51 52 53.. parsed-literal:: 54 55 typedef protect<f> g; 56 57:Return type: 58 |Metafunction Class|. 59 60:Semantics: 61 If ``f`` is a |bind expression|, equivalent to 62 63 .. parsed-literal:: 64 65 struct g 66 { 67 template< 68 typename U1 = |unspecified|\,\ |...| typename U\ *n* = |unspecified| 69 > 70 struct apply 71 : apply_wrap\ *n*\<f,U1,\ |...|\ U\ *n*\ > 72 { 73 }; 74 }; 75 76 otherwise equivalent to ``typedef f g;``. 77 78 79Example 80------- 81 82.. parsed-literal:: 83 84 struct f 85 { 86 template< typename T1, typename T2 > struct apply 87 { 88 typedef T2 type; 89 }; 90 }; 91 92 typedef bind< quote\ ``3``\<if\_>,_1,_2,bind<f,_1,_2> > b1; 93 typedef bind< quote\ ``3``\<if\_>,_1,_2,protect< bind<f,_1,_2> > > b2; 94 95 typedef apply_wrap\ ``2``\< b1,false\_,char >::type r1; 96 typedef apply_wrap\ ``2``\< b2,false\_,char >::type r2; 97 98 BOOST_MPL_ASSERT(( is_same<r1,char> )); 99 BOOST_MPL_ASSERT(( is_same<r2,protect< bind<f,_1,_2> > > )); 100 101 102See also 103-------- 104 105|Composition and Argument Binding|, |Invocation|, |bind|, |quote|, |apply_wrap| 106 107 108.. copyright:: Copyright � 2001-2009 Aleksey Gurtovoy and David Abrahams 109 Distributed under the Boost Software License, Version 1.0. (See accompanying 110 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 111