dev qol: Add -> operators to ValueWrapper for convenience

So we can type "foo->" instead of "foo.value()" (much shorter!)
This commit is contained in:
John Colvin committed 2025-06-13 20:50:29 +00:00
1 parent 114ac2fdc9
commit 23e4dbfa07
1 file changed
+13
+13
View File
@@ -24,6 +24,9 @@ class ValueWrapper {
constexpr const ValueT &value() const;
constexpr ValueT &value();
ValueT *operator->();
const ValueT *operator->() const;
private:
ValueT v_;
};
@@ -91,6 +94,16 @@ constexpr ValueT &ValueWrapper<Tag, ValueT>::value() {
return v_;
}
template <class Tag, class ValueT>
ValueT *ValueWrapper<Tag, ValueT>::operator->() {
return &v_;
}
template <class Tag, class ValueT>
const ValueT *ValueWrapper<Tag, ValueT>::operator->() const {
return &v_;
}
#define BIN_OP(result_t, op) \
template <class Tag, class ValueT> \
constexpr result_t operator op( \