changeset 27381:d4fdaeaab7f3

use default or deleted ctors/dtors/assignment ops in liboctave/util Files affected: caseless-str.h, kpse.h, oct-inttypes.h, quit.h, and str-vec.h.
author John W. Eaton <jwe@octave.org>
date Mon, 09 Sep 2019 16:40:08 -0400
parents 72e8f15b5527
children 9354d33dfbc4
files liboctave/util/caseless-str.h liboctave/util/kpse.h liboctave/util/oct-inttypes.h liboctave/util/quit.h liboctave/util/str-vec.h
diffstat 5 files changed, 25 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/caseless-str.h	Mon Sep 09 16:24:38 2019 -0400
+++ b/liboctave/util/caseless-str.h	Mon Sep 09 16:40:08 2019 -0400
@@ -35,17 +35,16 @@
   typedef std::string::iterator iterator;
   typedef std::string::const_iterator const_iterator;
 
-  caseless_str (void) : std::string () { }
+  caseless_str (void) = default;
+
   caseless_str (const std::string& s) : std::string (s) { }
   caseless_str (const char *s) : std::string (s) { }
 
-  caseless_str (const caseless_str& name) : std::string (name) { }
+  caseless_str (const caseless_str&) = default;
 
-  caseless_str& operator = (const caseless_str& pname)
-  {
-    std::string::operator = (pname);
-    return *this;
-  }
+  caseless_str& operator = (const caseless_str&) = default;
+
+  ~caseless_str (void) = default;
 
   bool operator < (const std::string& s) const
   {
--- a/liboctave/util/kpse.h	Mon Sep 09 16:24:38 2019 -0400
+++ b/liboctave/util/kpse.h	Mon Sep 09 16:40:08 2019 -0400
@@ -41,9 +41,13 @@
     set_end ();
   }
 
-  kpse_path_iterator (const kpse_path_iterator& pi)
-    : m_path (pi.m_path), m_b (pi.m_b), m_e (pi.m_e), m_len (pi.m_len)
-  { }
+  kpse_path_iterator (const kpse_path_iterator&) = default;
+
+  // No assignment!
+
+  kpse_path_iterator& operator = (const kpse_path_iterator&) = delete;
+
+  ~kpse_path_iterator (void) = default;
 
   kpse_path_iterator operator ++ (int)
   {
@@ -65,9 +69,6 @@
 
   void set_end (void);
   void next (void);
-
-  // No assignment.
-  kpse_path_iterator& operator = (const kpse_path_iterator&);
 };
 
 extern unsigned int kpse_debug;
--- a/liboctave/util/oct-inttypes.h	Mon Sep 09 16:24:38 2019 -0400
+++ b/liboctave/util/oct-inttypes.h	Mon Sep 09 16:40:08 2019 -0400
@@ -831,13 +831,11 @@
   octave_int (const octave_int<U>& i)
     : m_ival (octave_int_base<T>::truncate_int (i.value ())) { }
 
-  octave_int (const octave_int<T>& i) : m_ival (i.m_ival) { }
+  octave_int (const octave_int<T>&) = default;
 
-  octave_int& operator = (const octave_int<T>& i)
-  {
-    m_ival = i.m_ival;
-    return *this;
-  }
+  octave_int& operator = (const octave_int<T>&) = default;
+
+  ~octave_int (void) = default;
 
   T value (void) const { return m_ival; }
 
--- a/liboctave/util/quit.h	Mon Sep 09 16:24:38 2019 -0400
+++ b/liboctave/util/quit.h	Mon Sep 09 16:40:08 2019 -0400
@@ -43,18 +43,11 @@
   {
   public:
 
-    execution_exception (void) : m_stack_trace () { }
-
-    execution_exception (const execution_exception& x)
-      : m_stack_trace (x.m_stack_trace) { }
+    execution_exception (void) = default;
 
-    execution_exception& operator = (const execution_exception& x)
-    {
-      if (&x != this)
-        m_stack_trace = x.m_stack_trace;
+    execution_exception (const execution_exception&) = default;
 
-      return *this;
-    }
+    execution_exception& operator = (const execution_exception&) = default;
 
     ~execution_exception (void) = default;
 
--- a/liboctave/util/str-vec.h	Mon Sep 09 16:24:38 2019 -0400
+++ b/liboctave/util/str-vec.h	Mon Sep 09 16:40:08 2019 -0400
@@ -37,7 +37,7 @@
 {
 public:
 
-  string_vector (void) : m_data () { }
+  string_vector (void) = default;
 
   explicit string_vector (octave_idx_type n) : m_data (dim_vector (n, 1)) { }
 
@@ -45,9 +45,9 @@
 
   string_vector (const std::string& s) : m_data (dim_vector (1, 1), s) { }
 
-  string_vector (const string_vector& s) : m_data (s.m_data) { }
+  string_vector (const string_vector&) = default;
 
-  string_vector (string_vector&& s) : m_data (std::move (s.m_data)) { }
+  string_vector (string_vector&&) = default;
 
   //! Constructor for STL containers of std::string.
   //!
@@ -65,21 +65,9 @@
 
   string_vector (const char * const *s, octave_idx_type n);
 
-  string_vector& operator = (const string_vector& s)
-  {
-    if (this != &s)
-      m_data = s.m_data;
-
-    return *this;
-  }
+  string_vector& operator = (const string_vector&) = default;
 
-  string_vector& operator = (string_vector&& s)
-  {
-    if (this != &s)
-      m_data = std::move (s.m_data);
-
-    return *this;
-  }
+  string_vector& operator = (string_vector&&) = default;
 
   ~string_vector (void) = default;