HomePhabricator

Support serialization as another type without casting

Description

Support serialization as another type without casting

Summary:
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

Reviewers: #bitcoin_abc, deadalnix, Fabien

Reviewed By: #bitcoin_abc, Fabien

Maniphest Tasks: T633

Differential Revision: https://reviews.bitcoinabc.org/D2932

Details

Provenance
Pieter Wuille <pieter.wuille@gmail.com>Authored on Jul 7 2017, 23:06
Mark Lundeberg <36528214+markblundeberg@users.noreply.github.com>Committed on May 9 2019, 16:06
markblundebergPushed on May 9 2019, 16:07
Reviewer
Restricted Project
Differential Revision
D2932: Support serialization as another type without casting
Parents
rABC732f92fa1f60: Support deserializing into temporaries
Branches
Unknown
Tags
Unknown

Event Timeline

Mark Lundeberg <36528214+markblundeberg@users.noreply.github.com> committed rABCb2ffaa1dc828: Support serialization as another type without casting (authored by Pieter Wuille <pieter.wuille@gmail.com>).May 9 2019, 16:06