Akim Demaille
I used something more agressive:
[...[
/// Conversion to superclass. template <typename U> operator const poly_flyweight<U>&() const { const void* me = this; return *static_cast
(me); }
Wow, this is totally verboten. The following problems lurk:
1. poly_flyweight<U> need not be layout compatible with
poly_flyweight<T>.
2. Even if #1 holds, a pointer to Base need not be numerically
equivalent to a pointer to Derived (in the presence of multiple
inheritance, for instance.)
3. Even if #2 holds, the thing would work by pure chance (basically,
because a "casted" poly_flyweight<Base> happens never to touch
the internal factory of poly_flyweight<Derived>, which in principle
a conformant implementation is allowed to do).
All in all, the thing could potentially work, but why would that be
preferred over derived_poly_flyweight