--
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-proposal...@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/7b85d688-9013-407d-b7d3-10d28494e960%40isocpp.org.
--
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-proposal...@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/7b85d688-9013-407d-b7d3-10d28494e960%40isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbis2t0Dboe3%2BM23gS9i8zW4%2BLFWzM9PfTGmkiGUKEQ%2BBGQ%40mail.gmail.com.
--
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-proposal...@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/7b85d688-9013-407d-b7d3-10d28494e960%40isocpp.org.
I stepped into this too many times.One of the issues are the four < vs <= combinations.The way I solved is by creating a temporal object that allows chain comparison, and a cast-to-bool operator.if (chain(3) < x < 4)
On Friday, September 28, 2018 at 7:03:19 AM UTC-4, Daniel Gutson wrote:I stepped into this too many times.One of the issues are the four < vs <= combinations.The way I solved is by creating a temporal object that allows chain comparison, and a cast-to-bool operator.if (chain(3) < x < 4)So, something similar to the solution I provided? As I said, that solution would probably result in possible unnecessary comparisons (no logical short circuiting)
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b917d650-33b0-459d-bba0-c0f03bc4db8d%40isocpp.org.
El vie., 28 sept. 2018 11:26, Jack Adrian Zappa <adrian....@gmail.com> escribió:
On Friday, September 28, 2018 at 7:03:19 AM UTC-4, Daniel Gutson wrote:I stepped into this too many times.One of the issues are the four < vs <= combinations.The way I solved is by creating a temporal object that allows chain comparison, and a cast-to-bool operator.if (chain(3) < x < 4)So, something similar to the solution I provided? As I said, that solution would probably result in possible unnecessary comparisons (no logical short circuiting)No, the chain object contains a boolean and the last right hand operand as its only state. It should do nothing after the boolean becomes false.
On Friday, September 28, 2018 at 10:31:57 AM UTC-4, Daniel Gutson wrote:El vie., 28 sept. 2018 11:26, Jack Adrian Zappa <adrian....@gmail.com> escribió:
On Friday, September 28, 2018 at 7:03:19 AM UTC-4, Daniel Gutson wrote:I stepped into this too many times.One of the issues are the four < vs <= combinations.The way I solved is by creating a temporal object that allows chain comparison, and a cast-to-bool operator.if (chain(3) < x < 4)So, something similar to the solution I provided? As I said, that solution would probably result in possible unnecessary comparisons (no logical short circuiting)No, the chain object contains a boolean and the last right hand operand as its only state. It should do nothing after the boolean becomes false.Could you provide your solution? I'd be interested in finding out how you dealt with short circuiting.
Also, I take it that your solution wouldn't allow comparisons of different types such as a double and a float, or would it convert all objects to the type of first one chained?
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/52d6bd1b-4afb-4f16-adde-8ee8b5ba1041%40isocpp.org.
El vie., 28 de sep. de 2018 a la(s) 11:40, Adrian H (adrian....@gmail.com) escribió:
On Friday, September 28, 2018 at 10:31:57 AM UTC-4, Daniel Gutson wrote:El vie., 28 sept. 2018 11:26, Jack Adrian Zappa <adrian....@gmail.com> escribió:
On Friday, September 28, 2018 at 7:03:19 AM UTC-4, Daniel Gutson wrote:I stepped into this too many times.One of the issues are the four < vs <= combinations.The way I solved is by creating a temporal object that allows chain comparison, and a cast-to-bool operator.if (chain(3) < x < 4)So, something similar to the solution I provided? As I said, that solution would probably result in possible unnecessary comparisons (no logical short circuiting)No, the chain object contains a boolean and the last right hand operand as its only state. It should do nothing after the boolean becomes false.Could you provide your solution? I'd be interested in finding out how you dealt with short circuiting.Sure, I'm in a conference but I will do later.Also, I take it that your solution wouldn't allow comparisons of different types such as a double and a float, or would it convert all objects to the type of first one chained?Both the chain class and the comparison operators are templates. The result of the operator is a new (temporal) chain object with the template argument deduced. Let me provide the code later.
if (x & -100..100) { }
On Friday, September 28, 2018 at 10:53:35 AM UTC-4, Daniel Gutson wrote:El vie., 28 de sep. de 2018 a la(s) 11:40, Adrian H (adrian....@gmail.com) escribió:
On Friday, September 28, 2018 at 10:31:57 AM UTC-4, Daniel Gutson wrote:El vie., 28 sept. 2018 11:26, Jack Adrian Zappa <adrian....@gmail.com> escribió:
On Friday, September 28, 2018 at 7:03:19 AM UTC-4, Daniel Gutson wrote:I stepped into this too many times.One of the issues are the four < vs <= combinations.The way I solved is by creating a temporal object that allows chain comparison, and a cast-to-bool operator.if (chain(3) < x < 4)So, something similar to the solution I provided? As I said, that solution would probably result in possible unnecessary comparisons (no logical short circuiting)No, the chain object contains a boolean and the last right hand operand as its only state. It should do nothing after the boolean becomes false.Could you provide your solution? I'd be interested in finding out how you dealt with short circuiting.Sure, I'm in a conference but I will do later.Also, I take it that your solution wouldn't allow comparisons of different types such as a double and a float, or would it convert all objects to the type of first one chained?Both the chain class and the comparison operators are templates. The result of the operator is a new (temporal) chain object with the template argument deduced. Let me provide the code later.Cool. Still sounds very similar to what I posted:
#include <iostream>#include <type_traits>template<typename T>struct chain_impl {chain_impl(T&& obj, bool val) : obj(std::move(obj)), val(val) {}T&& obj;bool val;explicit operator bool() {return val;}};template<typename T>struct chain_impl<T&> {chain_impl(T& obj, bool val) : obj(obj), val(val) {}T& obj;bool val;explicit operator bool() {return val;}};template <typename T>decltype(auto) make_chain(T&& obj, bool val = true) {return chain_impl<std::conditional_t<std::is_lvalue_reference<T>::value, T&, T&&>>(std::forward<T>(obj), val);}template <typename T0, typename T1>auto operator< (chain_impl<T0>&& lhs, T1&& rhs) {if (lhs.val) {
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/bacc5cd9-230a-4865-858c-78566502cfef%40isocpp.org.
Wow. I take it back. The optimizer seems more than capable of removing all of the cruft. gcc 8.2 output:shows that there doesn't seem to be any boolean mid term storage and short circuiting does appear to be happening. I'm really impressed.Evan MS VC++ 2017 doesn't do too bad of a job. Though it does leave a bunch of unnecessary code in the binary, it doesn't actually execute it. https://godbolt.org/z/N58hN4Truly impressive. Seems that there is really no need for this feature after all.