Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<chrono>: Need more robust handling of custom arithmetic types #1909

Open
mnatsuhara opened this issue May 4, 2021 · 1 comment
Open

<chrono>: Need more robust handling of custom arithmetic types #1909

mnatsuhara opened this issue May 4, 2021 · 1 comment
Labels
bug Something isn't working chrono C++20 chrono

Comments

@mnatsuhara
Copy link
Contributor

Observed by @statementreply.

In general, we currently do not robustly handle custom arithmetic-like types. Note that we expect this use case to be very uncommon, so this is not a high-priority bug.

Until this is completely addressed, we should make sure to at least fail cleanly if custom arithmetic-like types are used. As an example, we currently use _STD nextafter on a duration::rep that could potentially be a custom arithmetic-like type, in which case it would fail cleanly.

STL/stl/inc/chrono

Lines 3243 to 3246 in 65eb507

} else {
const auto _Leap_sec_begin = _CHRONO ceil<_CommonType>(_Leap_sec_minus_one + seconds{1});
_Ticks = _CommonType{_STD nextafter(_Leap_sec_begin.count(), typename _CommonType::rep{0})};
}

@mnatsuhara mnatsuhara added bug Something isn't working chrono C++20 chrono labels May 4, 2021
@CaseyCarter
Copy link
Contributor

I'm not sure there's much we can do until the Standard clarifies what the handwavy "a class emulating an arithmetic type" is supposed to mean and how the Standard Library is supposed to interact with such a thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working chrono C++20 chrono
Projects
None yet
Development

No branches or pull requests

2 participants