From 9f6b35d9cfd0db46841eebf5a128d3873e42ddf2 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Thu, 21 Nov 2024 10:07:32 -0700 Subject: [PATCH] :bug: Fix `size_t` handling in `lookup::input` Problem: - `lookup::input` takes an `auto` template parameter. - Platform-specific definitions of `std::size_t` make it awkward to ensure instantiations of `lookup::input` with the same size are in fact the same type. Solution: - fix the type of the `lookup::input` template parameter to `std::size_t` --- include/lookup/input.hpp | 2 +- test/lookup/input.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/lookup/input.hpp b/include/lookup/input.hpp index 050c1421..07f8458e 100644 --- a/include/lookup/input.hpp +++ b/include/lookup/input.hpp @@ -11,7 +11,7 @@ #include namespace lookup { -template struct input { +template struct input { using key_type = K; using value_type = V; diff --git a/test/lookup/input.cpp b/test/lookup/input.cpp index 4cc4a32f..36b4367d 100644 --- a/test/lookup/input.cpp +++ b/test/lookup/input.cpp @@ -9,22 +9,22 @@ TEST_CASE("an input with no entries (type deduced)", "[input]") { constexpr auto input = lookup::input{1}; CHECK(input.default_value == 1); static_assert( - std::is_same_v const>); - CHECK(std::size(input) == 0ul); + std::is_same_v const>); + CHECK(std::size(input) == 0); } TEST_CASE("an input with no entries (explicit types)", "[input]") { constexpr auto input = lookup::input{1}; CHECK(input.default_value == 1); static_assert( - std::is_same_v const>); - CHECK(std::size(input) == 0ul); + std::is_same_v const>); + CHECK(std::size(input) == 0); } TEST_CASE("an input with some entries (type deduced)", "[input]") { constexpr auto input = lookup::input(1, std::array{lookup::entry{1.0f, 2}}); CHECK(input.default_value == 1); static_assert( - std::is_same_v const>); - CHECK(std::size(input) == 1ul); + std::is_same_v const>); + CHECK(std::size(input) == 1); }