
This implements the struct `__format_arg_store` and its dependencies: * the class basic_format_arg, * the class basic_format_args, * the class basic_format_context, * the function make_format_args, * the function wmake_format_args, * the function visit_format_arg, * several Standard required typedefs. The following parts will be implemented in a later patch: * the child class `basic_format_arg::handle`, * the function `basic_format_arg::basic_format_arg(const T* p)`. The following extension has been implemented: * the class basic_format_arg supports `__[u]int128_t` on platform where libc++ supports 128 bit integrals. Implements parts of: * P0645 Text Formatting Completes: * LWG3371 visit_format_arg and make_format_args are not hidden friends * LWG3542 basic_format_arg mishandles basic_string_view with custom traits Note https://mordante.github.io/blog/2021/06/05/format.html gives a bit more information about the goals and non-goals of this initial patch series. Reviewed By: #libc, ldionne, vitaut Differential Revision: https://reviews.llvm.org/D103357
25 lines
830 B
C++
25 lines
830 B
C++
//===----------------------------------------------------------------------===//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include <concepts>
|
|
#include <format>
|
|
|
|
#include "test_macros.h"
|
|
|
|
/// Returns whether the basic_format_arg contains a type T with the expected value.
|
|
template <class Context, class T>
|
|
bool test_basic_format_arg(std::basic_format_arg<Context> arg, T expected) {
|
|
return std::visit_format_arg(
|
|
[expected](auto a) {
|
|
if constexpr (std::same_as<decltype(a), T>)
|
|
return a == expected;
|
|
else
|
|
return false;
|
|
},
|
|
arg);
|
|
}
|