Skip to content

Commit

Permalink
Add operator() to vec_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnh committed Feb 22, 2024
1 parent c81e76a commit c4fae9d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
9 changes: 9 additions & 0 deletions include/kernel_float/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,15 @@ struct vector_ptr {
this->template at<K>(index).write(values);
}

/**
* Shorthand for `at(index)`. Returns a vector reference to can be used
* to assign to this pointer, contrary to `operator[]` that does not
* allow assignment.
*/
KERNEL_FLOAT_INLINE vector_ref<T, N, U, N> operator()(size_t index) const {
return at(index);
}

/**
* Gets the raw data pointer managed by this `vector_ptr`.
*/
Expand Down
21 changes: 15 additions & 6 deletions single_include/kernel_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

//================================================================================
// this file has been auto-generated, do not modify its contents!
// date: 2024-02-21 16:31:28.518919
// git hash: 4b0835655b5c2493054d8cbcba8b9ee4edc724d4
// date: 2024-02-22 10:17:59.488348
// git hash: c81e76a8c623162ef1970192f239b70d54c85123
//================================================================================

#ifndef KERNEL_FLOAT_MACROS_H
Expand Down Expand Up @@ -2779,14 +2779,14 @@ struct vector_ptr {
/**
* Shorthand for `read(index)`.
*/
KERNEL_FLOAT_INLINE vector<value_type, extent<N>> operator[](size_t index) const {
KERNEL_FLOAT_INLINE const vector<value_type, extent<N>> operator[](size_t index) const {
return read(index);
}

/**
* Shorthand for `read(0)`.
*/
KERNEL_FLOAT_INLINE vector<value_type, extent<N>> operator*() const {
KERNEL_FLOAT_INLINE const vector<value_type, extent<N>> operator*() const {
return read(0);
}

Expand All @@ -2803,6 +2803,15 @@ struct vector_ptr {
this->template at<K>(index).write(values);
}

/**
* Shorthand for `at(index)`. Returns a vector reference to can be used
* to assign to this pointer, contrary to `operator[]` that does not
* allow assignment.
*/
KERNEL_FLOAT_INLINE vector_ref<T, N, U, N> operator()(size_t index) const {
return at(index);
}

/**
* Gets the raw data pointer managed by this `vector_ptr`.
*/
Expand Down Expand Up @@ -2844,11 +2853,11 @@ struct vector_ptr<T, N, const U> {
return this->template at<K>(index).read();
}

KERNEL_FLOAT_INLINE vector<value_type, extent<N>> operator[](size_t index) const {
KERNEL_FLOAT_INLINE const vector<value_type, extent<N>> operator[](size_t index) const {
return read(index);
}

KERNEL_FLOAT_INLINE vector<value_type, extent<N>> operator*() const {
KERNEL_FLOAT_INLINE const vector<value_type, extent<N>> operator*() const {
return read(0);
}

Expand Down

0 comments on commit c4fae9d

Please sign in to comment.