From: Adam Emerson Date: Fri, 18 Aug 2023 22:07:22 +0000 (-0400) Subject: neorados: Make neorados::Entry aggregate initializable X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=edc46346f3f5a145df5c52ea39d8cf71159080fa;p=ceph.git neorados: Make neorados::Entry aggregate initializable Now that C++20 has designated initializers, this is the least confusing way to handle objects like this. Also switch to using the spaceship operator, while we're at it. Signed-off-by: Adam Emerson --- diff --git a/src/include/neorados/RADOS_Decodable.hpp b/src/include/neorados/RADOS_Decodable.hpp index 5e3a0d36eabb5..777a2525c8e04 100644 --- a/src/include/neorados/RADOS_Decodable.hpp +++ b/src/include/neorados/RADOS_Decodable.hpp @@ -35,34 +35,8 @@ struct Entry { std::string oid; std::string locator; - Entry() {} - Entry(std::string nspace, std::string oid, std::string locator) : - nspace(std::move(nspace)), oid(std::move(oid)), locator(locator) {} + friend auto operator <=>(const Entry&, const Entry&) = default; }; -inline bool operator ==(const Entry& l, const Entry r) { - return std::tie(l.nspace, l.oid, l.locator) == - std::tie(r.nspace, r.oid, r.locator); -} -inline bool operator !=(const Entry& l, const Entry r) { - return std::tie(l.nspace, l.oid, l.locator) != - std::tie(r.nspace, r.oid, r.locator); -} -inline bool operator <(const Entry& l, const Entry r) { - return std::tie(l.nspace, l.oid, l.locator) < - std::tie(r.nspace, r.oid, r.locator); -} -inline bool operator <=(const Entry& l, const Entry r) { - return std::tie(l.nspace, l.oid, l.locator) <= - std::tie(r.nspace, r.oid, r.locator); -} -inline bool operator >=(const Entry& l, const Entry r) { - return std::tie(l.nspace, l.oid, l.locator) >= - std::tie(r.nspace, r.oid, r.locator); -} -inline bool operator >(const Entry& l, const Entry r) { - return std::tie(l.nspace, l.oid, l.locator) > - std::tie(r.nspace, r.oid, r.locator); -} inline std::ostream& operator <<(std::ostream& out, const Entry& entry) { if (!entry.nspace.empty())