convert replace/replace_if into sequence-building algorithms

[SVN r26153]
This commit is contained in:
Aleksey Gurtovoy
2004-11-08 19:00:27 +00:00
parent 0d161d3c40
commit 30d3389b92
2 changed files with 47 additions and 21 deletions

View File

@@ -18,24 +18,37 @@
#include <boost/mpl/replace_if.hpp>
#include <boost/mpl/same_as.hpp>
#include <boost/mpl/aux_/common_name_wknd.hpp>
#include <boost/mpl/aux_/na_spec.hpp>
#include <boost/mpl/aux_/inserter_algorithm.hpp>
namespace boost { namespace mpl {
BOOST_MPL_AUX_COMMON_NAME_WKND(replace)
namespace aux {
template<
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
, typename BOOST_MPL_AUX_NA_PARAM(OldType)
, typename BOOST_MPL_AUX_NA_PARAM(NewType)
typename Sequence
, typename OldType
, typename NewType
, typename Inserter
>
struct replace
: replace_if< Sequence, same_as<OldType>, NewType >
struct replace_impl
: replace_if_impl< Sequence, same_as<OldType>, NewType, Inserter >
{
};
BOOST_MPL_AUX_NA_SPEC(3, replace)
template<
typename Sequence
, typename OldType
, typename NewType
, typename Inserter
>
struct reverse_replace_impl
: reverse_replace_if_impl< Sequence, same_as<OldType>, NewType, Inserter >
{
};
} // namespace aux
BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(4, replace)
}}

View File

@@ -19,14 +19,11 @@
#include <boost/mpl/transform.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/aux_/common_name_wknd.hpp>
#include <boost/mpl/aux_/na_spec.hpp>
#include <boost/mpl/aux_/inserter_algorithm.hpp>
#include <boost/mpl/aux_/config/forwarding.hpp>
namespace boost { namespace mpl {
BOOST_MPL_AUX_COMMON_NAME_WKND(replace_if)
namespace aux {
template< typename Predicate, typename T >
@@ -51,16 +48,15 @@ struct replace_if_op
};
};
} // namespace aux
template<
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
, typename BOOST_MPL_AUX_NA_PARAM(Predicate)
, typename BOOST_MPL_AUX_NA_PARAM(T)
, typename BOOST_MPL_AUX_NA_PARAM(Inserter)
typename Sequence
, typename Predicate
, typename T
, typename Inserter
>
struct replace_if
: transform1<
struct replace_if_impl
: transform1_impl<
Sequence
, protect< aux::replace_if_op<Predicate,T> >
, Inserter
@@ -68,7 +64,24 @@ struct replace_if
{
};
BOOST_MPL_AUX_NA_SPEC(3, replace_if)
template<
typename Sequence
, typename Predicate
, typename T
, typename Inserter
>
struct reverse_replace_if_impl
: reverse_transform1_impl<
Sequence
, protect< aux::replace_if_op<Predicate,T> >
, Inserter
>
{
};
} // namespace aux
BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(4, replace_if)
}}