24 ms·
serious question: would you throw an exception if T2 cannot be created ? or use a variant data-type ? or something else altogether?
by signa11 8y ago
serious question: would you throw an exception if T2 cannot be created ? or use a variant data-type ? or something else altogether?
- bigcheesegs 8y agoUse a variant type like llvm::Expected.
- signa11 8y agoyup, that's what i thought. i generally tend to use a construct simiar to 'error_or' though. that wrapped within a macro (^^) makes the whole invokation quite bearable
- ncmncm 8y agoGenerally, 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.