summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2020-09-02 22:22:58 +0200
committerPhilip Chimento <philip.chimento@gmail.com>2020-09-20 15:01:42 -0700
commit7f8cd63e7adfac3c0843406af4a93249e5a94705 (patch)
treef13acde06c6db824128f77246b5e4911218091e7
parent8b42e173e8eb1a03bf8045412818563b6f9b5ee0 (diff)
downloadgjs-7f8cd63e7adfac3c0843406af4a93249e5a94705.tar.gz
jsapi-util: Mark some GjsAutoPointer operations as constexpr
Most of them are just acces operators, so we can mark it clearer to the compiler.
-rw-r--r--gjs/jsapi-util.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 19a31802..315f3248 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -68,15 +68,17 @@ struct GjsAutoPointer : std::unique_ptr<T, decltype(free_func)> {
this->reset(ptr && ref ? reinterpret_cast<T*>(ref(ptr)) : ptr);
}
- operator T*() const { return this->get(); }
- T& operator[](size_t i) const { return static_cast<T*>(*this)[i]; }
+ constexpr operator T*() const { return this->get(); }
+ constexpr T& operator[](size_t i) const {
+ return static_cast<T*>(*this)[i];
+ }
- [[nodiscard]] T* copy() const {
+ [[nodiscard]] constexpr T* copy() const {
return reinterpret_cast<T*>(ref_func(this->get()));
}
template <typename C>
- [[nodiscard]] C* as() const {
+ [[nodiscard]] constexpr C* as() const {
return const_cast<C*>(reinterpret_cast<const C*>(this->get()));
}
};