Skip to content

Commit 857a9ef

Browse files
[libc++][format] Implement LWG4061
Effectively reverts commit 36ce0c3.
1 parent 8598bcb commit 857a9ef

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

libcxx/include/__format/format_context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ class
131131
_LIBCPP_HIDE_FROM_ABI explicit basic_format_context(_OutIt __out_it, basic_format_args<basic_format_context> __args)
132132
: __out_it_(std::move(__out_it)), __args_(__args) {}
133133
# endif
134+
135+
basic_format_context(const basic_format_context&) = delete;
136+
basic_format_context& operator=(const basic_format_context&) = delete;
134137
};
135138

136139
// A specialization for __retarget_buffer

libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,27 @@ void test() {
112112
#endif
113113
}
114114

115+
// The default constructor is suppressed by the deleted copy operations.
116+
// The move operations are implicitly deleted due to the deleted copy operations.
117+
115118
// std::back_insert_iterator<std::string>, copyable
116-
static_assert(std::is_copy_constructible_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
117-
static_assert(std::is_copy_assignable_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
119+
static_assert(
120+
!std::is_default_constructible_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
121+
122+
static_assert(!std::is_copy_constructible_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
123+
static_assert(!std::is_copy_assignable_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
118124

119-
static_assert(std::is_move_constructible_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
120-
static_assert(std::is_move_assignable_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
125+
static_assert(!std::is_move_constructible_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
126+
static_assert(!std::is_move_assignable_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
121127

122128
// cpp20_output_iterator, move only
129+
static_assert(!std::is_default_constructible_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
130+
123131
static_assert(!std::is_copy_constructible_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
124132
static_assert(!std::is_copy_assignable_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
125133

126-
static_assert(std::is_move_constructible_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
127-
static_assert(std::is_move_assignable_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
134+
static_assert(!std::is_move_constructible_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
135+
static_assert(!std::is_move_assignable_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
128136

129137
int main(int, char**) {
130138
test<std::back_insert_iterator<std::basic_string<char>>, char>();

libcxx/test/std/utilities/format/format.functions/bug_81590.compile.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct X : std::variant<X*> {
2525

2626
template <>
2727
struct std::formatter<X, char> : std::formatter<std::string, char> {
28-
static constexpr auto format(const X& x, auto ctx) {
28+
static constexpr auto format(const X& x, auto& ctx) {
2929
if (!x.p)
3030
return ctx.out();
3131
auto m = [&](const X* t) { return std::format_to(ctx.out(), "{}", *t); };

0 commit comments

Comments
 (0)