Support for BTS #1670: allow serializing shared_ptr<const T>
This commit is contained in:
parent
a0ca5ab29d
commit
ba96174e7f
1 changed files with 16 additions and 0 deletions
|
|
@ -143,6 +143,13 @@ namespace fc {
|
|||
fc::raw::pack( s, *v, _max_depth - 1 );
|
||||
}
|
||||
|
||||
template<typename Stream, typename T>
|
||||
inline void pack( Stream& s, const std::shared_ptr<const T>& v, uint32_t _max_depth )
|
||||
{
|
||||
FC_ASSERT( _max_depth > 0 );
|
||||
fc::raw::pack( s, *v, _max_depth - 1 );
|
||||
}
|
||||
|
||||
template<typename Stream, typename T, size_t N>
|
||||
inline void unpack( Stream& s, fc::array<T,N>& v, uint32_t _max_depth )
|
||||
{ try {
|
||||
|
|
@ -157,6 +164,15 @@ namespace fc {
|
|||
fc::raw::unpack( s, *v, _max_depth - 1 );
|
||||
} FC_RETHROW_EXCEPTIONS( warn, "std::shared_ptr<T>", ("type",fc::get_typename<T>::name()) ) }
|
||||
|
||||
template<typename Stream, typename T>
|
||||
inline void unpack( Stream& s, std::shared_ptr<const T>& v, uint32_t _max_depth )
|
||||
{ try {
|
||||
FC_ASSERT( _max_depth > 0 );
|
||||
T tmp;
|
||||
fc::raw::unpack( s, tmp, _max_depth - 1 );
|
||||
v = std::make_shared<const T>(tmp);
|
||||
} FC_RETHROW_EXCEPTIONS( warn, "std::shared_ptr<const T>", ("type",fc::get_typename<T>::name()) ) }
|
||||
|
||||
template<typename Stream> inline void pack( Stream& s, const unsigned_int& v, uint32_t _max_depth ) {
|
||||
uint64_t val = v.value;
|
||||
do {
|
||||
|
|
|
|||
Loading…
Reference in a new issue