Merge branch 'tm_fix_static_map_build'

This commit is contained in:
tamasmeszaros 2023-10-02 12:48:50 +02:00
commit f83abb09dc
3 changed files with 10 additions and 4 deletions

View File

@ -258,8 +258,14 @@ public:
// e.g.: auto map = make_staticmap<const char*, int>({ {"one", 1}, {"two", 2}})
// will work, and only the key and value type needs to be specified. No need
// to state the number of elements, that is deduced automatically.
template<class K, class V, size_t N, class Cmp = DefaultCmp<K, V>>
constexpr auto make_staticmap(const SMapEl<K, V> (&arr) [N], Cmp cmp = {})
template<class K, class V, size_t N>
constexpr auto make_staticmap(const SMapEl<K, V> (&arr) [N])
{
return StaticMap<K, V, N>{static_set_detail ::to_array(arr), DefaultCmp<K, V>{}};
}
template<class K, class V, size_t N, class Cmp>
constexpr auto make_staticmap(const SMapEl<K, V> (&arr) [N], Cmp cmp)
{
return StaticMap<K, V, N, Cmp>{static_set_detail ::to_array(arr), cmp};
}

View File

@ -42,7 +42,7 @@ add_executable(${_TEST_NAME}_tests
test_support_spots_generator.cpp
../data/prusaparts.cpp
../data/prusaparts.hpp
# test_static_map.cpp
test_static_map.cpp
)
if (TARGET OpenVDB::openvdb)

View File

@ -61,7 +61,7 @@ TEST_CASE("StaticMap should derive it's type using make_staticmap", "[StaticMap]
for (auto &[k, v] : ciManyMap) {
auto val = query(ciManyMap, k);
REQUIRE(val.has_value());
REQUIRE(val.value() == v);
REQUIRE(*val == v);
}
}