<div dir="ltr"> Hi Rafael,<div><br></div><div>I'd always use auto here, but I agree this example is a bit ambiguous for the docs. I've added a prototype for mayFail() in r264314.</div><div><br></div><div>- Lang.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 23, 2016 at 5:28 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">Should we use 'auto' in code that that?<br>
<br>
Cheers,<br>
Rafael<br>
<br>
<br>
On 22 March 2016 at 23:18, Lang Hames via llvm-commits<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Author: lhames<br>
> Date: Tue Mar 22 22:18:16 2016<br>
> New Revision: 264135<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264135&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=264135&view=rev</a><br>
> Log:<br>
> [Docs] Clarify boolean conversion for Error and Expected<T> in the Programmer's<br>
> Manual.<br>
><br>
><br>
> Modified:<br>
>     llvm/trunk/docs/ProgrammersManual.rst<br>
><br>
> Modified: llvm/trunk/docs/ProgrammersManual.rst<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.rst?rev=264135&r1=264134&r2=264135&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.rst?rev=264135&r1=264134&r2=264135&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/docs/ProgrammersManual.rst (original)<br>
> +++ llvm/trunk/docs/ProgrammersManual.rst Tue Mar 22 22:18:16 2016<br>
> @@ -356,12 +356,24 @@ that inherits from the ErrorInfo utility<br>
>      return Error::success();<br>
>    }<br>
><br>
> +Error values can be implicitly converted to bool: true for error, false for<br>
> +success, enabling the following idiom:<br>
> +<br>
> +.. code-block::<br>
> +<br>
> +  if (auto Err = mayFail())<br>
> +    return Err;<br>
> +<br>
> +  // Success! We can proceed.<br>
> +<br>
> +<br>
>  For functions that can fail but need to return a value the ``Expected<T>``<br>
>  utility can be used. Values of this type can be constructed with either a<br>
> -``T``, or a ``Error``. Values are implicitly convertible to boolean: true<br>
> -for success, false for error. If success, the ``T`` value can be accessed via<br>
> -the dereference operator. If failure, the ``Error`` value can be extracted<br>
> -using the ``takeError()`` method:<br>
> +``T``, or a ``Error``. Expected<T> values are also implicitly convertible to<br>
> +boolean, but with the opposite convention to Error: true for success, false for<br>
> +error. If success, the ``T`` value can be accessed via the dereference operator.<br>
> +If failure, the ``Error`` value can be extracted using the ``takeError()``<br>
> +method. Idiomatic usage looks like:<br>
><br>
>  .. code-block:: c++<br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>