aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-07-07 16:06:56 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2018-03-20 17:08:06 -0700
commit818dc74ba2745872fd68d2158380fc8bd331210e (patch)
treef72178344d09e88a312da73abed27f1716b8cfdd /src/wallet/wallet.h
parent8ee5c7b747171e335793c74cd9d2f7491da58164 (diff)
downloadbitcoin-818dc74ba2745872fd68d2158380fc8bd331210e.tar.xz
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/wallet/wallet.h')
-rw-r--r--src/wallet/wallet.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 5ac8457eb4..ae94d53401 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -395,7 +395,7 @@ public:
mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
}
- s << *static_cast<const CMerkleTx*>(this);
+ s << static_cast<const CMerkleTx&>(*this);
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << fSpent;
}
@@ -406,7 +406,7 @@ public:
Init(nullptr);
char fSpent;
- s >> *static_cast<CMerkleTx*>(this);
+ s >> static_cast<CMerkleTx&>(*this);
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> fSpent;