12#include "detray/definitions/detail/qualifiers.hpp"
13#include "detray/utils/ranges/ranges.hpp"
15namespace detray::ranges {
27template <
typename value_t>
47 : m_value{std::move(
value)} {}
52 template <
class... Args>
53 DETRAY_HOST_DEVICE
constexpr explicit single_view(std::in_place_t ,
55 : m_value{std::in_place, std::forward<Args>(args)...} {}
60 constexpr auto value() const -> value_t {
return m_value; }
65 constexpr auto ref() const -> const value_t& {
return m_value; }
69 constexpr auto ref() -> value_t& {
return m_value; }
73 constexpr auto begin() noexcept -> value_t* {
return &m_value; }
77 constexpr auto begin() const noexcept -> const value_t* {
return &m_value; }
81 constexpr auto end() noexcept -> value_t* {
return &m_value + 1; }
85 constexpr auto end() const noexcept -> const value_t* {
return &m_value + 1; }
89 constexpr auto data() noexcept -> value_t* {
return &m_value; }
93 constexpr auto data() const noexcept -> const value_t* {
return &m_value; }
97 static constexpr auto size() noexcept -> std::
size_t {
return 1; }
101 constexpr auto front() noexcept -> value_t {
return m_value; }
105 constexpr auto back() noexcept -> value_t {
return m_value; }
120template <
typename value_t>
125 constexpr single() =
default;
129 template <
typename deduced_value_t>
130 requires(!std::same_as<deduced_value_t, single>)
131 DETRAY_HOST_DEVICE
constexpr explicit single(
const deduced_value_t&
value)
136 template <
typename deduced_value_t>
137 requires(!std::same_as<deduced_value_t, single>)
138 DETRAY_HOST_DEVICE
constexpr explicit single(deduced_value_t&&
value)
144 template <
class... Args>
145 DETRAY_HOST_DEVICE
constexpr explicit single(std::in_place_t ,
147 :
base_type(std::in_place , std::forward<Args>(args)... ) {
153template <
typename deduced_value_t>
154DETRAY_HOST_DEVICE_DEDUCTION_GUIDE single(deduced_value_t)
155 -> single<deduced_value_t>;
Struct that implements a view on a single element.
Definition single.hpp:29
constexpr auto end() const noexcept -> const value_t *
Definition single.hpp:85
constexpr auto data() noexcept -> value_t *
Definition single.hpp:89
constexpr single_view(value_t &&value)
Construct the view by moving in its single element.
Definition single.hpp:46
constexpr auto ref() -> value_t &
Return a mutable reference to the stored element.
Definition single.hpp:69
constexpr auto operator[](const dindex) const -> value_t
Definition single.hpp:108
constexpr auto back() noexcept -> value_t
Definition single.hpp:105
constexpr single_view(const value_t &value)
Construct the view by copying its single element.
Definition single.hpp:40
constexpr auto begin() noexcept -> value_t *
Definition single.hpp:73
constexpr single_view()=default
Default constructor.
static constexpr auto size() noexcept -> std::size_t
Definition single.hpp:97
entry_t * iterator_t
Definition single.hpp:32
constexpr auto end() noexcept -> value_t *
Definition single.hpp:81
constexpr auto begin() const noexcept -> const value_t *
Definition single.hpp:77
constexpr single_view(std::in_place_t, Args &&... args)
Construct value in place from args.
Definition single.hpp:53
constexpr auto value() const -> entry_t
Definition single.hpp:60
constexpr auto data() const noexcept -> const value_t *
Definition single.hpp:93
constexpr auto ref() const -> const value_t &
Return a const reference to the stored element.
Definition single.hpp:65
constexpr auto front() noexcept -> value_t
Definition single.hpp:101
Defines a detray 'view'.
Definition ranges.hpp:190
unsigned int dindex
Default index type.
Definition indexing.hpp:18
constexpr single(const deduced_value_t &value)
Construct the view by copying a value.
Definition single.hpp:131
constexpr single(std::in_place_t, Args &&... args)
Construct the stored value in place.
Definition single.hpp:145
constexpr single(deduced_value_t &&value)
Construct the view by moving a value.
Definition single.hpp:138
detray::ranges::single_view< value_t > base_type
Base implementation storing the single value.
Definition single.hpp:123