r/cpp • • Aug 19 '26

C++26: std::polymorphic

https://www.sandordargo.com/blog/2026/08/19/cpp26-polymorphic
95 Upvotes

44 comments sorted by

View all comments

Show parent comment

1

u/_Noreturn Aug 25 '26 edited Aug 25 '26

I don't agree with your take, but that's fine. imo it should just be defined to be

bool operator==(polymorphic& a, polymorphic& b)
{ 
   bool has = a.is_valueless();
   if(has != b.is_valueless())
         return false;
    returb has && *a == *b;
}