diff --git a/include/fc/interprocess/container.hpp b/include/fc/interprocess/container.hpp index 1b74011..ed761b8 100644 --- a/include/fc/interprocess/container.hpp +++ b/include/fc/interprocess/container.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -33,25 +34,25 @@ namespace fc { } } - /* bip::flat_map == boost::flat_map + //bip::map == boost::map template - void to_variant( const bip::flat_map< K, V, T... >& var, fc::variant& vo ) { + void to_variant( const bip::map< K, V, T... >& var, fc::variant& vo ) { std::vector< variant > vars(var.size()); size_t i = 0; for( auto itr = var.begin(); itr != var.end(); ++itr, ++i ) vars[i] = fc::variant(*itr); vo = vars; } - +/* template - void from_variant( const variant& var, bip::flat_map& vo ) + void from_variant( const variant& var, bip::map& vo ) { const variants& vars = var.get_array(); vo.clear(); for( auto itr = vars.begin(); itr != vars.end(); ++itr ) - vo.insert( itr->as< std::pair >() ); + vo.insert( itr->as< std::pair >() ); Not safe for interprocess. Needs allocator } - */ +*/ template void to_variant( const bip::vector< T... >& t, fc::variant& v ) { @@ -72,6 +73,28 @@ namespace fc { } } + template + void to_variant( const bip::set< T... >& t, fc::variant& v ) { + std::vector vars; + vars.reserve(t.size()); + for( const auto& item : t ) { + vars.emplace_back( item ); + } + v = std::move(vars); + } + +/* + template + void from_variant( const fc::variant& v, bip::set< T, A... >& d ) { + const variants& vars = v.get_array(); + d.clear(); + d.reserve( vars.size() ); + for( uint32_t i = 0; i < vars.size(); ++i ) { + from_variant( vars[i], d[i] ); Not safe for interprocess. Needs allocator + } + } +*/ + template void to_variant( const bip::vector& t, fc::variant& v ) {