brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 2efc704 Raw
49 lines · c
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef SUPPORT_TEST_FORMAT_STRING_HPP11#define SUPPORT_TEST_FORMAT_STRING_HPP12 13#include <concepts>14#include <format>15#include <type_traits>16 17#include "test_macros.h"18 19#if TEST_STD_VER < 2020#  error "The format header requires at least C++20"21#endif22 23// Wrapper for basic_format_string.24//25// This layer of indirection is used since it's not possible to use26// std::basic_format_string<CharT, Args...> in the test function directly.27//28// In C++20 the basic-format-string was an exposition only type. In C++23 is29// has been replaced with basic_format_string. Both libc++ and MSVC STL offer30// 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_CHARACTERS33template <class CharT, class... Args>34using test_format_string =35    std::conditional_t<std::same_as<CharT, char>, std::format_string<Args...>, std::wformat_string<Args...>>;36#  else37template <class CharT, class... Args>38using test_format_string = std::format_string<Args...>;39#  endif40 41#else // TEST_STD_VER > 20 || defined(_LIBCPP_VERSION) || defined( _MSVC_STL_VERSION)42 43#  error                                                                                                               \44      "Please create a vendor specific version of the test typedef and file a PR at https://github.com/llvm/llvm-project"45 46#endif // TEST_STD_VER > 20 || defined(_LIBCPP_VERSION) || defined( _MSVC_STL_VERSION)47 48#endif // SUPPORT_TEST_FORMAT_STRING_HPP49