Skip to main content
13 events
when toggle format what by license comment
Dec 13, 2016 at 20:50 comment added Chris Beck good point, I added a link to wikipedia
Dec 13, 2016 at 20:48 history edited Chris Beck CC BY-SA 3.0
add a link to wikipedia defn of RVO
Dec 13, 2016 at 20:04 comment added Catskul @chris-beck You should probably include the definition of RVO as Return Value Optimization in your answer. It's not a household abbreviation for most.
Jul 16, 2016 at 0:10 comment added Chris Beck Yeah I guess the first time I did it more like he does it wtih exception_ptr, and in another project, I actually didn't use exceptions anywhere and I decided to just make an error struct specific to that library. I think the main drawback of using an error struct is that if that struct is larger than the thing that you are returning, then the expected<T> may be a significantly larger object than if you threw exceptions or used exception_ptr. But it still won't involve dynamic allocations or RTTI, and it will still be a relatively small object so this is probably a micro-optimization.
Jul 15, 2016 at 10:52 comment added Martin Ba - yeah I knew AA's talk. I found the design pretty weird since to unpack it (except_ptr) you had to throw an exception internally. Personally I think such a tool should work completely independent of execptions. Just a remark.
Jul 15, 2016 at 10:05 comment added CodesInChaos The proposed [[nodiscard]] attribute will be helpful for this error handling approach since it ensures that you don't simply ignore the error result by accident.
Jul 15, 2016 at 9:16 history edited Chris Beck CC BY-SA 3.0
edited body
Jul 15, 2016 at 9:10 history edited Chris Beck CC BY-SA 3.0
added 15 characters in body
Jul 15, 2016 at 9:07 comment added Chris Beck Andrei Alexandrescu's talk is here: channel9.msdn.com/Shows/Going+Deep/… He shows in detail how to construct a class like this and what considerations you might have.
Jul 15, 2016 at 9:07 comment added Chris Beck You're right, I guess it isn't accepted yet. But there are several open source implementations floating around, and I've rolled my own a couple times I guess. It's less complicated than doing a variant type since there's only two possible states. The main design considerations are like, what exact interface do you want, and do you want it to be like Andrescu's expected<T> where the error object is actually supposed to be an exception_ptr, or do you just want to use some structure type or something like that.
Jul 15, 2016 at 9:05 history edited Chris Beck CC BY-SA 3.0
added 27 characters in body
Jul 15, 2016 at 7:25 comment added Martin Ba std::expected is still a non-accepted proposal, right?
Jul 15, 2016 at 6:23 history answered Chris Beck CC BY-SA 3.0