[libcxx-commits] [PATCH] D144277: [libc++][format] Addresses LWG3881.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Feb 17 11:10:26 PST 2023
Mordante updated this revision to Diff 498454.
Mordante added a comment.
CI fixes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144277/new/
https://reviews.llvm.org/D144277
Files:
libcxx/docs/Status/Cxx2bIssues.csv
libcxx/include/__format/container_adaptor.h
libcxx/test/std/containers/container.adaptors/container.adaptors.format/format.functions.tests.h
Index: libcxx/test/std/containers/container.adaptors/container.adaptors.format/format.functions.tests.h
===================================================================
--- libcxx/test/std/containers/container.adaptors/container.adaptors.format/format.functions.tests.h
+++ libcxx/test/std/containers/container.adaptors/container.adaptors.format/format.functions.tests.h
@@ -250,6 +250,14 @@
test_char_escaped_string<CharT>(
check, check_exception, std::priority_queue{input.begin(), input.end(), std::greater{}});
test_char_escaped_string<CharT>(check, check_exception, std::stack{input.begin(), input.end()});
+
+ // LWG3881 fixes formatting characters with a string as container.
+ test_char_default<CharT>(check, check_exception, std::queue{std::basic_string<CharT>{input.begin(), input.end()}});
+ test_char_default<CharT>(
+ check,
+ check_exception,
+ std::priority_queue{std::greater{}, std::basic_string<CharT>{input.begin(), input.end()}});
+ test_char_default<CharT>(check, check_exception, std::stack{std::basic_string<CharT>{input.begin(), input.end()}});
}
//
Index: libcxx/include/__format/container_adaptor.h
===================================================================
--- libcxx/include/__format/container_adaptor.h
+++ libcxx/include/__format/container_adaptor.h
@@ -19,6 +19,8 @@
#include <__format/concepts.h>
#include <__format/formatter.h>
#include <__format/range_default_formatter.h>
+#include <__ranges/all.h>
+#include <__ranges/ref_view.h>
#include <queue>
#include <stack>
@@ -35,8 +37,9 @@
template <class _Adaptor, class _CharT>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_container_adaptor {
private:
- using __maybe_const_adaptor = __fmt_maybe_const<_Adaptor, _CharT>;
- formatter<typename _Adaptor::container_type, _CharT> __underlying_;
+ using __maybe_const_container = __fmt_maybe_const<typename _Adaptor::container_type, _CharT>;
+ using __maybe_const_adaptor = __maybe_const<is_const_v<__maybe_const_container>, _Adaptor>;
+ formatter<ranges::ref_view<__maybe_const_container>, _CharT> __underlying_;
public:
template <class _ParseContext>
Index: libcxx/docs/Status/Cxx2bIssues.csv
===================================================================
--- libcxx/docs/Status/Cxx2bIssues.csv
+++ libcxx/docs/Status/Cxx2bIssues.csv
@@ -305,6 +305,6 @@
"`3878 <https://wg21.link/LWG3878>`__","import ``std;`` should guarantee initialization of standard iostreams objects","February 2023","","",""
"`3879 <https://wg21.link/LWG3879>`__","``erase_if`` for ``flat_{,multi}set`` is incorrectly specified","February 2023","","",""
"`3880 <https://wg21.link/LWG3880>`__","Clarify ``operator+=`` complexity for ``{chunk,stride}_view::iterator``","February 2023","","","|ranges|"
-"`3881 <https://wg21.link/LWG3881>`__","Incorrect formatting of container adapters backed by ``std::string``","February 2023","","","|format|"
+"`3881 <https://wg21.link/LWG3881>`__","Incorrect formatting of container adapters backed by ``std::string``","February 2023","|Complete|","17.0","|format|"
"","","","","",""
"`3343 <https://wg21.link/LWG3343>`__","Ordering of calls to ``unlock()`` and ``notify_all()`` in Effects element of ``notify_all_at_thread_exit()`` should be reversed","Not Yet Adopted","|Complete|","16.0",""
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144277.498454.patch
Type: text/x-patch
Size: 3334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230217/b9afe8d9/attachment.bin>
More information about the libcxx-commits
mailing list