| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
That fix is currently not good... removing std::is_base_of_v<X, C> && makes it ambiguous. I am changing template< typename C, typename X >
requires (std::is_base_of_v<X, C> && !std::is_same_v<C,X>)
auto is( X const& x ) -> bool {
return dynamic_cast<C const*>(&x) != nullptr;
}to template< typename C, typename X >
requires (
( std::is_base_of_v<X, C> ||
( std::is_polymorphic_v<C> && std::is_polymorphic_v<X>)
) && !std::is_same_v<C,X>)
auto is( X const& x ) -> bool {
return dynamic_cast<C const*>(&x) != nullptr;
}That will make the code unambiguous and will solve the issue. |
Sorry, something went wrong.
|
Thanks. Interim ack: I'm going to hold off on this and other changes to cpp2util.h for a short time, including most/all of the is and as fixes, because cpp2util.h is not yet covered by the current regression tests. (The current tests only cover regressions in .cpp lowering, and don't cover actually executing the resulting programs which is what exercises the code in cpp2util.h.) I'm about to add support for actually executing the regression test programs (in at least one compiler, three would be ideal) and check in those results. Then they'll cover the cpp2util.h fixes too and we can work through those with some automated support for knowing we aren't getting regressions. |
Sorry, something went wrong.
|
OK, that sounds good. I am also struggling with ensuring what is working or not. I am supporting myself with a compiler explorer to ensure if new ideas are working on gcc, clang, and MSVC. |
Sorry, something went wrong.
|
Looks good! Thanks. |
Sorry, something went wrong.
…decast [FIX] is() function to handle polymorphic sidecast
| Back | FazBrowse Home | New Git URL |
The current implementation is not handling sidecasts.
The code:
returns false - the current implementation of is() function is using std::is_base_of that blocks using dynamic_cast for sidecast. The current fix removes the requirement for B2 being a base for B1. The current fix add a check if we are dealing with polymorpic types - if yes then the dynamic_cast is called.
This PR close is() part of the #127
as() will be fixed after finalizing discussion here: #106 (it requires handling case when dynamic_cast will return nullptr or throw bad_cast).