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 "test_macros.h" 21 #include "../../rep.h" 22 23 template <class D, class R> 24 void test(R r)25test(R r) 26 { 27 D d(r); 28 assert(d.count() == r); 29 #if TEST_STD_VER >= 11 30 constexpr D d2(R(2)); 31 static_assert(d2.count() == 2, ""); 32 #endif 33 } 34 main()35int main() 36 { 37 test<std::chrono::duration<int> >(5); 38 test<std::chrono::duration<int, std::ratio<3, 2> > >(5); 39 test<std::chrono::duration<Rep, std::ratio<3, 2> > >(Rep(3)); 40 test<std::chrono::duration<double, std::ratio<2, 3> > >(5.5); 41 } 42