On Sun, Nov 7, 2010 at 1:20 AM, Peter Wright
so if the SortByName object outlives the Graph then it could blow up spectacularly. But the alternative of copying the entire graph seemed a bit excessive.
Another way to fix it (and also avoid the reference-storing problem) requires using Boost::Bind - change SortByName to this:
<snip/> ...and the A.sort call to this:
A.sort( boost::bind(SortByName
(), g, _1, _2) );
It does avoid the reference-storing problem. I believe it does so by copying
the entire graph. boost::bind() stores its parameters by value.
If that is in fact excessive, you could write:
A.sort( boost::bind(SortByName