Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds ANKERL_UNORDERED_DENSE_DISABLE_PMR, bumps version #129

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 4.4.0
VERSION 4.5.0
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
21 changes: 10 additions & 11 deletions include/ankerl/unordered_dense.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
///////////////////////// ankerl::unordered_dense::{map, set} /////////////////////////

// A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion.
// Version 4.4.0
// Version 4.5.0
// https://github.com/martinus/unordered_dense
//
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2023 Martin Leitner-Ankerl <[email protected]>
// Copyright (c) 2022-2024 Martin Leitner-Ankerl <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -31,7 +31,7 @@

// see https://semver.org/spec/v2.0.0.html
#define ANKERL_UNORDERED_DENSE_VERSION_MAJOR 4 // NOLINT(cppcoreguidelines-macro-usage) incompatible API changes
#define ANKERL_UNORDERED_DENSE_VERSION_MINOR 4 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible functionality
#define ANKERL_UNORDERED_DENSE_VERSION_MINOR 5 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible functionality
#define ANKERL_UNORDERED_DENSE_VERSION_PATCH 0 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible bug fixes

// API versioning with inline namespace, see https://www.foonathan.net/2018/11/inline-namespaces/
Expand Down Expand Up @@ -98,7 +98,7 @@
# include <cstdlib> // for abort
# endif

# if defined(__has_include)
# if defined(__has_include) && !defined(ANKERL_UNORDERED_DENSE_DISABLE_PMR)
# if __has_include(<memory_resource>)
# define ANKERL_UNORDERED_DENSE_PMR std::pmr // NOLINT(cppcoreguidelines-macro-usage)
# include <memory_resource> // for polymorphic_allocator
Expand Down Expand Up @@ -271,17 +271,17 @@ inline void mum(uint64_t* a, uint64_t* b) {

ANKERL_UNORDERED_DENSE_EXPORT template <typename T, typename Enable = void>
struct hash {
auto operator()(T const& obj) const
noexcept(noexcept(std::declval<std::hash<T>>().operator()(std::declval<T const&>()))) -> uint64_t {
auto operator()(T const& obj) const noexcept(noexcept(std::declval<std::hash<T>>().operator()(std::declval<T const&>())))
-> uint64_t {
return std::hash<T>{}(obj);
}
};

template <typename T>
struct hash<T, typename std::hash<T>::is_avalanching> {
using is_avalanching = void;
auto operator()(T const& obj) const
noexcept(noexcept(std::declval<std::hash<T>>().operator()(std::declval<T const&>()))) -> uint64_t {
auto operator()(T const& obj) const noexcept(noexcept(std::declval<std::hash<T>>().operator()(std::declval<T const&>())))
-> uint64_t {
return std::hash<T>{}(obj);
}
};
Expand Down Expand Up @@ -1113,9 +1113,8 @@ class table : public std::conditional_t<is_map_v<T>, base_table_type_map<T>, bas
}

template <typename... Args>
auto do_place_element(dist_and_fingerprint_type dist_and_fingerprint,
value_idx_type bucket_idx,
Args&&... args) -> std::pair<iterator, bool> {
auto do_place_element(dist_and_fingerprint_type dist_and_fingerprint, value_idx_type bucket_idx, Args&&... args)
-> std::pair<iterator, bool> {

// emplace the new value. If that throws an exception, no harm done; index is still in a valid state
m_values.emplace_back(std::forward<Args>(args)...);
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: '4.4.0',
version: '4.5.0',
license: 'MIT',
default_options : [
'cpp_std=c++17',
Expand Down
3 changes: 3 additions & 0 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

cmd_and_dir = [
# needs honggfuzz installed
['env', 'CXX_LD=mold', 'CXX=ccache clang++', 'meson', 'setup', '--buildtype', 'debug', '-Dcpp_std=c++23', 'builddir/clang_cpp23_debug'],
['env', 'CXX_LD=mold', 'CXX=ccache g++', 'meson', 'setup', '--buildtype', 'debug', '-Dcpp_std=c++23', 'builddir/gcc_cpp23_debug'],

['env', 'CXX_LD=mold', 'CXX=ccache clang++', 'meson', 'setup', '--buildtype', 'debug', '-Dcpp_std=c++17', 'builddir/clang_cpp17_debug'],
['env', 'CXX_LD=mold', 'CXX=ccache clang++', 'meson', 'setup', '--buildtype', 'release', '-Dcpp_std=c++17', 'builddir/clang_cpp17_release'],
['env', 'CXX_LD=mold', 'CXX=ccache g++', 'meson', 'setup', '--buildtype', 'release', '-Dcpp_std=c++17', 'builddir/gcc_cpp17_release'],
Expand Down
16 changes: 12 additions & 4 deletions test/unit/ctors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ TEST_CASE_MAP("ctors_map", counter::obj, counter::obj) {
auto counts = counter();
INFO(counts);

{ auto m = map_t{}; }
{ auto m = map_t{0, alloc_t{}}; }
{ auto m = map_t{0, hash_t{}, alloc_t{}}; }
{ auto m = map_t{alloc_t{}}; }
{
auto m = map_t{};
}
{
auto m = map_t{0, alloc_t{}};
}
{
auto m = map_t{0, hash_t{}, alloc_t{}};
}
{
auto m = map_t{alloc_t{}};
}
REQUIRE(counts.dtor() == 0);

{
Expand Down
2 changes: 1 addition & 1 deletion test/unit/namespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <doctest.h>

namespace versioned_namespace = ankerl::unordered_dense::v4_4_0;
namespace versioned_namespace = ankerl::unordered_dense::v4_5_0;

static_assert(std::is_same_v<versioned_namespace::map<int, int>, ankerl::unordered_dense::map<int, int>>);
static_assert(std::is_same_v<versioned_namespace::hash<int>, ankerl::unordered_dense::hash<int>>);
Expand Down
4 changes: 3 additions & 1 deletion test/unit/pmr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ TEST_CASE_PMR_MAP("pmr", uint64_t, uint64_t) {

TEST_CASE_PMR_MAP("pmr_no_null", uint64_t, uint64_t) {
auto mr = no_null_memory_resource();
{ auto map = map_t(&mr); }
{
auto map = map_t(&mr);
}
{
auto map = map_t(&mr);
for (size_t i = 0; i < 1; ++i) {
Expand Down
8 changes: 6 additions & 2 deletions test/unit/windows_include.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ TEST_CASE("unordered_dense_with_windows_h") {
auto key = size_t{6};
map.erase(counter::obj(key, counts));
}
{ map = map_t{}; }
{
map = map_t{};
}
{
auto m = map_t{};
m.swap(map);
}
{ map.clear(); }
{
map.clear();
}
{
auto s = size_t{7};
map.rehash(s);
Expand Down
Loading