This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: std::regex: inserting std::wregex to std::vector loses some std::wregex values
- From: Tim Shen <timshen at google dot com>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: Jonathan Wakely <jwakely at redhat dot com>, Paolo Carlini <paolo dot carlini at oracle dot com>, Stefan Schweter <stefan at schweter dot it>, "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 16 Sep 2014 17:28:21 -0700
- Subject: Re: std::regex: inserting std::wregex to std::vector loses some std::wregex values
- Authentication-results: sourceware.org; auth=none
- References: <540C6873 dot 9030205 at schweter dot it> <CAH6eHdSdmAdo420reU92ujW+nT63H431vsuP9YzZo5YQPj1T3A at mail dot gmail dot com> <CAG4ZjNkti0p=XAdhDYeXbcUx3mtqxH4P-U5F9DXmahG1=0b1Dg at mail dot gmail dot com> <CAG4ZjNmwG1VYrA2cnw7_hhxcHukC01U-DOzfpdjbZhcLgLP_sQ at mail dot gmail dot com> <54156B0B dot 2050006 at oracle dot com> <CAG4ZjNm_PzVYhyonUGOq3fMK8Drj9FNseXepKCts_SGzF=LSkQ at mail dot gmail dot com> <20140915101056 dot GS22778 at redhat dot com> <CAG4ZjNkizOzm+L4T9PRCJp2Ss2LdZYC4Uq02T0DGJpf=77yWWg at mail dot gmail dot com> <20140916092353 dot GX22778 at redhat dot com> <CAG4ZjNkGruTpG1JtzcMDM=R01KmLAx5XkyUhNvw2Yt6tQMP6mw at mail dot gmail dot com> <CAH6eHdTZc359HkA2GSKNqHFAbLMdazB+qx2j8gcrc=F9zF81Zw at mail dot gmail dot com>
On Tue, Sep 16, 2014 at 4:37 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 16 September 2014 21:39, Tim Shen wrote:
>> shared_ptr can still be used as a "copy-on-write" mechanism, as long
>> as it does a regex recompile when imbuing.
>
> And as long as there are no references from the shared data to
> per-instance members.
>
>> it makes copy
>> constructing/assigning fast but imbue slow.
>
> Sounds like a good trade off to me.
>
>> shared_ptr, however, has
>> larger overhead, but I think it's affordable; we can make _NFA
>> intrusively shared to reduce it.
>
> IMHO the overhead of shared_ptr is entirely acceptable. I'd prefer
> reusing shared_ptr to adding yet another form of reference counting in
> the library.
I get the answer from you ;)
http://stackoverflow.com/questions/13912286/intrusive-ptr-in-c11
So I'll change the patch to move _M_traits to _NFA, and add a new
basic_regex::_M_loc member.
Should the abi compatible fix be another patch for branch 4.9? In
which the move ctor is not noexcept and calls the copy ctor?
--
Regards,
Tim Shen