Boost logo

Boost Users :

Subject: Re: [Boost-users] string_ref and modifying underlying data
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2015-08-04 10:14:41

On Mon, Aug 3, 2015 at 8:27 AM, james <dirtydroog_at_[hidden]> wrote:

> Hi,
> I'm curious about the decision taken to not allow string_ref to modify the
> data it represents.
> I'm modifying our JSON parser to use it, and sometimes I need to normalise
> a field to
> uppercase or lowercase. Obviously I cannot now do this without making a
> copy of the normalised field somewhere with either std::string or
> boost::string_ref.
Consider the following code:

      const char *foo = "abcdef";
      string_ref sr{foo, 6};

Given only "sr", how can you tell if it is possible to change the contents ?

-- Marshall

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at