CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    May 2008
    Location
    Bucharest
    Posts
    2

    Multimap insert issue

    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:

    Code:
    // this is the structure:
    struct si {
     int s0;
     int ch;
    }
    Code:
    //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:

    Code:
     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>:perator()(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:air<const si, sf>, _KeyOfValue = std::_Select1st<std:air<const si, sf> >, _Compare = std::less<si>, _Alloc = std::allocator<std:air<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:air<const _Key, _Tp>, std::_Select1st<std:air<const _Key, _Tp> >, _Compare, _Alloc>::iterator std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(const std:air<const _Key, _Tp>&) [with _Key = si, _Tp = sf, _Compare = std::less<si>, _Alloc = std::allocator<std:air<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 ?
    Last edited by rubenscript; May 1st, 2008 at 04:21 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured