From: Claudio La Rosa <clros@tiscali.it>
To: gcc-help@gcc.gnu.org
Subject: Problem extending boost::multi_index on GCC 4.6
Date: Tue, 06 Dec 2011 18:46:00 -0000 [thread overview]
Message-ID: <32924615.post@talk.nabble.com> (raw)
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.
next reply other threads:[~2011-12-06 18:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-06 18:46 Claudio La Rosa [this message]
2011-12-06 18:53 ` Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=32924615.post@talk.nabble.com \
--to=clros@tiscali.it \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).