ブースト flat_map を使用して反復処理を試みていますが、反復子の作成方法がわかりません。
my_map = mySeg.find<tlsSHMMap>("temp_map").first; //fetch a pointer to the map
tlsShmemAllocator alloc_inst (mySeg.get_segment_manager());
for (boost::container::flat_map<int, tlsStorage, std::less<int>() ,alloc_inst >::const_iterator row = my_map->begin();
row != my_map->end();
++row)
{
//do stuff
}
「tlsStorage」は、データベースからのデータを格納するために使用する構造体です。ブースト フラット マップは、コードの別の場所で次のように宣言されています。
boost::container::flat_map tls_temp_map = mySeg.construct<tlsSHMMap>("temp_map") (std::less<int>() ,alloc_inst); //object name
上記のコードは機能しません。ここにエラーがありますが、何かアイデアはありますか?
src/dbm/dbm_shm_server.cc: In member function 'int redcom::dbm::ShmServer::StartServer()':
src/dbm/dbm_shm_server.cc:353:24: warning: unused variable 'tls_main_map' [-Wunused-variable]
tlsSHMMap* tls_main_map;
^
src/dbm/dbm_shm_server.cc:354:24: warning: unused variable 'tls_temp_map' [-Wunused-variable]
tlsSHMMap* tls_temp_map;
^
src/dbm/dbm_shm_server.cc: In member function 'void redcom::dbm::ShmServer::fake_notify()':
src/dbm/dbm_shm_server.cc:2023:84: error: the value of 'alloc_inst' is not usable in a constant expression
for (boost::container::flat_map<int, tlsStorage, std::less<int>() ,alloc_inst >::const_iterator row = my_map->begin();
^
src/dbm/dbm_shm_server.cc:2021:40: note: 'alloc_inst' was not declared 'constexpr'
const tlsShmemAllocator alloc_inst (mySeg.get_segment_manager());
^
src/dbm/dbm_shm_server.cc:2023:95: error: type/value mismatch at argument 4 in template parameter list for 'template<class Key, class T, class Compare, class Allocator> class boost::container::flat_map'
for (boost::container::flat_map<int, tlsStorage, std::less<int>() ,alloc_inst >::const_iterator row = my_map->begin();
^
src/dbm/dbm_shm_server.cc:2023:95: error: expected a type, got 'alloc_inst'
src/dbm/dbm_shm_server.cc:2023:113: error: invalid type in declaration before 'row'
for (boost::container::flat_map<int, tlsStorage, std::less<int>() ,alloc_inst >::const_iterator row = my_map->begin();
^
src/dbm/dbm_shm_server.cc:2023:113: error: expected ';' before 'row'
src/dbm/dbm_shm_server.cc:2023:113: error: 'row' was not declared in this scope
src/dbm/dbm_shm_server.cc:2024:37: error: expected ')' before ';' token
row != my_map->end();
^
src/dbm/dbm_shm_server.cc:2023:98: warning: unused variable 'const_iterator' [-Wunused-variable]
for (boost::container::flat_map<int, tlsStorage, std::less<int>() ,alloc_inst >::const_iterator row = my_map->begin();
^
src/dbm/dbm_shm_server.cc:2025:19: error: 'row' was not declared in this scope
++row)
^
src/dbm/dbm_shm_server.cc:2025:22: error: expected ';' before ')' token
++row)
^
distcc[31606] ERROR: compile src/dbm/dbm_shm_server.cc on localhost failed
scons: *** [debug/build/x86_64-unknown-freebsd9.2/dbm/dbm_shm_server.o] Error 1
scons: building terminated because of errors.