20 #ifndef RAJA_INDEXVALUE_HPP
21 #define RAJA_INDEXVALUE_HPP
23 #include "RAJA/config.hpp"
48 template<
typename TYPE,
typename VALUE = RAJA::Index_type>
90 return static_cast<TYPE&
>(*this);
105 return static_cast<TYPE&
>(*this);
111 return TYPE(
value + a);
117 return TYPE(
value + a.value);
123 return TYPE(
value - a);
129 return TYPE(
value - a.value);
135 return TYPE(
value * a);
141 return TYPE(
value * a.value);
147 return TYPE(
value / a);
153 return TYPE(
value / a.value);
159 return TYPE(
value % a);
165 return TYPE(
value % a.value);
171 return static_cast<TYPE&
>(*this);
177 return static_cast<TYPE&
>(*this);
183 return static_cast<TYPE&
>(*this);
189 return static_cast<TYPE&
>(*this);
195 return static_cast<TYPE&
>(*this);
201 return static_cast<TYPE&
>(*this);
207 return static_cast<TYPE&
>(*this);
213 return static_cast<TYPE&
>(*this);
233 return (
value <=
x.value);
253 return (
value >=
x.value);
263 return (
value ==
x.value);
273 return (
value !=
x.value);
287 template<
typename TO,
typename FROM>
293 template<
typename TO,
typename FROM>
297 return static_cast<TO
>(*val);
308 template<
typename TO,
typename FROM>
311 return internal::convertIndex_helper<TO, FROM>(val);
319 template<
typename FROM>
321 typename std::enable_if<std::is_base_of<IndexValueBase, FROM>::value,
322 typename FROM::value_type>::type
331 template<
typename FROM>
333 typename std::enable_if<!std::is_base_of<IndexValueBase, FROM>::value,
342 template<
typename FROM,
typename Enable =
void>
348 template<
typename FROM>
351 typename
std::enable_if<std::is_base_of<IndexValueBase, FROM>::value>
::type>
353 using type =
typename FROM::value_type;
363 template<
typename FROM>
372 template<
typename FROM>
374 typename std::conditional<std::is_floating_point<FROM>::value,
375 std::common_type<FROM>,
376 std::make_signed<FROM>>::type::type;
385 #define RAJA_INDEX_VALUE(TYPE, NAME) \
386 class TYPE : public ::RAJA::IndexValue<TYPE> \
388 using parent = ::RAJA::IndexValue<TYPE>; \
391 using IndexValueType = TYPE; \
392 RAJA_HOST_DEVICE RAJA_INLINE TYPE() : parent::IndexValue() {} \
393 RAJA_HOST_DEVICE RAJA_INLINE explicit TYPE(::RAJA::Index_type v) \
394 : parent::IndexValue(v) \
396 static inline std::string getName() { return NAME; } \
405 #define RAJA_INDEX_VALUE_T(TYPE, IDXT, NAME) \
406 class TYPE : public ::RAJA::IndexValue<TYPE, IDXT> \
409 RAJA_HOST_DEVICE RAJA_INLINE TYPE() \
410 : RAJA::IndexValue<TYPE, IDXT>::IndexValue() \
412 RAJA_HOST_DEVICE RAJA_INLINE explicit TYPE(IDXT v) \
413 : RAJA::IndexValue<TYPE, IDXT>::IndexValue(v) \
415 static inline std::string getName() { return NAME; } \
Header file for common RAJA internal macro definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
constexpr RAJA_HOST_DEVICE RAJA_INLINE TO convertIndex_helper(FROM const val)
Definition: IndexValue.hpp:288
Definition: AlignedRangeIndexSetBuilders.cpp:35
constexpr RAJA_HOST_DEVICE RAJA_INLINE TO convertIndex(FROM const val)
Function provides a way to take either an int or any Index<> type, and convert it to another type,...
Definition: IndexValue.hpp:309
typename internal::StripIndexTypeT< FROM >::type strip_index_type_t
Strips a strongly typed index to its underlying type In the case of a non-strongly typed index,...
Definition: IndexValue.hpp:364
constexpr RAJA_HOST_DEVICE RAJA_INLINE std::enable_if< std::is_base_of< IndexValueBase, FROM >::value, typename FROM::value_type >::type stripIndexType(FROM const val)
Function that strips the strongly typed Index<> and returns its underlying value_type value.
Definition: IndexValue.hpp:323
typename std::conditional< std::is_floating_point< FROM >::value, std::common_type< FROM >, std::make_signed< FROM > >::type::type make_signed_t
Converts a type into a signed type. Also handles floating point types as std::make_signed only suppor...
Definition: IndexValue.hpp:376
Definition: ListSegment.hpp:416
Definition: IndexValue.hpp:34
Strongly typed "integer" class.
Definition: IndexValue.hpp:50
RAJA_HOST_DEVICE RAJA_INLINE TYPE & operator++()
preincrement stored index
Definition: IndexValue.hpp:87
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator/(TYPE a) const
division to underlying index from another strong type
Definition: IndexValue.hpp:151
RAJA_HOST_DEVICE RAJA_INLINE TYPE & operator*=(TYPE x)
Definition: IndexValue.hpp:198
constexpr RAJA_INLINE IndexValue(IndexValue &&)=default
RAJA_HOST_DEVICE constexpr RAJA_INLINE IndexValue(value_type v)
Explicit constructor.
Definition: IndexValue.hpp:65
RAJA_HOST_DEVICE RAJA_INLINE const value_type & operator*() const
Dereference provides cast-to-integer.
Definition: IndexValue.hpp:73
RAJA_HOST_DEVICE RAJA_INLINE bool operator>=(TYPE x) const
Definition: IndexValue.hpp:251
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator-(TYPE a) const
subtraction to underlying index from another strong type
Definition: IndexValue.hpp:127
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator/(value_type a) const
division to underlying index from an Index_type
Definition: IndexValue.hpp:145
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator--(int)
postdecrement – returns a copy
Definition: IndexValue.hpp:94
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator+(TYPE a) const
addition to underlying index from another strong type
Definition: IndexValue.hpp:115
RAJA_HOST_DEVICE RAJA_INLINE bool operator<=(value_type x) const
Definition: IndexValue.hpp:226
RAJA_HOST_DEVICE RAJA_INLINE TYPE & operator/=(value_type x)
Definition: IndexValue.hpp:204
RAJA_HOST_DEVICE RAJA_INLINE bool operator!=(value_type x) const
Definition: IndexValue.hpp:266
RAJA_HOST_DEVICE RAJA_INLINE bool operator<(TYPE x) const
Definition: IndexValue.hpp:221
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator+(value_type a) const
addition to underlying index from an Index_type
Definition: IndexValue.hpp:109
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator%(value_type a) const
modulus to underlying index from an Index_type
Definition: IndexValue.hpp:157
RAJA_HOST_DEVICE RAJA_INLINE TYPE & operator+=(TYPE x)
Definition: IndexValue.hpp:174
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator*(value_type a) const
multiplication to underlying index from an Index_type
Definition: IndexValue.hpp:133
RAJA_HOST_DEVICE RAJA_INLINE bool operator==(value_type x) const
Definition: IndexValue.hpp:256
RAJA_INLINE IndexValue & operator=(IndexValue const &)=default
RAJA_HOST_DEVICE RAJA_INLINE bool operator>(value_type x) const
Definition: IndexValue.hpp:236
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator++(int)
postincrement – returns a copy
Definition: IndexValue.hpp:79
static std::string getName()
RAJA_INLINE IndexValue & operator=(IndexValue &&)=default
constexpr RAJA_INLINE IndexValue(IndexValue const &)=default
RAJA_HOST_DEVICE RAJA_INLINE TYPE & operator--()
preincrement stored index
Definition: IndexValue.hpp:102
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator*(TYPE a) const
multiplication to underlying index from another strong type
Definition: IndexValue.hpp:139
RAJA_HOST_DEVICE RAJA_INLINE bool operator!=(TYPE x) const
Definition: IndexValue.hpp:271
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator-(value_type a) const
subtraction to underlying index from an Index_type
Definition: IndexValue.hpp:121
RAJA_HOST_DEVICE RAJA_INLINE TYPE & operator*=(value_type x)
Definition: IndexValue.hpp:192
RAJA_HOST_DEVICE RAJA_INLINE bool operator<(value_type x) const
Definition: IndexValue.hpp:216
value_type value
Definition: IndexValue.hpp:281
RAJA_HOST_DEVICE RAJA_INLINE TYPE & operator-=(value_type x)
Definition: IndexValue.hpp:180
RAJA_HOST_DEVICE RAJA_INLINE bool operator<=(TYPE x) const
Definition: IndexValue.hpp:231
RAJA_HOST_DEVICE RAJA_INLINE TYPE & operator/=(TYPE x)
Definition: IndexValue.hpp:210
constexpr RAJA_INLINE IndexValue()=default
Default constructor initializes value to 0.
RAJA_HOST_DEVICE RAJA_INLINE bool operator==(TYPE x) const
Definition: IndexValue.hpp:261
RAJA_HOST_DEVICE RAJA_INLINE TYPE & operator-=(TYPE x)
Definition: IndexValue.hpp:186
RAJA_HOST_DEVICE RAJA_INLINE value_type & operator*()
Dereference provides cast-to-integer.
Definition: IndexValue.hpp:70
RAJA_HOST_DEVICE RAJA_INLINE bool operator>(TYPE x) const
Definition: IndexValue.hpp:241
RAJA_HOST_DEVICE RAJA_INLINE TYPE operator%(TYPE a) const
modulus to underlying index from another strong type
Definition: IndexValue.hpp:163
VALUE value_type
Definition: IndexValue.hpp:52
RAJA_HOST_DEVICE RAJA_INLINE bool operator>=(value_type x) const
Definition: IndexValue.hpp:246
RAJA_HOST_DEVICE RAJA_INLINE TYPE & operator+=(value_type x)
Definition: IndexValue.hpp:168
typename FROM::value_type type
Definition: IndexValue.hpp:353
Definition: IndexValue.hpp:344
FROM type
Definition: IndexValue.hpp:345
Header file for RAJA type definitions.