Skip to content

[libc++][format] Adds flat_(|multi)map formatter. #124418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

mordante
Copy link
Member

@mordante mordante commented Jan 25, 2025

These types should be formattable out-of-the-box. This patch validates that is true.

@mordante mordante requested a review from a team as a code owner January 25, 2025 16:40
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jan 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 25, 2025

@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)

Changes

This type should be formattable out-of-the-box. This patch validates that is true.


Full diff: https://github.com/llvm/llvm-project/pull/124418.diff

2 Files Affected:

  • (modified) libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp (+8)
  • (modified) libcxx/test/std/utilities/format/format.range/format.range.fmtmap/format.functions.tests.h (+4)
diff --git a/libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp b/libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
index 88a485a256c801..1f384fa48d2a47 100644
--- a/libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
@@ -24,6 +24,7 @@
 #include <concepts>
 #include <deque>
 #include <filesystem>
+#include <flat_map>
 #include <format>
 #include <forward_list>
 #include <list>
@@ -242,6 +243,13 @@ void test_P2286() {
   assert_is_formattable<std::multiset<int>, CharT>();
   assert_is_formattable<std::multimap<int, int>, CharT>();
 
+#if TEST_STD_VER >= 23
+  // assert_is_formattable<std::flat_set<int>, CharT>();
+  assert_is_formattable<std::flat_map<int, int>, CharT>();
+  // assert_is_formattable<std::flat_multiset<int>, CharT>();
+  // assert_is_formattable<std::flat_multimap<int, int>, CharT>();
+#endif // TEST_STD_VER >= 2
+
   assert_is_formattable<std::unordered_set<int>, CharT>();
   assert_is_formattable<std::unordered_map<int, int>, CharT>();
   assert_is_formattable<std::unordered_multiset<int>, CharT>();
diff --git a/libcxx/test/std/utilities/format/format.range/format.range.fmtmap/format.functions.tests.h b/libcxx/test/std/utilities/format/format.range/format.range.fmtmap/format.functions.tests.h
index fc638da9c840dc..c00288a1ecbd82 100644
--- a/libcxx/test/std/utilities/format/format.range/format.range.fmtmap/format.functions.tests.h
+++ b/libcxx/test/std/utilities/format/format.range/format.range.fmtmap/format.functions.tests.h
@@ -10,6 +10,7 @@
 #define TEST_STD_UTILITIES_FORMAT_FORMAT_RANGE_FORMAT_RANGE_FMTMAP_FORMAT_FUNCTIONS_TESTS_H
 
 #include <algorithm>
+#include <flat_map>
 #include <format>
 #include <map>
 #include <unordered_map>
@@ -442,6 +443,9 @@ void test_int(TestFunction check, ExceptionTest check_exception, auto&& input) {
 template <class CharT, class TestFunction, class ExceptionTest>
 void test_int(TestFunction check, ExceptionTest check_exception) {
   test_int<CharT>(check, check_exception, std::map<int, int>{{1, -1}, {42, -42}, {-42, 42}});
+#if TEST_STD_VER >= 23
+  test_int<CharT>(check, check_exception, std::flat_map<int, int>{{1, -1}, {42, -42}, {-42, 42}});
+#endif
 }
 
 //

These types should be formattable out-of-the-box. This patch validates
that is true.
@mordante mordante force-pushed the review/formatter_flat_map branch from 676989a to 764bc44 Compare January 25, 2025 19:53
@mordante mordante changed the title [libc++][format] Adds flat_map formatter. [libc++][format] Adds flat_(|multi)map formatter. Jan 25, 2025
@ldionne ldionne merged commit 3bf8e67 into llvm:main Jan 27, 2025
77 checks passed
@mordante mordante deleted the review/formatter_flat_map branch February 3, 2025 18:09
Quuxplusone added a commit to Quuxplusone/llvm-project that referenced this pull request Feb 18, 2025
Quuxplusone added a commit to Quuxplusone/llvm-project that referenced this pull request Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants