Compiles in Commandline-Mode but not from Editor (template/typename T)

 

Hi,

phenomenon. This piece of code is rejected when I compile from the editor, but not when its compiled via commandline. 
Editor compiler reports: "T" unexpected token for the first line. 

  public: template<typename T> T Get(int index, T defaultvalue=(T)NULL)
      {
      // ... 
      if (index < 0 || index >= cnt_elements) return defaultvalue;
      return (T)data[index];
      }


Any ideas?

 
Doerk Hilger:
This piece of code is rejected when I compile from the editor

No compilation errors from metaeditor for the code you posted.


 
Vladislav Boyko #:

No compilation errors from metaeditor for the code you posted.


We are in MQL4. Not MQL5. 

 
The way out seems to be
   #ifdef __MQL5__
   public: template<typename T> T Get(int index, T defaultvalue=(T)NULL)
   #else 
   public: template<typename T> T Get(int index, T defaultvalue=NULL)
   #endif 
      {
      
/... 
      if (index < 0 || index >= cnt_elements) return defaultvalue;
      return (T)data[index];
      }
... but that still does not explain, why the compiler fails when started from editor, and the code looks less proper/safe too.