# HG changeset patch # User Alpar Juttner # Date 1340376125 -7200 # Node ID a10624ed1997bbcf37dba039a750aba48813e736 # Parent 38e1d4383262a146b119291383c65007f7704ec3# Parent 7440937d154b70e90a0d50c77c97ee5f4a86ba87 Merge bugfix #444 diff -r 38e1d4383262 -r a10624ed1997 lemon/path.h --- a/lemon/path.h Sun May 06 17:18:39 2012 +0200 +++ b/lemon/path.h Fri Jun 22 16:42:05 2012 +0200 @@ -64,6 +64,12 @@ /// Default constructor Path() {} + /// \brief Copy constructor + /// + Path(const Path& cpath) { + pathCopy(cpath, *this); + } + /// \brief Template copy constructor /// /// This constuctor initializes the path from any other path type. @@ -73,6 +79,13 @@ pathCopy(cpath, *this); } + /// \brief Copy assignment + /// + Path& operator=(const Path& cpath) { + pathCopy(cpath, *this); + return *this; + } + /// \brief Template copy assignment /// /// This operator makes a copy of a path of any other type. @@ -252,6 +265,12 @@ /// Default constructor SimplePath() {} + /// \brief Copy constructor + /// + SimplePath(const SimplePath& cpath) { + pathCopy(cpath, *this); + } + /// \brief Template copy constructor /// /// This path can be initialized with any other path type. It just @@ -261,6 +280,13 @@ pathCopy(cpath, *this); } + /// \brief Copy assignment + /// + SimplePath& operator=(const SimplePath& cpath) { + pathCopy(cpath, *this); + return *this; + } + /// \brief Template copy assignment /// /// This path can be initialized with any other path type. It just @@ -431,6 +457,12 @@ /// Default constructor ListPath() : first(0), last(0) {} + /// \brief Copy constructor + /// + ListPath(const ListPath& cpath) : first(0), last(0) { + pathCopy(cpath, *this); + } + /// \brief Template copy constructor /// /// This path can be initialized with any other path type. It just @@ -447,6 +479,13 @@ clear(); } + /// \brief Copy assignment + /// + ListPath& operator=(const ListPath& cpath) { + pathCopy(cpath, *this); + return *this; + } + /// \brief Template copy assignment /// /// This path can be initialized with any other path type. It just @@ -758,6 +797,12 @@ /// Default constructor StaticPath() : len(0), arcs(0) {} + /// \brief Copy constructor + /// + StaticPath(const StaticPath& cpath) : arcs(0) { + pathCopy(cpath, *this); + } + /// \brief Template copy constructor /// /// This path can be initialized from any other path type. @@ -773,6 +818,13 @@ if (arcs) delete[] arcs; } + /// \brief Copy assignment + /// + StaticPath& operator=(const StaticPath& cpath) { + pathCopy(cpath, *this); + return *this; + } + /// \brief Template copy assignment /// /// This path can be made equal to any other path type. It simply diff -r 38e1d4383262 -r a10624ed1997 test/path_test.cc --- a/test/path_test.cc Sun May 06 17:18:39 2012 +0200 +++ b/test/path_test.cc Fri Jun 22 16:42:05 2012 +0200 @@ -38,7 +38,36 @@ checkConcept, ListPath >(); } +// Check if proper copy consructor is called (use valgrind for testing) +template +void checkCopy() +{ + ListDigraph g; + ListDigraph::Arc a = g.addArc(g.addNode(), g.addNode()); + + _Path p,q; + p.addBack(a); + q=p; + _Path r(p); + StaticPath s(r); +} + int main() { check_concepts(); + + checkCopy >(); + checkCopy >(); + checkCopy >(); + + ListDigraph g; + ListDigraph::Arc a = g.addArc(g.addNode(), g.addNode()); + + Path p; + StaticPath q,r; + p.addBack(a); + q=p; + r=q; + StaticPath s(q); + return 0; }