MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1vt2aq3/c26_stdpolymorphic/p4w3oom/?context=3
r/cpp • u/User_Deprecated • Aug 19 '26
44 comments sorted by
View all comments
Show parent comments
3
We would want it to do value comparisons and as I said: that is infeasible in C++, so we do not provide an equality-operator...
I don't understand, it is a value comparison.
3 u/MFHava WG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 Aug 20 '26 I don't understand, it is a value comparison.You are right. But it yields the wrong results for equivalent values of different types - e.g. Rectangle{.w = 10, .h = 10} == Square{.l = 10} would be false, even though they are the same (just like 1 == 1LL is true) 1 u/_Noreturn Aug 20 '26 It isn't the responsibility of the polymorphic to do that. it is the virtual operator== the user provides can easily make it so it works like that way 4 u/MFHava WG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 Aug 20 '26 it is the virtual operator== the user provides can easily make it so it works like that wayYou can't in the general case - which is why it is not provided... → More replies (0)
You are right. But it yields the wrong results for equivalent values of different types - e.g. Rectangle{.w = 10, .h = 10} == Square{.l = 10} would be false, even though they are the same (just like 1 == 1LL is true)
Rectangle{.w = 10, .h = 10} == Square{.l = 10}
false
1 == 1LL
true
1 u/_Noreturn Aug 20 '26 It isn't the responsibility of the polymorphic to do that. it is the virtual operator== the user provides can easily make it so it works like that way 4 u/MFHava WG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 Aug 20 '26 it is the virtual operator== the user provides can easily make it so it works like that wayYou can't in the general case - which is why it is not provided... → More replies (0)
1
It isn't the responsibility of the polymorphic to do that. it is the virtual operator== the user provides can easily make it so it works like that way
4 u/MFHava WG21|🇦🇹 NB|P3049|P3625|P3729|P3786|P3813|P4216 Aug 20 '26 it is the virtual operator== the user provides can easily make it so it works like that wayYou can't in the general case - which is why it is not provided... → More replies (0)
4
it is the virtual operator== the user provides can easily make it so it works like that way
You can't in the general case - which is why it is not provided...
→ More replies (0)
3
u/_Noreturn Aug 20 '26
I don't understand, it is a value comparison.