|
Boost : |
From: Bruno Martínez (br1_at_[hidden])
Date: 2004-01-25 11:07:20
John Maddock wrote:
> 2) An explicit constructor can catch sloppy code:
> std::string trim(const std::string & s)
> {
> return regex_replace(s, "\\A\\s+|\\s+\\z", ""); // inefficient use of
> non-explicit constructor
> }
> In this case the code can be much more effieciently expressed as:
> std::string trim(const std::string & s)
> {
> static const boost::regex e("\\A\\s+|\\s+\\z");
> return regex_replace(s, e, "");
> }
Is the behaviour of this in a multiple-threaded environment correct?
Bruno
ADSL - Para estar las 24 horas en internet
http://www.internet.com.uy Tel. 707.42.52
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk