Ginkgo Generated from branch based on master. Ginkgo version 1.7.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
std_extensions.hpp
1/*******************************<GINKGO LICENSE>******************************
2Copyright (c) 2017-2023, the Ginkgo authors
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions
7are met:
8
91. Redistributions of source code must retain the above copyright
10notice, this list of conditions and the following disclaimer.
11
122. Redistributions in binary form must reproduce the above copyright
13notice, this list of conditions and the following disclaimer in the
14documentation and/or other materials provided with the distribution.
15
163. Neither the name of the copyright holder nor the names of its
17contributors may be used to endorse or promote products derived from
18this software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31******************************<GINKGO LICENSE>*******************************/
32
33#ifndef GKO_PUBLIC_CORE_BASE_STD_EXTENSIONS_HPP_
34#define GKO_PUBLIC_CORE_BASE_STD_EXTENSIONS_HPP_
35
36
37#include <exception>
38#include <functional>
39#include <memory>
40#include <type_traits>
41
42
43// This header provides implementations of useful utilities introduced into the
44// C++ standard after C++14 (e.g. C++17 and C++20).
45// For documentation about these utilities refer to the newer version of the
46// standard.
47
48
49namespace gko {
55namespace xstd {
56namespace detail {
57
58
59template <typename... Ts>
60struct make_void {
61 using type = void;
62};
63
64
65} // namespace detail
66
67
68// Added in C++17
69template <typename... Ts>
70using void_t = typename detail::make_void<Ts...>::type;
71
72
73// Disable deprecation warnings when using standard > C++14
74inline bool uncaught_exception() noexcept
75{
76#if __cplusplus > 201402L
77 return std::uncaught_exceptions() > 0;
78#else
79 return std::uncaught_exception();
80#endif
81}
82
83
84// Kept for backward compatibility.
85template <bool B, typename T = void>
86using enable_if_t = std::enable_if_t<B, T>;
87
88
89// Kept for backward compatibility.
90template <bool B, typename T, typename F>
91using conditional_t = std::conditional_t<B, T, F>;
92
93
94// Kept for backward compatibility.
95template <typename T>
96using decay_t = std::decay_t<T>;
97
98
99// Kept for backward compatibility.
100template <typename T>
101constexpr bool greater(const T&& lhs, const T&& rhs)
102{
103 return std::greater<void>()(lhs, rhs);
104}
105
106
107// Kept for backward compatibility.
108template <typename T>
109constexpr bool greater_equal(const T&& lhs, const T&& rhs)
110{
111 return std::greater_equal<void>()(lhs, rhs);
112}
113
114
115// Kept for backward compatibility.
116template <typename T>
117constexpr bool less(const T&& lhs, const T&& rhs)
118{
119 return std::less<void>()(lhs, rhs);
120}
121
122
123// Kept for backward compatibility.
124template <typename T>
125constexpr bool less_equal(const T&& lhs, const T&& rhs)
126{
127 return std::less_equal<void>()(lhs, rhs);
128}
129
130
131// available in <type_traits> with C++17
132template <class...>
133struct conjunction : std::true_type {};
134template <class B1>
135struct conjunction<B1> : B1 {};
136template <class B1, class... Bn>
137struct conjunction<B1, Bn...>
138 : std::conditional_t<bool(B1::value), conjunction<Bn...>, B1> {};
139
140
141} // namespace xstd
142} // namespace gko
143
144
145#endif // GKO_PUBLIC_CORE_BASE_STD_EXTENSIONS_HPP_
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
Definition std_extensions.hpp:133