|
[Rivet] Updated Cuts system prototype/demoAndy Buckley andy.buckley at cern.chTue May 7 18:00:24 BST 2013
Thanks David, good to have some extra input. There's a reason I didn't do that: I didn't think it'd work! You changed the AND/OR/NOT Cut functors to store const references, but those 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! One other question, since I've only looked at the diff, not applied it yet: would it be ok on this evidence for Projections to also store const Cut& references, set by their constructors? And do they have to be const (i.e. need to be set by the constructor initialization list), or could they also be resettable by methods on a non-const Projection before registering it? Bear in mind that in general Projection objects are new'd to copy them into the ProjectionHandler infrastructure. Being able to *store* Cuts polymorphically without requiring heap allocation was one of the big problems that I had when first trying to make this work... hence my avoiding references or pointers in the previous version, at the cost of proliferating very complex types. Thanks again! Andy On 03/05/13 18:15, David Grellscheid wrote: > Hi Andy, > > What I was thinking of only works if you're allowed to evaluate the > template expression on assignment (as in vecA = vecB + vecC + vecD). > Here, we need to pass the unevaluated expressions around instead. > > But isn't that what the base class is for? Turn all the operator members > into const references and then all your 'auto' can become "const Cut &". > No template mess needed, and forgetting the '&' anywhere causes a > compiler error beause of the abstract base class. > > Diff attached... > > David > > > > On 03/05/2013 16:22, David Grellscheid wrote: >> Hi Andy, >> >> I like it, it's really neat now! I have the feeling that something can >> still be condensed a bit more, but I'll have to play with it. The >> Softsusy code successfully hides the template stuff completely away from >> the end users, so I must have had a way of achieving that 10 years ago >> without C++11 :-D >> >> I'll copy the pastebin and send you a diff if I get it sorted. >> >> See you, >> >> David >> _______________________________________________ >> Rivet mailing list >> Rivet at projects.hepforge.org >> http://www.hepforge.org/lists/listinfo/rivet > > > _______________________________________________ > Rivet mailing list > Rivet at projects.hepforge.org > http://www.hepforge.org/lists/listinfo/rivet > -- Dr Andy Buckley, Royal Society University Research Fellow Particle Physics Expt Group, University of Edinburgh
More information about the Rivet mailing list |