Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-12-05 12:28:06


Robert Ramey:

> I've been reading the posts on this subject with interest. I don't have
> strong position myself. I do believe that some extra effort and/or
> risk is justified to get best performance. I'm leaving for you guys
> to do battle over the various alternatives. I strongly believe
> in const correctness and believe that things are "const" for a reason
> so I'm not enamored with a const_cast of any kind. I would
> much prefer a "guarenteed correct" solution if its close to best
> efficiency.
>
> Hence I like the current suggestion. But does't it presume
> that s.begin() points to a real array which would be an implemenation
> feature?. That is, do I know that a standard conforming string
> is actually an array of adjacent characters?

The standard doesn't guarantee that a std::string is a contiguous array, but
all existing implementations are. You can use &s[0] and take the risk, or
you can prefer dispatching on whether s.begin() returns a pointer.


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