17 #include <type_traits>
21 inline namespace _V1 {
22 namespace ext::oneapi::experimental {
27 template <
typename PropT,
typename PropertiesT>
29 template <
typename PropT,
typename T,
typename... Ts>
32 template <
typename PropT,
typename... Rest>
34 template <
typename PropT,
typename... PropValuesTs,
typename... Rest>
36 PropT,
std::tuple<property_value<PropT, PropValuesTs...>, Rest...>>
41 template <
typename CTPropertyT,
typename PropertiesT =
void>
45 template <
typename CTPropertyT,
typename OtherProperty,
typename... Rest>
47 std::tuple<OtherProperty, Rest...>> {
50 std::tuple<Rest...>>
::type;
52 template <
typename CTPropertyT,
typename... CTPropertyValueTs,
typename... Rest>
55 std::tuple<property_value<CTPropertyT, CTPropertyValueTs...>, Rest...>> {
59 template <
typename CTPropertyT,
bool HasProperty,
typename PropertiesT =
void>
60 static constexpr std::enable_if_t<
67 template <
typename CTPropertyT,
bool HasProperty,
typename PropertiesT =
void>
68 static constexpr std::enable_if_t<!HasProperty, void>
get_property() {
78 template <
typename T,
typename... Ts>
80 : std::conditional_t<IsRuntimeProperty<T>::value,
81 PrependTuple<T, typename RuntimePropertyStorage<
82 std::tuple<Ts...>>::type>,
83 RuntimePropertyStorage<std::tuple<Ts...>>> {};
87 template <
typename T,
typename... TupleTs>
89 : std::integral_constant<
90 size_t, (0 + ... + static_cast<size_t>(std::is_same_v<T, TupleTs>))> {
95 template <
typename PropertyArgsT>
97 : std::integral_constant<size_t, 0> {};
98 template <
typename PropertyArgsT,
typename PropertyT,
typename... PropertyTs>
100 std::tuple<PropertyT, PropertyTs...>> {
101 static constexpr
size_t NumOccurrences =
103 static_assert(NumOccurrences <= 1,
104 "Duplicate occurrences of property in constructor arguments.");
105 static constexpr
size_t value =
113 template <
typename PropertyArgsT,
typename PropertiesT>
115 template <
typename PropertyArgsT>
117 static constexpr std::tuple<>
Extract(
const PropertyArgsT &) {
118 return std::tuple<>{};
121 template <
typename PropertyArgsT,
typename PropertyT,
typename... PropertiesTs>
123 std::tuple<PropertyT, PropertiesTs...>> {
124 static constexpr std::tuple<PropertyT, PropertiesTs...>
125 Extract(
const PropertyArgsT &PropertyValues) {
128 constexpr
size_t NumOccurrences =
132 "Duplicate occurrences of property in constructor arguments.");
133 static_assert(NumOccurrences == 1 ||
134 std::is_default_constructible_v<PropertyT>,
135 "Each property in the property list must either be given an "
136 "argument in the constructor or be default-constructible.");
138 auto NextExtractedProperties =
142 if constexpr (NumOccurrences == 1) {
143 return std::tuple_cat(
144 std::tuple<PropertyT>{std::get<PropertyT>(PropertyValues)},
145 NextExtractedProperties);
147 return std::tuple_cat(std::tuple<PropertyT>{PropertyT{}},
148 NextExtractedProperties);
157 "Properties must be in a tuple.");
159 "Unrecognized property in property list.");
161 "Properties in property list are not sorted.");
162 static_assert(detail::SortedAllUnique<PropertiesT>::value,
163 "Duplicate properties in property list.");
164 static_assert(detail::NoConflictingProperties<PropertiesT>::value,
165 "Conflicting properties in property list.");
168 template <
typename... PropertyValueTs,
170 std::tuple<PropertyValueTs...>>::value,
173 : Storage(detail::ExtractProperties<
std::tuple<PropertyValueTs...>,
174 StorageT>::Extract({props...})) {
179 constexpr
size_t NumContainedProps =
182 static_assert(NumContainedProps ==
sizeof...(PropertyValueTs),
183 "One or more property argument is not a property in the "
187 template <
typename PropertyT>
188 static constexpr std::enable_if_t<detail::IsProperty<PropertyT>::value,
bool>
193 template <
typename PropertyT>
194 typename std::enable_if_t<detail::IsRuntimeProperty<PropertyT>::value &&
195 has_property<PropertyT>(),
198 return std::get<PropertyT>(Storage);
201 template <
typename PropertyT>
202 typename std::enable_if_t<detail::IsRuntimeProperty<PropertyT>::value &&
203 !has_property<PropertyT>(),
206 static_assert(has_property<PropertyT>(),
207 "Property list does not contain the requested property.");
211 template <
typename PropertyT>
215 static_assert(has_property<PropertyT>(),
216 "Property list does not contain the requested property.");
217 return detail::get_property<PropertyT, has_property<PropertyT>(),
227 #ifdef __cpp_deduction_guides
229 template <
typename... PropertyValueTs>
230 properties(PropertyValueTs... props)
231 -> properties<
typename detail::Sorted<PropertyValueTs...>::type>;
238 template <
typename... PropertyValueTs>
241 properties<std::tuple<PropertyValueTs...>>,
242 properties<typename detail::Sorted<PropertyValueTs...>::type>> {};
244 #if __cplusplus > 201402L
245 template <
typename propertiesT>
253 template <
typename... PropertyValueTs>
257 template <
typename LHSPropertiesT,
typename RHSPropertiesT>
259 template <
typename... LHSPropertiesTs,
typename... RHSPropertiesTs>
263 std::tuple<LHSPropertiesTs...>, std::tuple<RHSPropertiesTs...>>
::type>;
265 template <
typename LHSPropertiesT,
typename RHSPropertiesT>
269 template <
typename Properties,
typename PropertyKey,
typename Cond =
void>
271 template <
typename ValT>
static constexpr ValT
get(ValT Default) {
276 template <
typename Properties,
typename PropertyKey>
278 Properties, PropertyKey,
279 std::enable_if_t<is_property_list_v<Properties> &&
280 Properties::template has_property<PropertyKey>()>> {
281 template <
typename ValT>
static constexpr ValT
get(ValT) {
282 return Properties::template get_property<PropertyKey>().value;
291 template <
typename SyclT,
typename FirstProp,
typename... RestProps>
299 template <
typename SyclT,
typename PropertiesT>
302 template <
typename SyclT>
307 template <
typename SyclT,
typename PropT>
310 : std::bool_constant<
311 ext::oneapi::experimental::is_property_key_of<PropT, SyclT>::value> {
314 template <
typename SyclT,
typename... Props>
317 : std::bool_constant<check_all_props_are_keys_of<SyclT, Props...>()> {};
322 template <
typename PropertiesT>
std::enable_if_t< detail::IsRuntimeProperty< PropertyT >::value &&has_property< PropertyT >), PropertyT > get_property() const
std::enable_if_t< detail::IsRuntimeProperty< PropertyT >::value &&!has_property< PropertyT >), void > get_property() const
static constexpr auto get_property(typename std::enable_if_t< detail::IsCompileTimeProperty< PropertyT >::value > *=0)
static constexpr std::enable_if_t< detail::IsProperty< PropertyT >::value, bool > has_property()
constexpr properties(PropertyValueTs... props)
constexpr bool is_property_list_v
constexpr bool check_all_props_are_keys_of()
static constexpr std::enable_if_t< HasProperty, typename FindCompileTimePropertyValueType< CTPropertyT, PropertiesT >::type > get_property()
typename merged_properties< LHSPropertiesT, RHSPropertiesT >::type merged_properties_t
typename FindCompileTimePropertyValueType< CTPropertyT, std::tuple< Rest... > >::type type
static constexpr ValT get(ValT)
static constexpr ValT get(ValT Default)
is_device_copyable is a user specializable class template to indicate that a type T is device copyabl...