Skip to content

Commit 2756e85

Browse files
committed
Fix is() to handle polimorphic sidecast
1 parent b1754db commit 2756e85

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/cpp2util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,13 @@ auto is( X const& ) -> bool {
531531
}
532532

533533
template< typename C, typename X >
534-
requires (std::is_base_of_v<X, C> && !std::is_same_v<C,X>)
534+
requires (!std::is_same_v<C,X>)
535535
auto is( X const& x ) -> bool {
536536
return dynamic_cast<C const*>(&x) != nullptr;
537537
}
538538

539539
template< typename C, typename X >
540-
requires (std::is_base_of_v<X, C> && !std::is_same_v<C,X>)
540+
requires (!std::is_same_v<C,X>)
541541
auto is( X const* x ) -> bool {
542542
return dynamic_cast<C const*>(x) != nullptr;
543543
}

0 commit comments

Comments
 (0)