diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-04-10 19:56:22 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-04-10 20:54:33 +0200 |
commit | 0a8054e7cd5c76d01e4ac7234e3883d05f6f5fdd (patch) | |
tree | ff45a44e6f9bf3a76df3f5f23a80208b550d7a96 /src/addrman.h | |
parent | a84b056d5f1bc28b08937af3485124e68bb93024 (diff) | |
parent | 818dc74ba2745872fd68d2158380fc8bd331210e (diff) |
Merge #12731: Support serialization as another type without casting
818dc74 Support serialization as another type without casting (Pieter Wuille)
Pull request description:
This adds a `READWRITEAS(type, obj)` macro which serializes `obj` as if it were converted to `const type&` when `const`, and to `type&` when non-`const`. No actual cast is involved, so this only works when this conversion can be done automatically.
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.
This is a redo of #12712, using a slightly different interface.
Tree-SHA512: 262f0257284ff99b5ffaec9b997c194e221522ba35c3ac8eaa9bb344449d7ea0a314de254dc77449fa7aaa600f8cd9a24da65aade8c1ec6aa80c6e9a7bba5ca7
Diffstat (limited to 'src/addrman.h')
-rw-r--r-- | src/addrman.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/addrman.h b/src/addrman.h index 6dec3fe416..a36f7ea100 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -59,7 +59,7 @@ public: template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(*static_cast<CAddress*>(this)); + READWRITEAS(CAddress, *this); READWRITE(source); READWRITE(nLastSuccess); READWRITE(nAttempts); |