mirror of
https://github.com/yuzu-emu/FasTC
synced 2024-11-22 22:03:42 +00:00
Allow additional indexable types
Instead of using operator() to index into the second operand of the VectorAddition function, use operator[]. This way we can add to pointers and std::vector types as well.
This commit is contained in:
parent
1b7691993d
commit
7ed5c13405
2 changed files with 6 additions and 2 deletions
|
@ -110,7 +110,7 @@ namespace FasTC {
|
||||||
const VectorTypeTwo &v2) {
|
const VectorTypeTwo &v2) {
|
||||||
VectorTypeOne a(v1);
|
VectorTypeOne a(v1);
|
||||||
for(int i = 0; i < VectorTypeOne::Size; i++) {
|
for(int i = 0; i < VectorTypeOne::Size; i++) {
|
||||||
a(i) += v2(i);
|
a(i) += v2[i];
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ namespace FasTC {
|
||||||
const VectorTypeTwo &v2) {
|
const VectorTypeTwo &v2) {
|
||||||
VectorTypeOne a(v1);
|
VectorTypeOne a(v1);
|
||||||
for(int i = 0; i < VectorTypeOne::Size; i++) {
|
for(int i = 0; i < VectorTypeOne::Size; i++) {
|
||||||
a(i) -= v2(i);
|
a(i) -= v2[i];
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,10 @@ TEST(VectorBase, Addition) {
|
||||||
EXPECT_EQ(au[0], 6);
|
EXPECT_EQ(au[0], 6);
|
||||||
EXPECT_EQ(au[1], 5);
|
EXPECT_EQ(au[1], 5);
|
||||||
|
|
||||||
|
au = v2u + fv + uv;
|
||||||
|
EXPECT_EQ(au[0], 11);
|
||||||
|
EXPECT_EQ(au[1], 7);
|
||||||
|
|
||||||
FasTC::VectorBase<float, 2> af = v2f + v2u;
|
FasTC::VectorBase<float, 2> af = v2f + v2u;
|
||||||
EXPECT_NEAR(af[0], 6.1f, kEpsilon);
|
EXPECT_NEAR(af[0], 6.1f, kEpsilon);
|
||||||
EXPECT_NEAR(af[1], 5.2f, kEpsilon);
|
EXPECT_NEAR(af[1], 5.2f, kEpsilon);
|
||||||
|
|
Loading…
Reference in a new issue