vector, matrix: +operator

This commit is contained in:
BlackMATov
2021-01-27 00:54:19 +07:00
parent c46fa4e0d2
commit e3518b0c89
4 changed files with 17 additions and 1 deletions

View File

@@ -192,6 +192,13 @@ namespace vmath_hpp::detail
namespace vmath_hpp
{
// +operator
template < typename T, std::size_t Size >
[[nodiscard]] constexpr mat<T, Size> operator+(const mat<T, Size>& xs) {
return xs;
}
// -operator
template < typename T, std::size_t Size >

View File

@@ -165,6 +165,13 @@ namespace vmath_hpp::detail
namespace vmath_hpp
{
// +operator
template < typename T, std::size_t Size >
[[nodiscard]] constexpr vec<T, Size> operator+(const vec<T, Size>& xs) {
return xs;
}
// -operator
template < typename T, std::size_t Size >

View File

@@ -58,7 +58,8 @@ TEST_CASE("vmath/mat_fun") {
}
SECTION("operators") {
STATIC_REQUIRE(-int2x2(1,2,3,4) == int2x2(-1,-2,-3,-4));
STATIC_REQUIRE(+int2x2(1,-2,3,-4) == int2x2(1,-2,3,-4));
STATIC_REQUIRE(-int2x2(1,-2,3,-4) == int2x2(-1,2,-3,4));
STATIC_REQUIRE(~uint2x2(0xF0F0F0F0,0x0F0F0F0F,0xF0F0F0F0,0x0F0F0F0F) == uint2x2(0x0F0F0F0F,0xF0F0F0F0,0x0F0F0F0F,0xF0F0F0F0));
STATIC_REQUIRE(!int2x2(-1,0,1,2) == bool2x2(false,true,false,false));

View File

@@ -41,6 +41,7 @@ TEST_CASE("vmath/vec_fun") {
}
SECTION("Operators") {
STATIC_REQUIRE(+int2(1,-2) == int2(1,-2));
STATIC_REQUIRE(-int2(1,-2) == int2(-1,2));
STATIC_REQUIRE(~uint2(0xF0F0F0F0,0x0F0F0F0F) == uint2(0x0F0F0F0F,0xF0F0F0F0));
STATIC_REQUIRE(!int3(-1,0,1) == bool3(false, true, false));