[libc++][format] Addresses LWG3810.

LWG3810 CTAD for std::basic_format_args

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D144275
This commit is contained in:
Mark de Wever 2023-02-17 18:10:14 +01:00
parent 01afb3fb99
commit 8caa8d95af
3 changed files with 35 additions and 2 deletions

View File

@ -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|"

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -71,7 +71,9 @@ private:
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

View File

@ -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
}