changeset 32128:d3023141b792

new function to duplicate index_exception objects * lo-array-errwarn.h, lo-array-errwarn.cc (index_exception::dup): New pure virtual function. (invalid_index::dup, out_of_range::dup): New functions. (class invalid_index, class out_of_range): Provide default copy and move constructors. * ov-complex.cc (complex_index_exception::dup): New function. (class complex_index_exception): Provide default copy and move constructors.
author Petter T. <petter.vilhelm@gmail.com>
date Thu, 15 Jun 2023 15:46:59 -0400
parents 408aa8a98b58
children 13fbc97f9362
files libinterp/octave-value/ov-complex.cc liboctave/util/lo-array-errwarn.cc liboctave/util/lo-array-errwarn.h
diffstat 3 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-complex.cc	Thu Jun 15 12:26:25 2023 -0400
+++ b/libinterp/octave-value/ov-complex.cc	Thu Jun 15 15:46:59 2023 -0400
@@ -80,6 +80,8 @@
     update_message ();
   }
 
+  OCTAVE_DEFAULT_COPY_MOVE (complex_index_exception)
+
   ~complex_index_exception () = default;
 
   void update_message ()
@@ -93,6 +95,13 @@
   {
     return "Octave:invalid-index";
   }
+
+  index_exception * dup ()
+  {
+    complex_index_exception *retval = new complex_index_exception {*this};
+    retval->set_identifier (retval->err_id ());
+    return retval;
+  }
 };
 
 OCTAVE_END_NAMESPACE(octave)
--- a/liboctave/util/lo-array-errwarn.cc	Thu Jun 15 12:26:25 2023 -0400
+++ b/liboctave/util/lo-array-errwarn.cc	Thu Jun 15 15:46:59 2023 -0400
@@ -179,6 +179,8 @@
     update_message ();
   }
 
+  OCTAVE_DEFAULT_COPY_MOVE (invalid_index)
+
   void update_message ()
   {
     static std::string exp
@@ -194,6 +196,13 @@
   {
     return error_id_invalid_index;
   }
+
+  index_exception * dup ()
+  {
+    invalid_index *retval = new invalid_index {*this};
+    retval->set_identifier (retval->err_id ());
+    return retval;
+  }
 };
 
 // Complain if an index is negative, fractional, or too big.
@@ -247,6 +256,8 @@
     update_message ();
   }
 
+  OCTAVE_DEFAULT_COPY_MOVE (out_of_range)
+
   void update_message ()
   {
     set_message (expression () + ": out of bound "
@@ -260,6 +271,13 @@
     return error_id_index_out_of_bounds;
   }
 
+  index_exception * dup ()
+  {
+    out_of_range *retval = new out_of_range {*this};
+    retval->set_identifier (retval->err_id ());
+    return retval;
+  }
+
 private:
 
   // Dimension of object being accessed.
--- a/liboctave/util/lo-array-errwarn.h	Thu Jun 15 12:26:25 2023 -0400
+++ b/liboctave/util/lo-array-errwarn.h	Thu Jun 15 15:46:59 2023 -0400
@@ -92,6 +92,9 @@
     update_message ();
   }
 
+  // Return a newly allocated copy of the index_exception object.
+  virtual index_exception * dup () = 0;
+
 private:
 
   // Value of invalid index.