• Adam Simpkins's avatar
    implement to() conversions for std::chrono to timespec/timeval · dc91b004
    Adam Simpkins authored
    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
    dc91b004
CMakeLists.txt 25.7 KB