]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
common: add versioned encodings for std::variant
authorCasey Bodley <cbodley@redhat.com>
Tue, 14 Nov 2023 01:05:47 +0000 (20:05 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 1 Dec 2023 13:52:31 +0000 (08:52 -0500)
commit8e92cbac3e4c1d7643b5e02735a1dabb3326658d
tree8709e6579162a590c644953cfd723496beefe94d
parent122c6b2170bf02f425245003381f5377ef188f0a
common: add versioned encodings for std::variant

adds two encoding strategies for `std::variant<>` under the namespaces
`ceph::versioned_variant` and `ceph::converted_variant`

these versioned encodings allow the variant to be extended with new
types, provided that they're always added to the end without changing
or removing existing types. because of this requirement, no default
encoding is provided for `std::variant`. callers must opt in to one
namespace or the other

the `converted_variant` encoding requires the variant's first type T
to use versioned encoding, and guarantees that the variant's encoding
is backward-compatible with T's

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/common/versioned_variant.h [new file with mode: 0644]
src/test/common/CMakeLists.txt
src/test/common/test_versioned_variant.cc [new file with mode: 0644]