|
Boost Users : |
Subject: Re: [Boost-users] Container with insertion order
From: Claude (clros_at_[hidden])
Date: 2011-11-27 16:16:22
I was trying to encapsulate a boost multiindex in a class usable as std::
map.
This is code:
template<typename K,typename V>
class Ordered_Map
{
private:
struct item
{
item(K k,V v) : first(k),second(v)
{}
K first;
V second;
};
typedef multi_index_container<
item,
indexed_by< random_access<>,
ordered_unique<member<item, K, &item::first> >
>
> container;
container c;
public:
V operator[](const K& key)
{
c.insert(c.end(), item(key,2));
return (??);
}
void begin()
{
//for (container::const_iterator i = c.begin(); i != c.end(); ++i)
//std::cout << i->first << " - " << i->second << std::endl;
}
};
I have some problems; The operator[] is not yet complete.
But the real problem is the begin() method, it should return a
container::const_iterator, but if I use the signature:
*container::const_iterator begin()*
{
return c.begin();
}
I get an error :-(
If I use container::const_iteraton inside the method begin() as type..it
work as type, but it don't work as returned type of begin()!
-- View this message in context: http://boost.2283326.n4.nabble.com/Container-with-insertion-order-tp4097717p4113393.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net