Date: Sat, 4 Jan 2020 14:45:51 +0000
Dear all
First time reporting something, and no idea if this is the appropriate way to do it.
I was playing around with the three-way comparison (spaceship) operator and was surprised when this failed to compile with MSVC:
int x{2};
int y{2};
auto s = x <=> y;
s == std::strong_ordering::equal; // compile failure
VC++ does not define the overload in <compare> for:
operator==(strong_ordering, strong_ordering);
I checked the standard library document and it is not defined, so VC++ is within its right to ignore it and be confirming:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0768r1.pdf
However, gcc does define it:
https://github.com/wezrule/gcc/blob/master/libstdc%2B%2B-v3/libsupc%2B%2B/compare#L299
So this compiles with gcc and not MSVC:
https://godbolt.org/z/uRLimE
I wonder if it should be added as an alternative to comparing with 0, gcc (libstdc++) saw value in adding it and it would be good to not have yet more inconsistencies in c++ implementations.
Cheers,
Wesley
First time reporting something, and no idea if this is the appropriate way to do it.
I was playing around with the three-way comparison (spaceship) operator and was surprised when this failed to compile with MSVC:
int x{2};
int y{2};
auto s = x <=> y;
s == std::strong_ordering::equal; // compile failure
VC++ does not define the overload in <compare> for:
operator==(strong_ordering, strong_ordering);
I checked the standard library document and it is not defined, so VC++ is within its right to ignore it and be confirming:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0768r1.pdf
However, gcc does define it:
https://github.com/wezrule/gcc/blob/master/libstdc%2B%2B-v3/libsupc%2B%2B/compare#L299
So this compiles with gcc and not MSVC:
https://godbolt.org/z/uRLimE
I wonder if it should be added as an alternative to comparing with 0, gcc (libstdc++) saw value in adding it and it would be good to not have yet more inconsistencies in c++ implementations.
Cheers,
Wesley
Received on 2020-01-04 08:48:22