diff libinterp/corefcn/strfns.cc @ 33034:49128bdb9eb2

use explicit lambda-expression captures (bug #65318) Previously, we recommended using implicit capture by value (if possible) in all lambda expressions in Octave. However, this choice causes trouble in the transition period leading up to C++20, when the meaning changes for capturing 'this' by reference when the default capture is '='. Since all lambda expressions in Octave only need to capture a few variables it seems better and relatively easy to simply name all captured variable explicitly. (The maximum number of captured variables currently appears to be seven, including 'this', but the vast majority are capturing just one or two.) Affected files: Canvas.cc, GLCanvas.cc, QTerminal.cc, command-widget.cc, documentation.cc, files-dock-widget.cc, interpreter-qobject.cc, file-editor-tab.cc, file-editor.cc, octave-qscintilla.cc, main-window.cc, octave-dock-widget.cc, octave-qobject.cc, set-path-model.cc, settings-dialog.cc, variable-editor-model.cc, variable-editor.cc, call-stack.cc, gl2ps-print.cc, graphics.cc, input.cc, interpreter.cc, load-path.cc, mex.cc, pr-output.cc, strfns.cc, sysdep.cc, __delaunayn__.cc, audiodevinfo.cc, audioread.cc, oct-parse.yy, pt-eval.cc, Array-util.cc, Range.h, lo-sysdep.cc, lo-regexp.cc, oct-glob.cc, oct-string.cc, and url-transfer.cc.
author John W. Eaton <jwe@octave.org>
date Fri, 16 Feb 2024 14:42:54 -0500
parents 2e484f9f1f18
children fb44a9db1bc6
line wrap: on
line diff
--- a/libinterp/corefcn/strfns.cc	Fri Feb 16 03:09:40 2024 -0500
+++ b/libinterp/corefcn/strfns.cc	Fri Feb 16 14:42:54 2024 -0500
@@ -908,7 +908,7 @@
                codepage, std::strerror (errno));
     }
 
-  unwind_action free_utf8_str ([=] () { ::free (utf8_str); });
+  unwind_action free_utf8_str ([utf8_str] () { ::free (utf8_str); });
 
   octave_idx_type len = length;
 
@@ -953,7 +953,7 @@
                codepage, std::strerror (errno));
     }
 
-  unwind_action free_native_bytes ([=] () { ::free (native_bytes); });
+  unwind_action free_native_bytes ([native_bytes] () { ::free (native_bytes); });
 
   octave_idx_type len = length;