public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem extending boost::multi_index on GCC 4.6
@ 2011-12-06 18:46 Claudio La Rosa
  2011-12-06 18:53 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Claudio La Rosa @ 2011-12-06 18:46 UTC (permalink / raw)
  To: gcc-help


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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Problem extending boost::multi_index on GCC 4.6
  2011-12-06 18:46 Problem extending boost::multi_index on GCC 4.6 Claudio La Rosa
@ 2011-12-06 18:53 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2011-12-06 18:53 UTC (permalink / raw)
  To: Claudio La Rosa; +Cc: gcc-help

On 6 December 2011 18:45, Claudio La Rosa wrote:
>
> This code work well on MSVC 2010 but I have various compiler error on GCC
> 4.6.1 (Ubuntu 11.10). Why?

http://gcc.gnu.org/wiki/VerboseDiagnostics#dependent_base

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-06 18:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-06 18:46 Problem extending boost::multi_index on GCC 4.6 Claudio La Rosa
2011-12-06 18:53 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).