implement to() conversions for std::chrono to timespec/timeval
authorAdam Simpkins <simpkins@fb.com>
Sun, 19 Nov 2017 23:14:20 +0000 (15:14 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sun, 19 Nov 2017 23:31:10 +0000 (15:31 -0800)
commitdc91b004d384ba57887b38d4668845bffee0ba08
tree9744ee493e281ff0e61eaa53781ae5a63216a4a4
parentaa7f8dcd47b82f753862919d3456a961b30c0ab4
implement to() conversions for std::chrono to timespec/timeval

Summary:
Add folly::to() conversions to convert between std::chrono::duration or
std::chrono::time_point types and struct timespec or struct timeval types.

To conform to the behavior of the existing arithmetic-to-arithmetic
conversions, this code performs proper overflow checking and throws a
`ConversionError` on overflow.  This unfortunately does make the code rather
complicated compared to a non-checking implementation.

Conversions between some unusual duration types is not implemented yet, and
will fail at compile time if someone tries to use it.  This happens for
durations where neither the numerator nor the denominator of the ratio is 1.
For instance, 7/13ths of a second.

Reviewed By: yfeldblum

Differential Revision: D6356700

fbshipit-source-id: 9dce8ab8f32d8c18089f32c7176a8abf3c3f11f7
CMakeLists.txt
folly/Makefile.am
folly/chrono/Conv.h [new file with mode: 0644]
folly/chrono/test/ConvTest.cpp [new file with mode: 0644]
folly/chrono/test/Makefile.am [new file with mode: 0644]
folly/configure.ac