[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / libcxx / test / support / test_format_string.h
blob49e94c7dbfc78f4253922f2b0ab869e5b5345e3f
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
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
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef SUPPORT_TEST_FORMAT_STRING_HPP
11 #define SUPPORT_TEST_FORMAT_STRING_HPP
13 #include <concepts>
14 #include <format>
15 #include <type_traits>
17 #include "test_macros.h"
19 #if TEST_STD_VER < 20
20 # error "The format header requires at least C++20"
21 #endif
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...>>;
36 # else
37 template <class CharT, class... Args>
38 using test_format_string = std::format_string<Args...>;
39 # endif
41 #else // TEST_STD_VER > 20 || defined(_LIBCPP_VERSION) || defined( _MSVC_STL_VERSION)
43 # error
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