Home | History | Annotate | Download | only in time.duration.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 // duration
     13 
     14 // template <class Rep2>
     15 //   explicit duration(const Rep2& r);
     16 
     17 #include <chrono>
     18 #include <cassert>
     19 
     20 #include "../../rep.h"
     21 
     22 template <class D, class R>
     23 void
     24 test(R r)
     25 {
     26     D d(r);
     27     assert(d.count() == r);
     28 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
     29     constexpr D d2(R(2));
     30     static_assert(d2.count() == 2, "");
     31 #endif
     32 }
     33 
     34 int main()
     35 {
     36     test<std::chrono::duration<int> >(5);
     37     test<std::chrono::duration<int, std::ratio<3, 2> > >(5);
     38     test<std::chrono::duration<Rep, std::ratio<3, 2> > >(Rep(3));
     39     test<std::chrono::duration<double, std::ratio<2, 3> > >(5.5);
     40 }
     41