You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Jie Yu <yu...@gmail.com> on 2017/10/30 14:27:23 UTC

Review Request 63410: Added a general hash function for Option.

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

Review request for mesos and Benjamin Bannier.


Repository: mesos


Description
-------

Added a general hash function for Option<T>.


Diffs
-----

  3rdparty/stout/include/stout/option.hpp 0ff6a857b737e893df4516807de50d2ed958b2ae 
  3rdparty/stout/tests/option_tests.cpp 73b03b097d24da9063eb7ce45d33a7dc411f653d 


Diff: https://reviews.apache.org/r/63410/diff/1/


Testing
-------

make check


Thanks,

Jie Yu


Re: Review Request 63410: Added a general hash function for Option.

Posted by Benjamin Bannier <bb...@apache.org>.

> On Oct. 30, 2017, 3:39 p.m., Benjamin Bannier wrote:
> > 3rdparty/stout/include/stout/option.hpp
> > Lines 233-234 (patched)
> > <https://reviews.apache.org/r/63410/diff/1/?file=1872635#file1872635line233>
> >
> >     I believe we can simplify this since `boost::hash_combine` is already templated on the type of the second argument and will call the correct hash function automatically,
> >     
> >         boost::hash_combine(seed, option.get());

I am dropping this since `boost::hash_combine` does not invoke `std::hash<T>`, but instead `boost::hash_value<T>`. That means that that while it works for types Boost knows about (e.g., `int` in your test), it does not work for custom types introduced by us.


- Benjamin


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


On Oct. 30, 2017, 3:27 p.m., Jie Yu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/63410/
> -----------------------------------------------------------
> 
> (Updated Oct. 30, 2017, 3:27 p.m.)
> 
> 
> Review request for mesos and Benjamin Bannier.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Added a general hash function for Option<T>.
> 
> 
> Diffs
> -----
> 
>   3rdparty/stout/include/stout/option.hpp 0ff6a857b737e893df4516807de50d2ed958b2ae 
>   3rdparty/stout/tests/option_tests.cpp 73b03b097d24da9063eb7ce45d33a7dc411f653d 
> 
> 
> Diff: https://reviews.apache.org/r/63410/diff/1/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jie Yu
> 
>


Re: Review Request 63410: Added a general hash function for Option.

Posted by Benjamin Bannier <bb...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/63410/#review189574
-----------------------------------------------------------


Fix it, then Ship it!





3rdparty/stout/include/stout/option.hpp
Line 19 (original), 19 (patched)
<https://reviews.apache.org/r/63410/#comment266727>

    Let's include `functional` for `std::hash` here.



3rdparty/stout/include/stout/option.hpp
Lines 233-234 (patched)
<https://reviews.apache.org/r/63410/#comment266729>

    I believe we can simplify this since `boost::hash_combine` is already templated on the type of the second argument and will call the correct hash function automatically,
    
        boost::hash_combine(seed, option.get());


- Benjamin Bannier


On Oct. 30, 2017, 3:27 p.m., Jie Yu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/63410/
> -----------------------------------------------------------
> 
> (Updated Oct. 30, 2017, 3:27 p.m.)
> 
> 
> Review request for mesos and Benjamin Bannier.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Added a general hash function for Option<T>.
> 
> 
> Diffs
> -----
> 
>   3rdparty/stout/include/stout/option.hpp 0ff6a857b737e893df4516807de50d2ed958b2ae 
>   3rdparty/stout/tests/option_tests.cpp 73b03b097d24da9063eb7ce45d33a7dc411f653d 
> 
> 
> Diff: https://reviews.apache.org/r/63410/diff/1/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jie Yu
> 
>