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 41593: stout: Added `jsonify` function.
Date Mon, 04 Jan 2016 19:21:45 GMT


> On Dec. 22, 2015, 4:52 a.m., Benjamin Hindman wrote:
> > 3rdparty/libprocess/3rdparty/stout/include/stout/jsonify.hpp, lines 58-63
> > <https://reviews.apache.org/r/41593/diff/2/?file=1173648#file1173648line58>
> >
> >     An implicit cast operator that is non-const is always code smell because the
compiler is what is often implicitly invoking the function! In this case I know why it's safe
for you to do this, but anyone else reading the code would have no idea. It would be great
to have a comment here which explains why it's safe to `std::move(*this)`, otherwise, this
looks dangerous!
> >     
> >     Also, if anyone ever changes this implementation is there anyway to check this
invariant that you have so that they make sure they change this code too?
> 
> Michael Park wrote:
>     Right. I initially had rvalue ref-qualifier on this operator like this `operator
std::string() && { ... }`, which makes it so that it is only invocable on a rvalue
`JsonifyProxy`. I took it out because I thought maybe it would have been controversial reactions
towards it.
>     
>     How about we just call `write_` directly instead? It would have been nice to leverage
`operator<<` but without the ref-qualifier it's not quite accurate.
>     
>     ```cpp
>     operator std::string() const {
>       std::ostringstream stream;
>       that.write_(&stream);
>       return stream.str();
>     }
>     ```
>     
>     What do you think?

Synced with BenH offline, we agreed to introduce the ref-qualifiers.


- Michael


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


On Jan. 4, 2016, 7:14 p.m., Michael Park wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/41593/
> -----------------------------------------------------------
> 
> (Updated Jan. 4, 2016, 7:14 p.m.)
> 
> 
> Review request for mesos and Benjamin Hindman.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> See summary.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/3rdparty/stout/README.md a2a3dc6120b10c8fe82088b9f0ebecfa5642f945

>   3rdparty/libprocess/3rdparty/stout/include/Makefile.am b2dea9b93adfa3ea0415a0b5c81a369dd29b6cfe

>   3rdparty/libprocess/3rdparty/stout/include/stout/jsonify.hpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/41593/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Michael Park
> 
>


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