From 41cd527620d94a11362f2a5a1aa86643be22d36e Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Wed, 28 Jun 2017 14:03:31 -0400 Subject: SERVER-29910 Make RoleGraph non-copyable (but movable) Changed explicit trivial constructor to `default`. Removed explicit trivial destructor for non-virtual class. Declared `default` move-assignment and move-constructor methods. Removed `swap` implementations in favor of move assignment. Removed a test which dealt specifically with copyability since the class is no longer copyable. --- src/mongo/db/auth/role_graph.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/mongo/db/auth/role_graph.h') diff --git a/src/mongo/db/auth/role_graph.h b/src/mongo/db/auth/role_graph.h index 4d8334b7710..9a5c3d639cb 100644 --- a/src/mongo/db/auth/role_graph.h +++ b/src/mongo/db/auth/role_graph.h @@ -55,7 +55,17 @@ class OperationContext; * recomputePrivilegeData() on the object. */ class RoleGraph { + // Disallow copying + RoleGraph(const RoleGraph&) = delete; + RoleGraph& operator=(const RoleGraph&) = delete; + public: + RoleGraph() noexcept = default; + + // Explicitly make RoleGraph movable + RoleGraph(RoleGraph&&) noexcept = default; + RoleGraph& operator=(RoleGraph&&) noexcept = default; + /** * Adds to "privileges" the privileges associated with the named built-in role, and returns * true. Returns false if "role" does not name a built-in role, and does not modify @@ -64,10 +74,6 @@ public: */ static bool addPrivilegesForBuiltinRole(const RoleName& role, PrivilegeVector* privileges); - RoleGraph(); - RoleGraph(const RoleGraph& other); - ~RoleGraph(); - // Built-in roles for backwards compatibility with 2.2 and prior static const std::string BUILTIN_ROLE_V0_READ; static const std::string BUILTIN_ROLE_V0_READ_WRITE; @@ -309,6 +315,8 @@ private: std::set _allRoles; }; -void swap(RoleGraph& lhs, RoleGraph& rhs); +inline void swap(RoleGraph& lhs, RoleGraph& rhs) { + lhs.swap(rhs); +} } // namespace mongo -- cgit v1.2.1