template<
typename T>
class bio::TransparentWrapper< T >
TransparentWrappers should appear to be the type they wrap in all respects. However, this is not currently possible for member access.
Unfortunately, operator type() alone is not sufficient to treat this new class as the type it holds and we must instead forward all operations to the contained type.
ugh.
If you know of a better solution to this problem, please make a pull request.
For example 5 + TransparentWrapper<int>(2) = 7; however, TransparentWrapper<MyClass>(myObject).mSomeMember is invalid.
To use TransparentWrappers for more than operations on built-in types, you can use the pattern:
MyClass* myObject;
*myObject = TransparentWrapper< MyClass >(myOtherObject);
Using this pattern invokes the operator MyClass(), casting *this TransparentWrapper to an instance of MyClass.
This wrapper can be inherited from (BIO_STRONG_TYPEDEF, Cached, Final).
As of BIO_ABI_VERSION 12 the destructor is NON-virtual: TransparentWrapper has no vtable, so it adds no vptr to the (typically 1-4 byte) value it wraps. This is a deliberate footprint optimization — a wrapped Id / Property / BondType is now a POD-sized value instead of carrying an 8 B vptr (e.g. Bond 32 -> 16 B).
CONSTRAINT (load-bearing): because the destructor is non-virtual you MUST NEVER destroy a derived wrapper through a TransparentWrapper< T >* base pointer — delete (TransparentWrapper< T >*) derivedPtr is undefined behavior. Every wrapper type is used BY VALUE (members, Arrangement / vector elements, return values); none is heap-allocated and deleted through this base, which is exactly what makes the de-virt safe. Audited fleet-wide (lib/bio + every consumer) before the v12 cascade. If you ever need polymorphic destruction of a wrapper, give that subclass its OWN virtual dtor and delete through that type.
NOTE: TransparentWrappers will not be Primitive unless explicitly implemented as such. See macros/StrongTypedef.h for more info.
- Template Parameters
-