Errors, bugs, questions - page 1749

 
fxsaber:
I have made a tick indicator in kodobase. But I can't attach the sources - I press "Attach files", the inscription disappears, but the interface for selecting files does not appear.
maybe an adblock is installed? which blocks all pop-up windows
 
Vladislav Andruschenko:
maybe an adblock is installed? which blocks all pop-ups

I haven't changed anything. Everything was working before.

When checking out, I press this button

Nothing comes back, except this.

 
Sergei Vladimirov:
Yes I understand your question. There is a function with a more appropriate signature, but it can't be called because it's protected. Yes, the behaviour is different from Studio: in MKL, there's tighter type control (in this case). I don't know if that should be considered a bug. If you control the type of the argument passed to the function, there is no problem.

The control is rather selective and therefore more inconsistent, which follows from here

class A {
public:
        void f( int ) const {} /*(1)*/        
        void f( int )       {} /*(2)*/
};
class B : public A {
public:
        void f( int ) const {} /*(3)*/
};
void OnStart()
{
        B b; //не const B
        b.f( 0 ); //(*)

}
Here in (*) in aggregate (considering not const B b ) the call A::f/*(2)*/ is more likely to be

But C++ always does not analyse a base class for a more suitable method if the derived one just has a suitable one.

And MQL - in the previous example, it analyzed the base class for a more suitable method, while in this one it doesn't (here as well as C++ will call B::f/*(3)*/), which means that there is no unified approach

Another example of inconsistent control: C++ finds the following code

class A { public:
        void f(  int i ) const {}
        void f( uint i )       {}
};
void OnStart()
{
        A a;
        a.f((int)0 );
}
erroneous, and the MQL is good
 
A100:

The control is rather selective and therefore more inconsistent, which follows from here

class A {
public:
        void f( int ) const {} /*(1)*/        
        void f( int )       {} /*(2)*/
};
class B : public A {
public:
        void f( int ) const {} /*(3)*/
};
void OnStart()
{
        B b; //не const B
        b.f( 0 ); //(*)

}
Here in (*), by aggregate (taking into account not const B b ), the call A::f/*(2)*/ is more

But C++ always does not analyse a base class for a more suitable method if the derived one has just a suitable one.

And MQL - in the previous example, it analyzed the base class for a more suitable method, while in this one it doesn't (here as well as C++ will call B::f/*(3)*/), which means that there is no unified approach

Another example of inconsistent control: C++ finds the following code

class A { public:
        void f(  int i ) const {}
        void f( uint i )       {}
};
void OnStart()
{
        A a;
        a.f((int)0 );
}
faulty, and the MQL is good
what is your C++ compiler? i have gcc and everything passes without errors
 
coderex:
What C++ compiler do you use? I use gcc and everything passes without any errors
And what function does gcc call in the end?
class A { public:
        void f(          int i ) const {} //1
        void f( unsigned int i )       {} //2
};
void OnStart()
{
        A a;
        a.f((int)0 );
}

(1) or (2). I will now insert the compiler message

That's really a strict control: one method fits better in terms of signature, the other in terms of consistency

 
A100:

This is really a strict control: one method is more suitable by signature, the other by constancy

Well, if you make const A a;, then (1) should be called. If not, it's at the compiler's discretion. I.e. there cannot be uniqueness. And it's not clear why such a code should be written.
 
fxsaber:
And it's not clear why you would write such a thing.

Replace f -> operator[], take your recent example - think how to make [] both left and right. Add constancy to taste - then wrap it in a template and you have something similar.

If make const - consider without if

If there cannot be unambiguity, you should at least issue a warning

 
A100:
Replace f -> operator[], take your recent example - think how to make [] both left and right. Add constancy to taste - then wrap it in a template and you'll have something similar.
Which example are we talking about? Could you give not the source, but the final entry that should work?
 
fxsaber:
Which example are we talking about? Could you give not the source, but the final entry that should work?

You should end up with something like this

void OnStart()
{
        A<int> a;
        int b  = a[ 0 ];
        a[ 0 ] = a[ 1 ];
        a[ 1 ] = b;
}
 
A100:

The end result should be something like this

void OnStart()
{
        A<int> a;
        int b  = a[ 0 ];
        a[ 0 ] = a[ 1 ];
        a[ 1 ] = b;
}
Are the indices constant?
Reason: