Skip to content

Commit

Permalink
fix: change contains() return type from size_to to bool
Browse files Browse the repository at this point in the history
Also bumps version to 1.3.3
  • Loading branch information
martinus committed Sep 24, 2022
1 parent d0cc4f2 commit a3cee71
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12)
project("unordered_dense"
VERSION 1.3.2
VERSION 1.3.3
DESCRIPTION "A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion"
HOMEPAGE_URL "https://github.com/martinus/unordered_dense")

Expand Down
8 changes: 4 additions & 4 deletions include/ankerl/unordered_dense.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///////////////////////// ankerl::unordered_dense::{map, set} /////////////////////////

// A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion.
// Version 1.3.2
// Version 1.3.3
// https://github.com/martinus/unordered_dense
//
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
Expand Down Expand Up @@ -32,7 +32,7 @@
// see https://semver.org/spec/v2.0.0.html
#define ANKERL_UNORDERED_DENSE_VERSION_MAJOR 1 // NOLINT(cppcoreguidelines-macro-usage) incompatible API changes
#define ANKERL_UNORDERED_DENSE_VERSION_MINOR 3 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible functionality
#define ANKERL_UNORDERED_DENSE_VERSION_PATCH 2 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible bug fixes
#define ANKERL_UNORDERED_DENSE_VERSION_PATCH 3 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible bug fixes

// API versioning with inline namespace, see https://www.foonathan.net/2018/11/inline-namespaces/
#define ANKERL_UNORDERED_DENSE_VERSION_CONCAT1(major, minor, patch) v##major##_##minor##_##patch
Expand Down Expand Up @@ -1188,12 +1188,12 @@ class table {
return do_find(key);
}

auto contains(Key const& key) const -> size_t {
auto contains(Key const& key) const -> bool {
return find(key) != end();
}

template <class K, class H = Hash, class KE = KeyEqual, is_transparent<H, KE> = true>
auto contains(K const& key) const -> size_t {
auto contains(K const& key) const -> bool {
return find(key) != end();
}

Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#

project('unordered_dense', 'cpp',
version: '1.3.2',
version: '1.3.3',
license: 'MIT',
default_options : ['cpp_std=c++17', 'warning_level=3', 'werror=true'])

Expand Down
5 changes: 4 additions & 1 deletion test/unit/contains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
#include <cstdint> // for uint64_t

TEST_CASE("contains") {
auto map = ankerl::unordered_dense::map<uint64_t, uint64_t>();
using map_t = ankerl::unordered_dense::map<uint64_t, uint64_t>;
static_assert(std::is_same_v<bool, decltype(map_t{}.contains(1))>);

auto map = map_t();

REQUIRE(!map.contains(0));
REQUIRE(!map.contains(123));
Expand Down
6 changes: 3 additions & 3 deletions test/unit/namespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include <doctest.h>

static_assert(std::is_same_v<ankerl::unordered_dense::v1_3_2::map<int, int>, ankerl::unordered_dense::map<int, int>>);
static_assert(std::is_same_v<ankerl::unordered_dense::v1_3_2::hash<int>, ankerl::unordered_dense::hash<int>>);
static_assert(std::is_same_v<ankerl::unordered_dense::v1_3_3::map<int, int>, ankerl::unordered_dense::map<int, int>>);
static_assert(std::is_same_v<ankerl::unordered_dense::v1_3_3::hash<int>, ankerl::unordered_dense::hash<int>>);

TEST_CASE("version_namespace") {
auto map = ankerl::unordered_dense::v1_3_2::map<int, int>{};
auto map = ankerl::unordered_dense::v1_3_3::map<int, int>{};
REQUIRE(map.empty());
}

0 comments on commit a3cee71

Please sign in to comment.