-
Notifications
You must be signed in to change notification settings - Fork 8
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
Replace Boolean with convertible_to<bool> #389
Comments
That breaks the use of (non-scoped) enums as booleans. Does that matter? |
Assigning to myself... |
This can be implemented with something like |
Would also outlaw using |
Have you used that idiom, or seen others using it? |
I recall reading that someone proposed having |
The following namespace detail {
template <class B>
constexpr bool boolean_v =
std::is_integral<B>::value || std::is_enum<B>::value;
template <MoveConstructible B>
requires requires(const B& b) { b.operator bool(); }
constexpr bool boolean_v<B> = true;
struct implicit_bool {
implicit_bool(bool);
};
}
template <class B>
concept bool Boolean =
detail::boolean_v<decay_t<B>> &&
requires (const decay_t<B> b) {
{ b } -> detail::implicit_bool;
}; Thoughts? EDIT: I observe that just because a class type provides |
Doesn't that still allow
|
Yup. |
This is why we have the boolean expression grammar that is the current formulation of Note that the current (#155) formulation is still underconstrained in that it only specifies the behavior of a single model of template<Range Rng1, Range Rng2>
bool f(Rng1&& rng1, Rng2&& rng2) {
return begin(rng1) == end(rng1) && begin(rng2) == end(rng2);
} where the |
Maybe I'm just chicken, but this (changing |
🐔! Serious response: We don't really have an idea of the impact this will have on existing codebases that want to transition to Ranges. One way to get that idea would be to put it into the TS. A better way might be to leave the TS alone and survey users and implementers: "What impact would it have on your Ranges code if <blank happens>?" |
So, leave |
Strengthening requirements means implementors of models have to do more work (do I meet the tighter requirements?). Weakening requirements means users of models have to do more work (are the weaker guarantees sufficient for my usage?). My hunch is that there will be more users than implementors of That said, our historical response to this kind of dilemma is to screw things down as tightly as possible: I'd almost prefer to require exactly |
I'm way too 🐔 for that. I want Ranges TS to ship in Toronto. I can just imagine the long faces we would get if we brought forward a proposal to change |
Yip. I afraid that if we slip another meeting we'll start to hear "you should rebase on C++17!" Given my belief that there's no reasonable middle ground between |
Yes, please. However, going off N4651, it appears to me that What is the motivation for changing |
(We're up to N4671 as of this week's pre-meeting mailing, FYI - there are only a few editorial differences.) Yes, those are observations both correct.
and that those prices buy us flexibility that mostly will not be used. I made a comment in Kona to the effect that I'm reasonably certain that Changing |
It's not at all obvious to me that these are desirable, since it would exclude a |
I'd like to suggest another tact here. Probably my biggest problem with If we bring forward such a suggestion, it would be nice to have some numbers about if/how much it improves compile times. |
LEWG voted in Cologne to replace |
I would characterize this as LEWG providing encouragement to bring a proposal to make such a change; this phrasing suggests that LEWG has approved making the change which they of course cannot without a proposal. |
From LWG Kona review of #155.
Boolean
is an enormously complicated hunk of specification for what is essentially intended to allow people to return integers from comparison operators in addition tobool
. LWG made the suggestion to simply defineBoolean
as:which achieves the same goal with two lines of spec. At the very least, it's a reasonable idea to apply this simplification for the TS and see if anyone complains.
Proposed Resolution
See P1934.
The text was updated successfully, but these errors were encountered: