CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Problem with template class ?

    I'm assuming this problem is happening because the classes are template classes. Here's a cut-down version of the code that's giving me the problem:-

    Code:
    template<typename Time> class Note;
    
    template<typename Time>
    class Sequence : virtual public ControlSet {
    public:
    	// c'tors etc
    
    public:
    	struct EarlierNoteComparator {
    		inline bool operator()(const boost::shared_ptr< const Note<Time> > a,
    		                       const boost::shared_ptr< const Note<Time> > b) const {
    			return musical_time_less_than (a->time(), b->time());
    		}
    	};
    
    	typedef typename boost::shared_ptr<Evoral::Note<Time> >  NotePtr;
    
    	typedef std::multiset<NotePtr, EarlierNoteComparator> Notes;
    
    	void set_notes (const Sequence<Time>::Notes& n);
    };
    Basically, the above code compiles with gcc but when I try to compile it with MSVC (version 8) I get this error at the red line:-

    error C2061: syntax error : identifier 'Notes'
    Can anyone tell me what the problem is?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Problem with template class ?

    Looks like a case where you need to disambiguate with typename, e.g.,
    Code:
    void set_notes (const typename Sequence<Time>::Notes& n);
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Problem with template class ?

    Thanks Laserlight, you just beat me to it (I just found the same result purely by trial and error!)
    "A problem well stated is a problem half solved.” - Charles F. Kettering

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