Thread: STL problem

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    7

    STL problem

    I have a problem using STL. When I type the following code into my program:

    Code:
    typedef std::multiset<int, std::less<int>> ims;
    The following error happens:

    d:\vs 6.0 test\testex34.cpp(8) : error C2146: syntax error : missing ',' before identifier 'ims'
    d:\vs 6.0 test\testex34.cpp(8) : error C2065: 'ims' : undeclared identifier
    d:\vs 6.0 test\testex34.cpp(8) : error C2143: syntax error : missing '>' before ';'
    d:\vs 6.0 test\testex34.cpp(8) : warning C4091: 'typedef ' : ignored on left of 'class std::multiset' when no variable is declared

    I don't understand what seem to be the error. Can you help me? Thank you for your help.

    Note: I am using Microsoft Visual C++ 6.0

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Add a space between the last two angle brackets:
    Code:
    typedef std::multiset<int, std::less<int> > ims;
    Otherwise the compiler gets confused and parses the line incorrectly.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    You shouldn't have to specify std::less<int> as a comparator. It's already the default.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Note: I am using Microsoft Visual C++ 6.0
    That particular compiler has serious conformance issues with the standard library. I'd recommend upgrading the library. That won't fix your current problem (yet), but it will sidestep dozens of problems you're likely to encounter.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  2. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  3. STL vector <T> problem
    By correlcj in forum C++ Programming
    Replies: 11
    Last Post: 11-06-2002, 07:18 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM