Features of the mql5 language, subtleties and tricks - page 226

 
mktr8591 #:
In the navigator, right click on the directory -> "Compile"

Phenomenal!

Thank you!
 
 

Determining the staticity of an array.

// Определяет static/dynamic nonconst-массива.
template <typename T>
bool IsStatic( T &Array[] )
{
  T ArrayTmp[];
  
  return(!ArraySwap(Array, ArrayTmp) || !ArraySwap(Array, ArrayTmp));
}


Application.

void OnStart()
{
  int Array1[1];
  int Array2[];
  
  Print(IsStatic(Array1)); // true
  Print(IsStatic(Array2)); // false
}
 
fxsaber #:

Determine the staticity of the array.

Doesn't ArrayIsDynamic work?

 
trader6_1 #:

Is ArrayIsDynamic not working?

I didn't know, thanks.

 
The study showed that it is possible to achieve free acceleration with two strings.
#include <RadixSort.mqh> // https://www.mql5.com/en/code/38763

#define ArraySort RadixSort // Замена ArraySort на RadixSort.
Of course, if one-dimensional arrays are used.
 
That's an interesting result.
template <typename T>
void f() { Print(__FUNCTION__); }

void OnStart()
{
//  f<int>(); // "void OnStart()"::f<int>
  
  {
    f<int>(); // "void OnStart()"::unnamed#2b753b62::f<int>
  }  
}
 
Compiler limitation.
void OnStart()
{
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
  // Количество вложений, начиная с которого компилятор будет выдавать "'{' - program is too complex"
  }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
  }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
  }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
  }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
  }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
  }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
  }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}
 
fxsaber #:
Interesting result.

If there are a lot of include-files and you need to know which function in the assembled source is higher, you can use this method.

template <typename T>
void f() { Print(__FUNCTION__); }

#define  MACROS_INIT f<int>();

void f2()
{
  MACROS_INIT  
}

void f1()
{
  MACROS_INIT  
}

void OnStart()
{
  f1();
  f2();
}


// f2 прописана выше f1 в собранном исходнике.
"void f2()"::f<int>
"void f2()"::f<int>
 
fxsaber #:
That's an interesting result.

Strange that it hasn't been fixed yet:

Forum on trading, automated trading systems and testing trading strategies

Bugs, bugs, questions

A100, 2020.08.01 05:42

Error during execution:
template<typename T>
void f( T ) { Print( __FUNCTION__); }
void OnStart()
{
        {
                f<ulong>( 1 );
        }
}

Result: OnStart::unnamed#00000216656562DC80::f<ulong>

Expected: OnStart::f<ulong>


Reason: