Skip to content

Commit c4fae9d

Browse files
committed
Add operator() to vec_ptr
1 parent c81e76a commit c4fae9d

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

include/kernel_float/memory.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,15 @@ struct vector_ptr {
481481
this->template at<K>(index).write(values);
482482
}
483483

484+
/**
485+
* Shorthand for `at(index)`. Returns a vector reference to can be used
486+
* to assign to this pointer, contrary to `operator[]` that does not
487+
* allow assignment.
488+
*/
489+
KERNEL_FLOAT_INLINE vector_ref<T, N, U, N> operator()(size_t index) const {
490+
return at(index);
491+
}
492+
484493
/**
485494
* Gets the raw data pointer managed by this `vector_ptr`.
486495
*/

single_include/kernel_float.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

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

2323
#ifndef KERNEL_FLOAT_MACROS_H
@@ -2779,14 +2779,14 @@ struct vector_ptr {
27792779
/**
27802780
* Shorthand for `read(index)`.
27812781
*/
2782-
KERNEL_FLOAT_INLINE vector<value_type, extent<N>> operator[](size_t index) const {
2782+
KERNEL_FLOAT_INLINE const vector<value_type, extent<N>> operator[](size_t index) const {
27832783
return read(index);
27842784
}
27852785

27862786
/**
27872787
* Shorthand for `read(0)`.
27882788
*/
2789-
KERNEL_FLOAT_INLINE vector<value_type, extent<N>> operator*() const {
2789+
KERNEL_FLOAT_INLINE const vector<value_type, extent<N>> operator*() const {
27902790
return read(0);
27912791
}
27922792

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

2806+
/**
2807+
* Shorthand for `at(index)`. Returns a vector reference to can be used
2808+
* to assign to this pointer, contrary to `operator[]` that does not
2809+
* allow assignment.
2810+
*/
2811+
KERNEL_FLOAT_INLINE vector_ref<T, N, U, N> operator()(size_t index) const {
2812+
return at(index);
2813+
}
2814+
28062815
/**
28072816
* Gets the raw data pointer managed by this `vector_ptr`.
28082817
*/
@@ -2844,11 +2853,11 @@ struct vector_ptr<T, N, const U> {
28442853
return this->template at<K>(index).read();
28452854
}
28462855

2847-
KERNEL_FLOAT_INLINE vector<value_type, extent<N>> operator[](size_t index) const {
2856+
KERNEL_FLOAT_INLINE const vector<value_type, extent<N>> operator[](size_t index) const {
28482857
return read(index);
28492858
}
28502859

2851-
KERNEL_FLOAT_INLINE vector<value_type, extent<N>> operator*() const {
2860+
KERNEL_FLOAT_INLINE const vector<value_type, extent<N>> operator*() const {
28522861
return read(0);
28532862
}
28542863

0 commit comments

Comments
 (0)