From 7f2e034e40d98a1577e16688bf3a20afd9e389b8 Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+liss-h@users.noreply.github.com> Date: Thu, 21 May 2026 13:27:12 +0200 Subject: [PATCH 1/2] Feature: ignore leak macro (#187) --- include/dice/template-library/macro_util.hpp | 12 ++++++++++++ tests/tests_macro_util.cpp | 12 +++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/dice/template-library/macro_util.hpp b/include/dice/template-library/macro_util.hpp index fe1a153..08f9aba 100644 --- a/include/dice/template-library/macro_util.hpp +++ b/include/dice/template-library/macro_util.hpp @@ -40,4 +40,16 @@ #define DICE_FILENAME __FILE__ #endif // __FILE_NAME__ + +#if defined(__has_include) && __has_include() && (defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer) || __has_feature(leak_sanitizer)) +#include +/** + * Tell the leak sanitizer to ignore that the given object is leaked. + */ +#define DICE_IGNORE_LEAK(ptr) __lsan_ignore_object(ptr) +#else +#define DICE_IGNORE_LEAK(ptr) +#endif + + #endif // DICE_TEMPLATELIBRARY_MACROUTIL_HPP diff --git a/tests/tests_macro_util.cpp b/tests/tests_macro_util.cpp index 3ff9487..9742125 100644 --- a/tests/tests_macro_util.cpp +++ b/tests/tests_macro_util.cpp @@ -13,4 +13,14 @@ TEST_SUITE("macro_util") { DICE_IDENT_CONCAT(hello_, MY_IDENT) = 12; CHECK_EQ(hello_world, 12); } -} \ No newline at end of file + + TEST_CASE("filename") { + std::string_view const f = DICE_FILENAME; + CHECK(f.ends_with("tests_macro_util.cpp")); + } + + TEST_CASE("ignore leak") { + auto *my_obj = new int{42}; + DICE_IGNORE_LEAK(my_obj); + } +} From 3d85a0ef5b8900ec850e1fe31dd29a07a672d9ea Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+liss-h@users.noreply.github.com> Date: Thu, 21 May 2026 13:29:49 +0200 Subject: [PATCH 2/2] version bump --- CMakeLists.txt | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1ea298..63d3772 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.24) project( dice-template-library - VERSION 2.5.0 + VERSION 2.6.0 DESCRIPTION "This template library is a collection of template-oriented code that we, the Data Science Group at UPB, found pretty handy. It contains: `switch_cases` (Use runtime values in compile-time context), `integral_template_tuple` (Create a tuple-like structure that instantiates a template for a range of values), `integral_template_variant` (A wrapper type for `std::variant` guarantees to only contain variants of the form `T` and `for_{types,values,range}` (Compile time for loops for types, values or ranges))." HOMEPAGE_URL "https://dice-research.org/") diff --git a/README.md b/README.md index 3b5a6f5..7e1d2cb 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,7 @@ A C++23 compatible compiler. Code was only tested on x86_64. ## Include it in your projects ### Conan You can use it with [conan](https://conan.io/). -To do so, you need to add `dice-template-library/2.5.0` to the `[requires]` section of your conan file. +To do so, you need to add `dice-template-library/2.6.0` to the `[requires]` section of your conan file. ## Build and Run Tests and Examples