[nest] Allow Ret value copy (#801)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Wed, 25 Jul 2018 23:17:21 +0000 (08:17 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 25 Jul 2018 23:17:21 +0000 (08:17 +0900)
This commit revises 'nest::Ret' class and 'nest::expr::Subscript' class
to make 'nest::Ret' values copy-assignable.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/nest/include/nest/Ret.h
contrib/nest/include/nest/expr/Subscript.h
contrib/nest/src/Ret.test.cpp

index 7abb003..75c0166 100644 (file)
@@ -20,8 +20,8 @@ public:
   const expr::Subscript &sub(void) const { return _sub; }
 
 private:
-  DomainID const _id;
-  expr::Subscript const _sub;
+  DomainID _id;
+  expr::Subscript _sub;
 };
 
 } // namespace nest
index 5e5a4c8..6f16b22 100644 (file)
@@ -28,7 +28,7 @@ public:
   const std::shared_ptr<expr::Node> &at(uint32_t n) const { return _indices.at(n); }
 
 private:
-  std::vector<std::shared_ptr<expr::Node>> const _indices;
+  std::vector<std::shared_ptr<expr::Node>> _indices;
 };
 
 } // namespace expr
index 11560e5..cd3c78d 100644 (file)
@@ -19,3 +19,24 @@ TEST(RET, ctor)
   ASSERT_EQ(ret.id().value(), 0);
   ASSERT_EQ(ret.sub().rank(), 1);
 }
+
+TEST(RET, copy)
+{
+  nest::DomainID src_id{0};
+  nest::expr::Subscript src_sub{std::make_shared<DummyNode>()};
+
+  const nest::Ret src{src_id, src_sub};
+
+  nest::DomainID dst_id{1};
+  nest::expr::Subscript dst_sub{std::make_shared<DummyNode>(), std::make_shared<DummyNode>()};
+
+  nest::Ret dst{dst_id, dst_sub};
+
+  ASSERT_EQ(dst.id().value(), 1);
+  ASSERT_EQ(dst.sub().rank(), 2);
+
+  dst = src;
+
+  ASSERT_EQ(dst.id().value(), 0);
+  ASSERT_EQ(dst.sub().rank(), 1);
+}