45 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <chrono>10 11// time_point12 13// explicit time_point(const duration& d);14 15#include <chrono>16#include <cassert>17 18#include "test_macros.h"19 20int main(int, char**)21{22 typedef std::chrono::system_clock Clock;23 typedef std::chrono::milliseconds Duration;24 {25 std::chrono::time_point<Clock, Duration> t(Duration(3));26 assert(t.time_since_epoch() == Duration(3));27 }28 {29 std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));30 assert(t.time_since_epoch() == Duration(3000));31 }32#if TEST_STD_VER > 1133 {34 constexpr std::chrono::time_point<Clock, Duration> t(Duration(3));35 static_assert(t.time_since_epoch() == Duration(3), "");36 }37 {38 constexpr std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));39 static_assert(t.time_since_epoch() == Duration(3000), "");40 }41#endif42 43 return 0;44}45