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_STRING_HPP
11 #define SUPPORT_TEST_FORMAT_STRING_HPP
15 #include <type_traits>
17 #include "test_macros.h"
20 # error "The format header requires at least C++20"
23 // Wrapper for basic_format_string.
25 // This layer of indirection is used since it's not possible to use
26 // std::basic_format_string<CharT, Args...> in the test function directly.
28 // In C++20 the basic-format-string was an exposition only type. In C++23 is
29 // has been replaced with basic_format_string. Both libc++ and MSVC STL offer
30 // it as an extension in C++20.
31 #if TEST_STD_VER > 20 || defined(_LIBCPP_VERSION) || defined(_MSVC_STL_VERSION)
32 # ifndef TEST_HAS_NO_WIDE_CHARACTERS
33 template <class CharT
, class... Args
>
34 using test_format_string
=
35 std::conditional_t
<std::same_as
<CharT
, char>, std::format_string
<Args
...>, std::wformat_string
<Args
...>>;
37 template <class CharT
, class... Args
>
38 using test_format_string
= std::format_string
<Args
...>;
41 #else // TEST_STD_VER > 20 || defined(_LIBCPP_VERSION) || defined( _MSVC_STL_VERSION)
44 "Please create a vendor specific version of the test typedef and file a review at https://reviews.llvm.org/"
46 #endif // TEST_STD_VER > 20 || defined(_LIBCPP_VERSION) || defined( _MSVC_STL_VERSION)
48 #endif // SUPPORT_TEST_FORMAT_STRING_HPP