In MQL5 there is always room for an exploit ! ;) - page 7

 
o_O:
canmemcpy be used?
 
Комбинатор:
can memcpy be used?

no )

You see, if you have to make some preparations before calling SendParam, it's easier to wrap int into some CInt class.

 
o_O:

There's no native way to take a pointer. I mean, if you don't use the CInt wrapper from the beginning, you'll have a hard time handling pointers.

Well, in the pluses, you do the cooking too.


void f(int* value)
{
   //do something
}

{
   int x = 5;
   f(&x);
}

Taking an address is a preparation. Instead it's going to be

f(GetPtr(x)) plus you have to pass the type

 
o_O:

Suppose there is a function in a class

SendParam(int type, void* param)

in which the type of parameter (type) and the parameter itself, or rather a pointer to it (void*) are passed.

The parameter can be of any type (class or simple type).

The parameter can be of any type (a class or a simple type).

what is the problem, legal void:
template<typename T>
void SendReceiveParam(T& param);
....
{
double dval = 10;
SendReceiveParam(dval);
int ival = 10;
SendReceiveParam(ival)
...
// ref on the structure object
struct AAA { void operator=(int a) {} };
AAA struct_val;
SendReceiveParam(struct_val);
}

write an illegal one via int pointers?
 
I still don't understand the problem statement. Apparently there is no clear statement of what you want to achieve, even in the example.
 
fxsaber:
I still don't understand the problem's condition. Apparently, there's no clear formulation of what we want to get, even in the example.

I have already written twice that we try to pass a pointer to int into void* parameter.

( memcpy and intermediate class options have already been suggested, no need to repeat them).

 
o_O:

I have already written twice that we try to pass a pointer to int into void* parameter.

(memcpy, intermediate class options have already been suggested, no need to repeat them)

Damn, at least in C syntax can you give me an example of code that should work in MQL too?
 
alexsis78:
what is the problem, legal void:
template<typename T>
void SendReceiveParam(T& param);

nice, but it doesn't fit.

it cannot pass NULL

 
fxsaber:
Shit, at least in C syntax can we have an example code that should work in MQL as well?
void SendParam(void* );

int a=10;
SendParam(&a);
SendParam(NULL);
 
o_O:
void SendParam(void* );

int a=10;
SendParam(&a);
SendParam(NULL);
Thanks for the example! But I didn't catch the purpose of use - convenience. Please add another piece from SendParam to see how a pointer to int, for example, wants to be used.
o_O:

beautiful, but it doesn't fit.

What exactly is beautiful? It seems to be a head-on application of templates. Or maybe I'm missing something?
Reason: