[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / libcxx / test / support / test_basic_format_arg.h
blobf51f6e97cbed0e2fa5bc5260f04daa5681602314
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 #include <concepts>
10 #include <format>
11 #include <utility>
13 #include "test_macros.h"
15 /// Returns whether the basic_format_arg contains a type T with the expected value.
16 template <class Context, class T>
17 bool test_basic_format_arg(std::basic_format_arg<Context> arg, T expected) {
18 auto visitor = [expected](auto a) {
19 if constexpr (std::same_as<decltype(a), T>)
20 return a == expected;
21 else
22 return false;
24 #if TEST_STD_VER >= 26 && defined(TEST_HAS_EXPLICIT_THIS_PARAMETER)
25 return arg.visit(std::move(visitor));
26 #else
27 return std::visit_format_arg(std::move(visitor), arg);
28 #endif