Re: Patch for Scintillua style handling
Csaba Raduly <[email protected]>
| Newsgroups | gmane.editors.scite.general |
|---|---|
| Message-ID | <CAEhDDbAmQXsoZ33O41hyOpsH=iQL3GkmQ0wDwAPTJnvVg--7gQ@mail.gmail.com> |
Assigning a temporary to a *const* reference extends the lifetime of the temporary to the lifetime of the reference. See the first exception under https://en.cppreference.com/w/cpp/language/lifetime#Temporary_object_lifetime Csaba On Tue, 30 Aug 2022 at 01:34, 'Neil Hodgson' via scite-interest <[email protected]> wrote: > > Mitchell, the lifetime of the variable referred to by 'name' may be a problem. 'name' is a reference, which is essentially a pointer and does not keep the thing referred to alive. I'm unsure of the actual C++ rules here but I think the value returned by 'wEditor.NameOfStyle(style)' can be deallocated at the end of that statement so will be dead when 'name' is used. Its better to just make 'name' a 'std::string' rather than a reference. > > const std::string &name = wEditor.NameOfStyle(style); > ... > end = name.find('.', ++end); > > Neil > > -- > You received this message because you are subscribed to the Google Groups "scite-interest" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/msgid/scite-interest/82B5F2D8-B4F2-43B1-9586-BA13689BF9F5%40me.com. -- You can get very substantial performance improvements by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler So if you're looking for a completely portable, 100% standards-conformant way to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK) -- You received this message because you are subscribed to the Google Groups "scite-interest" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/scite-interest/CAEhDDbAmQXsoZ33O41hyOpsH%3DiQL3GkmQ0wDwAPTJnvVg--7gQ%40mail.gmail.com.