CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2004
    Posts
    1

    STL Map copntaining vector of structs.

    I'm having a problem with
    Itr = MMIDCache.insert(Itr, MMIDList::value_type(NMKey, MMIDStructs));

    where MMIDStructs is a typedef of my vector. I've tried using the long form(non typedef) std::vector<MMIData> and I still get the error C2275: 'MMIDStructs' : illegal use of this type as an expression.

    Is this even possible to do or am I just lost in the syntax?

    Thanks,
    Doug

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: STL Map copntaining vector of structs.

    Quote Originally Posted by doug760
    I'm having a problem with
    Itr = MMIDCache.insert(Itr, MMIDList::value_type(NMKey, MMIDStructs));

    where MMIDStructs is a typedef of my vector. I've tried using the long form(non typedef) std::vector<MMIData> and I still get the error C2275: 'MMIDStructs' : illegal use of this type as an expression.

    Is this even possible to do or am I just lost in the syntax?

    Thanks,
    Doug
    Please post a complete example that duplicates the error. Explanations in English are not as effective as seeing your actual code.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    May 2004
    Posts
    45

    Re: STL Map copntaining vector of structs.

    Code:
    Itr = MMIDCache.insert(Itr, MMIDList::value_type(NMKey, MMIDStructs));
    Is MMIDList a map<>?
    If yes, value_type is a typedef:
    Code:
    typedef pair<const Key, T> value_type;
    so you want to use of of the pair's constructors:
    Code:
        pair();
        pair(const T& x, const U& y);
        template<class V, class W>
            pair(const pair<V, W>& pr);
    You can see that all constructors require values, not types, as parameters.

  4. #4
    Join Date
    May 2004
    Posts
    45

    Re: STL Map copntaining vector of structs.

    Maybe you'll have to use make_pair.

    The declaration of make_pair is:

    Code:
    template<class T, class U>
        pair<T, U> make_pair(const T& x, const U& y);
    so you can use make_pair<NMKey, MMIDStructs>(__ the value of the NMKey__, __ the value of MMIDStructs __)

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