Revert "[libc] Breakup freelist_malloc into separate files" (#119749)
[llvm-project.git] / libcxx / test / std / utilities / format / format.formattable / concept.formattable.float.compile.pass.cpp
blobbddc36dad2b73f2c706c733d17ea8657f60e2fdd
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
11 // <format>
13 // template<class T, class charT>
14 // concept formattable = ...
16 #include <concepts>
17 #include <format>
19 #include "test_macros.h"
21 template <class T, class CharT>
22 void assert_is_not_formattable() {
23 static_assert(!std::formattable<T, CharT>);
26 template <class T, class CharT>
27 void assert_is_formattable() {
28 // Only formatters for CharT == char || CharT == wchar_t are enabled for the
29 // standard formatters. When CharT is a different type the formatter should
30 // be disabled.
31 if constexpr (std::same_as<CharT, char>
32 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
33 || std::same_as<CharT, wchar_t>
34 #endif
36 static_assert(std::formattable<T, CharT>);
37 else
38 assert_is_not_formattable<T, CharT>();
41 template <class CharT>
42 void test() {
43 assert_is_formattable<float, CharT>();
44 assert_is_formattable<double, CharT>();
45 assert_is_formattable<long double, CharT>();
48 void test() {
49 test<char>();
50 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
51 test<wchar_t>();
52 #endif
53 test<char8_t>();
54 test<char16_t>();
55 test<char32_t>();
57 test<int>();