Ginkgo  Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
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 
21 namespace gko {
27 namespace xstd {
28 namespace detail {
29 
30 
31 template <typename... Ts>
32 struct make_void {
33  using type = void;
34 };
35 
36 
37 } // namespace detail
38 
39 
40 // Added in C++17
41 template <typename... Ts>
42 using void_t = typename detail::make_void<Ts...>::type;
43 
44 
45 // Disable deprecation warnings when using standard > C++14
46 inline 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.
58 template <bool B, typename T = void>
59 using enable_if_t = std::enable_if_t<B, T>;
60 
61 
62 // Kept for backward compatibility.
63 template <bool B, typename T, typename F>
64 using conditional_t = std::conditional_t<B, T, F>;
65 
66 
67 // Kept for backward compatibility.
68 template <typename T>
69 using decay_t = std::decay_t<T>;
70 
71 
72 // Kept for backward compatibility.
73 template <typename T>
74 constexpr bool greater(const T&& lhs, const T&& rhs)
75 {
76  return std::greater<void>()(lhs, rhs);
77 }
78 
79 
80 // Kept for backward compatibility.
81 template <typename T>
82 constexpr 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.
89 template <typename T>
90 constexpr bool less(const T&& lhs, const T&& rhs)
91 {
92  return std::less<void>()(lhs, rhs);
93 }
94 
95 
96 // Kept for backward compatibility.
97 template <typename T>
98 constexpr 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
105 template <class...>
106 struct conjunction : std::true_type {};
107 template <class B1>
108 struct conjunction<B1> : B1 {};
109 template <class B1, class... Bn>
110 struct 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_
gko::xstd::conjunction
Definition: std_extensions.hpp:106
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::xstd::conjunction< B1 >
Definition: std_extensions.hpp:108