aboutsummaryrefslogtreecommitdiff
path: root/src/primitives
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2017-07-07 16:06:56 -0700
committerPieter Wuille <[email protected]>2018-03-20 17:08:06 -0700
commit818dc74ba2745872fd68d2158380fc8bd331210e (patch)
treef72178344d09e88a312da73abed27f1716b8cfdd /src/primitives
parentMerge #12727: [RPC] Remove unreachable help conditions in rpcwallet.cpp (diff)
downloaddiscoin-818dc74ba2745872fd68d2158380fc8bd331210e.tar.xz
discoin-818dc74ba2745872fd68d2158380fc8bd331210e.zip
Support serialization as another type without casting
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.
Diffstat (limited to 'src/primitives')
-rw-r--r--src/primitives/block.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/primitives/block.h b/src/primitives/block.h
index 5d6d44ac7..1fca55d91 100644
--- a/src/primitives/block.h
+++ b/src/primitives/block.h
@@ -93,7 +93,7 @@ public:
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
- READWRITE(*static_cast<CBlockHeader*>(this));
+ READWRITEAS(CBlockHeader, *this);
READWRITE(vtx);
}