//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11, c++14 // // ceil // template // time_point // ceil(const time_point& t); #include #include #include template void test(const FromDuration& df, const ToDuration& d) { typedef std::chrono::system_clock Clock; typedef std::chrono::time_point FromTimePoint; typedef std::chrono::time_point ToTimePoint; { FromTimePoint f(df); ToTimePoint t(d); typedef decltype(std::chrono::ceil(f)) R; static_assert((std::is_same::value), ""); assert(std::chrono::ceil(f) == t); } } template void test_constexpr () { typedef std::chrono::system_clock Clock; typedef std::chrono::time_point FromTimePoint; typedef std::chrono::time_point ToTimePoint; { constexpr FromTimePoint f{FromDuration{From}}; constexpr ToTimePoint t{ToDuration{To}}; static_assert(std::chrono::ceil(f) == t, ""); } } int main() { // 7290000ms is 2 hours, 1 minute, and 30 seconds test(std::chrono::milliseconds( 7290000), std::chrono::hours( 3)); test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2)); test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122)); test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-121)); // 9000000ms is 2 hours and 30 minutes test_constexpr (); test_constexpr (); test_constexpr (); test_constexpr (); test_constexpr (); test_constexpr (); }