Fix warnings generated for Index class (#8626)
authorSergei Barannikov/AI Tools Lab /SRR/Engineer/Samsung Electronics <s.barannikov@samsung.com>
Tue, 12 Nov 2019 05:26:23 +0000 (08:26 +0300)
committer이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Tue, 12 Nov 2019 05:26:23 +0000 (14:26 +0900)
* Fix the type of the parameter of the copy constructor of the `Index` class. This silences -Wdeprecated-copy GCC 8.1+ warnings.
* Make the copy constructor and copy assignment operator defaulted. This silences clang-tidy warnings suggesting to pass objects of `Index` class by const reference.
* Fix description of inequality operators.

Signed-off-by: Sergei Barannikov <s.barannikov@samsung.com>
runtime/neurun/core/include/util/Index.h

index d1fdc23..bd8eeb3 100644 (file)
@@ -49,13 +49,13 @@ public:
    *
    * @param o Value in the underlying type
    */
-  explicit Index(T o) : _index{o} {}
+  explicit Index(const T o) : _index{o} {}
   /**
    * @brief Copy Constructor
    *
    * @param o Object to be copied
    */
-  Index(const Index &o) : _index{o._index} {}
+  Index(const Index &o) = default;
 
   /**
    * @brief Assign a value in the underlying time
@@ -63,7 +63,7 @@ public:
    * @param o Value in the underlying type
    * @return Index& Reference of this pointer
    */
-  Index &operator=(T o)
+  Index &operator=(const T o)
   {
     _index = o;
     return *this;
@@ -75,11 +75,7 @@ public:
    * @param o Object to be copied
    * @return Index& Reference of this pointer
    */
-  Index &operator=(const T &o)
-  {
-    _index = o._index;
-    return *this;
-  }
+  Index &operator=(const Index &o) = default;
 
   /**
    * @brief Equality operator
@@ -99,14 +95,14 @@ public:
    * @brief Inquality operator
    *
    * @param o The other value in the underlying type to compare
-   * @return true if underlying value is the same, false otherwise
+   * @return true if underlying value is different, false otherwise
    */
   bool operator!=(T o) const { return !(*this == o); }
   /**
    * @brief Inquality operator
    *
    * @param o The other object to compare
-   * @return true if underlying value is the same, false otherwise
+   * @return true if underlying value is different, false otherwise
    */
   bool operator!=(const Index &o) const { return !(*this == o); }