1 #ifndef DASH__RANGES_H__INCLUDED 2 #define DASH__RANGES_H__INCLUDED 49 #include <dash/Types.h> 50 #include <dash/Meta.h> 52 #include <type_traits> 66 template <
typename ViewT>
70 template <
typename ViewType>
71 class IndexSetIdentity;
74 template <
typename Iterator,
typename Sentinel = Iterator>
78 template <
typename Iterator,
typename Sentinel>
79 class IteratorRange<Iterator *, Sentinel *>;
88 template <
typename RangeType>
89 constexpr
auto begin(RangeType && range)
90 -> decltype(std::forward<RangeType>(range).
begin()) {
91 return std::forward<RangeType>(range).
begin();
97 template <
class RangeType>
98 constexpr
auto end(RangeType && range)
99 -> decltype(std::forward<RangeType>(range).
end()) {
100 return std::forward<RangeType>(range).
end();
106 template <
class RangeType>
109 -> decltype(std::forward<RangeType>(r).
size()) {
110 return std::forward<RangeType>(r).
size();
117 struct _is_range_type
123 typedef typename std::remove_reference<
124 typename std::remove_const<T>::type
131 template <
typename C>
static yes has_dash_begin(
134 std::move(std::declval<T>())
137 template <
typename C>
static no has_dash_begin(...);
140 template <
typename C>
static yes has_dash_end(
143 std::move(std::declval<T>())
146 template <
typename C>
static no has_dash_end(...);
150 sizeof(has_dash_begin(static_cast<ValueT*>(
nullptr))) ==
sizeof(yes)
151 &&
sizeof(has_dash_end(static_cast<ValueT*>(
nullptr))) ==
sizeof(yes)
163 template<
typename C,
typename C::iterator (C::*)() = &C::begin >
164 static yes has_begin(C *);
165 static no has_begin(...);
167 template<
typename C,
typename C::iterator (C::*)() const = &C::begin >
168 static yes has_const_begin(C *);
169 static no has_const_begin(...);
173 template<
typename C,
typename C::iterator (C::*)() = &C::end >
174 static yes has_end(C *);
175 static no has_end(...);
177 template<
typename C,
typename C::iterator (C::*)() const = &C::end >
178 static yes has_const_end(C *);
179 static no has_const_end(...);
183 (
sizeof(has_begin(static_cast<ValueT*>(
nullptr)))
185 ||
sizeof(has_const_begin(static_cast<ValueT*>(
nullptr)))
188 (
sizeof(has_end(static_cast<ValueT*>(
nullptr)))
190 ||
sizeof(has_const_end(static_cast<ValueT*>(
nullptr)))
242 template <
class RangeType>
243 struct is_range : dash::detail::_is_range_type<RangeType> { };
248 typename Sentinel = Iterator >
251 typedef Iterator iterator;
252 typedef Sentinel sentinel;
255 RangeType & derived() {
256 return static_cast<RangeType &
>(*this);
258 const RangeType & derived()
const {
259 return static_cast<const RangeType &
>(*this);
279 typedef typename RangeT::index_type index_type;
280 typedef typename RangeT::index_set_type index_set_type;
285 typedef std::integral_constant<bool, false> is_view;
291 typedef std::integral_constant<bool, std::is_same<
305 :
public RangeBase< IteratorRange<Iterator, Sentinel>,
315 typedef Iterator iterator;
316 typedef Sentinel sentinel;
318 typedef typename iterator::pattern_type pattern_type;
319 typedef dash::IndexSetIdentity<self_t> index_set_type;
320 typedef typename iterator::value_type value_type;
324 std::is_pointer<iterator>::value,
326 typename iterator::local_type
332 std::is_pointer<sentinel>::value,
334 typename sentinel::local_type
342 template <
class Container>
348 constexpr IteratorRange(iterator &
begin, sentinel &
end)
353 constexpr iterator
begin()
const {
return _begin; }
354 constexpr iterator
end()
const {
return _end; }
356 constexpr
const local_type
local()
const {
363 constexpr
const pattern_type & pattern()
const {
364 return _begin.pattern();
367 constexpr index_set_type index_set()
const {
368 return index_set_type(*
this);
378 typename LocalIterator,
379 typename LocalSentinel >
388 LocalIterator * _begin;
389 LocalSentinel * _end;
392 typedef LocalIterator * iterator;
393 typedef LocalSentinel * sentinel;
395 typedef dash::IndexSetIdentity<self_t> index_set_type;
396 typedef LocalIterator value_type;
398 typedef iterator local_iterator;
399 typedef sentinel local_sentinel;
404 template <
class Container>
410 constexpr IteratorRange(iterator &
begin, sentinel &
end)
415 constexpr iterator
begin()
const {
return _begin; }
416 constexpr iterator
end()
const {
return _end; }
418 constexpr
const local_type &
local()
const {
422 constexpr index_set_type index_set()
const {
423 return index_set_type(*
this);
431 template <
class Iterator,
class Sentinel>
434 const Iterator &
begin,
435 const Sentinel &
end) {
445 template <
class Iterator,
class Sentinel>
459 template <
class Iterator,
class Sentinel>
471 #endif // DASH__RANGES_H__INCLUDED constexpr dash::IteratorRange< const Iterator, const Sentinel > make_range(const Iterator &begin, const Sentinel &end)
Adapter utility function.
size_t size()
Return the number of units in the global team.
constexpr auto end(RangeType &&range) -> decltype(std::forward< RangeType >(range).end())
constexpr auto local(ViewType &v) -> typename std::enable_if<(std::is_pointer< typename ViewType::iterator >::value||(dash::view_traits< ViewValueT >::is_local::value)), ViewType &>::type
This class is a simple memory pool which holds allocates elements of size ValueType.
std::integral_constant< bool, false > is_projection
Whether the view type is a projection (has less dimensions than the view's domain type)...
constexpr auto begin(RangeType &&range) -> decltype(std::forward< RangeType >(range).begin())
internal::default_signed_index default_index_t
Signed integer type used as default for index values.
Adapter template for range concept, wraps begin and end iterators in range type.
std::integral_constant< bool, std::is_same< RangeT, typename RangeT::local_type >::value > is_local
Whether the view / container type is a local view.
Definition of type trait dash::is_range<T> with static member value indicating whether type T is a mo...
std::integral_constant< bool, true > is_origin
Whether the view is the origin domain.
Specialization of adapter template for range concept, wraps begin and end pointers in range type...