diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2020-07-30 22:12:54 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2020-07-30 22:12:54 +0200 |
commit | 96eb8471d11667a56466a6f701d1d23fa64c2225 (patch) | |
tree | 57dee15821f849be71cb07e97cd925c85d3909c7 | |
parent | d785003e9979068acc40a679f6470bd28f38fa01 (diff) |
Fix result of Head update
Also make Ref conversion explicit and comparison operators explicitly
deleted to avoid similar issues.
-rw-r--r-- | include/erebos/storage.h | 9 |
1 files changed, 6 insertions, 3 deletions
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<Ref> 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<Object> operator->() const; @@ -523,12 +526,12 @@ template<typename T> std::optional<Head<T>> Head<T>::update(const std::function<Stored<T>(const Stored<T> &)> & f) const { auto res = Storage::updateHead(T::headTypeId, mid, ref(), [&f, this](const Ref & r) { - return f(r == ref() ? stored() : Stored<T>::load(r)).ref(); + return f(r.digest() == ref().digest() ? stored() : Stored<T>::load(r)).ref(); }); if (!res) return std::nullopt; - if (*res == ref()) + if (res->digest() == ref().digest()) return *this; return Head<T>(mid, *res); } |