Currently zserio::Optional<T> allocates on heap for objects bigger than a hard-coded threshold (3 * sizeof(void*)). However in some cases it can be worthless to allocate T on heap, especially when the T allocates on heap by itself - i.e. when T is a container. Consider std::vector and std::string (including pmr versions).
We already have similar optimization for zserio::View<T> - see #38.
Also consider to do similar improvement in zserio::Variant.