aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-04-29 01:13:05 +0200
committerSven Göthel <[email protected]>2024-04-29 01:13:05 +0200
commit06261cfdfeec0d8186b62d7e1be849fb5276227d (patch)
treed5f5a8db8fc947314dcff7899638014ad541f9a2
parentc0ae093faa9ce36cff928d58c3f82758d59343c9 (diff)
math: vec[234][fi]: Add begin, cbegin methods and explicit const_pointer and pointer conversion ops, allowing to access aligned memory like Matrix4
-rw-r--r--include/jau/math/vec2f.hpp6
-rw-r--r--include/jau/math/vec2i.hpp6
-rw-r--r--include/jau/math/vec3f.hpp6
-rw-r--r--include/jau/math/vec4f.hpp6
4 files changed, 24 insertions, 0 deletions
diff --git a/include/jau/math/vec2f.hpp b/include/jau/math/vec2f.hpp
index 598d01e..9a830f7 100644
--- a/include/jau/math/vec2f.hpp
+++ b/include/jau/math/vec2f.hpp
@@ -86,12 +86,18 @@ namespace jau::math {
return (&x)[i];
}
+ explicit operator const_pointer() const noexcept { return &x; }
+ constexpr const_iterator cbegin() const noexcept { return &x; }
+
/** Returns writeable reference to component */
constexpr reference operator[](size_t i) noexcept {
assert(i < 2);
return (&x)[i];
}
+ explicit operator pointer() noexcept { return &x; }
+ constexpr iterator begin() noexcept { return &x; }
+
/** xy = this, returns xy. */
constexpr iterator get(iterator xy) const noexcept {
xy[0] = x;
diff --git a/include/jau/math/vec2i.hpp b/include/jau/math/vec2i.hpp
index 17e84de..ec6e237 100644
--- a/include/jau/math/vec2i.hpp
+++ b/include/jau/math/vec2i.hpp
@@ -83,12 +83,18 @@ namespace jau::math {
return (&x)[i];
}
+ explicit operator const_pointer() const noexcept { return &x; }
+ constexpr const_iterator cbegin() const noexcept { return &x; }
+
/** Returns writeable reference to component */
constexpr reference operator[](size_t i) noexcept {
assert(i < 2);
return (&x)[i];
}
+ explicit operator pointer() noexcept { return &x; }
+ constexpr iterator begin() noexcept { return &x; }
+
/** xy = this, returns xy. */
constexpr iterator get(iterator xy) const noexcept {
xy[0] = x;
diff --git a/include/jau/math/vec3f.hpp b/include/jau/math/vec3f.hpp
index b63a405..c68b45c 100644
--- a/include/jau/math/vec3f.hpp
+++ b/include/jau/math/vec3f.hpp
@@ -96,12 +96,18 @@ namespace jau::math {
return (&x)[i];
}
+ explicit operator const_pointer() const noexcept { return &x; }
+ constexpr const_iterator cbegin() const noexcept { return &x; }
+
/** Returns writeable reference to component */
constexpr reference operator[](size_t i) noexcept {
assert(i < 3);
return (&x)[i];
}
+ explicit operator pointer() noexcept { return &x; }
+ constexpr iterator begin() noexcept { return &x; }
+
/** xyz = this, returns xyz. */
constexpr iterator get(iterator xyz) const noexcept {
xyz[0] = x;
diff --git a/include/jau/math/vec4f.hpp b/include/jau/math/vec4f.hpp
index 2580c17..b27c767 100644
--- a/include/jau/math/vec4f.hpp
+++ b/include/jau/math/vec4f.hpp
@@ -97,12 +97,18 @@ namespace jau::math {
return (&x)[i];
}
+ explicit operator const_pointer() const noexcept { return &x; }
+ constexpr const_iterator cbegin() const noexcept { return &x; }
+
/** Returns writeable reference to component */
constexpr reference operator[](size_t i) noexcept {
assert(i < 4);
return (&x)[i];
}
+ explicit operator pointer() noexcept { return &x; }
+ constexpr iterator begin() noexcept { return &x; }
+
/** xyzw = this, returns xyzw. */
constexpr iterator get(iterator xyzw) const noexcept {
xyzw[0] = x;