|
Boost : |
Subject: [boost] [algorithm] to_lower_copy / to_upper_copy with no output param assumes sequence to be same as input
From: Sebastian Karlsson (sairony_at_[hidden])
Date: 2011-06-22 09:05:46
It would seem: std::string foo = boost::algorithm::to_lower_copy<
std::string >( "bar" ); isn't valid. Instead one has to do for
example: std::string foo = boost::algorithm::to_lower_copy(
std::string( "bar" ) ), which while perhaps just as terse and natural
creates an extra unneeded temporary. I propose the following addition,
as well as one for to_upper_copy:
template<typename OutputSequenceT, typename RangeT>
inline OutputSequenceT
to_lower_copy(
const RangeT& Input,
const std::locale& Loc=std::locale())
{
OutputSequenceT Output( ::boost::begin( Input ), ::boost::end( Input ) );
::boost::algorithm::detail::transform_range(
::boost::as_literal( Output ),
::boost::algorithm::detail::to_lowerF<
typename range_value<OutputSequenceT>::type >(Loc));
return Output;
}
Or perhaps I've missed something altogether :)
Kind regards,
Sebastian Karlsson
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk