1.. Algorithms/Transformation Algorithms//replace |40 2 3replace 4======= 5 6Synopsis 7-------- 8 9.. parsed-literal:: 10 11 template< 12 typename Sequence 13 , typename OldType 14 , typename NewType 15 , typename In = |unspecified| 16 > 17 struct replace 18 { 19 typedef |unspecified| type; 20 }; 21 22 23 24Description 25----------- 26 27Returns a copy of the original sequence where every type identical to ``OldType`` 28has been replaced with ``NewType``. 29 30|transformation algorithm disclaimer| 31 32Header 33------ 34 35.. parsed-literal:: 36 37 #include <boost/mpl/replace.hpp> 38 39 40Model of 41-------- 42 43|Reversible Algorithm| 44 45 46Parameters 47---------- 48 49+---------------+-----------------------------------+-------------------------------+ 50| Parameter | Requirement | Description | 51+===============+===================================+===============================+ 52| ``Sequence`` | |Forward Sequence| | A original sequence. | 53+---------------+-----------------------------------+-------------------------------+ 54| ``OldType`` | Any type | A type to be replaced. | 55+---------------+-----------------------------------+-------------------------------+ 56| ``NewType`` | Any type | A type to replace with. | 57+---------------+-----------------------------------+-------------------------------+ 58| ``In`` | |Inserter| | An inserter. | 59+---------------+-----------------------------------+-------------------------------+ 60 61 62Expression semantics 63-------------------- 64 65|Semantics disclaimer...| |Reversible Algorithm|. 66 67For any |Forward Sequence| ``s``, an |Inserter| ``in``, and arbitrary types ``x`` and ``y``: 68 69 70.. parsed-literal:: 71 72 typedef replace<s,x,y,in>::type r; 73 74:Return type: 75 A type. 76 77:Semantics: 78 Equivalent to 79 80 .. parsed-literal:: 81 82 typedef replace_if< s,y,is_same<_,x>,in >::type r; 83 84 85Complexity 86---------- 87 88Linear. Performs exactly ``size<s>::value`` comparisons for 89identity / insertions. 90 91 92Example 93------- 94 95.. parsed-literal:: 96 97 typedef vector<int,float,char,float,float,double> types; 98 typedef vector<int,double,char,double,double,double> expected; 99 typedef replace< types,float,double >::type result; 100 101 BOOST_MPL_ASSERT(( equal< result,expected > )); 102 103 104See also 105-------- 106 107|Transformation Algorithms|, |Reversible Algorithm|, |reverse_replace|, |replace_if|, |remove|, |transform| 108 109 110.. copyright:: Copyright � 2001-2009 Aleksey Gurtovoy and David Abrahams 111 Distributed under the Boost Software License, Version 1.0. (See accompanying 112 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 113