diff --git a/keys.hh b/keys.hh index 9fce736d59..dd97d42aa4 100644 --- a/keys.hh +++ b/keys.hh @@ -146,6 +146,19 @@ public: auto components(const schema& s) const { return components(); } + + bool is_empty() const { + return _bytes.empty(); + } + + explicit operator bool() const { + return !is_empty(); + } + + // For backward compatibility with existing code. + bool is_empty(const schema& s) const { + return is_empty(); + } }; template @@ -304,8 +317,17 @@ public: return get_compound_type(s)->end(_bytes); } + bool is_empty() const { + return _bytes.empty(); + } + + explicit operator bool() const { + return !is_empty(); + } + + // For backward compatibility with existing code. bool is_empty(const schema& s) const { - return begin(s) == end(s); + return is_empty(); } // Returns a range of bytes_view @@ -520,10 +542,6 @@ public: bool is_full(const schema& s) const { return TopLevel::get_compound_type(s)->is_full(base::_bytes); } - - bool is_empty(const schema& s) const { - return TopLevel::get_compound_type(s)->is_empty(base::_bytes); - } }; template @@ -542,10 +560,6 @@ public: return TopLevel::get_compound_type(s)->is_full(base::_bytes); } - bool is_empty(const schema& s) const { - return TopLevel::get_compound_type(s)->is_empty(base::_bytes); - } - // Can be called only if is_full() FullTopLevel to_full(const schema& s) const { return FullTopLevel::from_exploded(s, base::explode(s)); @@ -803,4 +817,4 @@ struct appending_hash { void operator()(Hasher& h, const clustering_key_prefix& ck, const schema& s) const { appending_hash()(h, ck.view(), s); } -}; \ No newline at end of file +};