[
https://issues.apache.org/jira/browse/MESOS-2757?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14692346#comment-14692346
]
Benjamin Mahler commented on MESOS-2757:
----------------------------------------
Sorry for the delay, it will take me a bit of time to get back to this. It's a
trade-off, we recognize that it isn't ideal to make this feel like a pointer
(e.g. object slicing), but at the same time Option & friends are pointer-like
in that they are a level of indirection to the underlying value. Note the
similarities:
{code}
Option<vector<int>> o;
if (o.isSome()) {
return o->size();
}
vector<int>* v;
if (v != NULL) {
return v->size();
}
{code}
Ultimately, we'd like to avoid the clunkiness that .get() entails when we're
accessing a value through Option & friends:
{code}
Option<vector<int>> o;
if (o.isSome()) {
return o.get().size();
}
{code}
Note that this is proliferating quite a bit and it seems to be making the code
less readable. Also, folly and boost's optionals provide these operators as
well, FWIW.
Makes sense [~arojas]?
> Add -> operator for Option<T>, Try<T>, Result<T>, Future<T>.
> ------------------------------------------------------------
>
> Key: MESOS-2757
> URL: https://issues.apache.org/jira/browse/MESOS-2757
> Project: Mesos
> Issue Type: Improvement
> Components: libprocess, stout
> Reporter: Joris Van Remoortere
> Assignee: Benjamin Mahler
> Labels: c++11, option, stout, twitter
>
> Let's add operator overloads to Option<T> to allow access to the underlying T
> using the `->` operator.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)