Skip to content

Commit 2d6be93

Browse files
authored
Merge pull request #931 from acts-project/feat/surf_lookup_assert
Add some assertions to the surface lookup
2 parents f288947 + f55e556 commit 2d6be93

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core/include/detray/core/detail/surface_lookup.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -156,31 +156,36 @@ class surface_lookup {
156156
/// Elementwise access. Needs @c operator[] for storage type - non-const
157157
DETRAY_HOST_DEVICE
158158
constexpr decltype(auto) operator[](const std::size_t i) {
159+
assert(i < m_container.size());
159160
return m_container[i];
160161
}
161162

162163
/// Elementwise access. Needs @c operator[] for storage type - const
163164
DETRAY_HOST_DEVICE
164165
constexpr decltype(auto) operator[](const std::size_t i) const {
166+
assert(i < m_container.size());
165167
return m_container[i];
166168
}
167169

168170
/// @returns context based access to an element (also range checked)
169171
DETRAY_HOST_DEVICE
170172
constexpr decltype(auto) at(const dindex i) noexcept {
173+
assert(i < m_container.size());
171174
return m_container.at(i);
172175
}
173176

174177
/// @returns context based access to an element (also range checked) - const
175178
DETRAY_HOST_DEVICE
176179
constexpr decltype(auto) at(const dindex i) const noexcept {
180+
assert(i < m_container.size());
177181
return m_container.at(i);
178182
}
179183

180184
/// @returns the surface descriptor according to the global surface index
181185
/// @param sf_index
182186
DETRAY_HOST_DEVICE
183187
constexpr decltype(auto) search(dindex sf_index) const {
188+
assert(sf_index < m_container.size());
184189
return m_container[sf_index];
185190
}
186191

0 commit comments

Comments
 (0)