Mercurial > octave
changeset 32121:ae588860b6fa
new function to get first element or undefined value from octave_value_list
* ovl.h (octave_value_list::first_or_nil_ov): New function.
author | Petter T. <petter.vilhelm@gmail.com> |
---|---|
date | Wed, 14 Jun 2023 16:09:36 -0400 |
parents | 0bce463a9b1a |
children | 920e88fd8ab7 |
files | libinterp/octave-value/ovl.h |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ovl.h Wed Jun 14 16:07:47 2023 -0400 +++ b/libinterp/octave-value/ovl.h Wed Jun 14 16:09:36 2023 -0400 @@ -172,6 +172,14 @@ void clear () { m_data.clear (); } + octave_value first_or_nil_ov () const + { + if (length ()) + return m_data.front (); + + return octave_value (); + } + private: std::vector<octave_value> m_data;