From: 이한종/동작제어Lab(SR)/Engineer/삼성전자 Date: Thu, 26 Jul 2018 08:30:56 +0000 (+0900) Subject: [coco] Add a static_assert for type of Child (#830) X-Git-Tag: nncc_backup~2295 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=23455639da3559a72b48ca3b967f60b90f27e264;p=platform%2Fcore%2Fml%2Fnnfw.git [coco] Add a static_assert for type of Child (#830) This commit limits the type of template parameter `Child` to be subclass of `DLinkedList::Node`. Signed-off-by: Hanjoung Lee --- diff --git a/contrib/coco/core/include/coco/ADT/DLinkedList.h b/contrib/coco/core/include/coco/ADT/DLinkedList.h index ea46633..d2af781 100644 --- a/contrib/coco/core/include/coco/ADT/DLinkedList.h +++ b/contrib/coco/core/include/coco/ADT/DLinkedList.h @@ -4,6 +4,7 @@ #include "coco/ADT/PtrLink.h" #include +#include namespace coco { @@ -134,6 +135,8 @@ template struct DLinkedList public: Node(const PtrLink *link) : _link{link} { + static_assert(std::is_base_of::value, "Type `Child` must be subclass of `Node`."); + _prev = nullptr; _next = nullptr; } @@ -160,7 +163,6 @@ template struct DLinkedList assert(_prev == nullptr); assert(_next == nullptr); - // REQUIRE Child should inheir Node class auto curr = reinterpret_cast(this); // Update the link of the current node @@ -188,7 +190,6 @@ template struct DLinkedList assert(_prev == nullptr); assert(_next == nullptr); - // REQUIRE Child should inherit Node class auto curr = reinterpret_cast(this); // Update the link of the current node @@ -211,7 +212,6 @@ template struct DLinkedList public: void detach(void) { - // REQUIRE Child SHOULD inherit Node class auto curr = reinterpret_cast(this); // Update parent-child relation