diff --git a/include/fc/container/deque.hpp b/include/fc/container/deque.hpp index 66f2c19..6a05dc8 100644 --- a/include/fc/container/deque.hpp +++ b/include/fc/container/deque.hpp @@ -6,29 +6,6 @@ namespace fc { namespace raw { - template - inline void pack( Stream& s, const std::deque& 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 - inline void unpack( Stream& s, std::deque& 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 diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 44597bf..1b62fa9 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace fc { namespace raw { @@ -443,6 +444,29 @@ namespace fc { } } + template + inline void pack( Stream& s, const std::deque& 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 + inline void unpack( Stream& s, std::deque& 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 inline void pack( Stream& s, const std::vector& value ) { diff --git a/include/fc/variant.hpp b/include/fc/variant.hpp index 513aac3..11ab95a 100644 --- a/include/fc/variant.hpp +++ b/include/fc/variant.hpp @@ -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() ); } @@ -472,10 +471,10 @@ namespace fc template void to_variant( const std::deque& t, variant& v ) { - std::deque vars(t.size()); - for( size_t i = 0; i < t.size(); ++i ) - vars[i] = variant(t[i]); - v = std::move(vars); + std::vector vars(t.size()); + for( size_t i = 0; i < t.size(); ++i ) + vars[i] = variant(t[i]); + v = std::move(vars); }