diff --git a/CMakeLists.txt b/CMakeLists.txt index 05600436..035b13e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.12) project("unordered_dense" - VERSION 2.0.1 + VERSION 2.0.2 DESCRIPTION "A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion" HOMEPAGE_URL "https://github.com/martinus/unordered_dense") diff --git a/include/ankerl/unordered_dense.h b/include/ankerl/unordered_dense.h index 737d12bf..64c2e930 100644 --- a/include/ankerl/unordered_dense.h +++ b/include/ankerl/unordered_dense.h @@ -1,7 +1,7 @@ ///////////////////////// ankerl::unordered_dense::{map, set} ///////////////////////// // A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion. -// Version 2.0.1 +// Version 2.0.2 // https://github.com/martinus/unordered_dense // // Licensed under the MIT License . @@ -32,7 +32,7 @@ // see https://semver.org/spec/v2.0.0.html #define ANKERL_UNORDERED_DENSE_VERSION_MAJOR 2 // NOLINT(cppcoreguidelines-macro-usage) incompatible API changes #define ANKERL_UNORDERED_DENSE_VERSION_MINOR 0 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible functionality -#define ANKERL_UNORDERED_DENSE_VERSION_PATCH 1 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible bug fixes +#define ANKERL_UNORDERED_DENSE_VERSION_PATCH 2 // 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 @@ -380,6 +380,15 @@ constexpr bool is_neither_convertible_v = !std::is_convertible_v && ! template constexpr bool has_reserve = is_detected_v; +// base type for map has mapped_type +template +struct base_table_type_map { + using mapped_type = T; +}; + +// base type for set doesn't have mapped_type +struct base_table_type_set {}; + // This is it, the table. Doubles as map and set, and uses `void` for T when its used as a set. template -class table { +class table : public std::conditional_t, base_table_type_set, base_table_type_map> { public: using value_container_type = std::conditional_t< is_detected_v, @@ -404,7 +413,6 @@ class table { public: using key_type = Key; - using mapped_type = T; using value_type = typename value_container_type::value_type; using size_type = typename value_container_type::size_type; using difference_type = typename value_container_type::difference_type; diff --git a/meson.build b/meson.build index 936cf00a..9821d815 100644 --- a/meson.build +++ b/meson.build @@ -18,7 +18,7 @@ # project('unordered_dense', 'cpp', - version: '2.0.1', + version: '2.0.2', license: 'MIT', default_options : ['cpp_std=c++17', 'warning_level=3', 'werror=true']) diff --git a/test/meson.build b/test/meson.build index 9528cffb..2096c7eb 100644 --- a/test/meson.build +++ b/test/meson.build @@ -63,6 +63,7 @@ test_sources = [ 'unit/replace.cpp', 'unit/reserve_and_assign.cpp', 'unit/reserve.cpp', + 'unit/set_or_map_types.cpp', 'unit/set.cpp', 'unit/std_hash.cpp', 'unit/swap.cpp', diff --git a/test/unit/namespace.cpp b/test/unit/namespace.cpp index c0c069c0..b5db1bc0 100644 --- a/test/unit/namespace.cpp +++ b/test/unit/namespace.cpp @@ -2,10 +2,10 @@ #include -static_assert(std::is_same_v, ankerl::unordered_dense::map>); -static_assert(std::is_same_v, ankerl::unordered_dense::hash>); +static_assert(std::is_same_v, ankerl::unordered_dense::map>); +static_assert(std::is_same_v, ankerl::unordered_dense::hash>); TEST_CASE("version_namespace") { - auto map = ankerl::unordered_dense::v2_0_1::map{}; + auto map = ankerl::unordered_dense::v2_0_2::map{}; REQUIRE(map.empty()); } diff --git a/test/unit/set_or_map_types.cpp b/test/unit/set_or_map_types.cpp new file mode 100644 index 00000000..b7cddb9c --- /dev/null +++ b/test/unit/set_or_map_types.cpp @@ -0,0 +1,11 @@ +#include + +template +using detect_has_mapped_type = typename T::mapped_type; + +using map_t = ankerl::unordered_dense::map; +static_assert(std::is_same_v); +static_assert(ankerl::unordered_dense::detail::is_detected_v); + +using set_t = ankerl::unordered_dense::set; +static_assert(!ankerl::unordered_dense::detail::is_detected_v);