mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Park <mp...@apache.org>
Subject Re: Review Request 65515: Added rvalue reference Try::get overloads.
Date Mon, 12 Feb 2018 07:47:10 GMT

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/65515/#review197246
-----------------------------------------------------------




3rdparty/stout/include/stout/try.hpp
Lines 73-86 (original), 73-100 (patched)
<https://reviews.apache.org/r/65515/#comment277383>

    It seems like MSVC is not happy with `const_cast<T&&>(non-lvalue)`.
    These days, it's easier to use a templated helper to avoid the duplication.
    
    ```cpp
      T& get() & { return get(*this); }
      const T& get() const & { return get(*this); }
      T&& get() && { return get(std::move(*this)); }
      const T&& get() const && { return get(std::move(*this)); }
      
      template <typename Self>
      static auto get(Self&& self) -> decltype(std::forward<Self>(self).data.get())
      {
        if (!self.data.isSome()) {
          assert(self.error_.isSome());
          ABORT("Try::get() but state == ERROR: " + self.error_->message);
        }
        return std::forward<Self>(self).data.get();
      }
    ```


- Michael Park


On Feb. 5, 2018, 2:08 p.m., Benjamin Mahler wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/65515/
> -----------------------------------------------------------
> 
> (Updated Feb. 5, 2018, 2:08 p.m.)
> 
> 
> Review request for mesos and Michael Park.
> 
> 
> Bugs: MESOS-2664
>     https://issues.apache.org/jira/browse/MESOS-2664
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> See summary.
> 
> 
> Diffs
> -----
> 
>   3rdparty/stout/include/stout/try.hpp 90f8aed56ce5d77e70af9e516faad152083d1488 
> 
> 
> Diff: https://reviews.apache.org/r/65515/diff/1/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Benjamin Mahler
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message