Skip to content

Commit 676989a

Browse files
committed
[libc++][format] Adds flat_map formatter.
This type should be formattable out-of-the-box. This patch validates that is true.
1 parent 3b30f20 commit 676989a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <concepts>
2525
#include <deque>
2626
#include <filesystem>
27+
#include <flat_map>
2728
#include <format>
2829
#include <forward_list>
2930
#include <list>
@@ -242,6 +243,13 @@ void test_P2286() {
242243
assert_is_formattable<std::multiset<int>, CharT>();
243244
assert_is_formattable<std::multimap<int, int>, CharT>();
244245

246+
#if TEST_STD_VER >= 23
247+
// assert_is_formattable<std::flat_set<int>, CharT>();
248+
assert_is_formattable<std::flat_map<int, int>, CharT>();
249+
// assert_is_formattable<std::flat_multiset<int>, CharT>();
250+
// assert_is_formattable<std::flat_multimap<int, int>, CharT>();
251+
#endif // TEST_STD_VER >= 2
252+
245253
assert_is_formattable<std::unordered_set<int>, CharT>();
246254
assert_is_formattable<std::unordered_map<int, int>, CharT>();
247255
assert_is_formattable<std::unordered_multiset<int>, CharT>();

libcxx/test/std/utilities/format/format.range/format.range.fmtmap/format.functions.tests.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define TEST_STD_UTILITIES_FORMAT_FORMAT_RANGE_FORMAT_RANGE_FMTMAP_FORMAT_FUNCTIONS_TESTS_H
1111

1212
#include <algorithm>
13+
#include <flat_map>
1314
#include <format>
1415
#include <map>
1516
#include <unordered_map>
@@ -442,6 +443,9 @@ void test_int(TestFunction check, ExceptionTest check_exception, auto&& input) {
442443
template <class CharT, class TestFunction, class ExceptionTest>
443444
void test_int(TestFunction check, ExceptionTest check_exception) {
444445
test_int<CharT>(check, check_exception, std::map<int, int>{{1, -1}, {42, -42}, {-42, 42}});
446+
#if TEST_STD_VER >= 23
447+
test_int<CharT>(check, check_exception, std::flat_map<int, int>{{1, -1}, {42, -42}, {-42, 42}});
448+
#endif
445449
}
446450

447451
//

0 commit comments

Comments
 (0)