3rdParty/boost/1.78.0/libs/mpl/doc/src/refmanual/replace.rst
.. Algorithms/Transformation Algorithms//replace |40
.. parsed-literal::
template<
typename Sequence
, typename OldType
, typename NewType
, typename In = |unspecified|
>
struct replace
{
typedef |unspecified| type;
};
Returns a copy of the original sequence where every type identical to OldType
has been replaced with NewType.
|transformation algorithm disclaimer|
.. parsed-literal::
#include <boost/mpl/replace.hpp>
|Reversible Algorithm|
+---------------+-----------------------------------+-------------------------------+
| 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. |
+---------------+-----------------------------------+-------------------------------+
|Semantics disclaimer...| |Reversible Algorithm|.
For any |Forward Sequence| s, an |Inserter| in, and arbitrary types x and y:
.. parsed-literal::
typedef replace<s,x,y,in>::type r;
:Return type: A type.
:Semantics: Equivalent to
.. parsed-literal::
typedef replace_if< s,y,is_same<_,x>,in >::type r;
Linear. Performs exactly size<s>::value comparisons for
identity / insertions.
.. parsed-literal::
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 > ));
|Transformation Algorithms|, |Reversible Algorithm|, |reverse_replace|, |replace_if|, |remove|, |transform|
.. copyright:: Copyright 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)