
On Wed, Jun 22, 2011 at 3:56 PM, Olaf van der Spek <ml@vdspek.org> wrote:
On Wed, Jun 22, 2011 at 3:05 PM, Sebastian Karlsson <sairony@gmail.com> wrote:
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 ) );
Doesn't this also do an unnecessary copy?
Olaf
Maybe one would hope (N)RVO would kick in. But that would depend on the rest of the definition... - Jeff