diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index f21c6dc0..cb8caaa9 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -394,6 +394,11 @@ public: return c.count(); } + constexpr Duration operator-() const + { + return BaseDuration::operator-(); + } + explicit constexpr operator bool() const { return *this != BaseDuration::zero(); diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp index bcfc1941..cb9fe004 100644 --- a/src/libcamera/base/utils.cpp +++ b/src/libcamera/base/utils.cpp @@ -425,6 +425,12 @@ std::string toAscii(const std::string &str) * \return The tick count of the Duration expressed in \a Period */ +/** + * \fn Duration::operator-() + * \brief Negation operator to negate a \a Duration + * \return The duration, with the number of ticks negated + */ + /** * \fn Duration::operator bool() * \brief Boolean operator to test if a \a Duration holds a non-zero time value diff --git a/test/utils.cpp b/test/utils.cpp index d25475cb..195fddc9 100644 --- a/test/utils.cpp +++ b/test/utils.cpp @@ -167,6 +167,12 @@ protected: return TestFail; } + exposure = 100ms; + if ((-exposure).get() != -100) { + cerr << "utils::Duration failed negation" << endl; + return TestFail; + } + return TestPass; }