[libcxx-commits] [libcxx] [libc++] [test] Improve test coverage for containers' scary.pass.cpp (PR #131550)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 16 23:57:04 PDT 2025


================
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <flat_map>
+
+// class flat_map
+// class flat_multimap
+
+// Extension: SCARY/N2913 iterator compatibility between flat_map and flat_multimap
+
+#include <flat_map>
+
+#include "test_macros.h"
+
+void test() {
+  typedef std::flat_map<int, int> M1;
+  typedef std::flat_multimap<int, int> M2;
+
+  ASSERT_SAME_TYPE(M1::iterator, M2::iterator);
+  ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator);
----------------
frederick-vs-ja wrote:

These lines are currently wrong for libc++. It was intended that our `flat_(multi)map`'s iterators are _not_ SCARY, see #117445.

Perhaps it should be `static_assert`'d that these iterator types are different, and no implicit conversion, explicit construction, or assignment is possible between them.

CC @huixie90 @ldionne.

https://github.com/llvm/llvm-project/pull/131550


More information about the libcxx-commits mailing list