We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4159905 commit 8060dc4Copy full SHA for 8060dc4
include/cpp2util.h
@@ -2307,8 +2307,15 @@ class range
2307
, last{ l }
2308
{
2309
// Represent all ranges as half-open; after this we can forget the flag
2310
- if (include_last) {
2311
- ++last;
+ if (include_last) {
+ if constexpr (std::integral<TT>) {
2312
+ if (last == std::numeric_limits<TT>::max()) {
2313
+ throw std::runtime_error(
2314
+ "range with last == numeric_limits<T>::max() will "
2315
+ "overflow");
2316
+ }
2317
2318
+ ++last;
2319
}
2320
2321
0 commit comments