From 7e24bc494a2543656c79e2b3d80fb58f15e87d6f Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 5 Jul 2024 14:42:21 +0800 Subject: [PATCH] Implement LWG-4061 Should `std::basic_format_context` be default-constructible/copyable/movable? (#4758) --- stl/inc/format | 3 +++ tests/libcxx/expected_results.txt | 3 +++ .../P0645R10_text_formatting_custom_formatting/test.cpp | 9 +++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/stl/inc/format b/stl/inc/format index 0dceebb05..4b6c1441f 100644 --- a/stl/inc/format +++ b/stl/inc/format @@ -2208,6 +2208,9 @@ private: _Out&& _OutputIt_, const basic_format_args& _Ctx_args, const _Lazy_locale& _Loc_) : _OutputIt(_STD move(_OutputIt_)), _Args(_Ctx_args), _Loc(_Loc_) {} + basic_format_context(const basic_format_context&) = delete; + basic_format_context& operator=(const basic_format_context&) = delete; + public: using iterator = _Out; using char_type = _CharT; diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index d7b145919..ebd56bb13 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -168,6 +168,9 @@ std/utilities/memory/specialized.algorithms/uninitialized.move/ranges_uninitiali std/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer.value/ctor.default.pass.cpp FAIL std/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer.value/ctor.iter.pass.cpp FAIL +# libc++ doesn't implement LWG-4061 +std/utilities/format/format.functions/bug_81590.compile.pass.cpp FAIL + # If any feature-test macro test is failing, this consolidated test will also fail. std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp FAIL diff --git a/tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp b/tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp index 6a9db58b1..68e10a838 100644 --- a/tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp +++ b/tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp @@ -266,8 +266,13 @@ void test_basic_format_context_construction() { using context = basic_format_context; static_assert(!is_default_constructible_v); - static_assert(is_copy_constructible_v == is_copy_constructible_v); - static_assert(is_move_constructible_v); + static_assert(!is_copy_constructible_v); + static_assert(!is_move_constructible_v); + + // Also test the deleted copy assignment operator + // from LWG-4061 "Should std::basic_format_context be default-constructible/copyable/movable?" + static_assert(!is_copy_assignable_v); + static_assert(!is_move_assignable_v); static_assert(!is_constructible_v>); static_assert(!is_constructible_v&>);