HomePhabricator

Support serialization as another type without casting

Authored by Pieter Wuille <pieter.wuille@gmail.com> on Jul 7 2017, 23:06.

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

Committed
Mark Lundeberg <36528214+markblundeberg@users.noreply.github.com>May 9 2019, 16:06
Pushed
jasonbcoxMay 9 2019, 16:47
Reviewer
Restricted Project
Differential Revision
D2932: Support serialization as another type without casting
Parents
rSTAGING732f92fa1f60: Support deserializing into temporaries
Branches
Unknown
Tags
Unknown

Event Timeline

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