Replace non-constexpr decrement in std::chrono::floor
* include/std/chrono (floor): Replace non-constexpr operation. * testsuite/20_util/duration_cast/rounding.cc: Test conversion to durations with floating pointer representations. From-SVN: r241122
This commit is contained in:
parent
4d0cdd0ce6
commit
0c0d2a4cf0
@ -1,5 +1,9 @@
|
||||
2016-10-13 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
* include/std/chrono (floor): Replace non-constexpr operation.
|
||||
* testsuite/20_util/duration_cast/rounding.cc: Test conversion to
|
||||
durations with floating pointer representations.
|
||||
|
||||
* src/c++11/compatibility-thread-c++0x.cc (_Bind_simple)
|
||||
(_Bind_simple_helper, __bind_simple): Restore for ABI compat symbols.
|
||||
|
||||
|
@ -224,7 +224,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
|
||||
{
|
||||
auto __to = chrono::duration_cast<_ToDur>(__d);
|
||||
if (__to > __d)
|
||||
--__to;
|
||||
return __to - _ToDur{1};
|
||||
return __to;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@
|
||||
using namespace std::chrono_literals;
|
||||
using std::chrono::seconds;
|
||||
|
||||
using fp_seconds = std::chrono::duration<float>;
|
||||
|
||||
static_assert( std::chrono::floor<seconds>(1000ms) == 1s );
|
||||
static_assert( std::chrono::floor<seconds>(1001ms) == 1s );
|
||||
static_assert( std::chrono::floor<seconds>(1500ms) == 1s );
|
||||
@ -34,6 +36,7 @@ static_assert( std::chrono::floor<seconds>(1999ms) == 1s );
|
||||
static_assert( std::chrono::floor<seconds>(2000ms) == 2s );
|
||||
static_assert( std::chrono::floor<seconds>(2001ms) == 2s );
|
||||
static_assert( std::chrono::floor<seconds>(2500ms) == 2s );
|
||||
static_assert( std::chrono::floor<fp_seconds>(500ms) == fp_seconds{0.5f} );
|
||||
|
||||
static_assert( std::chrono::ceil<seconds>(1000ms) == 1s );
|
||||
static_assert( std::chrono::ceil<seconds>(1001ms) == 2s );
|
||||
@ -42,6 +45,7 @@ static_assert( std::chrono::ceil<seconds>(1999ms) == 2s );
|
||||
static_assert( std::chrono::ceil<seconds>(2000ms) == 2s );
|
||||
static_assert( std::chrono::ceil<seconds>(2001ms) == 3s );
|
||||
static_assert( std::chrono::ceil<seconds>(2500ms) == 3s );
|
||||
static_assert( std::chrono::ceil<fp_seconds>(500ms) == fp_seconds{0.5f} );
|
||||
|
||||
static_assert( std::chrono::round<seconds>(1000ms) == 1s );
|
||||
static_assert( std::chrono::round<seconds>(1001ms) == 1s );
|
||||
|
Loading…
Reference in New Issue
Block a user