This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question regarding template instantiation of tempory type


Hi Arthur,

If your parameters are constant, then you should put in "T const&" for the parameter type.

If the parameters are being mutated by the function (indicated by the absence of const), then temporaries are supposed to generate an error because mutating a temporary is considered a programming error by the compiler. (There are a few ways to work around this situation, but it takes a little more work on the invocation side of the fence, and involves wrapping the temporary with something that returns a non-const reference to itself.)

HTH,
--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]