boost.multi_index & IPC
typedef managed_shared_memory::allocator<char>::type char_allocator;
typedef basic_string comp_key_search;
typedef boost::multi_index::composite_key_compare<
std::greater<int>,
std::greater typedef boost::multi_index::composite_key comp_key_sortbyprice;
typedef boost::multi_index::composite_key_compare<
std::greater<float>,
std::greater<int>,
std::greater typedef boost::multi_index::multi_index_container<
quote,
boost::multi_index::indexed_by<
boost::multi_index::ordered_non_unique quote_mic; int main()
{
/*
struct shm_remove
{
shm_remove() { shared_memory_object::remove("MySharedMemory"); }
~shm_remove(){ shared_memory_object::remove("MySharedMemory"); }
} remover;
*/
managed_shared_memory segment(open_only,"MySharedMemory");
quote_mic *quotes = segment.find_or_construct
陈海峰
std::vector<quote> result;
BOOST_FOREACH(const quote& q, idx_sortbyprice)
{
int kind = q.kind;
if (kind == 1 || kind == 11)
{ // std::cout << "市场" << q.market << ",类别" << q.kind << >
", " << q.secname << ",最新价" << q.price << std::endl;
result.push_back(q); this statement will compile error, why? how to write?
Can you post the exact compiler error you're getting. Thank you, Joaquín M López Muñoz Telefónica Digital
On Mon, 09 Apr 2012 14:44:10 +0200, 陈海峰
struct quote { public: int market; int kind; shm_string seccode; shm_string secname; float price; float zf;
quote(int market_, int kind_, const char* seccode_, const char_allocator& a, const char* secname_, const char_allocator& b, float price_, float zf_): market(market_),kind(kind_), seccode(seccode_, a), secname(secname_, b), price(price_), zf(zf_) {} };
std::vector<quote> result; result.push_back(q); this statement will compile error, why? how to
Unless I miss something in modern STL, you need copy constructor for quote.
On Mon, 09 Apr 2012 14:44:10 +0200, 陈海峰
wrote: std::vector<quote> result; result.push_back(q); this statement will compile error, > >
why? how to
Unless I miss something in modern STL, you need copy constructor for quote.
The ctor is generated automitically unless ome of the members are not copyable. The only suspicious guy here is shm_string. But having the compiler error would saves us some wild guessing. Joaquín M López Muñoz Telefónica Digital
participants (3)
-
Joaquín M López Muñoz
-
Viatcheslav.Sysoltsev@h-d-gmbh.de
-
陈海峰