Skip to content

Commit b2afd57

Browse files
[ADT] Use "= default" in DirectedGraph.h
This patch uses "= default" in copy/move constructors and assignment operators of DirectedGraph. Now, the original code: DGraphType &operator=(const DGraphType &&G) is most likely unintended -- a move assignment operator with const r-value reference. This patch fixes that.
1 parent fea2cca commit b2afd57

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

llvm/include/llvm/ADT/DirectedGraph.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,10 @@ template <class NodeType, class EdgeType> class DirectedGraph {
181181

182182
DirectedGraph() = default;
183183
explicit DirectedGraph(NodeType &N) : Nodes() { addNode(N); }
184-
DirectedGraph(const DGraphType &G) : Nodes(G.Nodes) {}
185-
DirectedGraph(DGraphType &&RHS) : Nodes(std::move(RHS.Nodes)) {}
186-
DGraphType &operator=(const DGraphType &G) {
187-
Nodes = G.Nodes;
188-
return *this;
189-
}
190-
DGraphType &operator=(const DGraphType &&G) {
191-
Nodes = std::move(G.Nodes);
192-
return *this;
193-
}
184+
DirectedGraph(const DGraphType &G) = default;
185+
DirectedGraph(DGraphType &&RHS) = default;
186+
DGraphType &operator=(const DGraphType &G) = default;
187+
DGraphType &operator=(DGraphType &&G) = default;
194188

195189
const_iterator begin() const { return Nodes.begin(); }
196190
const_iterator end() const { return Nodes.end(); }

0 commit comments

Comments
 (0)