This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::regex: inserting std::wregex to std::vector loses some std::wregex values


Hi,

On 09/15/2014 06:46 PM, Tim Shen wrote:
On Mon, Sep 15, 2014 at 3:10 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
With this patch basic_regex::_M_traits becames a pointer, but that
pointer becomes null after a move - is that safe?

It looks wrong to allocate a traits object in the default constructor
but not in the move constructor, and to allow _M_traits to be null
following assign(), e.g. does this work OK after your patch?

  std::regex r;
  std::regex rr = std::move(r);
  r.assign("a");
  regex_match("a", r);
No it doesn't, sorry. The reason _M_traits can't be nullptr is imbue()
and getloc(), so should we implement move constructor using default
construction and swap?
But then the move constructor can't be noexcept anymore, because I see that currently the default constructor isn't noexcept. Thus we should first make sure that the default constructor is noexcept, which is a good idea anyway.

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]