mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Schwartzmeyer <and...@schwartzmeyer.com>
Subject Re: Review Request 64729: Templated operator overloads of `Duration`.
Date Fri, 12 Jan 2018 01:01:02 GMT

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

(Updated Jan. 11, 2018, 5:01 p.m.)


Review request for mesos, Greg Mann, Jie Yu, Joseph Wu, and Michael Park.


Changes
-------

Fixed implementation by templating the operators.


Summary (updated)
-----------------

Templated operator overloads of `Duration`.


Repository: mesos


Description (updated)
-------

Without this change, every use of `Duration * 2` throws a conversion
warning because we multiply `Duration` by `int` and `size_t` without
casting to `double`, and the operator overloads were all accepting only
doubles.

By templating them on `typename T`, we gain two benefits: no conversion
warnings are emitted because an `int64_t` can be safely multiplied by
any arithemetic type without casting, and when multiplying by integral
types, we are no longer subject to potential FPE introduced by casting
to a `double`. It is safe to simply template on `typename T` without
checking if it is an arithmetic type, as the compiler will only generate
a template if `double nanos * T multiplier` is valid.


Diffs (updated)
-----

  3rdparty/stout/include/stout/duration.hpp d10b6a4d4d1a0096334c30fdec725ecc55c9f0ea 


Diff: https://reviews.apache.org/r/64729/diff/4/

Changes: https://reviews.apache.org/r/64729/diff/3-4/


Testing
-------


Thanks,

Andrew Schwartzmeyer


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