WPILibC++ 2023.4.3-108-ge5452e3
STLForwardCompat.h
Go to the documentation of this file.
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/// \file
10/// This file contains library features backported from future STL versions.
11///
12/// These should be replaced with their STL counterparts as the C++ version LLVM
13/// is compiled with is updated.
14///
15//===----------------------------------------------------------------------===//
16
17#ifndef WPIUTIL_WPI_STLFORWARDCOMPAT_H
18#define WPIUTIL_WPI_STLFORWARDCOMPAT_H
19
20#include <type_traits>
21
22namespace wpi {
23
24//===----------------------------------------------------------------------===//
25// Features from C++17
26//===----------------------------------------------------------------------===//
27
28template <typename T>
29struct negation // NOLINT(readability-identifier-naming)
30 : std::integral_constant<bool, !bool(T::value)> {};
31
32template <typename...>
33struct conjunction // NOLINT(readability-identifier-naming)
34 : std::true_type {};
35template <typename B1> struct conjunction<B1> : B1 {};
36template <typename B1, typename... Bn>
37struct conjunction<B1, Bn...>
38 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
39
40template <typename...>
41struct disjunction // NOLINT(readability-identifier-naming)
42 : std::false_type {};
43template <typename B1> struct disjunction<B1> : B1 {};
44template <typename B1, typename... Bn>
45struct disjunction<B1, Bn...>
46 : std::conditional<bool(B1::value), B1, disjunction<Bn...>>::type {};
47
48struct in_place_t // NOLINT(readability-identifier-naming)
49{
50 explicit in_place_t() = default;
51};
52/// \warning This must not be odr-used, as it cannot be made \c inline in C++14.
53constexpr in_place_t in_place; // NOLINT(readability-identifier-naming)
54
55template <typename T>
56struct in_place_type_t // NOLINT(readability-identifier-naming)
57{
58 explicit in_place_type_t() = default;
59};
60
61template <std::size_t I>
62struct in_place_index_t // NOLINT(readability-identifier-naming)
63{
64 explicit in_place_index_t() = default;
65};
66
67//===----------------------------------------------------------------------===//
68// Features from C++20
69//===----------------------------------------------------------------------===//
70
71template <typename T>
72struct remove_cvref // NOLINT(readability-identifier-naming)
73{
74 using type = std::remove_cv_t<std::remove_reference_t<T>>;
75};
76
77template <typename T>
78using remove_cvref_t // NOLINT(readability-identifier-naming)
80
81} // namespace wpi
82
83#endif // WPIUTIL_WPI_STLFORWARDCOMPAT_H
type
Definition: core.h:575
Definition: AprilTagFieldLayout.h:18
constexpr in_place_t in_place
Definition: STLForwardCompat.h:53
typename wpi::remove_cvref< T >::type remove_cvref_t
Definition: STLForwardCompat.h:79
Definition: STLForwardCompat.h:35
Definition: STLForwardCompat.h:34
Definition: STLForwardCompat.h:43
Definition: STLForwardCompat.h:42
Definition: STLForwardCompat.h:63
in_place_index_t()=default
Definition: STLForwardCompat.h:49
in_place_t()=default
Definition: STLForwardCompat.h:57
in_place_type_t()=default
Definition: STLForwardCompat.h:30
Definition: STLForwardCompat.h:73
std::remove_cv_t< std::remove_reference_t< T > > type
Definition: STLForwardCompat.h:74