Benjamin Mahler created MESOS-1008:
--------------------------------------
Summary: 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)