aboutsummaryrefslogtreecommitdiff
path: root/src/protocol.h
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/protocol.h
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/protocol.h')
-rw-r--r--src/protocol.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/protocol.h b/src/protocol.h
index e518d1194..b8deacb5f 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -349,7 +349,7 @@ public:
uint64_t nServicesInt = nServices;
READWRITE(nServicesInt);
nServices = static_cast<ServiceFlags>(nServicesInt);
- READWRITE(*static_cast<CService*>(this));
+ READWRITEAS(CService, *this);
}
// TODO: make private (improves encapsulation)