Mercurial > octave
comparison liboctave/array/Range.h @ 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 | 7de59b26cf79 |
children |
comparison
equal
deleted
inserted
replaced
33033:7de59b26cf79 | 33034:49128bdb9eb2 |
---|---|
249 // Loop over all values in IDX, executing the lambda | 249 // Loop over all values in IDX, executing the lambda |
250 // expression for each index value. | 250 // expression for each index value. |
251 | 251 |
252 T *array = retval.rwdata (); | 252 T *array = retval.rwdata (); |
253 | 253 |
254 idx.loop (n, [=, &array] (octave_idx_type i) | 254 idx.loop (n, [this, &array] (octave_idx_type i) |
255 { | 255 { |
256 if (i == 0) | 256 if (i == 0) |
257 // Required for proper NaN handling. | 257 // Required for proper NaN handling. |
258 *array++ = (m_numel == 0 ? m_final : m_base); | 258 *array++ = (m_numel == 0 ? m_final : m_base); |
259 else if (i < m_numel - 1) | 259 else if (i < m_numel - 1) |