Blender V4.3
BLI_generic_key.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11#include <memory>
12
13#include "BLI_utildefines.h"
14
15namespace blender {
16
26 public:
27 virtual ~GenericKey() = default;
28
30 virtual uint64_t hash() const = 0;
31
36 virtual bool equal_to(const GenericKey &other) const = 0;
37
43 virtual std::unique_ptr<GenericKey> to_storable() const = 0;
44
45 friend bool operator==(const GenericKey &a, const GenericKey &b)
46 {
47 const bool are_equal = a.equal_to(b);
48 /* Ensure that equality check is symmetric. */
49 BLI_assert(are_equal == b.equal_to(a));
50 return are_equal;
51 }
52
53 friend bool operator!=(const GenericKey &a, const GenericKey &b)
54 {
55 return !(a == b);
56 }
57};
58
59} // namespace blender
#define BLI_assert(a)
Definition BLI_assert.h:50
virtual uint64_t hash() const =0
virtual std::unique_ptr< GenericKey > to_storable() const =0
friend bool operator==(const GenericKey &a, const GenericKey &b)
virtual bool equal_to(const GenericKey &other) const =0
virtual ~GenericKey()=default
friend bool operator!=(const GenericKey &a, const GenericKey &b)
local_group_size(16, 16) .push_constant(Type b
unsigned __int64 uint64_t
Definition stdint.h:90