DPC++ Runtime
Runtime libraries for oneAPI DPC++
functional.hpp
Go to the documentation of this file.
1 //==----------- functional.hpp --- SYCL functional -------------------------==//
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 #pragma once
10 
12 
13 #include <functional>
14 
15 namespace sycl {
17 
18 template <typename T = void> using plus = std::plus<T>;
19 template <typename T = void> using multiplies = std::multiplies<T>;
20 template <typename T = void> using bit_and = std::bit_and<T>;
21 template <typename T = void> using bit_or = std::bit_or<T>;
22 template <typename T = void> using bit_xor = std::bit_xor<T>;
23 template <typename T = void> using logical_and = std::logical_and<T>;
24 template <typename T = void> using logical_or = std::logical_or<T>;
25 
26 template <typename T = void> struct minimum {
27  T operator()(const T &lhs, const T &rhs) const {
28  return std::less<T>()(lhs, rhs) ? lhs : rhs;
29  }
30 };
31 
32 template <> struct minimum<void> {
33  struct is_transparent {};
34  template <typename T, typename U>
35  auto operator()(T &&lhs, U &&rhs) const ->
36  typename std::common_type<T &&, U &&>::type {
37  return std::less<>()(std::forward<const T>(lhs), std::forward<const U>(rhs))
38  ? std::forward<T>(lhs)
39  : std::forward<U>(rhs);
40  }
41 };
42 
43 template <typename T = void> struct maximum {
44  T operator()(const T &lhs, const T &rhs) const {
45  return std::greater<T>()(lhs, rhs) ? lhs : rhs;
46  }
47 };
48 
49 template <> struct maximum<void> {
50  struct is_transparent {};
51  template <typename T, typename U>
52  auto operator()(T &&lhs, U &&rhs) const ->
53  typename std::common_type<T &&, U &&>::type {
54  return std::greater<>()(std::forward<const T>(lhs),
55  std::forward<const U>(rhs))
56  ? std::forward<T>(lhs)
57  : std::forward<U>(rhs);
58  }
59 };
60 
61 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
62 } // namespace sycl
sycl::_V1::logical_or
std::logical_or< T > logical_or
Definition: functional.hpp:24
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:11
sycl::_V1::minimum
Definition: functional.hpp:26
sycl::_V1::maximum
Definition: functional.hpp:43
sycl::_V1::bit_and
std::bit_and< T > bit_and
Definition: functional.hpp:20
sycl::_V1::multiplies
std::multiplies< T > multiplies
Definition: functional.hpp:19
sycl::_V1::logical_and
std::logical_and< T > logical_and
Definition: functional.hpp:23
sycl::_V1::bit_or
std::bit_or< T > bit_or
Definition: functional.hpp:21
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
defines_elementary.hpp
sycl::_V1::bit_xor
std::bit_xor< T > bit_xor
Definition: functional.hpp:22
sycl::_V1::minimum< void >::operator()
auto operator()(T &&lhs, U &&rhs) const -> typename std::common_type< T &&, U && >::type
Definition: functional.hpp:35
sycl::_V1::maximum::operator()
T operator()(const T &lhs, const T &rhs) const
Definition: functional.hpp:44
sycl::_V1::plus
std::plus< T > plus
Definition: functional.hpp:18
sycl::_V1::minimum::operator()
T operator()(const T &lhs, const T &rhs) const
Definition: functional.hpp:27
sycl::_V1::maximum< void >::operator()
auto operator()(T &&lhs, U &&rhs) const -> typename std::common_type< T &&, U && >::type
Definition: functional.hpp:52