okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge branch 'f-139b-arc' into f-139-relad33b8074

main
1.8 KiB54 linesraw
1//==---- iterator_adaptor.h -----------------------*- C++ -*----------------==//
2//
3// Copyright (C) Intel Corporation
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5// See https://llvm.org/LICENSE.txt for license information.
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef __DPCT_ITERATOR_ADAPTOR_H__
10#define __DPCT_ITERATOR_ADAPTOR_H__
11
12#include <boost/iterator_adaptors.hpp>
13
14namespace dpct {
15
16typedef boost::use_default use_default;
17
18typedef boost::iterator_core_access iterator_core_access;
19
20template <class Derived, class Base, class Value = use_default,
21          class Traversal = use_default, class System = use_default,
22          class Reference = use_default, class Difference = use_default>
23class iterator_adaptor
24    : public boost::iterator_adaptor<Derived, Base, Value, Traversal, Reference,
25                                     Difference> {
26protected:
27  typedef boost::iterator_adaptor<Derived, Base, Value, Traversal, Reference,
28                                  Difference>
29      base_t;
30
31  // Note: System tag is not used to dispatch to any specific backend, this is
32  //       controlled explicitly by the user with execution policies. System tag
33  //       is kept for potential future extension by specialization based on
34  //       this part of the type definition.
35
36public:
37  // It is the user's responsibility to ensure extra data is available on the
38  // device if they want to use this iterator with device execution policies
39  using is_passed_directly = ::std::true_type;
40  using iterator_category = ::std::random_access_iterator_tag;
41
42  iterator_adaptor() {}
43
44  explicit iterator_adaptor(Base const &iter) : base_t(iter) {}
45
46  typename base_t::reference
47  operator[](typename base_t::difference_type n) const {
48    return *(this->derived() + n);
49  }
50};
51
52} // end namespace dpct
53
54#endif