thrust/iterator/tabulate_output_iterator.h

File members: thrust/iterator/tabulate_output_iterator.h

// SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once

#include <thrust/detail/config.h>

#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
#  pragma GCC system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
#  pragma clang system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
#  pragma system_header
#endif // no system header

#include <thrust/iterator/detail/tabulate_output_iterator.inl>

THRUST_NAMESPACE_BEGIN

template <typename BinaryFunction, typename System = use_default, typename DifferenceT = ptrdiff_t>
class tabulate_output_iterator : public detail::tabulate_output_iterator_base<BinaryFunction, System, DifferenceT>
{
public:
  using super_t = detail::tabulate_output_iterator_base<BinaryFunction, System, DifferenceT>;

  friend class thrust::iterator_core_access;
  tabulate_output_iterator() = default;

  _CCCL_HOST_DEVICE tabulate_output_iterator(BinaryFunction fun)
      : fun(fun)
  {}

private:
  _CCCL_HOST_DEVICE typename super_t::reference dereference() const
  {
    return detail::tabulate_output_iterator_proxy<BinaryFunction, DifferenceT>(fun, *this->base());
  }

  BinaryFunction fun;

}; // end tabulate_output_iterator

template <typename BinaryFunction>
tabulate_output_iterator<BinaryFunction> _CCCL_HOST_DEVICE make_tabulate_output_iterator(BinaryFunction fun)
{
  return tabulate_output_iterator<BinaryFunction>(fun);
} // end make_tabulate_output_iterator

THRUST_NAMESPACE_END