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

Enable floating point ranges #1776

Merged
merged 2 commits into from
Oct 27, 2019

Conversation

mvd4
Copy link

@mvd4 mvd4 commented Oct 16, 2019

Description

The generator helper range(start, end, step) currently only supports integer ranges.
This seems to be an artificial limitation, as the underlying RangeGenerator<T> works fine also for floating point types.

This PR changes the static_assert that limits the types for range(start, end, step) to also support floating point types. It also introduces additional tests to cover the extended functionality.

@codecov
Copy link

codecov bot commented Oct 16, 2019

Codecov Report

Merging #1776 into master will decrease coverage by 2.11%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #1776      +/-   ##
==========================================
- Coverage   87.97%   85.86%   -2.11%     
==========================================
  Files         138      131       -7     
  Lines        5468     3754    -1714     
==========================================
- Hits         4810     3223    -1587     
+ Misses        658      531     -127

@horenmar
Copy link
Member

Actually it does not support floating point numbers intentionally. The original PR had no limits on the generator, but I wanted to avoid bug reports from people who'd use the generator for floating point numbers, without taking proper care of edge conditions caused by floating point rounding.

This is incidentally also why the static assert is placed in the helper function and not in the generator class itself -- it allows advanced users to create the generator manually if needed.


I'll think about lifting the restriction.

@horenmar horenmar added the Tweak label Oct 20, 2019
@horenmar horenmar force-pushed the bugfix/enable-floating-point-ranges branch from 204595b to 6a08225 Compare October 26, 2019 18:53
@horenmar horenmar merged commit 9a55817 into catchorg:master Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants