Skip to content

Commit 024a112

Browse files
authored
Merge pull request TheHPXProject#6994 from aneek22112007-tech/fix/low-risk-improvements
Small Code Quality Boost: Addressing long-standing FIXMEs and TODOs
2 parents 3715392 + 0e9d3ff commit 024a112

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

libs/core/compute_local/include/hpx/compute_local/detail/iterator.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ namespace hpx::compute::detail {
5858
{
5959
}
6060

61+
public:
6162
HPX_HOST_DEVICE iterator(iterator const& other) noexcept
6263
: base_type(other)
6364
, target_(other.target_)

libs/core/compute_local/include/hpx/compute_local/vector.hpp

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,47 @@ namespace hpx::compute {
240240
return *(data_ + pos);
241241
}
242242

243-
// TODO: implement front()
244-
// TODO: implement back()
243+
/// Returns a reference to the first element in the container.
244+
/// Calling front on an empty container is undefined.
245+
HPX_HOST_DEVICE
246+
reference front()
247+
{
248+
#if !defined(__CUDA_ARCH__)
249+
HPX_ASSERT(!empty());
250+
#endif
251+
return *data_;
252+
}
253+
254+
/// \copydoc front()
255+
HPX_HOST_DEVICE
256+
const_reference front() const
257+
{
258+
#if !defined(__CUDA_ARCH__)
259+
HPX_ASSERT(!empty());
260+
#endif
261+
return *data_;
262+
}
263+
264+
/// Returns a reference to the last element in the container.
265+
/// Calling back on an empty container is undefined.
266+
HPX_HOST_DEVICE
267+
reference back()
268+
{
269+
#if !defined(__CUDA_ARCH__)
270+
HPX_ASSERT(!empty());
271+
#endif
272+
return *(data_ + size_ - 1);
273+
}
274+
275+
/// \copydoc back()
276+
HPX_HOST_DEVICE
277+
const_reference back() const
278+
{
279+
#if !defined(__CUDA_ARCH__)
280+
HPX_ASSERT(!empty());
281+
#endif
282+
return *(data_ + size_ - 1);
283+
}
245284

246285
/// Returns pointer to the underlying array serving as element storage.
247286
/// The pointer is such that range [data(); data() + size()) is always a

0 commit comments

Comments
 (0)