# HG changeset patch # User Alpar Juttner # Date 1340375926 -7200 # Node ID a5810903ed28c2184c54742465439861ad5ba227 # Parent 4764031c082c6c2b13501867b9d65e665a939334# Parent 7440937d154b70e90a0d50c77c97ee5f4a86ba87 Merge bugfix #444 to branch 1.2 diff -r 4764031c082c -r a5810903ed28 lemon/path.h --- a/lemon/path.h Sun May 06 16:52:11 2012 +0200 +++ b/lemon/path.h Fri Jun 22 16:38:46 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 4764031c082c -r a5810903ed28 test/path_test.cc --- a/test/path_test.cc Sun May 06 16:52:11 2012 +0200 +++ b/test/path_test.cc Fri Jun 22 16:38:46 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; }