rubenscript
May 1st, 2008, 04:08 PM
Hi, I'm new on this forum, I need your help. So, I want to create a multimap that consists of a pair of a structure and a set. like this:
// this is the structure:
struct si {
int s0;
int ch;
}
//and a set
set<int> sf;
I defined the multimap like this:
multimap<si, set<int> > m;
Now I try to insert a pair in the multimap, with:
m.insert (pair<si, set<int> > (m_si, m_sf));
but this returns me a very long error, and I don't know how to resolve it. The error is:
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_function.h: In member function âbool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = si]â:
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_tree.h:812: instantiated from âtypename std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::insert_equal(const _Val&) [with _Key = si, _Val = std::pair<const si, sf>, _KeyOfValue = std::_Select1st<std::pair<const si, sf> >, _Compare = std::less<si>, _Alloc = std::allocator<std::pair<const si, sf> >]â
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_multimap.h:348: instantiated from âtypename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, _Alloc>::iterator std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(const std::pair<const _Key, _Tp>&) [with _Key = si, _Tp = sf, _Compare = std::less<si>, _Alloc = std::allocator<std::pair<const si, sf> >]â
set.cpp:30: instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_function.h:227: error: no match for âoperator<â in â__x < __yâ
My Question: How do I construct a multimap consisting of pairs of struct and set. I need this to construct a NFA. si would be the initial state along with the character input and sf would be the final states set, in which the nfa goes after performing the transition from state s0 with character ch.
Thanks in advance!
I would appreciate very much a rapid response from you.
// Later Edit:
Ok, I did some digging, it seems that it works if the first parameter of the function insert is not a struct, but a basic data type, but isn't there another predefined data structure in c++ that allows you to have pairs of structs, or pairs of struct and sets ?
// this is the structure:
struct si {
int s0;
int ch;
}
//and a set
set<int> sf;
I defined the multimap like this:
multimap<si, set<int> > m;
Now I try to insert a pair in the multimap, with:
m.insert (pair<si, set<int> > (m_si, m_sf));
but this returns me a very long error, and I don't know how to resolve it. The error is:
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_function.h: In member function âbool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = si]â:
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_tree.h:812: instantiated from âtypename std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::insert_equal(const _Val&) [with _Key = si, _Val = std::pair<const si, sf>, _KeyOfValue = std::_Select1st<std::pair<const si, sf> >, _Compare = std::less<si>, _Alloc = std::allocator<std::pair<const si, sf> >]â
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_multimap.h:348: instantiated from âtypename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, _Alloc>::iterator std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(const std::pair<const _Key, _Tp>&) [with _Key = si, _Tp = sf, _Compare = std::less<si>, _Alloc = std::allocator<std::pair<const si, sf> >]â
set.cpp:30: instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../../include/c++/4.0.0/bits/stl_function.h:227: error: no match for âoperator<â in â__x < __yâ
My Question: How do I construct a multimap consisting of pairs of struct and set. I need this to construct a NFA. si would be the initial state along with the character input and sf would be the final states set, in which the nfa goes after performing the transition from state s0 with character ch.
Thanks in advance!
I would appreciate very much a rapid response from you.
// Later Edit:
Ok, I did some digging, it seems that it works if the first parameter of the function insert is not a struct, but a basic data type, but isn't there another predefined data structure in c++ that allows you to have pairs of structs, or pairs of struct and sets ?