<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 27, 2016 at 9:51 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> Yeah - this will be pretty rare, and I want it to be ugly - nobody should<br>
> use a pre-checked error except for the error-as-out-parameter idiom.<br>
> Actually Error::errorAsOutParameter() sounds good. :)<br>
<br>
</span>And even that is only for constructors, right? Otherwise one should<br>
use Expected.<br>
<br>
In fact, using an std::error_code (or equivalent) as a parameter of<br>
constructed always looked a bit odd IMHO. With good move constructors<br>
we should be able to have trivial private constructors and always use<br>
an static create method that returns an ErrorOr (or equivalent).<br></blockquote><div><br></div><div>It is a bit weird - but, as you say, it was already weird - and these migrations/error handling improvements can be a lot of churn already, so it'll probably be helpful to not have to tackle those refactorings simultaneously, but flag them for future cleanup with a clear API like this (like migrating parts of the codebase to unique_ptr - those "release" calls are an obvious place to go hunting for future cleanup where unique_ptr hasn't been pushed through al the APIs)<br><br>& it's not always possible to solve with movement - some objects have important in-memory identity of the object itself (in many cases, then, you might have a factory that returns unique_ptr instead, or raw pointers from a slab allocator, etc - but that's part of the problem: whether the type should have baked in knowledge about the allocation scheme or not) & so ctor fail is about all you can do.<br><br>- Dave</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div></div>