Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-08-21 08:32:24


Paul Hamilton wrote:
> Peter Dimov wrote:
>
>> Paul Hamilton wrote:
>>> [...] I propose that we change the code:
>>>
>>> static const std::basic_string<Ch, Tr> emptyStr;
>>>
>>> To:
>>>
>>> const std::basic_string<Ch, Tr> emptyStr = "";
>>>
>>> Which basically does exactly the same thing.
>>
>> = "" is not needed, it just forces a redundant strlen call (at
>> least).
>> As I
>> already pointed out,
>>
>> std::basic_string<Ch, Tr> emptyStr;
>>
>> is enough; or even
>>
>> os.str(std::basic_string<Ch, Tr>());
>>
>> (if it doesn't cause parser problems.)
>
> Like this?
>
> *** feed_args.hpp.orig Thu Aug 21 22:45:28 2003
> --- feed_args.hpp Thu Aug 21 22:46:40 2003
> ***************
> *** 33,42 ****
> namespace {
>
> - template<class Tr, class Ch> inline
> - void empty_buf(BOOST_IO_STD basic_ostringstream<Ch,Tr> & os) {
> - static const std::basic_string<Ch, Tr> emptyStr;
> - os.str(emptyStr);
> - }
> -
> template<class Ch, class Tr>
> void do_pad( std::basic_string<Ch,Tr> & s,
> --- 33,36 ----
> ***************
> *** 139,143 ****
> // in order to find width
> put_head( oss_, x );
> ! empty_buf( oss_);
>
> const std::streamsize w=oss_.width();
> --- 133,137 ----
> // in order to find width
> put_head( oss_, x );
> ! oss_.str(std::basic_string<Ch, Tr>());
>
> const std::streamsize w=oss_.width();
> ***************

This will work, although I had

template<class Tr, class Ch> inline
    void empty_buf(BOOST_IO_STD basic_ostringstream<Ch,Tr> & os) {
        os.str( std::basic_string<Ch, Tr>() );
    }

in mind as it is a smaller change.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk