--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1fea07df-46a6-4df2-865a-849be8f8d129%40isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkUmThSamFisncxMCaqFd6Ze7GWH-q%2BTjMn4YfFTn2T8%2Bw%40mail.gmail.com.
> Also that inverted logic has a high chance of confusing anyone who comesI don't know precisely what you mean by "inverted" logic
> across it, and it some cases, it is not even clear which or operator you
> choose.
>
> var = var || allocate();
>
> If allocate doesn't return a pointer, but a boolean (or due to a refactor
> it changes) then the expression above would no longer do the right thing:
> assign 1 to var if either expression is true, which is not expected.
, but I don't agree that it would necessarily confuse anyone who comes across it - it would just be unfamiliar syntax, which they would look up. It's true that the expression would compile regardless of whether allocate() returns a bool or a pointer, which could cause a surprising bug due to implicit pointer-to-bool conversion, but I don't feel like that's very likely, or that it would be very likely that a refactor would cause a problem there either. Specifically if your allocate() is changed from returning a pointer to returning a bool during a refactor, its signature would change in other ways that would cause a compile error there, i.e. taking a reference to the pointer to allocate as an argument instead of returning it.
Jefferson Carpenter
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/05da71c2-80cf-63dd-b2c6-8cd342db5140%40gmail.com.
#define OR_ELSE(v, e) ([&](auto MACRO_OR_ELSE_VALUE_X){ return (MACRO_OR_ELSE_VALUE_X ? MACRO_OR_ELSE_VALUE_X : (e)); }(v))
auto z = h() ? OR_ELSE(OR_ELSE(x, foo()), bar()) : zz();
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c7cd5d95-0031-4e50-b7a1-9adcff695bd2%40isocpp.org.
I am a little surprised and dismayed at the eagerness to resort to macros.We can already safely overload operators with a custom generator type. No need for macros, language extensions or any other magic.live demonstration: http://coliru.stacked-crooked.com/a/bc751df610a220ce
Cheers,
Miguel
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANiq72kNstxnyLTCOBfNorEiyudTijCAUHwH4DsoT14WqcNs4w%40mail.gmail.com.
But my point was we *already have* an operator with the exact semantics of the macro above - it's just a gnu extension. We could just propose that!x = x?:new int;It's unambiguous, it's obvious it's a conditional, it's a one-liner, and more importantly, it can be used for way more than just pointers. Oh, and we have implementations and knowledge of how it behaves, and it's also not a weird new form of || or |.It also fails to compile if "x" and the expression if x is falsy don't have a common type, which is *also* important.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.