[libcxx-commits] [PATCH] D137911: [libc++][format] Makes format_context copyable.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 21 10:37:14 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG36ce0c3b1e58: [libc++][format] Makes format_context copyable. (authored by Mordante).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137911/new/
https://reviews.llvm.org/D137911
Files:
libcxx/include/__format/format_context.h
libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp
Index: libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp
===================================================================
--- libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp
+++ libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp
@@ -28,23 +28,13 @@
#include "test_basic_format_arg.h"
#include "test_format_context.h"
+#include "test_iterators.h"
#include "make_string.h"
#include "platform_support.h" // locale name macros
#include "test_macros.h"
template <class OutIt, class CharT>
void test() {
- static_assert(
- !std::is_copy_constructible_v<std::basic_format_context<OutIt, CharT>>);
- static_assert(
- !std::is_copy_assignable_v<std::basic_format_context<OutIt, CharT>>);
- // The move operations are implicitly deleted due to the
- // deleted copy operations.
- static_assert(
- !std::is_move_constructible_v<std::basic_format_context<OutIt, CharT>>);
- static_assert(
- !std::is_move_assignable_v<std::basic_format_context<OutIt, CharT>>);
-
std::basic_string<CharT> string = MAKE_STRING(CharT, "string");
// The type of the object is an exposition only type. The temporary is needed
// to extend the lifetype of the object since args stores a pointer to the
@@ -118,6 +108,20 @@
#endif
}
+// std::back_insert_iterator<std::string>, copyable
+static_assert(std::is_copy_constructible_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
+static_assert(std::is_copy_assignable_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
+
+static_assert(std::is_move_constructible_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
+static_assert(std::is_move_assignable_v<std::basic_format_context<std::back_insert_iterator<std::string>, char>>);
+
+// cpp20_output_iterator, move only
+static_assert(!std::is_copy_constructible_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
+static_assert(!std::is_copy_assignable_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
+
+static_assert(std::is_move_constructible_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
+static_assert(std::is_move_assignable_v<std::basic_format_context<cpp20_output_iterator<int*>, char>>);
+
int main(int, char**) {
test<std::back_insert_iterator<std::basic_string<char>>, char>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
Index: libcxx/include/__format/format_context.h
===================================================================
--- libcxx/include/__format/format_context.h
+++ libcxx/include/__format/format_context.h
@@ -85,9 +85,6 @@
template <class _Tp>
using formatter_type = formatter<_Tp, _CharT>;
- basic_format_context(const basic_format_context&) = delete;
- basic_format_context& operator=(const basic_format_context&) = delete;
-
_LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context>
arg(size_t __id) const noexcept {
return __args_.get(__id);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137911.476945.patch
Type: text/x-patch
Size: 3082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221121/7440e533/attachment.bin>
More information about the libcxx-commits
mailing list