aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/room.cpp5
-rw-r--r--lib/util.h21
2 files changed, 23 insertions, 3 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 8f50607f..7ff8f5e9 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -97,7 +97,7 @@ class Room::Private
Connection* connection;
QString id;
JoinState joinState;
- RoomSummary summary;
+ RoomSummary summary = { none, 0, none };
/// The state of the room at timeline position before-0
/// \sa timelineBase
std::unordered_map<StateEventKey, StateEventPtr> baseState;
@@ -1065,7 +1065,8 @@ int Room::joinedCount() const
int Room::invitedCount() const
{
// TODO: Store invited users in Room too
- return d->summary.invitedMemberCount;
+ Q_ASSERT(!d->summary.invitedMemberCount.omitted());
+ return d->summary.invitedMemberCount.value();
}
int Room::totalMemberCount() const
diff --git a/lib/util.h b/lib/util.h
index 336248d3..77c2bfdb 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -107,6 +107,25 @@ namespace QMatrixClient
return *this;
}
+ bool operator==(const value_type& rhs) const
+ {
+ return !omitted() && value() == rhs;
+ }
+ friend bool operator==(const value_type& lhs,
+ const Omittable<value_type>& rhs)
+ {
+ return rhs == lhs;
+ }
+ bool operator!=(const value_type& rhs) const
+ {
+ return !operator==(rhs);
+ }
+ friend bool operator!=(const value_type& lhs,
+ const Omittable<value_type>& rhs)
+ {
+ return !(rhs == lhs);
+ }
+
bool omitted() const { return _omitted; }
const value_type& value() const
{
@@ -136,7 +155,7 @@ namespace QMatrixClient
}
value_type&& release() { _omitted = true; return std::move(_value); }
- operator value_type&() & { return editValue(); }
+ operator const value_type&() const & { return value(); }
const value_type* operator->() const & { return &value(); }
value_type* operator->() & { return &editValue(); }
const value_type& operator*() const & { return value(); }