diff options
Diffstat (limited to 'libstdc++-v3/include/std/chrono')
-rw-r--r-- | libstdc++-v3/include/std/chrono | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index 6d9df7d7dda..f4c4ef017e6 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -39,6 +39,7 @@ #include <type_traits> #include <limits> #include <ctime> +#include <bits/parse_numbers.h> // for literals support. #ifdef _GLIBCXX_USE_C99_STDINT_TR1 @@ -786,4 +787,136 @@ _GLIBCXX_END_NAMESPACE_VERSION #endif // C++11 +#if __cplusplus > 201103L + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +inline namespace literals { +inline namespace chrono_literals { + + namespace __detail { + + using namespace __parse_int; + + template<unsigned long long _Val, typename _Dur> + struct _Select_type + : conditional< + _Val <= static_cast<unsigned long long> + (numeric_limits<typename _Dur::rep>::max()), + _Dur, void> + { + static constexpr typename _Select_type::type + value{static_cast<typename _Select_type::type>(_Val)}; + }; + + template<unsigned long long _Val, typename _Dur> + constexpr typename _Select_type<_Val, _Dur>::type + _Select_type<_Val, _Dur>::value; + + } // __detail + + inline constexpr chrono::duration<long double, ratio<3600,1>> + operator"" h(long double __hours) + { return chrono::duration<long double, ratio<3600,1>>{__hours}; } + + template <char... _Digits> + inline constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::hours>::type + operator"" h() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::hours>::value; + } + + inline constexpr chrono::duration<long double, ratio<60,1>> + operator"" min(long double __mins) + { return chrono::duration<long double, ratio<60,1>>{__mins}; } + + template <char... _Digits> + inline constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::minutes>::type + operator"" min() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::minutes>::value; + } + + inline constexpr chrono::duration<long double> + operator"" s(long double __secs) + { return chrono::duration<long double>{__secs}; } + + template <char... _Digits> + inline constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::seconds>::type + operator"" s() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::seconds>::value; + } + + inline constexpr chrono::duration<long double, milli> + operator"" ms(long double __msecs) + { return chrono::duration<long double, milli>{__msecs}; } + + template <char... _Digits> + inline constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::milliseconds>::type + operator"" ms() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::milliseconds>::value; + } + + inline constexpr chrono::duration<long double, micro> + operator"" us(long double __usecs) + { return chrono::duration<long double, micro>{__usecs}; } + + template <char... _Digits> + inline constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::microseconds>::type + operator"" us() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::microseconds>::value; + } + + inline constexpr chrono::duration<long double, nano> + operator"" ns(long double __nsecs) + { return chrono::duration<long double, nano>{__nsecs}; } + + template <char... _Digits> + inline constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::nanoseconds>::type + operator"" ns() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::nanoseconds>::value; + } + +} // inline namespace chrono_literals +} // inline namespace literals + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif //_GLIBCXX_USE_C99_STDINT_TR1 + +#endif // __cplusplus > 201103L + #endif //_GLIBCXX_CHRONO |