1//===- STLForwardCompat.h - Library features from future STLs ------C++ -*-===//
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//===----------------------------------------------------------------------===//
8//
9// This file contains library features backported from future STL versions.
10//
11// These should be replaced with their STL counterparts as the C++ version LLVM
12// is compiled with is updated.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_ADT_STLFORWARDCOMPAT_H
17#define LLVM_ADT_STLFORWARDCOMPAT_H
18
19#include <type_traits>
20
21namespace llvm {
22
23//===----------------------------------------------------------------------===//
24// Features from C++17
25//===----------------------------------------------------------------------===//
26
27template <typename T>
28struct negation // NOLINT(readability-identifier-naming)
29 : std::integral_constant<bool, !bool(T::value)> {};
30
31template <typename...>
32struct conjunction // NOLINT(readability-identifier-naming)
33 : std::true_type {};
34template <typename B1> struct conjunction<B1> : B1 {};
35template <typename B1, typename... Bn>
36struct conjunction<B1, Bn...>
37 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
38
39template <typename...>
40struct disjunction // NOLINT(readability-identifier-naming)
41 : std::false_type {};
42template <typename B1> struct disjunction<B1> : B1 {};
43template <typename B1, typename... Bn>
44struct disjunction<B1, Bn...>
45 : std::conditional<bool(B1::value), B1, disjunction<Bn...>>::type {};
46
47//===----------------------------------------------------------------------===//
48// Features from C++20
49//===----------------------------------------------------------------------===//
50
51template <typename T>
52struct remove_cvref // NOLINT(readability-identifier-naming)
53{
54 using type = std::remove_cv_t<std::remove_reference_t<T>>;
55};
56
57template <typename T>
58using remove_cvref_t // NOLINT(readability-identifier-naming)
59 = typename llvm::remove_cvref<T>::type;
60
61} // namespace llvm
62
63#endif // LLVM_ADT_STLFORWARDCOMPAT_H
64