[libcxx-commits] [libcxx] 8caa8d9 - [libc++][format] Addresses LWG3810.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 17 12:08:31 PST 2023


Author: Mark de Wever
Date: 2023-02-17T21:08:24+01:00
New Revision: 8caa8d95afe47db91d8a4e123ad2deac63d44754

URL: https://github.com/llvm/llvm-project/commit/8caa8d95afe47db91d8a4e123ad2deac63d44754
DIFF: https://github.com/llvm/llvm-project/commit/8caa8d95afe47db91d8a4e123ad2deac63d44754.diff

LOG: [libc++][format] Addresses LWG3810.

  LWG3810 CTAD for std::basic_format_args

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D144275

Added: 
    libcxx/test/std/utilities/format/format.arguments/format.args/ctad.compile.pass.cpp

Modified: 
    libcxx/docs/Status/Cxx2bIssues.csv
    libcxx/include/__format/format_args.h

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/Status/Cxx2bIssues.csv b/libcxx/docs/Status/Cxx2bIssues.csv
index 6162e72f4867b..f03e11875f197 100644
--- a/libcxx/docs/Status/Cxx2bIssues.csv
+++ b/libcxx/docs/Status/Cxx2bIssues.csv
@@ -286,7 +286,7 @@
 "`3772 <https://wg21.link/LWG3772>`__","``repeat_view``'s ``piecewise`` constructor is missing Postconditions","February 2023","","","|ranges|"
 "`3786 <https://wg21.link/LWG3786>`__","Flat maps' deduction guide needs to default ``Allocator`` to be useful","February 2023","","",""
 "`3803 <https://wg21.link/LWG3803>`__","``flat_foo`` constructors taking ``KeyContainer`` lack ``KeyCompare`` parameter","February 2023","","",""
-"`3810 <https://wg21.link/LWG3810>`__","CTAD for ``std::basic_format_args``","February 2023","","","|format|"
+"`3810 <https://wg21.link/LWG3810>`__","CTAD for ``std::basic_format_args``","February 2023","|Complete|","17.0","|format|"
 "`3827 <https://wg21.link/LWG3827>`__","Deprecate ``<stdalign.h>`` and ``<stdbool.h>`` macros","February 2023","","",""
 "`3828 <https://wg21.link/LWG3828>`__","Sync ``intmax_t`` and ``uintmax_t`` with C2x","February 2023","","",""
 "`3833 <https://wg21.link/LWG3833>`__","Remove specialization ``template<size_t N> struct formatter<const charT[N], charT>``","February 2023","","","|format|"

diff  --git a/libcxx/include/__format/format_args.h b/libcxx/include/__format/format_args.h
index 762ae4418ae2e..32f1de97c2d1c 100644
--- a/libcxx/include/__format/format_args.h
+++ b/libcxx/include/__format/format_args.h
@@ -71,7 +71,9 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args {
     const basic_format_arg<_Context>* __args_;
   };
 };
-_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_args);
+
+template <class _Context, class... _Args>
+basic_format_args(__format_arg_store<_Context, _Args...>) -> basic_format_args<_Context>;
 
 #endif //_LIBCPP_STD_VER >= 20
 

diff  --git a/libcxx/test/std/utilities/format/format.arguments/format.args/ctad.compile.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.args/ctad.compile.pass.cpp
new file mode 100644
index 0000000000000..b500b1ee7b1d5
--- /dev/null
+++ b/libcxx/test/std/utilities/format/format.arguments/format.args/ctad.compile.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-has-no-incomplete-format
+
+// <format>
+
+// template<class Context, class... Args>
+//   basic_format_args(format-arg-store<Context, Args...>) -> basic_format_args<Context>;
+
+#include <concepts>
+#include <format>
+
+#include "test_macros.h"
+
+void test() {
+  // Note the Standard way to create a format-arg-store is by using make_format_args.
+  static_assert(std::same_as<decltype(std::basic_format_args(std::make_format_args(42))),
+                             std::basic_format_args<std::format_context>>);
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  static_assert(std::same_as<decltype(std::basic_format_args(std::make_wformat_args(42))),
+                             std::basic_format_args<std::wformat_context>>);
+
+#endif
+}


        


More information about the libcxx-commits mailing list