1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <chrono>
20 
21 #if defined(_WIN32)
22 // We don't have C++14 on Windows yet.
23 // Reimplement std::chrono_literals ourselves until we do.
24 
25 // Silence the following warning (which gets promoted to an error):
26 // error: literal operator suffixes not preceded by ‘_’ are reserved for future standardization
27 #pragma GCC system_header
28 
29 constexpr std::chrono::seconds operator"" s(unsigned long long s) {
30     return std::chrono::seconds(s);
31 }
32 
33 constexpr std::chrono::duration<long double> operator"" s(long double s) {
34     return std::chrono::duration<long double>(s);
35 }
36 
37 constexpr std::chrono::milliseconds operator"" ms(unsigned long long ms) {
38     return std::chrono::milliseconds(ms);
39 }
40 
41 constexpr std::chrono::duration<long double, std::milli> operator"" ms(long double ms) {
42     return std::chrono::duration<long double, std::milli>(ms);
43 }
44 #else
45 using namespace std::chrono_literals;
46 #endif
47