diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-07-19 18:18:46 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-07-19 23:42:56 +0100 |
commit | 2d614822e9ea2a3d8800045d66e3220743753d09 (patch) | |
tree | f74a1e102751408cacbe0bcf20f90ec5a1196b7c /libgcc | |
parent | e92ca8d3b4cab96a9f79466b5158381cb3103f9d (diff) | |
download | gcc-2d614822e9ea2a3d8800045d66e3220743753d09.zip gcc-2d614822e9ea2a3d8800045d66e3220743753d09.tar.gz gcc-2d614822e9ea2a3d8800045d66e3220743753d09.tar.bz2 |
libstdc++: Check for std::ratio in arithmetic and comparisons [PR110593]
The standard says that it should be ill-formed to use std::ratio_equal
etc. with types which are not specializations of std::ratio. This
implements that requirement.
We don't need to add assertions to every one of the class templates,
because many of them are implemented in terms of other ones. For
example, ratio_divide and ratio_subtract can rely on the assertions in
ratio_multiply and ratio_add respectively.
libstdc++-v3/ChangeLog:
PR libstdc++/110593
* include/bits/chrono.h (duration): Improve static assert
messages.
(__is_ratio): Move to ...
* include/std/ratio (__is_ratio): ... here.
(__is_ratio_v): New variable template and partial
specialization.
(__are_both_ratios): New function template.
(__ratio_multiply, ratio_equal, ratio_less, __ratio_add):
Add static assertion.
* testsuite/20_util/ratio/requirements/type_constraints.cc:
New test.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc:
Adjust expected error.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc:
Likewise.
Diffstat (limited to 'libgcc')
0 files changed, 0 insertions, 0 deletions