2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef SUPPORT_TEST_FORMAT_CONTEXT_HPP
11 #define SUPPORT_TEST_FORMAT_CONTEXT_HPP
14 * @file Helper functions to create a @ref std::basic_format_context.
16 * Since the standard doesn't specify how a @ref std::basic_format_context is
17 * constructed this is implementation defined. To make the public API tests of
18 * the class generic this header defines helper functions to create the
21 * @note This requires every standard library implementation to write their own
22 * helper function. Vendors are encouraged to file a review at
23 * https://reviews.llvm.org/ so their specific implementation can be part of
27 #include "test_macros.h"
30 #error "The format header requires at least C++20"
35 #ifndef TEST_HAS_NO_LOCALIZATION
39 #ifdef _LIBCPP_VERSION
41 /** Creates a std::basic_format_context as-if the formatting function takes no locale. */
42 template <class OutIt
, class CharT
>
43 std::basic_format_context
<OutIt
, CharT
> test_format_context_create(
45 std::basic_format_args
<std::basic_format_context
<OutIt
, CharT
>> args
) {
46 return std::__format_context_create(std::move(out_it
), args
);
49 # ifndef TEST_HAS_NO_LOCALIZATION
50 /** Creates a std::basic_format_context as-if the formatting function takes locale. */
51 template <class OutIt
, class CharT
>
52 std::basic_format_context
<OutIt
, CharT
> test_format_context_create(
54 std::basic_format_args
<std::basic_format_context
<OutIt
, CharT
>> args
,
56 return std::__format_context_create(std::move(out_it
), args
, std::move(loc
));
58 # endif // TEST_HAS_NO_LOCALIZATION
59 #else // _LIBCPP_VERSION
60 # error "Please create a vendor specific version of the test functions and file a review at https://reviews.llvm.org/"
61 #endif // _LIBCPP_VERSION
63 #endif // SUPPORT_TEST_FORMAT_CONTEXT_HPP