From 60eefb228c9b5c2846d3640d68ae5a7ccb0c254d Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 1 Jun 2026 16:09:22 +0200 Subject: Adding unary - operator --- modules/codec/c++/data.hpp | 4 ++++ modules/codec/c++/data_math.hpp | 13 +++++++++++++ 2 files changed, 17 insertions(+) (limited to 'modules/codec/c++') diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index ae9d8eb..79a6ab8 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -171,6 +171,10 @@ public: constexpr data operator-(const data& rhs)const{ return {get() - rhs.get()}; } + + constexpr data operator-() const { + return {-get()}; + } constexpr data& operator++() { set(get() + static_cast::type>(1)); diff --git a/modules/codec/c++/data_math.hpp b/modules/codec/c++/data_math.hpp index 48dae91..9d07eb3 100644 --- a/modules/codec/c++/data_math.hpp +++ b/modules/codec/c++/data_math.hpp @@ -131,6 +131,19 @@ public: return c; } + data, encode::Native> operator-() const { + data, encode::Native> c; + + rank_iterator::in_fixed_bounds([&](const data, encode::Native>& index) -> error_or{ + c.at(index) = -at(index); + return make_void(); + }); + + return c; + } + + + template data, encode::Native> cast_to() const { data, encode::Native> native_change; -- cgit v1.2.3