rep.pass.cpp revision 473f838128bcf118ab50d08a65a83433ed1b015a
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
22template <class D, class R>
23void
24test(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
34int 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