Problem extending boost::multi_index on GCC 4.6

Claudio La Rosa clros@tiscali.it
Tue Dec 6 18:46:00 GMT 2011


Hi!
I have this class that extends the boost::multi_index:

#include <boost/multi_index_container.hpp> 
#include <boost/multi_index/ordered_index.hpp> 
#include <boost/multi_index/member.hpp> 
#include <boost/multi_index/random_access_index.hpp> 

using namespace boost::multi_index; 

template<typename K,typename V> 
struct mutable_pair 
{ 
        typedef K first_type; 
        typedef V second_type; 
        mutable_pair():first(K()),second(V()){} 
        mutable_pair(const K& f,const V&s):first(f),second(s){} 
        mutable_pair(const std::pair<K,V>&
p):first(p.first),second(p.second){} 
        K first; 
        mutable V second; 
}; 

template<typename K,typename V> 
class Ordered_Map : public multi_index_container< 
        mutable_pair<K, V>, 
  indexed_by< random_access<>, 
  ordered_unique<member<mutable_pair<K,V>, K, &mutable_pair<K, V>::first> >
> 
> 
{ 
public: 
        V& operator[]( const K& key ) 
        { 
               //here I have error on end() (but no error on insert()) and
on get<>(). end() insert() and get<>() should be methods of superclass.This
code work well on MSVC 2010
                insert(end(), mutable_pair<K, V>(key,V())); //error on end()
on GCC
                return get<1>().find(key)->second;             //error on
get<>() on GCC
        } 
}; 

int main() 
{ 
        Ordered_Map<std::string,int> myMap; 
        myMap["Joe"] = 3; 
        myMap["Lillo"] = 9; 
        myMap["Mary"] = -3; 
        for (auto i = myMap.cbegin(); i != myMap.cend(); ++i) 
        std::cout << i->first << " - " << i->second << std::endl; 
        std::cin.get(); 
        return 0; 
} 

This code work well on MSVC 2010 but I have various compiler error on GCC
4.6.1 (Ubuntu 11.10). Why?
-- 
View this message in context: http://old.nabble.com/Problem-extending-boost%3A%3Amulti_index-on-GCC-4.6-tp32924615p32924615.html
Sent from the gcc - Help mailing list archive at Nabble.com.



More information about the Gcc-help mailing list