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

diffmax_t type does not satisfy the standards's "integer-class" requirements #1774

Open
gnaggnoyil opened this issue Apr 19, 2023 · 0 comments

Comments

@gnaggnoyil
Copy link

[iterator.concept.winc]#3 requires an integer-class type to be able to represent values either from $−2^{N−1}$ to $2^{N−1}−1$ or from 0 to $2^N-1$:

The range of representable values of an integer-class type is the continuous set of values over which it is defined. For any integer-class type, its range of representable values is either $−2^{N−1}$ to $2^{N−1}−1$ (inclusive) for some integer N, in which case it is a signed-integer-class type, or 0 to $2^N-1$ (inclusive) for some integer N, in which case it is an unsigned-integer-class type.

However, the following code:

#include <limits>
#include <iostream>
#include <cstdint>
#include <range/v3/all.hpp>

int main(){
    auto r = ranges::cpp20::views::iota(std::uintmax_t(0), std::uintmax_t(1));
    using t = ranges::cpp20::range_difference_t<decltype(r)>;
    std::cout << std::numeric_limits<t>::min() << ' ';
    std::cout << std::numeric_limits<t>::max() << std::endl;
    return 0;
}

gives the output -18446744073709551615 18446744073709551615 on compiler explorer, which doesn't fit the above requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant