MQL5 Standard Library: Generic - Compatible with MT4?

 

Hey all!

I'm working in an EA framework so I can spin strategies up for both MQL4 and MQL5, and I'd like to implement a HashMap, since there's an implementation already done for MQL5 in /Include/Generic/HashMap.mqh, I gave it a shot and moved the folder to MT4 to see what happens. To my surprise, HashMap.mqh only gave one compilation error, which by the way I don't fully get why it's triggering:

`'i' - variable already defined PrimeGenerator.mqh 65 12`

//+------------------------------------------------------------------+
//| Fast generator of prime value.                                   |
//+------------------------------------------------------------------+
int CPrimeGenerator::GetPrime(const int min)
  {
//--- a typical resize algorithm would pick the smallest prime number in this array
//--- that is larger than twice the previous capacity. 
//--- get next prime value from table
   for(int i=0; i<ArraySize(s_primes); i++)
     {
      int prime=s_primes[i];
      if(prime>=min)
         return(prime);
     }
//--- outside of our predefined table
   for(int i=(min|1); i<=INT_MAX;i+=2)
     {
      if(IsPrime(i) && ((i-1)%s_hash_prime!=0))
         return(i);
     }
   return(min);
  }

As far as I can tell, the scope of one loop shouldn't affect the other, but for some reason it is giving that "variable already declared" error.

This is an easy fix, so I tested changing it to a `j` and HashMap.mqh compiled without trouble. 

Has anyone tried using this in MT4? I'd like to make sure it's actually working for both platforms before going too deep in the development and figuring out I need to make a custom implementation for MQL4.