source:
downloads/boost_1_34_1/libs/mpl/doc/src/refmanual/replace.rst
@
29
Last change on this file since 29 was 29, checked in by landauf, 17 years ago | |
---|---|
File size: 2.5 KB |
replace
Synopsis
template< typename Sequence , typename OldType , typename NewType , typename In = |unspecified| > struct replace { typedef |unspecified| type; };
Description
Returns a copy of the original sequence where every type identical to OldType has been replaced with NewType.
Header
#include <boost/mpl/replace.hpp>
Model of
Parameters
Parameter | Requirement | Description |
---|---|---|
Sequence | |Forward Sequence| | A original sequence. |
OldType | Any type | A type to be replaced. |
NewType | Any type | A type to replace with. |
In | |Inserter| | An inserter. |
Expression semantics
|Semantics disclaimer...| |Reversible Algorithm|.
For any |Forward Sequence| s, an |Inserter| in, and arbitrary types x and y:
typedef replace<s,x,y,in>::type r;
Return type: | A type. |
---|---|
Semantics: | Equivalent to typedef replace_if< s,y,is_same<_,x>,in >::type r; |
Complexity
Linear. Performs exactly size<s>::value comparisons for identity / insertions.
Example
typedef vector<int,float,char,float,float,double> types; typedef vector<int,double,char,double,double,double> expected; typedef replace< types,float,double >::type result; BOOST_MPL_ASSERT(( equal< result,expected > ));
Note: See TracBrowser
for help on using the repository browser.