diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-08-14 13:55:21 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-08-14 13:55:21 +0000 |
commit | ac2c0bc968bbca3f8f5ce578c78bf68b0c4c5566 (patch) | |
tree | 73ab593a4e17d4e3788e88432c865af86da6a8ef | |
parent | a64e72607dcb77cf7e923100cc6c71651e2da433 (diff) |
Simplify overflow checks in duration literalslinaro-local/tested/gnu-master
* include/std/chrono (__check_overflow): Simplify definition.
(_Checked_integral_constant): Remove.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263537 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libstdc++-v3/ChangeLog | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/std/chrono | 18 |
2 files changed, 7 insertions, 14 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 15ff3db6134..cf69f216072 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,8 @@ 2018-08-14 Jonathan Wakely <jwakely@redhat.com> + * include/std/chrono (__check_overflow): Simplify definition. + (_Checked_integral_constant): Remove. + PR libstdc++/86846 * src/c++17/default_resource.h: New file, defining default_res. * src/c++17/memory_resource.cc [ATOMIC_POINTER_LOCK_FREE != 2] diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index da03fdccce4..871c896144a 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -900,24 +900,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wliteral-suffix" - template<typename _Rep, unsigned long long _Val> - struct _Checked_integral_constant - : integral_constant<_Rep, static_cast<_Rep>(_Val)> - { - static_assert(_Checked_integral_constant::value >= 0 - && _Checked_integral_constant::value == _Val, - "literal value cannot be represented by duration type"); - }; - template<typename _Dur, char... _Digits> constexpr _Dur __check_overflow() { using _Val = __parse_int::_Parse_int<_Digits...>; - using _Rep = typename _Dur::rep; - // TODO: should be simply integral_constant<_Rep, _Val::value> - // but GCC doesn't reject narrowing conversions to _Rep. - using _CheckedVal = _Checked_integral_constant<_Rep, _Val::value>; - return _Dur{_CheckedVal::value}; + constexpr typename _Dur::rep __repval = _Val::value; + static_assert(__repval >= 0 && __repval == _Val::value, + "literal value cannot be represented by duration type"); + return _Dur(__repval); } constexpr chrono::duration<long double, ratio<3600,1>> |