diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h index 087d4bf289b878..20c07559eae448 100644 --- a/libcxx/include/__format/format_context.h +++ b/libcxx/include/__format/format_context.h @@ -131,6 +131,9 @@ class _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(_OutIt __out_it, basic_format_args __args) : __out_it_(std::move(__out_it)), __args_(__args) {} # endif + + basic_format_context(const basic_format_context&) = delete; + basic_format_context& operator=(const basic_format_context&) = delete; }; // A specialization for __retarget_buffer diff --git a/libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp index 40720105060f0d..83ece7da73ad30 100644 --- a/libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp +++ b/libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp @@ -112,19 +112,27 @@ void test() { #endif } +// The default constructor is suppressed by the deleted copy operations. +// The move operations are implicitly deleted due to the deleted copy operations. + // std::back_insert_iterator, copyable -static_assert(std::is_copy_constructible_v, char>>); -static_assert(std::is_copy_assignable_v, char>>); +static_assert( + !std::is_default_constructible_v, char>>); + +static_assert(!std::is_copy_constructible_v, char>>); +static_assert(!std::is_copy_assignable_v, char>>); -static_assert(std::is_move_constructible_v, char>>); -static_assert(std::is_move_assignable_v, char>>); +static_assert(!std::is_move_constructible_v, char>>); +static_assert(!std::is_move_assignable_v, char>>); // cpp20_output_iterator, move only +static_assert(!std::is_default_constructible_v, char>>); + static_assert(!std::is_copy_constructible_v, char>>); static_assert(!std::is_copy_assignable_v, char>>); -static_assert(std::is_move_constructible_v, char>>); -static_assert(std::is_move_assignable_v, char>>); +static_assert(!std::is_move_constructible_v, char>>); +static_assert(!std::is_move_assignable_v, char>>); int main(int, char**) { test>, char>(); diff --git a/libcxx/test/std/utilities/format/format.functions/bug_81590.compile.pass.cpp b/libcxx/test/std/utilities/format/format.functions/bug_81590.compile.pass.cpp index 127f6546ccbe71..5f248f88582d00 100644 --- a/libcxx/test/std/utilities/format/format.functions/bug_81590.compile.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/bug_81590.compile.pass.cpp @@ -25,7 +25,7 @@ struct X : std::variant { template <> struct std::formatter : std::formatter { - static constexpr auto format(const X& x, auto ctx) { + static constexpr auto format(const X& x, auto& ctx) { if (!x.p) return ctx.out(); auto m = [&](const X* t) { return std::format_to(ctx.out(), "{}", *t); };