[libcxx-commits] [libcxx] [libc++][format] LWG4106: `basic_format_args` should not be default-constructible (PR #97250)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 5 06:13:16 PDT 2024
https://github.com/frederick-vs-ja updated https://github.com/llvm/llvm-project/pull/97250
>From 80e556adc35758a1700f101908e7929f796294e8 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 1 Jul 2024 10:21:55 +0800
Subject: [PATCH 1/2] [libc++][format] Implement LWG4106
---
libcxx/include/__format/format_args.h | 2 --
.../format/format.arguments/format.args/ctor.pass.cpp | 9 ++-------
.../format/format.arguments/format.args/get.pass.cpp | 5 -----
3 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/libcxx/include/__format/format_args.h b/libcxx/include/__format/format_args.h
index a5fde36a298174..07923570f38930 100644
--- a/libcxx/include/__format/format_args.h
+++ b/libcxx/include/__format/format_args.h
@@ -28,8 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Context>
class _LIBCPP_TEMPLATE_VIS basic_format_args {
public:
- basic_format_args() noexcept = default;
-
template <class... _Args>
_LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept
: __size_(sizeof...(_Args)) {
diff --git a/libcxx/test/std/utilities/format/format.arguments/format.args/ctor.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.args/ctor.pass.cpp
index c0575c545bde31..bb542a8e63ecf6 100644
--- a/libcxx/test/std/utilities/format/format.arguments/format.args/ctor.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.arguments/format.args/ctor.pass.cpp
@@ -9,12 +9,12 @@
// <format>
-// basic_format_args() noexcept;
// template<class... Args>
// basic_format_args(const format-arg-store<Context, Args...>& store) noexcept;
#include <format>
#include <cassert>
+#include <type_traits>
#include "test_macros.h"
@@ -24,12 +24,7 @@ void test() {
char c = 'c';
nullptr_t p = nullptr;
using Context = std::basic_format_context<CharT*, CharT>;
- {
- ASSERT_NOEXCEPT(std::basic_format_args<Context>{});
-
- std::basic_format_args<Context> format_args{};
- assert(!format_args.get(0));
- }
+ static_assert(!std::is_default_constructible_v<std::basic_format_args<Context>>);
{
auto store = std::make_format_args<Context>(i);
ASSERT_NOEXCEPT(std::basic_format_args<Context>{store});
diff --git a/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp
index c590cebf48accd..af8d7eff6f6b8d 100644
--- a/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp
@@ -82,11 +82,6 @@ void test_string_view(From value) {
template <class CharT>
void test() {
using Context = std::basic_format_context<CharT*, CharT>;
- {
- const std::basic_format_args<Context> format_args{};
- ASSERT_NOEXCEPT(format_args.get(0));
- assert(!format_args.get(0));
- }
using char_type = typename Context::char_type;
std::basic_string<char_type> empty;
>From 3ee593e1f8a2b06cad6657edbe50e034c68d0965 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Fri, 5 Jul 2024 21:13:08 +0800
Subject: [PATCH 2/2] @mordante's review comments
Co-authored-by: Mark de Wever <zar-rpg at xs4all.nl>
---
.../utilities/format/format.arguments/format.args/get.pass.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp
index af8d7eff6f6b8d..1c12c063e98781 100644
--- a/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp
@@ -82,7 +82,6 @@ void test_string_view(From value) {
template <class CharT>
void test() {
using Context = std::basic_format_context<CharT*, CharT>;
-
using char_type = typename Context::char_type;
std::basic_string<char_type> empty;
std::basic_string<char_type> str = MAKE_STRING(char_type, "abc");
More information about the libcxx-commits
mailing list