diff --git a/include/fc/container/flat.hpp b/include/fc/container/flat.hpp index 0888d0b..48fdf75 100644 --- a/include/fc/container/flat.hpp +++ b/include/fc/container/flat.hpp @@ -54,6 +54,35 @@ namespace fc { value.insert( std::move(tmp) ); } } + + template + void pack( Stream& s, const bip::vector& value ) { + pack( s, unsigned_int((uint32_t)value.size()) ); + if( !std::is_fundamental::value ) { + auto itr = value.begin(); + auto end = value.end(); + while( itr != end ) { + fc::raw::pack( s, *itr ); + ++itr; + } + } else { + s.write( (const char*)value.data(), value.size() ); + } + } + + template + void unpack( Stream& s, bip::vector& value ) { + unsigned_int size; + unpack( s, size ); + value.resize( size ); + if( !std::is_fundamental::value ) { + for( auto& item : value ) + unpack( s, item ); + } else { + s.read( (char*)value.data(), value.size() ); + } + } + } // namespace raw diff --git a/include/fc/container/flat_fwd.hpp b/include/fc/container/flat_fwd.hpp index 9f3ef4f..98dd954 100644 --- a/include/fc/container/flat_fwd.hpp +++ b/include/fc/container/flat_fwd.hpp @@ -1,11 +1,13 @@ #pragma once #include #include +#include namespace fc { using boost::container::flat_map; using boost::container::flat_set; + namespace bip = boost::interprocess; namespace raw { template @@ -16,6 +18,12 @@ namespace fc { void pack( Stream& s, const flat_map& value ); template void unpack( Stream& s, flat_map& value ) ; + + + template + void pack( Stream& s, const bip::vector& value ); + template + void unpack( Stream& s, bip::vector& value ); } // namespace raw } // fc diff --git a/include/fc/variant.hpp b/include/fc/variant.hpp index 5c2d3ae..ccb2960 100644 --- a/include/fc/variant.hpp +++ b/include/fc/variant.hpp @@ -312,6 +312,12 @@ namespace fc return tmp; } + template + void as( T& v )const + { + from_variant( *this, v ); + } + variant& operator=( variant&& v ); variant& operator=( const variant& v );