Destructors, const structs, and opEquals

Jonathan M Davis jmdavisProg at gmx.com
Sat Dec 4 04:41:36 PST 2010


On Saturday 04 December 2010 03:49:26 so wrote:
> > On Friday 03 December 2010 22:42:06 Don wrote:
> >> (1) Should temporaries be allowed to be passed as 'const ref'?
> > 
> > I honestly do not understand why they can't be already. C++ definitely
> > allows
> > this.
> 
> If you don't mean new C++ standards, this is not true. It is supported by
> non-standard extensions.

I'm 99.99% certain that it's perfectly legal to pass a temporary to a function 
that takes a const T& and that it's in the standard. I'm fairly certain that 
I've read it in at least one book (though I'd have to look it up to be sure), 
but regardless, both gcc and Visual Studio definitely allow it, so if it's non-
standard, it's still highly supported.

- Jonathan M Davis


More information about the Digitalmars-d mailing list