diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2017-06-28 14:03:31 -0400 |
---|---|---|
committer | Sara Golemon <sara.golemon@mongodb.com> | 2017-06-30 16:39:17 -0400 |
commit | 41cd527620d94a11362f2a5a1aa86643be22d36e (patch) | |
tree | 677f096715460583ef59fdd3551c9cb6ae2ab7ad /src/mongo/db/auth/role_graph.h | |
parent | 453028f378f8344197cea0e3ded53f445ccd5abf (diff) | |
download | mongo-41cd527620d94a11362f2a5a1aa86643be22d36e.tar.gz |
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.
Diffstat (limited to 'src/mongo/db/auth/role_graph.h')
-rw-r--r-- | src/mongo/db/auth/role_graph.h | 18 |
1 files changed, 13 insertions, 5 deletions
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<RoleName> _allRoles; }; -void swap(RoleGraph& lhs, RoleGraph& rhs); +inline void swap(RoleGraph& lhs, RoleGraph& rhs) { + lhs.swap(rhs); +} } // namespace mongo |