Home » U++ Library support » U++ Core » Default comparisons for type derived from Moveable
Default comparisons for type derived from Moveable [message #60322] |
Tue, 21 November 2023 13:39 |
busiek
Messages: 68 Registered: February 2011 Location: Poland
|
Member |
|
|
With c++20 with have a feature to generate comparisons operator: Default comparisons. However, when class is derived from Upp::Moveable (which is common case) we face a problem that there is no default generated comparison operator for EmptyClass. The definition of this class could be changed to:
struct EmptyClass
{
#if __cplusplus >= 202002L
auto operator<=>(const EmptyClass&) const = default;
#endif
};
But then it leads to some conflicts for classes derived from Moveable which have some comparison operator defined by themselves. This means I have to use NTL_MOVEABLE() which is not as convenient as inheriting from Moveable. Is there any simple way in Upp to fix that?
[Updated on: Tue, 21 November 2023 14:48] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat Sep 21 02:21:37 CEST 2024
Total time taken to generate the page: 0.04439 seconds
|