fixes updates for deque to variant

This commit is contained in:
Daniel Larimer 2016-02-11 17:16:39 -05:00
parent 7840ef16e9
commit bde8a7f424
3 changed files with 28 additions and 28 deletions

View file

@ -6,29 +6,6 @@
namespace fc {
namespace raw {
template<typename Stream, typename T>
inline void pack( Stream& s, const std::deque<T>& value ) {
pack( s, unsigned_int((uint32_t)value.size()) );
auto itr = value.begin();
auto end = value.end();
while( itr != end ) {
fc::raw::pack( s, *itr );
++itr;
}
}
template<typename Stream, typename T>
inline void unpack( Stream& s, std::deque<T>& value ) {
unsigned_int size; unpack( s, size );
FC_ASSERT( size.value*sizeof(T) < MAX_ARRAY_ALLOC_SIZE );
value.resize(size.value);
auto itr = value.begin();
auto end = value.end();
while( itr != end ) {
fc::raw::unpack( s, *itr );
++itr;
}
}
} // namespace raw

View file

@ -13,6 +13,7 @@
#include <fc/safe.hpp>
#include <fc/io/raw_fwd.hpp>
#include <map>
#include <deque>
namespace fc {
namespace raw {
@ -443,6 +444,29 @@ namespace fc {
}
}
template<typename Stream, typename T>
inline void pack( Stream& s, const std::deque<T>& value ) {
pack( s, unsigned_int((uint32_t)value.size()) );
auto itr = value.begin();
auto end = value.end();
while( itr != end ) {
fc::raw::pack( s, *itr );
++itr;
}
}
template<typename Stream, typename T>
inline void unpack( Stream& s, std::deque<T>& value ) {
unsigned_int size; unpack( s, size );
FC_ASSERT( size.value*sizeof(T) < MAX_ARRAY_ALLOC_SIZE );
value.resize(size.value);
auto itr = value.begin();
auto end = value.end();
while( itr != end ) {
fc::raw::unpack( s, *itr );
++itr;
}
}
template<typename Stream, typename T>
inline void pack( Stream& s, const std::vector<T>& value ) {

View file

@ -463,7 +463,6 @@ namespace fc
{
const variants& vars = var.get_array();
tmp.clear();
tmp.reserve( vars.size() );
for( auto itr = vars.begin(); itr != vars.end(); ++itr )
tmp.push_back( itr->as<T>() );
}
@ -472,10 +471,10 @@ namespace fc
template<typename T>
void to_variant( const std::deque<T>& t, variant& v )
{
std::deque<variant> vars(t.size());
for( size_t i = 0; i < t.size(); ++i )
vars[i] = variant(t[i]);
v = std::move(vars);
std::vector<variant> vars(t.size());
for( size_t i = 0; i < t.size(); ++i )
vars[i] = variant(t[i]);
v = std::move(vars);
}