Ginkgo Generated from branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
std_extensions.hpp
1// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_BASE_STD_EXTENSIONS_HPP_
6#define GKO_PUBLIC_CORE_BASE_STD_EXTENSIONS_HPP_
7
8
9#include <exception>
10#include <functional>
11#include <memory>
12#include <type_traits>
13
14
15// This header provides implementations of useful utilities introduced into the
16// C++ standard after C++14 (e.g. C++17 and C++20).
17// For documentation about these utilities refer to the newer version of the
18// standard.
19
20
21namespace gko {
27namespace xstd {
28namespace detail {
29
30
31template <typename... Ts>
32struct make_void {
33 using type = void;
34};
35
36
37} // namespace detail
38
39
40// Added in C++17
41template <typename... Ts>
42using void_t = typename detail::make_void<Ts...>::type;
43
44
45// Disable deprecation warnings when using standard > C++14
46inline bool uncaught_exception() noexcept
47{
48// MSVC uses _MSVC_LANG as __cplusplus
49#if (defined(_MSVC_LANG) && _MSVC_LANG > 201402L) || __cplusplus > 201402L
50 return std::uncaught_exceptions() > 0;
51#else
52 return std::uncaught_exception();
53#endif
54}
55
56
57// Kept for backward compatibility.
58template <bool B, typename T = void>
59using enable_if_t = std::enable_if_t<B, T>;
60
61
62// Kept for backward compatibility.
63template <bool B, typename T, typename F>
64using conditional_t = std::conditional_t<B, T, F>;
65
66
67// Kept for backward compatibility.
68template <typename T>
69using decay_t = std::decay_t<T>;
70
71
72// Kept for backward compatibility.
73template <typename T>
74constexpr bool greater(const T&& lhs, const T&& rhs)
75{
76 return std::greater<void>()(lhs, rhs);
77}
78
79
80// Kept for backward compatibility.
81template <typename T>
82constexpr bool greater_equal(const T&& lhs, const T&& rhs)
83{
84 return std::greater_equal<void>()(lhs, rhs);
85}
86
87
88// Kept for backward compatibility.
89template <typename T>
90constexpr bool less(const T&& lhs, const T&& rhs)
91{
92 return std::less<void>()(lhs, rhs);
93}
94
95
96// Kept for backward compatibility.
97template <typename T>
98constexpr bool less_equal(const T&& lhs, const T&& rhs)
99{
100 return std::less_equal<void>()(lhs, rhs);
101}
102
103
104// available in <type_traits> with C++17
105template <class...>
106struct conjunction : std::true_type {};
107template <class B1>
108struct conjunction<B1> : B1 {};
109template <class B1, class... Bn>
110struct conjunction<B1, Bn...>
111 : std::conditional_t<bool(B1::value), conjunction<Bn...>, B1> {};
112
113
114} // namespace xstd
115} // namespace gko
116
117
118#endif // GKO_PUBLIC_CORE_BASE_STD_EXTENSIONS_HPP_
The Ginkgo namespace.
Definition abstract_factory.hpp:20
Definition std_extensions.hpp:106