Home | History | Annotate | Download | only in time.point.cons
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <chrono>
     11 
     12 // time_point
     13 
     14 // explicit time_point(const duration& d);
     15 
     16 #include <chrono>
     17 #include <cassert>
     18 
     19 #include "test_macros.h"
     20 
     21 int main()
     22 {
     23     typedef std::chrono::system_clock Clock;
     24     typedef std::chrono::milliseconds Duration;
     25     {
     26     std::chrono::time_point<Clock, Duration> t(Duration(3));
     27     assert(t.time_since_epoch() == Duration(3));
     28     }
     29     {
     30     std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
     31     assert(t.time_since_epoch() == Duration(3000));
     32     }
     33 #if TEST_STD_VER > 11
     34     {
     35     constexpr std::chrono::time_point<Clock, Duration> t(Duration(3));
     36     static_assert(t.time_since_epoch() == Duration(3), "");
     37     }
     38     {
     39     constexpr std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
     40     static_assert(t.time_since_epoch() == Duration(3000), "");
     41     }
     42 #endif
     43 }
     44