diff --git a/src/libslic3r/StaticMap.hpp b/src/libslic3r/StaticMap.hpp index 0ef6c840d3..84054dda32 100644 --- a/src/libslic3r/StaticMap.hpp +++ b/src/libslic3r/StaticMap.hpp @@ -258,8 +258,14 @@ public: // e.g.: auto map = make_staticmap({ {"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> -constexpr auto make_staticmap(const SMapEl (&arr) [N], Cmp cmp = {}) +template +constexpr auto make_staticmap(const SMapEl (&arr) [N]) +{ + return StaticMap{static_set_detail ::to_array(arr), DefaultCmp{}}; +} + +template +constexpr auto make_staticmap(const SMapEl (&arr) [N], Cmp cmp) { return StaticMap{static_set_detail ::to_array(arr), cmp}; } diff --git a/tests/libslic3r/CMakeLists.txt b/tests/libslic3r/CMakeLists.txt index fea6e8ac40..d10494461a 100644 --- a/tests/libslic3r/CMakeLists.txt +++ b/tests/libslic3r/CMakeLists.txt @@ -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) diff --git a/tests/libslic3r/test_static_map.cpp b/tests/libslic3r/test_static_map.cpp index 2ff5178f50..6722a30bfe 100644 --- a/tests/libslic3r/test_static_map.cpp +++ b/tests/libslic3r/test_static_map.cpp @@ -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); } }