Page MenuHomePhabricator

Support serialization as another type without casting

Authored by markblundeberg on May 5 2019, 18:07.



Backport of PR12731 (818dc74)

This adds a READWRITEAS(type, obj) macro which serializes obj as if it
were casted to (const type&) when const, and to (type&) when non-const.

This makes it usable in serialization code that uses a single
implementation for both serialization and deserializing, which doesn't
know the constness of the object involved.

Depends on D2929 and D2931

Test Plan

make check

Diff Detail

rABC Bitcoin ABC
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

This revision is now accepted and ready to land.May 9 2019, 07:28