[Rivet] Updated Cuts system prototype/demo

David Grellscheid david.grellscheid at durham.ac.uk
Tue May 7 22:15:44 BST 2013


Attached is a modified example that shows the problem. Compilation goes 
fine, but the cuts_ member is null at the usage point.

   David

On 07/05/2013 22:06, David Grellscheid wrote:
> 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
> _______________________________________________
> Rivet mailing list
> Rivet at projects.hepforge.org
> http://www.hepforge.org/lists/listinfo/rivet
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cuts.cc
Type: text/x-c++src
Size: 4042 bytes
Desc: not available
URL: <http://www.hepforge.org/lists-archive/rivet/attachments/20130507/6413df85/attachment.cc>


More information about the Rivet mailing list