|
[Rivet] Updated Cuts system prototype/demoDavid Grellscheid david.grellscheid at durham.ac.ukTue May 7 22:06:44 BST 2013
Hi Andy, > references are taken w.r.t. stack-allocated temporaries passed to > their constructors: I don't understand why this isn't as doomed to > failure as taking a pointer to a temporary? I suspect there is a > facet of C++ object lifetimes here that I don't/didn't appreciate! Damn. I knew I missed something there. A _local_ const reference to a temporary (all examples in main() are like that) keeps the temporary alive until all refs are gone, but that does not work across scopes. A slightly more indirect main function (e.g. set c3 with a function call) breaks for the reason you mentioned. It'll have to go back to smart_ptr or auto. Hmmm. At least in C++11 you won't need boost: all the functions you're using are in standard C++11. > need to be set by the constructor initialization list References don't have to be const, but must be set in the constructor. They cannot be re-pointed elsewhere. Assigning to the reference member later on changes the original object, it does not re-point the reference to something else. David
More information about the Rivet mailing list |