From a547336322430a5e0069b5679f1172e9a3f1fb4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Thu, 3 Sep 2026 13:27:56 +0200 Subject: [PATCH] Set default compare for iconst_map (#1560) This is consistent with (i)flat_map, and allows to just write iconst_map. Add tests, also fix iconst_set. --- include/etl/const_map.h | 2 +- include/etl/const_set.h | 2 +- test/test_const_map.cpp | 3 +++ test/test_const_multimap.cpp | 3 +++ test/test_const_multiset.cpp | 3 +++ test/test_const_set.cpp | 2 ++ test/test_flat_map.cpp | 2 ++ test/test_flat_multimap.cpp | 2 ++ test/test_flat_multiset.cpp | 2 ++ test/test_flat_set.cpp | 2 ++ 10 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/etl/const_map.h b/include/etl/const_map.h index 747cc5ed..6bcab37d 100644 --- a/include/etl/const_map.h +++ b/include/etl/const_map.h @@ -48,7 +48,7 @@ SOFTWARE. namespace etl { - template + template > class iconst_map { public: diff --git a/include/etl/const_set.h b/include/etl/const_set.h index e734de43..29841dba 100644 --- a/include/etl/const_set.h +++ b/include/etl/const_set.h @@ -48,7 +48,7 @@ SOFTWARE. namespace etl { - template + template > class iconst_set { public: diff --git a/test/test_const_map.cpp b/test/test_const_map.cpp index a3dc8f14..ee8b5aff 100644 --- a/test/test_const_map.cpp +++ b/test/test_const_map.cpp @@ -112,6 +112,9 @@ namespace using mapped_type = Data::mapped_type; using const_iterator = Data::const_iterator; + static_assert(etl::is_same, etl::iconst_map>>::value, + "default compare is not less"); + SUITE(test_const_map) { //************************************************************************* diff --git a/test/test_const_multimap.cpp b/test/test_const_multimap.cpp index 3e181311..02bd030e 100644 --- a/test/test_const_multimap.cpp +++ b/test/test_const_multimap.cpp @@ -111,6 +111,9 @@ namespace using mapped_type = Data::mapped_type; using const_iterator = Data::const_iterator; + static_assert(etl::is_same, etl::iconst_multimap>>::value, + "default compare is not less"); + SUITE(test_const_multimap) { //************************************************************************* diff --git a/test/test_const_multiset.cpp b/test/test_const_multiset.cpp index 62310317..8baf4198 100644 --- a/test/test_const_multiset.cpp +++ b/test/test_const_multiset.cpp @@ -114,6 +114,9 @@ namespace using key_type = Data::key_type; using const_iterator = Data::const_iterator; + static_assert(etl::is_same, etl::iconst_multiset>>::value, + "default compare is not less"); + SUITE(test_const_multiset) { //************************************************************************* diff --git a/test/test_const_set.cpp b/test/test_const_set.cpp index 47f78e0f..0383e852 100644 --- a/test/test_const_set.cpp +++ b/test/test_const_set.cpp @@ -112,6 +112,8 @@ namespace using key_type = Data::key_type; using const_iterator = Data::const_iterator; + static_assert(etl::is_same, etl::iconst_set>>::value, "default compare is not less"); + SUITE(test_const_set) { //************************************************************************* diff --git a/test/test_flat_map.cpp b/test/test_flat_map.cpp index ae9ddbdd..431c8980 100644 --- a/test/test_flat_map.cpp +++ b/test/test_flat_map.cpp @@ -211,6 +211,8 @@ namespace // return os; //} + static_assert(etl::is_same, etl::iflat_map>>::value, "default compare is not less"); + SUITE(test_flat_map) { NDC N0 = NDC("A"); diff --git a/test/test_flat_multimap.cpp b/test/test_flat_multimap.cpp index d1f3ccd9..01c1eba8 100644 --- a/test/test_flat_multimap.cpp +++ b/test/test_flat_multimap.cpp @@ -239,6 +239,8 @@ namespace return true; } + static_assert(etl::is_same, etl::iflat_multimap>>::value, "default compare is not less"); + SUITE(test_flat_multimap) { //************************************************************************* diff --git a/test/test_flat_multiset.cpp b/test/test_flat_multiset.cpp index 2d91748e..a0625d1a 100644 --- a/test/test_flat_multiset.cpp +++ b/test/test_flat_multiset.cpp @@ -241,6 +241,8 @@ namespace std::vector int_data; + static_assert(etl::is_same, etl::iflat_multiset>>::value, "default compare is not less"); + //************************************************************************* struct SetupFixture { diff --git a/test/test_flat_set.cpp b/test/test_flat_set.cpp index 7930c72d..f90fde74 100644 --- a/test/test_flat_set.cpp +++ b/test/test_flat_set.cpp @@ -261,6 +261,8 @@ namespace return (lhs.value < rhs.k.value); } + static_assert(etl::is_same, etl::iflat_set>>::value, "default compare is not less"); + //************************************************************************* struct SetupFixture {