Re:Lvalues, rvalues, glvalues, prvalues, xvalues, help (2018)
by signa11 on Thursday April 11, 2019 @08:03PM
(#19640570)
serious question: would you throw an exception if T2 cannot be created ? or use a variant data-type ? or something else altogether?
Re:Lvalues, rvalues, glvalues, prvalues, xvalues, help (2018)
by ncmncm on Friday April 12, 2019 @10:31PM
(#19650741)
Generally, yes, throw.
Sometimes an optional is better, such as when downstream already takes one.
Occasionally, checking whether the operation (and a bunch of others) would succeed is best, particularly in high-rel/high-av systems. There, you are probably also logging, first, what you are about to attempt.
Re:Lvalues, rvalues, glvalues, prvalues, xvalues, help (2018)
by bigcheesegs on Thursday April 11, 2019 @08:52PM
(#19640880)
Use a variant type like llvm::Expected.
Besides being horrible style, operating on references cripples the optimizer. "Avoid accidental copying"? What good is that if it's slower than if you did the copy?