diff --git a/deps/ox/src/ox/std/smallmap.hpp b/deps/ox/src/ox/std/smallmap.hpp index f2f20223..78502faf 100644 --- a/deps/ox/src/ox/std/smallmap.hpp +++ b/deps/ox/src/ox/std/smallmap.hpp @@ -17,7 +17,7 @@ namespace ox { -template +template class SmallMap { public: @@ -29,7 +29,7 @@ class SmallMap { K key = {}; T value{}; }; - using PairVector = Vector; + using PairVector = Vector; Vector m_keys; PairVector m_pairs; @@ -76,24 +76,24 @@ class SmallMap { }; -template -constexpr SmallMap::SmallMap(SmallMap const&other) { +template +constexpr SmallMap::SmallMap(SmallMap const&other) { m_pairs = other.m_pairs; } -template -constexpr SmallMap::SmallMap(SmallMap &&other) noexcept { +template +constexpr SmallMap::SmallMap(SmallMap &&other) noexcept { m_keys = std::move(other.m_keys); m_pairs = std::move(other.m_pairs); } -template -constexpr SmallMap::~SmallMap() { +template +constexpr SmallMap::~SmallMap() { clear(); } -template -constexpr bool SmallMap::operator==(SmallMap const&other) const { +template +constexpr bool SmallMap::operator==(SmallMap const&other) const { if (m_keys != other.m_keys) { return false; } @@ -106,8 +106,8 @@ constexpr bool SmallMap::operator==(SmallMap const&other) const { return true; } -template -constexpr SmallMap &SmallMap::operator=(SmallMap const&other) { +template +constexpr SmallMap &SmallMap::operator=(SmallMap const&other) { if (this != &other) { clear(); m_keys = other.m_keys; @@ -116,8 +116,8 @@ constexpr SmallMap &SmallMap::operator=(SmallMap const&other) return *this; } -template -constexpr SmallMap &SmallMap::operator=(SmallMap &&other) noexcept { +template +constexpr SmallMap &SmallMap::operator=(SmallMap &&other) noexcept { if (this != &other) { clear(); m_keys = std::move(other.m_keys); @@ -126,8 +126,8 @@ constexpr SmallMap &SmallMap::operator=(SmallMap &&other) noex return *this; } -template -constexpr T &SmallMap::operator[](MaybeView_t const&k) { +template +constexpr T &SmallMap::operator[](MaybeView_t const&k) { bool isNew{}; auto p = &access(m_pairs, k, isNew); if (isNew) { @@ -136,8 +136,8 @@ constexpr T &SmallMap::operator[](MaybeView_t const&k) { return p->value; } -template -constexpr Result SmallMap::at(MaybeView_t const&k) noexcept { +template +constexpr Result SmallMap::at(MaybeView_t const&k) noexcept { auto p = access(m_pairs, k); if (!p) { return {nullptr, OxError(1, "value not found for given key")}; @@ -145,8 +145,8 @@ constexpr Result SmallMap::at(MaybeView_t const&k) noexcept { return &p->value; } -template -constexpr Result SmallMap::at(MaybeView_t const&k) const noexcept { +template +constexpr Result SmallMap::at(MaybeView_t const&k) const noexcept { auto p = access(m_pairs, k); if (!p) { return {nullptr, OxError(1, "value not found for given key")}; @@ -154,8 +154,8 @@ constexpr Result SmallMap::at(MaybeView_t const&k) const noex return &p->value; } -template -constexpr void SmallMap::erase(MaybeView_t const&k) { +template +constexpr void SmallMap::erase(MaybeView_t const&k) { size_t i{}; for (auto const&p : m_pairs) { if (k == p.key) { @@ -167,29 +167,29 @@ constexpr void SmallMap::erase(MaybeView_t const&k) { std::ignore = m_keys.erase(i); } -template -constexpr bool SmallMap::contains(MaybeView_t const&k) const noexcept { +template +constexpr bool SmallMap::contains(MaybeView_t const&k) const noexcept { return access(m_pairs, k) != nullptr; } -template -constexpr std::size_t SmallMap::size() const noexcept { +template +constexpr std::size_t SmallMap::size() const noexcept { return m_keys.size(); } -template -constexpr Vector const&SmallMap::keys() const noexcept { +template +constexpr Vector const&SmallMap::keys() const noexcept { return m_keys; } -template -constexpr void SmallMap::clear() { +template +constexpr void SmallMap::clear() { m_pairs.clear(); } -template +template template -constexpr typename SmallMap::Pair const&SmallMap::access( +constexpr typename SmallMap::Pair const&SmallMap::access( PairVector const&pairs, KK const&k, bool &isNew) const { for (auto const&p : pairs) { if (p.key == k) { @@ -202,9 +202,9 @@ constexpr typename SmallMap::Pair const&SmallMap::access( return pairs.emplace_back(); } -template +template template -constexpr typename SmallMap::Pair &SmallMap::access( +constexpr typename SmallMap::Pair &SmallMap::access( PairVector &pairs, KK const&k, bool &isNew) { for (auto &p : pairs) { if (p.key == k) {