
Doesn't show the overloading part, but that's OK.
Quick question: Given the ability to return different (necessarily related?) types from the same open-method, can we say BOM allows co-variant return type? Like virtual methods / polymorphism allows, just more flexible that plain pointers?
Yes. And in that case, the return type can act as a tie-breaker, as described in
N2216.
Here is `transpose` with `const` and covariant return types:
BOOST_OPENMETHOD(
transpose, (shared_virtual_ptr<const Matrix>),
shared_virtual_ptr<const Matrix>);
BOOST_OPENMETHOD_OVERRIDE(
transpose, (shared_virtual_ptr<const OrdinaryMatrix>),
shared_virtual_ptr<const OrdinaryMatrix>) {
return make_shared_virtual<OrdinaryMatrix>();
}
BOOST_OPENMETHOD_OVERRIDE(
transpose, (shared_virtual_ptr<const SymmetricMatrix> m),
shared_virtual_ptr<const SymmetricMatrix>) {
return m;
}
You can call a specific overrider like so:
auto u = BOOST_OPENMETHOD_OVERRIDERS(
transpose)
On Mon, Mar 10, 2025 at 9:45 PM Jean-Louis Leroy via Boost
wrote: [...] handling of const-ness `const` is supported.
Doesn't show the overloading part, but that's OK.
Quick question: Given the ability to return different (necessarily related?) types from the same open-method, can we say BOM allows co-variant return type? Like virtual methods / polymorphism allows, just more flexible that plain pointers?
Thanks, --DD