From c8e25987b87eeb8a00a5a8fdc72775bf2b35cded Mon Sep 17 00:00:00 2001 From: Mislav Bradac Date: Tue, 13 Jun 2017 12:41:56 +0200 Subject: [PATCH] Add asserts to placeholder Reviewers: buda Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D463 --- src/utils/placeholder.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/placeholder.hpp b/src/utils/placeholder.hpp index 1eb09c8a9..e7942dfe4 100644 --- a/src/utils/placeholder.hpp +++ b/src/utils/placeholder.hpp @@ -56,6 +56,7 @@ class Placeholder { * @param T& item reference to the item initialized in allocated memory */ void set(const T &item) { + debug_assert(!initialized, "Placeholder object already initialized"); new (data._M_addr()) T(item); initialized = true; } @@ -66,6 +67,7 @@ class Placeholder { * @param T&& rvalue reference to the item which is moved to allocated memory */ void set(T &&item) { + debug_assert(!initialized, "Placeholder object already initialized"); new (data._M_addr()) T(std::move(item)); initialized = true; } @@ -79,6 +81,7 @@ class Placeholder { */ template void emplace(Args &&... args) { + debug_assert(!initialized, "Placeholder object already initialized"); new (data._M_addr()) T(args...); initialized = true; }