From 96eb8471d11667a56466a6f701d1d23fa64c2225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 30 Jul 2020 22:12:54 +0200 Subject: Fix result of Head update Also make Ref conversion explicit and comparison operators explicitly deleted to avoid similar issues. --- include/erebos/storage.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'include/erebos/storage.h') diff --git a/include/erebos/storage.h b/include/erebos/storage.h index 57304e1..34ed9df 100644 --- a/include/erebos/storage.h +++ b/include/erebos/storage.h @@ -168,10 +168,13 @@ public: Ref & operator=(const Ref &) = default; Ref & operator=(Ref &&) = default; + bool operator==(const Ref &) = delete; + bool operator!=(const Ref &) = delete; + static std::optional create(Storage, const Digest &); static Ref zcreate(Storage); - constexpr operator bool() const { return true; } + explicit constexpr operator bool() const { return true; } const Object operator*() const; std::unique_ptr operator->() const; @@ -523,12 +526,12 @@ template std::optional> Head::update(const std::function(const Stored &)> & f) const { auto res = Storage::updateHead(T::headTypeId, mid, ref(), [&f, this](const Ref & r) { - return f(r == ref() ? stored() : Stored::load(r)).ref(); + return f(r.digest() == ref().digest() ? stored() : Stored::load(r)).ref(); }); if (!res) return std::nullopt; - if (*res == ref()) + if (res->digest() == ref().digest()) return *this; return Head(mid, *res); } -- cgit v1.2.3