kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
properties.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_IMPL_PROPERTIES_HPP
2
#define KOKKOS_EXECUTION_IMPL_PROPERTIES_HPP
3
4
#include "
kokkos-execution/stdexec.hpp
"
5
6
#include "Kokkos_Macros.hpp"
7
#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
8
import
kokkos.core;
9
#else
10
# include "Kokkos_Core.hpp"
11
#endif
12
32
33
namespace
Kokkos::Execution::Impl
{
34
36
template
<
typename
... Properties>
37
struct
properties
{ };
38
39
namespace
detail
{
40
41
template
<
template
<
typename
...>
typename
T,
typename
... Args>
42
consteval
void
deduce_from_base
(
const
T<Args...>&);
43
44
template
<
template
<
typename
...>
typename
T,
typename
... Args>
45
constexpr
T<Args...>&
as_base
(T<Args...>& base)
noexcept
{
46
return
base;
47
}
48
49
template
<
template
<
typename
...>
typename
T,
typename
... Args>
50
constexpr
const
T<Args...>&
as_base
(
const
T<Args...>& base)
noexcept
{
51
return
base;
52
}
53
54
template
<
typename
Property,
typename
Data>
55
constexpr
Property&
as_base
(Data& data)
noexcept
{
56
return
data;
57
}
58
59
template
<
typename
Property,
typename
Data>
60
constexpr
const
Property&
as_base
(
const
Data& data)
noexcept
{
61
return
data;
62
}
63
64
}
// namespace detail
65
67
template
<
typename
Data,
typename
Property>
68
consteval
bool
has_property
() {
69
return
std::derived_from<Data, Property>;
70
}
71
73
template
<
typename
Data,
template
<
typename
...>
typename
Property>
74
consteval
bool
has_property
() {
75
return
requires
(
const
Data& data) {
detail::deduce_from_base<Property>
(data); };
76
}
77
78
template
<
typename
Property,
typename
Data>
79
requires
(
has_property<std::remove_cvref_t<Data>
, Property>())
80
constexpr
decltype
(
auto
)
get_property
(Data&& data)
noexcept
{
// NOLINT(cppcoreguidelines-missing-std-forward)
81
return
stdexec::__forward_like<Data>(
detail::as_base<Property>
(data).m_value);
82
}
83
84
template
<
template
<
typename
...>
typename
Property,
typename
Data>
85
requires
(
has_property<std::remove_cvref_t<Data>
, Property>())
86
constexpr
decltype
(
auto
)
get_property
(Data&& data)
noexcept
{
// NOLINT(cppcoreguidelines-missing-std-forward)
87
return
stdexec::__forward_like<Data>(
detail::as_base<Property>
(data).m_value);
88
}
89
90
}
// namespace Kokkos::Execution::Impl
91
92
#endif
// KOKKOS_EXECUTION_IMPL_PROPERTIES_HPP
stdexec.hpp
Kokkos::Execution::Impl::detail
Definition
dispatch_label.hpp:29
Kokkos::Execution::Impl::detail::deduce_from_base
consteval void deduce_from_base(const T< Args... > &)
Kokkos::Execution::Impl::detail::as_base
constexpr T< Args... > & as_base(T< Args... > &base) noexcept
Definition
properties.hpp:45
Kokkos::Execution::Impl
Definition
attributes.hpp:6
Kokkos::Execution::Impl::has_property
consteval bool has_property()
Return true when Data derives from the property Property.
Definition
properties.hpp:68
Kokkos::Execution::Impl::get_property
constexpr decltype(auto) get_property(Data &&data) noexcept
Definition
properties.hpp:80
Kokkos::Execution::Impl::properties
Type list of properties.
Definition
properties.hpp:37
kokkos-execution
impl
properties.hpp
Generated on
for kokkos-execution by
1.18.0