Compile error, stl:set creation

  • Thread starter Thread starter BruceVx
  • Start date Start date
B

BruceVx

Guest
Hello,

The following extract from a WIN32 console program compiles without errors or warnings under Debian Linux and also Embarcadero (prev. Borland) C++ builder, but under VS15 gives errors:

1>c:\vs15 projects\makeseq\makeseq\makeseq.cpp(32): error C2065: 'greater': undeclared identifier

1>c:\vs15 projects\makeseq\makeseq\makeseq.cpp(32): error C2062: type 'char' unexpected


There are followon errors that all appear to stem from the inability to ‘recognise’ ‘greater’.


The snippet shown attempts to set up a couple of stl:set containers, one containing members of 2 chars. The approach is as per the Josuttis book “The C++ standard library”, chapter on sets.


I’ve tried numerous variants, but none will compile without errors. There must be some platform-specific syntactical requirement under VS that I’m missing.


Thanks for any suggestions. Apologies for line gaps in the code snippet, they seem to be locked in by the post editor.


======================================================================================================================================================


/*

Snippet to isolate set creation error.

*/


#include "stdafx.h"

#include <set>

#include <algorithm>


using namespace std ;


class mididat

{

public:

char kk ;

char vv ;

} ;


// MIDI sort routine, sorts on key no of pair only.


class MIDIsort

{

public:

bool operator() (const mididat& m1, const mididat& m2) const

{

return (m1.kk < m2.kk) ;

}

} ;


typedef set <mididat, MIDIsort> midiset ;

typedef set <char, greater<char> > nutype ; /******** LINE 32 (first reported error) ********/


mididat MIDIdat ;


// Sets for aggregating events

midiset NDset

nutype NUset ;

nutype NDnow ;


int main()

{

return 0;

}



bv

Continue reading...
 
Back
Top