mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-03 15:56:38 +02:00
adapted to the new range interface
[SVN r38122]
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
#include <locale>
|
#include <locale>
|
||||||
#include <boost/iterator/transform_iterator.hpp>
|
#include <boost/iterator/transform_iterator.hpp>
|
||||||
|
|
||||||
|
#include <boost/range/as_literal.hpp>
|
||||||
#include <boost/range/begin.hpp>
|
#include <boost/range/begin.hpp>
|
||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
#include <boost/range/value_type.hpp>
|
#include <boost/range/value_type.hpp>
|
||||||
@ -56,10 +57,9 @@ namespace boost {
|
|||||||
const RangeT& Input,
|
const RangeT& Input,
|
||||||
const std::locale& Loc=std::locale())
|
const std::locale& Loc=std::locale())
|
||||||
{
|
{
|
||||||
return std::transform(
|
return ::boost::algorithm::detail::transform_range_copy(
|
||||||
begin(Input),
|
|
||||||
end(Input),
|
|
||||||
Output,
|
Output,
|
||||||
|
as_literal(Input),
|
||||||
::boost::algorithm::detail::to_lowerF<
|
::boost::algorithm::detail::to_lowerF<
|
||||||
typename range_value<RangeT>::type >(Loc));
|
typename range_value<RangeT>::type >(Loc));
|
||||||
}
|
}
|
||||||
@ -73,15 +73,10 @@ namespace boost {
|
|||||||
const SequenceT& Input,
|
const SequenceT& Input,
|
||||||
const std::locale& Loc=std::locale())
|
const std::locale& Loc=std::locale())
|
||||||
{
|
{
|
||||||
return SequenceT(
|
return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
|
||||||
make_transform_iterator(
|
as_literal(Input),
|
||||||
begin(Input),
|
|
||||||
::boost::algorithm::detail::to_lowerF<
|
::boost::algorithm::detail::to_lowerF<
|
||||||
typename range_value<SequenceT>::type >(Loc)),
|
typename range_value<SequenceT>::type >(Loc));
|
||||||
make_transform_iterator(
|
|
||||||
end(Input),
|
|
||||||
::boost::algorithm::detail::to_lowerF<
|
|
||||||
typename range_value<SequenceT>::type >(Loc)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Convert to lower case
|
//! Convert to lower case
|
||||||
@ -97,10 +92,8 @@ namespace boost {
|
|||||||
WritableRangeT& Input,
|
WritableRangeT& Input,
|
||||||
const std::locale& Loc=std::locale())
|
const std::locale& Loc=std::locale())
|
||||||
{
|
{
|
||||||
std::transform(
|
::boost::algorithm::detail::transform_range(
|
||||||
begin(Input),
|
as_literal(Input),
|
||||||
end(Input),
|
|
||||||
begin(Input),
|
|
||||||
::boost::algorithm::detail::to_lowerF<
|
::boost::algorithm::detail::to_lowerF<
|
||||||
typename range_value<WritableRangeT>::type >(Loc));
|
typename range_value<WritableRangeT>::type >(Loc));
|
||||||
}
|
}
|
||||||
@ -129,10 +122,9 @@ namespace boost {
|
|||||||
const RangeT& Input,
|
const RangeT& Input,
|
||||||
const std::locale& Loc=std::locale())
|
const std::locale& Loc=std::locale())
|
||||||
{
|
{
|
||||||
return std::transform(
|
return ::boost::algorithm::detail::transform_range_copy(
|
||||||
begin(Input),
|
|
||||||
end(Input),
|
|
||||||
Output,
|
Output,
|
||||||
|
as_literal(Input),
|
||||||
::boost::algorithm::detail::to_upperF<
|
::boost::algorithm::detail::to_upperF<
|
||||||
typename range_value<RangeT>::type >(Loc));
|
typename range_value<RangeT>::type >(Loc));
|
||||||
}
|
}
|
||||||
@ -146,16 +138,10 @@ namespace boost {
|
|||||||
const SequenceT& Input,
|
const SequenceT& Input,
|
||||||
const std::locale& Loc=std::locale())
|
const std::locale& Loc=std::locale())
|
||||||
{
|
{
|
||||||
return SequenceT(
|
return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
|
||||||
make_transform_iterator(
|
as_literal(Input),
|
||||||
begin(Input),
|
|
||||||
::boost::algorithm::detail::to_upperF<
|
::boost::algorithm::detail::to_upperF<
|
||||||
typename range_value<SequenceT>::type >(Loc)),
|
typename range_value<SequenceT>::type >(Loc));
|
||||||
make_transform_iterator(
|
|
||||||
end(Input),
|
|
||||||
::boost::algorithm::detail::to_upperF<
|
|
||||||
typename range_value<SequenceT>::type >(Loc)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Convert to upper case
|
//! Convert to upper case
|
||||||
@ -171,10 +157,8 @@ namespace boost {
|
|||||||
WritableRangeT& Input,
|
WritableRangeT& Input,
|
||||||
const std::locale& Loc=std::locale())
|
const std::locale& Loc=std::locale())
|
||||||
{
|
{
|
||||||
std::transform(
|
::boost::algorithm::detail::transform_range(
|
||||||
begin(Input),
|
as_literal(Input),
|
||||||
end(Input),
|
|
||||||
begin(Input),
|
|
||||||
::boost::algorithm::detail::to_upperF<
|
::boost::algorithm::detail::to_upperF<
|
||||||
typename range_value<WritableRangeT>::type >(Loc));
|
typename range_value<WritableRangeT>::type >(Loc));
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,49 @@ namespace boost {
|
|||||||
const std::locale& m_Loc;
|
const std::locale& m_Loc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// algorithm implementation -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Transform a range
|
||||||
|
template<typename OutputIteratorT, typename RangeT, typename FunctorT>
|
||||||
|
OutputIteratorT transform_range_copy(
|
||||||
|
OutputIteratorT Output,
|
||||||
|
const RangeT& Input,
|
||||||
|
FunctorT Functor)
|
||||||
|
{
|
||||||
|
return std::transform(
|
||||||
|
begin(Input),
|
||||||
|
end(Input),
|
||||||
|
Output,
|
||||||
|
Functor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transform a range (in-place)
|
||||||
|
template<typename RangeT, typename FunctorT>
|
||||||
|
void transform_range(
|
||||||
|
const RangeT& Input,
|
||||||
|
FunctorT Functor)
|
||||||
|
{
|
||||||
|
std::transform(
|
||||||
|
begin(Input),
|
||||||
|
end(Input),
|
||||||
|
begin(Input),
|
||||||
|
Functor);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename SequenceT, typename RangeT, typename FunctorT>
|
||||||
|
inline SequenceT transform_range_copy(
|
||||||
|
const RangeT& Input,
|
||||||
|
FunctorT Functor)
|
||||||
|
{
|
||||||
|
return SequenceT(
|
||||||
|
make_transform_iterator(
|
||||||
|
begin(Input),
|
||||||
|
Functor),
|
||||||
|
make_transform_iterator(
|
||||||
|
end(Input),
|
||||||
|
Functor));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace algorithm
|
} // namespace algorithm
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
Reference in New Issue
Block a user