You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by "Benjamin Hindman (JIRA)" <ji...@apache.org> on 2014/02/15 01:32:25 UTC

[jira] [Commented] (MESOS-1008) Reduce copying in stout primitives {Try, Option, Result}.

    [ https://issues.apache.org/jira/browse/MESOS-1008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13902206#comment-13902206 ] 

Benjamin Hindman commented on MESOS-1008:
-----------------------------------------

:)

> Reduce copying in stout primitives {Try, Option, Result}.
> ---------------------------------------------------------
>
>                 Key: MESOS-1008
>                 URL: https://issues.apache.org/jira/browse/MESOS-1008
>             Project: Mesos
>          Issue Type: Improvement
>            Reporter: Benjamin Mahler
>
> The following will discuss Try, but the same applies to Option and Result.
> Currently retrieving the value from a Try requires a copy:
>   T get() const { ... return *t; }
> Instead, we can return a const&:
>   const T& get() const { ... return *t; }
> For existing callers, this should be fairly seamless:
>   const T& t = try.get(); // No change needed.
>   T t = try.get(); // No change needed, T is already required to be copyable.
>   try.get().mutator(); // Will no longer compile, but we should not allow this anyway!
> We can also add C++11 support for move to pilfer the Try, to avoid copies in the caller entirely:
>   T&& move() const { ... } // After a move(), we must guard Try operations.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)