1 // { dg-options "-std=gnu++0x" }
2 // { dg-require-cstdint "" }
4 // Copyright (C) 2008-2013 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // 20.8.3 Class template duration [time.duration]
24 #include <type_traits>
25 #include <testsuite_hooks.h>
36 type_emulator(const type_emulator
& e
)
40 operator*=(type_emulator a
)
47 operator+=(type_emulator a
)
61 operator==(type_emulator
<T
> a
, type_emulator
<T
> b
)
62 { return a
.i
== b
.i
; }
66 operator<(type_emulator
<T
> a
, type_emulator
<T
> b
)
71 operator+(type_emulator
<T
> a
, type_emulator
<T
> b
)
76 operator*(type_emulator
<T
> a
, type_emulator
<T
> b
)
81 template<typename T
, typename U
>
82 struct common_type
<type_emulator
<T
>, U
>
83 { typedef typename common_type
<T
,U
>::type type
; };
85 template<typename T
, typename U
>
86 struct common_type
<U
, type_emulator
<T
>>
87 { typedef typename common_type
<U
,T
>::type type
; };
89 template<typename T
, typename U
>
90 struct common_type
<type_emulator
<T
>, type_emulator
<U
>>
91 { typedef typename common_type
<T
,U
>::type type
; };
96 struct treat_as_floating_point
<type_emulator
<T
>>
97 : is_floating_point
<T
>
102 typedef type_emulator
<int> int_emulator
;
103 typedef type_emulator
<double> dbl_emulator
;
105 // 20.8.3.1 duration constructors [time.duration.cons]
109 bool test
__attribute__((unused
)) = true;
110 using std::chrono::duration
;
114 VERIFY(d1
.count() == static_cast<duration
<int>::rep
>(r
));
117 duration
<double> d2(s
);
118 VERIFY(d2
.count() == static_cast<duration
<double>::rep
>(s
));
121 duration
<int_emulator
> d3(ie
);
122 VERIFY(d3
.count() == static_cast<duration
<int_emulator
>::rep
>(ie
));
124 dbl_emulator
de(4.0);
125 duration
<dbl_emulator
> d4(de
);
126 VERIFY(d4
.count() == static_cast<duration
<dbl_emulator
>::rep
>(de
));