On Wed, Apr 16, 2003 at 08:48:55AM -0700, Michael Hunley wrote:
> Julia, the C++ standard disallows passing in inline constructed objects 
> to functions/constructors that do take non-const references.  

Yes.

> There is 
> an issue with potential scope and lifetime of the reference (the passed 
> in object is a temp and could go out of scope while the object it was 
> given to was still "using" it).

That's not exactly the reason (otherwise they would disallow const
references too). Lifetime of the temp object is guaranteed to persist
until the end of that statement. They're actually trying to "help" you
avoid putting valuable information into a temporary object.

> Wei: Does the StringSource(...).Ref() solve the issue?

Yes, I added a Ref() function to return a non-const reference to the 
object.

> StringSource    strSrc( rsak, true, dec );
> RSASSA_PKCS1v15_SHA_Signer privkey( strSrc );

That will work too.

Reply via email to