Boost logo

Boost :

From: Paul Hamilton (paul_at_[hidden])
Date: 2003-08-21 07:52:26


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();
***************
*** 184,188 ****
             // either it was multi-output with first output padding up
all width..
             // either it was one big arg and we are fine.
! empty_buf( oss_);
             oss_.width(0);
             put_last(oss_, x );
--- 178,182 ----
             // either it was multi-output with first output padding up
all width..
             // either it was one big arg and we are fine.
! oss_.str(std::basic_string<Ch, Tr>());
             oss_.width(0);
             put_last(oss_, x );
***************
*** 210,214 ****

     prev_state.apply_on(oss_);
! empty_buf( oss_);
     oss_.clear();
   } // end- put(..)
--- 204,208 ----

     prev_state.apply_on(oss_);
! oss_.str(std::basic_string<Ch, Tr>());
     oss_.clear();
   } // end- put(..)

---------------------
Paul Hamilton
pHamtec P/L - Software Makers
http://www.phamtec.com/
mailto:paul_at_[hidden]

The information transmitted is intended only for the person or entity
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you
received this in error, please contact the sender and delete the
material from any computer.
-----------------------------------------------------


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